This is my code.
@EventBusSubscriber
public class TNTDefusalHandler
{
@SubscribeEvent
public static void onLivingUpdate(LivingUpdateEvent event)
{
Entity entity = event.getEntityLiving();
World world = event.getEntityLiving().getEntityWorld();
BlockPos pos = new BlockPos(entity.getPosition().getX(), entity.getPosition().getY() - 1, entity.getPosition().getZ());
if (world.getBlockState(pos).getBlock() == Blocks.TNT)
{
world.setBlockToAir(pos);
}
}
}
Hi. I'm having a little trouble with the setBlockToAir method in the World class. I am trying to set a TNT block to air but it doesn't remove it properly and if I walk into the position where the block existed, it glitches my player. It doesn't output any errors in console and it says that the block has been removed whenever I print out the block at that location though it reappears whenever I relog. How can I fix this?
7 replies
Important Information
By using this site, you agree to our Terms of Use.