Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.megaloloful.wtech.mechanics;
- import net.minecraft.block.BlockPortal;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.item.EntityFallingBlock;
- import net.minecraft.init.Blocks;
- import net.minecraft.util.SoundCategory;
- import net.minecraft.util.math.BlockPos;
- import net.minecraftforge.event.entity.living.LivingDeathEvent;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- import net.minecraftforge.fml.common.network.NetworkRegistry;
- public class Crushing {
- public void onEntityDead(LivingDeathEvent event) {
- if(isAnvil(event.getEntity())) {
- BlockPos pos = event.getEntity().getPosition().down();
- IBlockState blockBelow = event.getEntity().getEntityWorld().getBlockState(pos);
- if(blockBelow.getBlock() == Blocks.COBBLESTONE) {
- event.getEntity().getEntityWorld().setBlockState(pos, Blocks.GRAVEL.getDefaultState());
- }
- event.setCanceled(true);
- }
- }
- public boolean isAnvil(Entity entity) {
- if(entity instanceof EntityFallingBlock && EntityFallingBlock.fallTile.getBlock == Blocks.ANVIL) {
- return true;
- } else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement