Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. package com.megaloloful.wtech.mechanics;
  2.  
  3. import net.minecraft.block.state.IBlockState;
  4. import net.minecraft.entity.Entity;
  5. import net.minecraft.entity.item.EntityFallingBlock;
  6. import net.minecraft.init.Blocks;
  7. import net.minecraft.util.SoundCategory;
  8. import net.minecraft.util.math.BlockPos;
  9. import net.minecraft.world.IWorldEventListener;
  10. import net.minecraftforge.event.entity.living.LivingDeathEvent;
  11. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  12. import net.minecraftforge.fml.common.network.NetworkRegistry;
  13. public class Crushing implements IWorldEventListener{
  14.  
  15.  
  16. @SubscribeEvent
  17. public void onDeath(onEntityRemoved event) {
  18. if(isAnvil(event.getEntity())) {
  19. BlockPos pos = event.getEntity().getPosition().down();
  20. IBlockState blockBelow = event.getEntity().getEntityWorld().getBlockState(pos);
  21. if(blockBelow.getBlock() == Blocks.COBBLESTONE) {
  22. event.getEntity().getEntityWorld().setBlockState(pos, Blocks.GRAVEL.getDefaultState());
  23. }
  24. event.setCanceled(true);
  25. }
  26. }
  27.  
  28. public boolean isAnvil(Entity entity) {
  29. if(entity instanceof EntityFallingBlock) {
  30. return true;
  31. } else {
  32. return false;
  33. }
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement