From 668f7ffed3f717adbbe2665b867668e3565a3aed Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:09:10 -0600 Subject: [PATCH] Hopefully fixed Lithium classloading weird things crashing dedicated servers, Closes #1434 --- .../mod/blocks/BlockAtomicReconstructor.java | 29 ++------- .../mod/blocks/BlockLaserRelay.java | 58 +++-------------- .../blocks/BlockLavaFactoryController.java | 30 ++------- .../mod/blocks/BlockPhantom.java | 61 ++--------------- .../mod/blocks/BlockPlayerInterface.java | 35 ++-------- .../mod/blocks/BlockVerticalDigger.java | 24 ++----- .../mod/blocks/IHudDisplay.java | 14 ++-- .../mod/blocks/blockhuds/IBlockHud.java | 15 +++++ .../mod/blocks/blockhuds/LaserRelayHud.java | 54 +++++++++++++++ .../blockhuds/LavaFactoryControllerHud.java | 33 ++++++++++ .../mod/blocks/blockhuds/MinerHud.java | 32 +++++++++ .../mod/blocks/blockhuds/PhantomHud.java | 65 +++++++++++++++++++ .../blocks/blockhuds/PlayerInterfaceHud.java | 35 ++++++++++ .../blocks/blockhuds/ReconstructorHud.java | 40 ++++++++++++ .../mod/event/ClientEvents.java | 4 +- .../mod/items/ItemBooklet.java | 8 +-- 16 files changed, 324 insertions(+), 213 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/IBlockHud.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/LaserRelayHud.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/LavaFactoryControllerHud.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/MinerHud.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/PhantomHud.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/PlayerInterfaceHud.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/ReconstructorHud.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java index 02d709512..288233f09 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java @@ -10,14 +10,12 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import com.mojang.blaze3d.platform.Window; import de.ellpeck.actuallyadditions.api.lens.ILensItem; import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.ReconstructorHud; import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; @@ -39,7 +37,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -47,6 +44,7 @@ import java.text.NumberFormat; import java.util.List; public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container implements IHudDisplay { + private static final IBlockHud HUD = new ReconstructorHud(); public static final DirectionProperty FACING = BlockStateProperties.FACING; public static final int NAME_FLAVOR_AMOUNTS_1 = 12; @@ -121,25 +119,8 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im } @Override - - public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { - if (!(rayCast instanceof BlockHitResult) || minecraft.level == null) { - return; - } - - BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos()); - if (tile instanceof TileEntityAtomicReconstructor) { - ItemStack slot = ((TileEntityAtomicReconstructor) tile).inv.getStackInSlot(0); - Component lens_name; - if (slot.isEmpty()) { - lens_name = Component.translatable("info.actuallyadditions.nolens"); - } else { - lens_name = slot.getItem().getName(slot); - - AssetUtil.renderStackToGui(slot, resolution.getGuiScaledWidth() / 2 + 15, resolution.getGuiScaledHeight() / 2 - 19, 1F); - } - guiGraphics.drawString(minecraft.font, lens_name.plainCopy().withStyle(ChatFormatting.YELLOW).withStyle(ChatFormatting.ITALIC).getString(), (int) (resolution.getGuiScaledWidth() / 2.0f + 35), (int) (resolution.getGuiScaledHeight() / 2.0f - 15), 0xFFFFFF); - } + public IBlockHud getHud() { + return HUD; } public static class TheItemBlock extends AABlockItem { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java index 721b1e7d9..95374dbd8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java @@ -10,29 +10,19 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import com.mojang.blaze3d.platform.Window; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.Network; import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.LaserRelayHud; import de.ellpeck.actuallyadditions.mod.config.CommonConfig; -import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles; import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade; import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyAdvanced; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyExtreme; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayFluids; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemAdvanced; +import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import io.netty.util.internal.ConcurrentSet; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; @@ -45,7 +35,6 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -55,7 +44,7 @@ import java.util.List; public class BlockLaserRelay extends FullyDirectionalBlock.Container implements IHudDisplay { - + private static final IBlockHud HUD = new LaserRelayHud(); //This took way too much fiddling around. I'm not good with numbers. // private static final float F = 1 / 16F; // private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(2 * F, 0, 2 * F, 1 - 2 * F, 10 * F, 1 - 2 * F); @@ -195,38 +184,6 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements } } - @Override - - public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { - if (!(rayCast instanceof BlockHitResult)) { - return; - } - - BlockPos pos = ((BlockHitResult) rayCast).getBlockPos(); - if (minecraft.level != null) { - boolean wearing = ItemEngineerGoggles.isWearing(player); - if (wearing || !stack.isEmpty()) { - boolean compass = stack.getItem() == CommonConfig.Other.relayConfigureItem; - if (wearing || compass || stack.getItem() instanceof ItemLaserWrench) { - BlockEntity tile = minecraft.level.getBlockEntity(pos); - if (tile instanceof TileEntityLaserRelay relay) { - - Component strg = relay.getExtraDisplayString(); - guiGraphics.drawString(minecraft.font, strg, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 5), 0xFFFFFF); - - Component expl; - if (compass) { - expl = relay.getCompassDisplayString(); - } else { - expl = Component.translatable("info.actuallyadditions.laserRelay.mode.noCompasss", Component.translatable(CommonConfig.Other.relayConfigureItem.getDescriptionId()).getString()).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC); - } - - guiGraphics.drawString(minecraft.font, expl, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 15), 0xFFFFFF); - } - } - } - } - } @Override public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) { @@ -245,12 +202,17 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements relayPositions.forEach(relayPos -> { BlockEntity tile = world.getBlockEntity(relayPos); if(tile instanceof TileEntityLaserRelay relay) { - relay.sendUpdate(); + relay.sendUpdate(); } }); } super.onRemove(state, world, pos, newState, isMoving); } + + @Override + public IBlockHud getHud() { + return HUD; + } // // @Override // public void breakBlock(World world, BlockPos pos, BlockState state) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java index 19f0b5843..213f31de8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java @@ -10,28 +10,23 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import com.mojang.blaze3d.platform.Window; import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.LavaFactoryControllerHud; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.Component; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; import javax.annotation.Nullable; public class BlockLavaFactoryController extends DirectionalBlock.Container implements IHudDisplay { + private static final IBlockHud HUD = new LavaFactoryControllerHud(); public BlockLavaFactoryController() { super(ActuallyBlocks.defaultPickProps(4.5F, 20.0F).sound(SoundType.METAL)); @@ -50,23 +45,12 @@ public class BlockLavaFactoryController extends DirectionalBlock.Container imple } @Override - - public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { - if (!(rayCast instanceof BlockHitResult)) { - return; - } - - TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController) minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos()); - if (factory != null) { - int state = factory.isMultiblock(); - if (state == TileEntityLavaFactoryController.NOT_MULTI) { - guiGraphics.drawWordWrap(minecraft.font, Component.translatable("tooltip.actuallyadditions.factory.notPart.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 5, 200, 0xFFFFFF); - } else if (state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA) { - guiGraphics.drawWordWrap(minecraft.font, Component.translatable("tooltip.actuallyadditions.factory.working.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 5, 200, 0xFFFFFF); - } - } + public IBlockHud getHud() { + return HUD; } + + /* @Override public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { switch (state.getValue(FACING)) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java index 21910cff9..d27b046e3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java @@ -10,46 +10,30 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import com.mojang.blaze3d.platform.Window; -import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBreaker; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomEnergyface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomItemface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomLiquiface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomRedstoneface; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.GuiGraphics; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.PhantomHud; +import de.ellpeck.actuallyadditions.mod.tile.*; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.FormattedText; -import net.minecraft.util.FormattedCharSequence; -import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import net.minecraft.world.phys.Vec3; import javax.annotation.Nullable; public class BlockPhantom extends BlockContainerBase implements IHudDisplay { + private static final IBlockHud HUD = new PhantomHud(); public final Type type; @@ -141,43 +125,10 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay { } @Override - - public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { - if (!(rayCast instanceof BlockHitResult)) { - return; - } - BlockPos pos = ((BlockHitResult) rayCast).getBlockPos(); - BlockEntity tile = minecraft.level.getBlockEntity(pos); - if (tile != null) { - if (tile instanceof IPhantomTile phantom) { - guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.blockPhantomRange.desc").append(": " + phantom.getRange()).withStyle(ChatFormatting.GOLD), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 40, ChatFormatting.WHITE.getColor()); - if (phantom.hasBoundPosition()) { - int distance = Mth.ceil(new Vec3(pos.getX(), pos.getY(), pos.getZ()).distanceTo(new Vec3(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ()))); - BlockState state = minecraft.level.getBlockState(phantom.getBoundPosition()); - Block block = state.getBlock(); - Item item = Item.byBlock(block); - String name = item.getName(new ItemStack(block)).getString(); - drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 30, 200, 0xFFFFFF, true); - - if (phantom.isBoundThingInRange()) { - drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true); - } else { - drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedNoRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true); - } - } else { - guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.notConnected.desc").withStyle(ChatFormatting.RED), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, ChatFormatting.WHITE.getColor()); - } - } - } + public IBlockHud getHud() { + return HUD; } - - public static void drawWordWrap(GuiGraphics gg, Font font, FormattedText text, int x, int y, int width, int color, boolean shadow) { - for (FormattedCharSequence line : font.split(text, width)) { - gg.drawString(font, line, x, y, color, shadow); - y += font.lineHeight; - } - } public enum Type { ITEMFACE, diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java index c715f0f41..5417a79a9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java @@ -10,28 +10,24 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import com.mojang.blaze3d.platform.Window; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.PlayerInterfaceHud; import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; import javax.annotation.Nullable; public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay { + private static final IBlockHud HUD = new PlayerInterfaceHud(); public BlockPlayerInterface() { super(ActuallyBlocks.defaultPickProps(4.5F, 10.0F)); } @@ -52,7 +48,7 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity player, ItemStack stack) { BlockEntity tile = world.getBlockEntity(pos); if (tile instanceof TileEntityPlayerInterface face) { - if (face.connectedPlayer == null) { + if (face.connectedPlayer == null) { face.connectedPlayer = player.getUUID(); face.playerName = player.getName().getString(); face.setChanged(); @@ -64,26 +60,7 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp } @Override - - public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { - if (!(rayCast instanceof BlockHitResult)) { - return; - } - - BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos()); - if (tile != null) { - if (tile instanceof TileEntityPlayerInterface face) { - String name = face.playerName == null - ? "Unknown" - : face.playerName; - guiGraphics.drawString(minecraft.font, "Bound to: " + ChatFormatting.RED + name, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 5), 0xFFFFFF); - guiGraphics.drawString(minecraft.font, "UUID: " + ChatFormatting.DARK_GREEN + face.connectedPlayer, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 15), 0xFFFFFF); - } - } + public IBlockHud getHud() { + return HUD; } - -/* @Override - public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { - return VoxelShapes.PLAYER_INTERFACE_SHAPE; - }*/ } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java index 26b74cdd0..9c812284b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockVerticalDigger.java @@ -10,27 +10,25 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import com.mojang.blaze3d.platform.Window; import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.MinerHud; import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; import javax.annotation.Nullable; public class BlockVerticalDigger extends DirectionalBlock.Container implements IHudDisplay { + private static final IBlockHud HUD = new MinerHud(); public BlockVerticalDigger() { super(ActuallyBlocks.defaultPickProps(8F, 30F)); @@ -54,20 +52,8 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I } @Override - - public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { - if (!(rayCast instanceof BlockHitResult)) { - return; - } - BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos()); - if (tile instanceof TileEntityVerticalDigger miner) { - String info = miner.checkY == 0 - ? "Done Mining!" - : miner.checkY == -1 - ? "Calculating positions..." - : "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + "."; - guiGraphics.drawString(minecraft.font, info, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f - 20), 0xFFFFFF); - } + public IBlockHud getHud() { + return HUD; } /* @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java index 14e8dfd3c..c14bc3e54 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java @@ -10,16 +10,12 @@ package de.ellpeck.actuallyadditions.mod.blocks; -import com.mojang.blaze3d.platform.Window; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiGraphics; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.phys.HitResult; +import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; public interface IHudDisplay { - - void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution); - + @OnlyIn(Dist.CLIENT) + IBlockHud getHud(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/IBlockHud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/IBlockHud.java new file mode 100644 index 000000000..a9c975cb2 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/IBlockHud.java @@ -0,0 +1,15 @@ +package de.ellpeck.actuallyadditions.mod.blocks.blockhuds; + +import com.mojang.blaze3d.platform.Window; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.HitResult; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +public interface IBlockHud { + @OnlyIn(Dist.CLIENT) + void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution); +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/LaserRelayHud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/LaserRelayHud.java new file mode 100644 index 000000000..0d7807170 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/LaserRelayHud.java @@ -0,0 +1,54 @@ +package de.ellpeck.actuallyadditions.mod.blocks.blockhuds; + +import com.mojang.blaze3d.platform.Window; +import de.ellpeck.actuallyadditions.mod.config.CommonConfig; +import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles; +import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +public class LaserRelayHud implements IBlockHud { + @Override + @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { + if (!(rayCast instanceof BlockHitResult)) { + return; + } + + BlockPos pos = ((BlockHitResult) rayCast).getBlockPos(); + if (minecraft.level != null) { + boolean wearing = ItemEngineerGoggles.isWearing(player); + if (wearing || !stack.isEmpty()) { + boolean compass = stack.getItem() == CommonConfig.Other.relayConfigureItem; + if (wearing || compass || stack.getItem() instanceof ItemLaserWrench) { + BlockEntity tile = minecraft.level.getBlockEntity(pos); + if (tile instanceof TileEntityLaserRelay relay) { + + Component strg = relay.getExtraDisplayString(); + guiGraphics.drawString(minecraft.font, strg, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 5), 0xFFFFFF); + + Component expl; + if (compass) { + expl = relay.getCompassDisplayString(); + } else { + expl = Component.translatable("info.actuallyadditions.laserRelay.mode.noCompasss", Component.translatable(CommonConfig.Other.relayConfigureItem.getDescriptionId()).getString()).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC); + } + + guiGraphics.drawString(minecraft.font, expl, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 15), 0xFFFFFF); + } + } + } + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/LavaFactoryControllerHud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/LavaFactoryControllerHud.java new file mode 100644 index 000000000..55abc3cbd --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/LavaFactoryControllerHud.java @@ -0,0 +1,33 @@ +package de.ellpeck.actuallyadditions.mod.blocks.blockhuds; + +import com.mojang.blaze3d.platform.Window; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +public class LavaFactoryControllerHud implements IBlockHud { + @Override + @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { + if (!(rayCast instanceof BlockHitResult)) { + return; + } + + TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController) minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos()); + if (factory != null) { + int state = factory.isMultiblock(); + if (state == TileEntityLavaFactoryController.NOT_MULTI) { + guiGraphics.drawWordWrap(minecraft.font, Component.translatable("tooltip.actuallyadditions.factory.notPart.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 5, 200, 0xFFFFFF); + } else if (state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA) { + guiGraphics.drawWordWrap(minecraft.font, Component.translatable("tooltip.actuallyadditions.factory.working.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 5, 200, 0xFFFFFF); + } + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/MinerHud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/MinerHud.java new file mode 100644 index 000000000..4319136bf --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/MinerHud.java @@ -0,0 +1,32 @@ +package de.ellpeck.actuallyadditions.mod.blocks.blockhuds; + +import com.mojang.blaze3d.platform.Window; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +public class MinerHud implements IBlockHud { + @Override + @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { + if (!(rayCast instanceof BlockHitResult)) { + return; + } + BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos()); + if (tile instanceof TileEntityVerticalDigger miner) { + String info = miner.checkY == 0 + ? "Done Mining!" + : miner.checkY == -1 + ? "Calculating positions..." + : "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + "."; + guiGraphics.drawString(minecraft.font, info, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f - 20), 0xFFFFFF); + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/PhantomHud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/PhantomHud.java new file mode 100644 index 000000000..d250dbdfa --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/PhantomHud.java @@ -0,0 +1,65 @@ +package de.ellpeck.actuallyadditions.mod.blocks.blockhuds; + +import com.mojang.blaze3d.platform.Window; +import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.util.FormattedCharSequence; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +public class PhantomHud implements IBlockHud { + @Override + @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { + if (!(rayCast instanceof BlockHitResult)) { + return; + } + BlockPos pos = ((BlockHitResult) rayCast).getBlockPos(); + BlockEntity tile = minecraft.level.getBlockEntity(pos); + if (tile != null) { + if (tile instanceof IPhantomTile phantom) { + guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.blockPhantomRange.desc").append(": " + phantom.getRange()).withStyle(ChatFormatting.GOLD), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 40, ChatFormatting.WHITE.getColor()); + if (phantom.hasBoundPosition()) { + int distance = Mth.ceil(new Vec3(pos.getX(), pos.getY(), pos.getZ()).distanceTo(new Vec3(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ()))); + BlockState state = minecraft.level.getBlockState(phantom.getBoundPosition()); + Block block = state.getBlock(); + Item item = Item.byBlock(block); + String name = item.getName(new ItemStack(block)).getString(); + drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 30, 200, 0xFFFFFF, true); + + if (phantom.isBoundThingInRange()) { + drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true); + } else { + drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedNoRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true); + } + } else { + guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.notConnected.desc").withStyle(ChatFormatting.RED), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, ChatFormatting.WHITE.getColor()); + } + } + } + } + + @OnlyIn(Dist.CLIENT) + public static void drawWordWrap(GuiGraphics gg, Font font, FormattedText text, int x, int y, int width, int color, boolean shadow) { + for (FormattedCharSequence line : font.split(text, width)) { + gg.drawString(font, line, x, y, color, shadow); + y += font.lineHeight; + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/PlayerInterfaceHud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/PlayerInterfaceHud.java new file mode 100644 index 000000000..8c00c32af --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/PlayerInterfaceHud.java @@ -0,0 +1,35 @@ +package de.ellpeck.actuallyadditions.mod.blocks.blockhuds; + +import com.mojang.blaze3d.platform.Window; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +public class PlayerInterfaceHud implements IBlockHud { + @Override + @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { + if (!(rayCast instanceof BlockHitResult)) { + return; + } + + BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos()); + if (tile != null) { + if (tile instanceof TileEntityPlayerInterface face) { + String name = face.playerName == null + ? "Unknown" + : face.playerName; + guiGraphics.drawString(minecraft.font, "Bound to: " + ChatFormatting.RED + name, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 5), 0xFFFFFF); + guiGraphics.drawString(minecraft.font, "UUID: " + ChatFormatting.DARK_GREEN + face.connectedPlayer, (int) (resolution.getGuiScaledWidth() / 2f + 5), (int) (resolution.getGuiScaledHeight() / 2f + 15), 0xFFFFFF); + } + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/ReconstructorHud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/ReconstructorHud.java new file mode 100644 index 000000000..c46b57291 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/blockhuds/ReconstructorHud.java @@ -0,0 +1,40 @@ +package de.ellpeck.actuallyadditions.mod.blocks.blockhuds; + +import com.mojang.blaze3d.platform.Window; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; +import de.ellpeck.actuallyadditions.mod.util.AssetUtil; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +public class ReconstructorHud implements IBlockHud { + @Override + @OnlyIn(Dist.CLIENT) + public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { + if (!(rayCast instanceof BlockHitResult) || minecraft.level == null) { + return; + } + + BlockEntity tile = minecraft.level.getBlockEntity(((BlockHitResult) rayCast).getBlockPos()); + if (tile instanceof TileEntityAtomicReconstructor) { + ItemStack slot = ((TileEntityAtomicReconstructor) tile).inv.getStackInSlot(0); + Component lens_name; + if (slot.isEmpty()) { + lens_name = Component.translatable("info.actuallyadditions.nolens"); + } else { + lens_name = slot.getItem().getName(slot); + + AssetUtil.renderStackToGui(slot, resolution.getGuiScaledWidth() / 2 + 15, resolution.getGuiScaledHeight() / 2 - 19, 1F); + } + guiGraphics.drawString(minecraft.font, lens_name.plainCopy().withStyle(ChatFormatting.YELLOW).withStyle(ChatFormatting.ITALIC).getString(), (int) (resolution.getGuiScaledWidth() / 2.0f + 35), (int) (resolution.getGuiScaledHeight() / 2.0f - 15), 0xFFFFFF); + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java index 2c7fcf18e..50874e63b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java @@ -233,7 +233,7 @@ public class ClientEvents { if (!stack.isEmpty()) { if (stack.getItem() instanceof IHudDisplay) { - ((IHudDisplay) stack.getItem()).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow()); + ((IHudDisplay) stack.getItem()).getHud().displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow()); } } @@ -243,7 +243,7 @@ public class ClientEvents { BlockEntity tileHit = minecraft.level.getBlockEntity(rayCast.getBlockPos()); if (blockHit instanceof IHudDisplay) { - ((IHudDisplay) blockHit).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow()); + ((IHudDisplay) blockHit).getHud().displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow()); } if (tileHit instanceof TileEntityBase base) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java index 730b9c7ca..78c311f51 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java @@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items; import com.mojang.blaze3d.platform.Window; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.ChatFormatting; import net.minecraft.advancements.AdvancementHolder; @@ -32,10 +31,12 @@ import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.phys.HitResult; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import java.util.List; -public class ItemBooklet extends ItemBase implements IHudDisplay { +public class ItemBooklet extends ItemBase { public static IBookletPage forcedPage; @@ -99,8 +100,7 @@ public class ItemBooklet extends ItemBase implements IHudDisplay { } } - @Override - + @OnlyIn(Dist.CLIENT) public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) { // if (rayCast != null && rayCast.getBlockPos() != null) { // BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());