Search in sources :

Example 1 with HoneyTankTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity in project ResourcefulBees by Resourceful-Bees.

the class SyncGUIMessage method handle.

public static void handle(SyncGUIMessage message, Supplier<NetworkEvent.Context> context) {
    context.get().enqueueWork(() -> {
        AbstractClientPlayer player = Minecraft.getInstance().player;
        if (player != null && player.level.isLoaded(message.pos)) {
            BlockEntity tileEntity = player.level.getBlockEntity(message.pos);
            if (tileEntity instanceof CentrifugeTileEntity) {
                ((CentrifugeTileEntity) tileEntity).handleGUINetworkPacket(message.buffer);
            }
            if (tileEntity instanceof HoneyGeneratorTileEntity) {
                ((HoneyGeneratorTileEntity) tileEntity).handleGUINetworkPacket(message.buffer);
            }
            if (tileEntity instanceof HoneyCongealerTileEntity) {
                ((HoneyCongealerTileEntity) tileEntity).handleGUINetworkPacket(message.buffer);
            }
            if (tileEntity instanceof HoneyTankTileEntity) {
                ((HoneyTankTileEntity) tileEntity).handleGUINetworkPacket(message.buffer);
            }
        }
    });
    context.get().setPacketHandled(true);
}
Also used : AbstractClientPlayer(net.minecraft.client.player.AbstractClientPlayer) HoneyTankTileEntity(com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity) CentrifugeTileEntity(com.teamresourceful.resourcefulbees.tileentity.CentrifugeTileEntity) HoneyCongealerTileEntity(com.teamresourceful.resourcefulbees.tileentity.HoneyCongealerTileEntity) HoneyGeneratorTileEntity(com.teamresourceful.resourcefulbees.tileentity.HoneyGeneratorTileEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 2 with HoneyTankTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity in project ResourcefulBees by Resourceful-Bees.

the class HoneyTank method getPickBlock.

@Override
public ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) {
    BlockEntity tileEntity = world.getBlockEntity(pos);
    if (tileEntity instanceof HoneyTankTileEntity) {
        HoneyTankTileEntity tank = (HoneyTankTileEntity) tileEntity;
        ItemStack stack = new ItemStack(state.getBlock().asItem());
        stack.setTag(tank.writeNBT(new CompoundTag()));
        return stack;
    }
    return tier.getTankItem().get().getDefaultInstance();
}
Also used : HoneyTankTileEntity(com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity) ItemStack(net.minecraft.world.item.ItemStack) CompoundTag(net.minecraft.nbt.CompoundTag) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 3 with HoneyTankTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity in project ResourcefulBees by Resourceful-Bees.

the class HoneyTank method animateTick.

@Override
public void animateTick(@NotNull BlockState stateIn, @NotNull Level world, @NotNull BlockPos pos, @NotNull Random rand) {
    HoneyTankTileEntity tank = getTileEntity(world, pos);
    if (tank == null) {
        return;
    }
    if (tank.getFluidTank().getFluid().getFluid() instanceof CustomHoneyFluid) {
        CustomHoneyFluid fluid = (CustomHoneyFluid) tank.getFluidTank().getFluid().getFluid();
        if (fluid.getHoneyData().getColor().isRainbow()) {
            world.sendBlockUpdated(pos, stateIn, stateIn, 2);
        }
    }
    super.animateTick(stateIn, world, pos, rand);
}
Also used : HoneyTankTileEntity(com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity) CustomHoneyFluid(com.teamresourceful.resourcefulbees.fluids.CustomHoneyFluid)

Example 4 with HoneyTankTileEntity

use of com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity in project ResourcefulBees by Resourceful-Bees.

the class HoneyTank method use.

@NotNull
@Override
public InteractionResult use(@NotNull BlockState state, Level world, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult blockRayTraceResult) {
    ItemStack heldItem = player.getItemInHand(hand);
    boolean usingHoney = heldItem.getItem() instanceof HoneyBottleItem;
    boolean usingBottle = heldItem.getItem() instanceof BottleItem;
    BlockEntity tileEntity = world.getBlockEntity(pos);
    if (tileEntity instanceof HoneyTankTileEntity) {
        HoneyTankTileEntity tank = (HoneyTankTileEntity) tileEntity;
        if (!world.isClientSide) {
            if (usingBottle) {
                tank.fillBottle(player, hand);
            } else if (usingHoney) {
                tank.emptyBottle(player, hand);
            } else {
                CentrifugeBlock.capabilityOrGuiUse(tileEntity, player, world, pos, hand);
            }
        }
        return InteractionResult.SUCCESS;
    }
    return super.use(state, world, pos, player, hand, blockRayTraceResult);
}
Also used : HoneyTankTileEntity(com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity) HoneyBottleItem(net.minecraft.world.item.HoneyBottleItem) ItemStack(net.minecraft.world.item.ItemStack) HoneyBottleItem(net.minecraft.world.item.HoneyBottleItem) BottleItem(net.minecraft.world.item.BottleItem) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

HoneyTankTileEntity (com.teamresourceful.resourcefulbees.tileentity.HoneyTankTileEntity)4 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)3 ItemStack (net.minecraft.world.item.ItemStack)2 CustomHoneyFluid (com.teamresourceful.resourcefulbees.fluids.CustomHoneyFluid)1 CentrifugeTileEntity (com.teamresourceful.resourcefulbees.tileentity.CentrifugeTileEntity)1 HoneyCongealerTileEntity (com.teamresourceful.resourcefulbees.tileentity.HoneyCongealerTileEntity)1 HoneyGeneratorTileEntity (com.teamresourceful.resourcefulbees.tileentity.HoneyGeneratorTileEntity)1 AbstractClientPlayer (net.minecraft.client.player.AbstractClientPlayer)1 CompoundTag (net.minecraft.nbt.CompoundTag)1 BottleItem (net.minecraft.world.item.BottleItem)1 HoneyBottleItem (net.minecraft.world.item.HoneyBottleItem)1 NotNull (org.jetbrains.annotations.NotNull)1