|
|
|
@ -5,6 +5,7 @@ import com.thebrokenrail.energonrelics.block.forcefield.util.BeamBlock;
|
|
|
|
|
import com.thebrokenrail.energonrelics.block.portal.PortalCooldownEntity;
|
|
|
|
|
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
@ -26,6 +27,8 @@ import java.util.function.Predicate;
|
|
|
|
|
public abstract class MixinEntity implements PortalCooldownEntity {
|
|
|
|
|
@Unique
|
|
|
|
|
private int energyPortalCooldown = 0;
|
|
|
|
|
@Unique
|
|
|
|
|
private boolean touchingBeam = false;
|
|
|
|
|
|
|
|
|
|
@Shadow
|
|
|
|
|
public abstract Box getBoundingBox();
|
|
|
|
@ -53,7 +56,8 @@ public abstract class MixinEntity implements PortalCooldownEntity {
|
|
|
|
|
for (int q = k; q < l; ++q) {
|
|
|
|
|
for (int r = m; r < n; ++r) {
|
|
|
|
|
pos.set(p, q, r);
|
|
|
|
|
if (test.test(getEntityWorld().getBlockState(pos).getBlock())) {
|
|
|
|
|
BlockState state = getEntityWorld().getBlockState(pos);
|
|
|
|
|
if (state.getCollisionShape(getEntityWorld(), pos).isEmpty() && test.test(state.getBlock())) {
|
|
|
|
|
getEntityWorld().getProfiler().pop();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -71,7 +75,7 @@ public abstract class MixinEntity implements PortalCooldownEntity {
|
|
|
|
|
|
|
|
|
|
@Inject(at = @At("HEAD"), method = "hasNoGravity", cancellable = true)
|
|
|
|
|
public void hasNoGravity(CallbackInfoReturnable<Boolean> info) {
|
|
|
|
|
if (!saving && isTouching(block -> block instanceof BeamBlock)) {
|
|
|
|
|
if (!saving && touchingBeam) {
|
|
|
|
|
info.setReturnValue(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -92,8 +96,13 @@ public abstract class MixinEntity implements PortalCooldownEntity {
|
|
|
|
|
energyPortalCooldown = tag.getInt(EnergonRelics.NAMESPACE + ":EnergyPortalCooldown");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Inject(at = @At("HEAD"), method = "tick")
|
|
|
|
|
public void tickHead(CallbackInfo info) {
|
|
|
|
|
touchingBeam = isTouching(block -> block instanceof BeamBlock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Inject(at = @At("RETURN"), method = "tick")
|
|
|
|
|
public void tick(CallbackInfo info) {
|
|
|
|
|
public void tickReturn(CallbackInfo info) {
|
|
|
|
|
energyPortalCooldown--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|