net.minecraft.block.BlockTrapDoor Java Examples

The following examples show how to use net.minecraft.block.BlockTrapDoor. 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: EasyPlaceUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Vec3d applyCarpetProtocolHitVec(BlockPos pos, IBlockState state, Vec3d hitVecIn)
{
    double x = hitVecIn.x;
    double y = hitVecIn.y;
    double z = hitVecIn.z;
    Block block = state.getBlock();
    EnumFacing facing = fi.dy.masa.malilib.util.BlockUtils.getFirstPropertyFacingValue(state);

    if (facing != null)
    {
        x = facing.ordinal() + 2 + pos.getX();
    }

    if (block instanceof BlockRedstoneRepeater)
    {
        x += ((state.getValue(BlockRedstoneRepeater.DELAY)) - 1) * 10;
    }
    else if (block instanceof BlockTrapDoor && state.getValue(BlockTrapDoor.HALF) == BlockTrapDoor.DoorHalf.TOP)
    {
        x += 10;
    }
    else if (block instanceof BlockRedstoneComparator && state.getValue(BlockRedstoneComparator.MODE) == BlockRedstoneComparator.Mode.SUBTRACT)
    {
        x += 10;
    }
    else if (block instanceof BlockStairs && state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP)
    {
        x += 10;
    }

    return new Vec3d(x, y, z);
}
 
Example #2
Source File: BlockMetalTrapDoor.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean onBlockActivated(final World world, final BlockPos coord, IBlockState state,
                                final EntityPlayer player, EnumHand hand, ItemStack heldItem, final EnumFacing facing,
                                final float partialX, final float partialY, final float partialZ) {
    if (this.metal.getToolHarvestLevel() > 1) {
        return true;
    }
    state = state.cycleProperty(BlockTrapDoor.OPEN);
    world.setBlockState(coord, state, 2);
    world.playEvent(player, ((Boolean)state.getValue(BlockTrapDoor.OPEN)) ? 1003 : 1006, coord, 0);
    return true;
}