Search in sources :

Example 1 with BlockEntityHopper

use of cn.nukkit.blockentity.BlockEntityHopper in project Nukkit by Nukkit.

the class BlockHopper method place.

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    BlockFace facing = face.getOpposite();
    if (facing == BlockFace.UP) {
        facing = BlockFace.DOWN;
    }
    this.setDamage(facing.getIndex());
    boolean powered = this.level.isBlockPowered(this);
    if (powered == this.isEnabled()) {
        this.setEnabled(!powered);
    }
    this.level.setBlock(this, this);
    CompoundTag nbt = new CompoundTag().putList(new ListTag<>("Items")).putString("id", BlockEntity.HOPPER).putInt("x", (int) this.x).putInt("y", (int) this.y).putInt("z", (int) this.z);
    new BlockEntityHopper(this.level.getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt);
    return true;
}
Also used : BlockEntityHopper(cn.nukkit.blockentity.BlockEntityHopper) BlockFace(cn.nukkit.math.BlockFace) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

BlockEntityHopper (cn.nukkit.blockentity.BlockEntityHopper)1 BlockFace (cn.nukkit.math.BlockFace)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1