Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. package com.megaloloful.wtech.mechanics;
  2.  
  3. import net.minecraft.block.BlockPortal;
  4. import net.minecraft.block.state.IBlockState;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.entity.item.EntityFallingBlock;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.util.SoundCategory;
  9. import net.minecraft.util.math.BlockPos;
  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 {
  14.  
  15.  
  16. public void onEntityDead(LivingDeathEvent event) {
  17. if(isAnvil(event.getEntity())) {
  18. BlockPos pos = event.getEntity().getPosition().down();
  19. IBlockState blockBelow = event.getEntity().getEntityWorld().getBlockState(pos);
  20. if(blockBelow.getBlock() == Blocks.COBBLESTONE) {
  21. event.getEntity().getEntityWorld().setBlockState(pos, Blocks.GRAVEL.getDefaultState());
  22. }
  23. event.setCanceled(true);
  24. }
  25. }
  26.  
  27. public boolean isAnvil(Entity entity) {
  28. if(entity instanceof EntityFallingBlock && EntityFallingBlock.fallTile.getBlock == Blocks.ANVIL) {
  29. return true;
  30. } else {
  31. return false;
  32. }
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement