Java Code Examples for net.minecraft.block.Block#rotateBlock()

The following examples show how to use net.minecraft.block.Block#rotateBlock() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChunkDisassembler.java    From archimedes-ships with MIT License 6 votes vote down vote up
private void rotateBlock(Block block, World world, int x, int y, int z, int deltarot)
{
	deltarot &= 3;
	if (deltarot != 0)
	{
		if (deltarot == 3)
		{
			block.rotateBlock(world, x, y, z, ForgeDirection.UP);
		} else
		{
			for (int r = 0; r < deltarot; r++)
			{
				block.rotateBlock(world, x, y, z, ForgeDirection.DOWN);
			}
		}
	}
}
 
Example 2
Source File: ItemPneumaticWrench.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
 */
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitVecX, float hitVecY, float hitVecZ){
    if(!world.isRemote) {
        Block block = world.getBlock(x, y, z);
        IPneumaticWrenchable wrenchable = null;
        if(block instanceof IPneumaticWrenchable) {
            wrenchable = (IPneumaticWrenchable)block;
        } else {
            wrenchable = ModInteractionUtils.getInstance().getWrenchable(world.getTileEntity(x, y, z));
        }
        if(wrenchable != null && ((ItemPneumaticWrench)Itemss.pneumaticWrench).getPressure(stack) > 0) {
            if(wrenchable.rotateBlock(world, player, x, y, z, ForgeDirection.getOrientation(side))) {
                if(!player.capabilities.isCreativeMode) ((ItemPneumaticWrench)Itemss.pneumaticWrench).addAir(stack, -PneumaticValues.USAGE_PNEUMATIC_WRENCH);
                NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.PNEUMATIC_WRENCH, x, y, z, 1.0F, 1.0F, false), world);
                return true;
            }
        } else if(block != null) {
            //rotating normal blocks doesn't cost energy.
            if(block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side))) {
                NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.PNEUMATIC_WRENCH, x, y, z, 1.0F, 1.0F, false), world);
                return true;
            }
        }
        return false;
    } else {
        return false;
    }
}