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);
}
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();
}
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);
}
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);
}
Aggregations