net.minecraft.block.entity.HopperBlockEntity Java Examples

The following examples show how to use net.minecraft.block.entity.HopperBlockEntity. 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: HopperMinecartEntity_cooldownFixMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "canOperate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/HopperBlockEntity;extract(Lnet/minecraft/inventory/Inventory;Lnet/minecraft/entity/ItemEntity;)Z", shift = At.Shift.BEFORE),cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private void extractAndReturnSuccess(CallbackInfoReturnable<Boolean> cir, List list_1) {
    if (CarpetExtraSettings.hopperMinecart8gtCooldown) {
        boolean result = HopperBlockEntity.extract(this, (ItemEntity) list_1.get(0));
        cir.setReturnValue(result);
        cir.cancel();
    }
}
 
Example #2
Source File: HopperMinecartEntity_transferItemsOutFeatureMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Inventory getOutputInventory() {
    Vec3d offsetToInventory = getBlockBelowCartOffset();
    //The visual rotation point of the minecart is roughly 0.5 above its feet (determined visually ingame)
    //Search 0.5 Blocks below the feet for an inventory
    Inventory inv =  HopperBlockEntity.getInventoryAt(this.world, this.getX() + offsetToInventory.x, this.getY() + 0.5 + offsetToInventory.y, this.getZ() + offsetToInventory.z);

    //There is probably a way nicer way to determine the access side of the target inventory
    if(inv instanceof BlockEntity){
        BlockPos pos = ((BlockEntity) inv).getPos();
        if(pos.getY() < MathHelper.floor(this.getY()))
            outputDirection = Direction.DOWN;
        else if(pos.getX() > MathHelper.floor(this.getX()))
            outputDirection = Direction.EAST;
        else if(pos.getX() < MathHelper.floor(this.getX()))
            outputDirection = Direction.WEST;
        else if(pos.getZ() > MathHelper.floor(this.getZ()))
            outputDirection = Direction.SOUTH;
        else if(pos.getZ() < MathHelper.floor(this.getZ()))
            outputDirection = Direction.NORTH;
        else outputDirection = Direction.DOWN;
    }else
        outputDirection = Direction.DOWN;



    return inv;
}