Search in sources :

Example 1 with BlockLeaves

use of net.minecraft.block.BlockLeaves in project PneumaticCraft by MineMaarten.

the class EntityVortex method onUpdate.

@Override
public void onUpdate() {
    oldMotionX = motionX;
    oldMotionY = motionY;
    oldMotionZ = motionZ;
    super.onUpdate();
    //blowOtherEntities();
    // equal to the potion effect friction. 0.95F
    motionX *= 0.95D;
    motionY *= 0.95D;
    motionZ *= 0.95D;
    if (motionX * motionX + motionY * motionY + motionZ * motionZ < 0.1D) {
        setDead();
    }
    if (!worldObj.isRemote) {
        int blockX = (int) Math.floor(posX);
        int blockY = (int) Math.floor(posY);
        int blockZ = (int) Math.floor(posZ);
        for (int i = 0; i < 7; i++) {
            // to 7 so the middle block will also trigger (with UNKNOWN direction)
            Block block = worldObj.getBlock(blockX + ForgeDirection.getOrientation(i).offsetX, blockY + ForgeDirection.getOrientation(i).offsetY, blockZ + ForgeDirection.getOrientation(i).offsetZ);
            if (block instanceof IPlantable || block instanceof BlockLeaves) {
                worldObj.func_147480_a(blockX + ForgeDirection.getOrientation(i).offsetX, blockY + ForgeDirection.getOrientation(i).offsetY, blockZ + ForgeDirection.getOrientation(i).offsetZ, true);
            }
        }
    }
}
Also used : BlockLeaves(net.minecraft.block.BlockLeaves) IPlantable(net.minecraftforge.common.IPlantable) Block(net.minecraft.block.Block)

Example 2 with BlockLeaves

use of net.minecraft.block.BlockLeaves 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)

Example 3 with BlockLeaves

use of net.minecraft.block.BlockLeaves in project Realistic-Terrain-Generation by Team-RTG.

the class DecoBase method tweakTreeLeaves.

public static void tweakTreeLeaves(DecoTree deco, boolean checkDecay, boolean decayable) {
    if (deco.getLeavesBlock().getBlock() instanceof BlockLeaves) {
        IBlockState leaves = deco.getLeavesBlock().withProperty(BlockLeaves.CHECK_DECAY, checkDecay).withProperty(BlockLeaves.DECAYABLE, decayable);
        deco.setLeavesBlock(leaves);
    }
}
Also used : BlockLeaves(net.minecraft.block.BlockLeaves) IBlockState(net.minecraft.block.state.IBlockState)

Example 4 with BlockLeaves

use of net.minecraft.block.BlockLeaves in project Realistic-Terrain-Generation by Team-RTG.

the class DecoBase method tweakShrubLeaves.

public static void tweakShrubLeaves(DecoShrub deco, boolean checkDecay, boolean decayable) {
    if (deco.getLeavesBlock().getBlock() instanceof BlockLeaves) {
        IBlockState leaves = deco.getLeavesBlock().withProperty(BlockLeaves.CHECK_DECAY, checkDecay).withProperty(BlockLeaves.DECAYABLE, decayable);
        deco.setLeavesBlock(leaves);
    }
}
Also used : BlockLeaves(net.minecraft.block.BlockLeaves) IBlockState(net.minecraft.block.state.IBlockState)

Aggregations

BlockLeaves (net.minecraft.block.BlockLeaves)4 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 IPlantable (net.minecraftforge.common.IPlantable)2 Entity (net.minecraft.entity.Entity)1 ItemStack (net.minecraft.item.ItemStack)1 IShearable (net.minecraftforge.common.IShearable)1