cn.nukkit.blockentity.BlockEntityHopper Java Examples

The following examples show how to use cn.nukkit.blockentity.BlockEntityHopper. 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: BlockHopper.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@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.meta = 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;
}
 
Example #2
Source File: BlockHopper.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    BlockEntity blockEntity = this.level.getBlockEntity(this);

    if (blockEntity instanceof BlockEntityHopper) {
        return player.addWindow(((BlockEntityHopper) blockEntity).getInventory()) != -1;
    }

    return false;
}
 
Example #3
Source File: BlockHopper.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getComparatorInputOverride() {
    BlockEntity blockEntity = this.level.getBlockEntity(this);

    if (blockEntity instanceof BlockEntityHopper) {
        return ContainerInventory.calculateRedstone(((BlockEntityHopper) blockEntity).getInventory());
    }

    return super.getComparatorInputOverride();
}
 
Example #4
Source File: BlockHopper.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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.getLocation());

    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);

    BlockEntityHopper hopper = (BlockEntityHopper) BlockEntity.createBlockEntity(BlockEntity.HOPPER, this.level.getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt);
    return hopper != null;
}
 
Example #5
Source File: BlockHopper.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    BlockEntity blockEntity = this.level.getBlockEntity(this);

    if (blockEntity instanceof BlockEntityHopper) {
        return player.addWindow(((BlockEntityHopper) blockEntity).getInventory()) != -1;
    }

    return false;
}
 
Example #6
Source File: BlockHopper.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getComparatorInputOverride() {
    BlockEntity blockEntity = this.level.getBlockEntity(this);

    if (blockEntity instanceof BlockEntityHopper) {
        return ContainerInventory.calculateRedstone(((BlockEntityHopper) blockEntity).getInventory());
    }

    return super.getComparatorInputOverride();
}
 
Example #7
Source File: BlockHopper.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: BlockHopper.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onActivate(Item item, Player player) {
    BlockEntity blockEntity = this.level.getBlockEntity(this);

    if (blockEntity instanceof BlockEntityHopper) {
        return player.addWindow(((BlockEntityHopper) blockEntity).getInventory()) != -1;
    }

    return false;
}
 
Example #9
Source File: BlockHopper.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getComparatorInputOverride() {
    BlockEntity blockEntity = this.level.getBlockEntity(this);

    if (blockEntity instanceof BlockEntityHopper) {
        return ContainerInventory.calculateRedstone(((BlockEntityHopper) blockEntity).getInventory());
    }

    return super.getComparatorInputOverride();
}
 
Example #10
Source File: HopperInventory.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public HopperInventory(BlockEntityHopper hopper) {
    super(hopper, InventoryType.HOPPER);
}
 
Example #11
Source File: HopperInventory.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockEntityHopper getHolder() {
    return (BlockEntityHopper) super.getHolder();
}
 
Example #12
Source File: HopperInventory.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public HopperInventory(BlockEntityHopper hopper) {
    super(hopper, InventoryType.HOPPER);
}
 
Example #13
Source File: HopperInventory.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockEntityHopper getHolder() {
    return (BlockEntityHopper) super.getHolder();
}
 
Example #14
Source File: HopperInventory.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public HopperInventory(BlockEntityHopper hopper) {
    super(hopper, InventoryType.HOPPER);
}
 
Example #15
Source File: HopperInventory.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockEntityHopper getHolder() {
    return (BlockEntityHopper) super.getHolder();
}