31 lines
1.0 KiB
Java
31 lines
1.0 KiB
Java
package com.thebrokenrail.twine.entity;
|
|
|
|
import com.thebrokenrail.twine.Twine;
|
|
import net.minecraft.entity.ai.goal.MoveToTargetPosGoal;
|
|
import net.minecraft.entity.mob.MobEntityWithAi;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.WorldView;
|
|
import net.minecraft.world.chunk.Chunk;
|
|
import net.minecraft.world.chunk.ChunkStatus;
|
|
|
|
public class StandOnGlowingObsidian extends MoveToTargetPosGoal {
|
|
public StandOnGlowingObsidian(MobEntityWithAi mob) {
|
|
super(mob, 1d, 24);
|
|
}
|
|
|
|
@Override
|
|
protected boolean isTargetPos(WorldView world, BlockPos pos) {
|
|
Chunk chunk = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, false);
|
|
if (chunk == null) {
|
|
return false;
|
|
} else {
|
|
return chunk.getBlockState(pos).isOf(Twine.GLOWING_OBSIDIAN) && chunk.getBlockState(pos.up()).isAir() && chunk.getBlockState(pos.up(2)).isAir();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean canStart() {
|
|
return super.canStart() && (mob.getHealth() / mob.getMaxHealth()) <= 0.5;
|
|
}
|
|
}
|