net.minecraft.item.ItemDoor Java Examples

The following examples show how to use net.minecraft.item.ItemDoor. 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: ItemWoodDoor.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
	if (side != 1)
		return false;
	else {
		y++;
		if (player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + 1, z, side, stack)) {
			if (!field_150939_a.canPlaceBlockAt(world, x, y, z))
				return false;
			else {
				ItemDoor.placeDoorBlock(world, x, y, z, MathHelper.floor_double((player.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3, field_150939_a);
				stack.stackSize--;
				return true;
			}
		} else
			return false;
	}
}
 
Example #2
Source File: BaseMethods.java    From pycode-minecraft with MIT License 5 votes vote down vote up
protected void put(BlockPos pos, IBlockState block_state, EnumFacing facing) {
    // don't run on client
    if (this.world == null || this.world.isRemote) return;

    Block block = block_state.getBlock();

    FMLLog.info("Putting %s at %s", block_state, pos);

    // handle special cases
    if (block instanceof BlockDoor) {
        ItemDoor.placeDoor(this.world, pos, facing, block, true);
    } else if (block instanceof BlockBed) {
        BlockPos headpos = pos.offset(facing);
        if (this.world.getBlockState(pos.down()).isSideSolid(this.world, pos.down(), EnumFacing.UP) &&
                this.world.getBlockState(headpos.down()).isSideSolid(this.world, headpos.down(), EnumFacing.UP)) {
            block_state = block_state
                    .withProperty(BlockBed.OCCUPIED, false).withProperty(BlockBed.FACING, facing)
                    .withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);
            if (this.world.setBlockState(pos, block_state, 11)) {
                block_state = block_state.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD);
                this.world.setBlockState(headpos, block_state, 11);
            }
        }
    } else {
        this.world.setBlockState(pos, block_state);
    }
}