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();
}
Aggregations