Search in sources :

Example 16 with IShearable

use of net.minecraftforge.common.IShearable in project PneumaticCraft by MineMaarten.

the class EntityVortex method onImpact.

@Override
protected void onImpact(MovingObjectPosition objectPosition) {
    if (objectPosition.entityHit != null) {
        Entity entity = objectPosition.entityHit;
        entity.motionX += motionX;
        entity.motionY += motionY;
        entity.motionZ += motionZ;
        if (!entity.worldObj.isRemote && entity instanceof IShearable) {
            IShearable shearable = (IShearable) entity;
            int x = (int) Math.floor(posX);
            int y = (int) Math.floor(posY);
            int z = (int) Math.floor(posZ);
            if (shearable.isShearable(null, worldObj, x, y, z)) {
                List<ItemStack> drops = shearable.onSheared(null, worldObj, x, y, z, 0);
                for (ItemStack stack : drops) {
                    PneumaticCraftUtils.dropItemOnGround(stack, worldObj, entity.posX, entity.posY, entity.posZ);
                }
            }
        }
    } else {
        Block block = worldObj.getBlock(objectPosition.blockX, objectPosition.blockY, objectPosition.blockZ);
        if (block instanceof IPlantable || block instanceof BlockLeaves) {
            motionX = oldMotionX;
            motionY = oldMotionY;
            motionZ = oldMotionZ;
        } else {
            setDead();
        }
    }
    hitCounter++;
    if (hitCounter > 20)
        setDead();
}
Also used : Entity(net.minecraft.entity.Entity) BlockLeaves(net.minecraft.block.BlockLeaves) IShearable(net.minecraftforge.common.IShearable) IPlantable(net.minecraftforge.common.IPlantable) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IShearable (net.minecraftforge.common.IShearable)16 Block (net.minecraft.block.Block)12 ItemStack (net.minecraft.item.ItemStack)11 IBlockState (net.minecraft.block.state.IBlockState)7 BlockPos (net.minecraft.util.math.BlockPos)5 EntityItem (net.minecraft.entity.item.EntityItem)4 IPlantable (net.minecraftforge.common.IPlantable)4 NNList (com.enderio.core.common.util.NNList)3 ArrayList (java.util.ArrayList)3 Entity (net.minecraft.entity.Entity)3 BlockLeaves (net.minecraft.block.BlockLeaves)2 World (net.minecraft.world.World)2 BlockBOPMushroom (biomesoplenty.common.block.BlockBOPMushroom)1 Vector3d (com.flowpowered.math.vector.Vector3d)1 IHarvestResult (crazypants.enderio.api.farm.IHarvestResult)1 FarmingTool (crazypants.enderio.base.farming.FarmingTool)1 Random (java.util.Random)1 UUID (java.util.UUID)1 IGrowable (net.minecraft.block.IGrowable)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1