mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-21 23:13:28 +01:00
Hopefully fixed Lithium classloading weird things crashing dedicated servers, Closes #1434
This commit is contained in:
parent
b8575c4a67
commit
668f7ffed3
16 changed files with 324 additions and 213 deletions
|
@ -10,14 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
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.tile.TileEntityAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
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.BlockStateProperties;
|
||||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -47,6 +44,7 @@ import java.text.NumberFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container implements IHudDisplay {
|
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 DirectionProperty FACING = BlockStateProperties.FACING;
|
||||||
|
|
||||||
public static final int NAME_FLAVOR_AMOUNTS_1 = 12;
|
public static final int NAME_FLAVOR_AMOUNTS_1 = 12;
|
||||||
|
@ -121,25 +119,8 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
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 static class TheItemBlock extends AABlockItem {
|
public static class TheItemBlock extends AABlockItem {
|
||||||
|
|
|
@ -10,29 +10,19 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
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.config.CommonConfig;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade;
|
import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
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.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
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.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.ItemInteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
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.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
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.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
|
||||||
|
@ -55,7 +44,7 @@ import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class BlockLaserRelay extends FullyDirectionalBlock.Container implements IHudDisplay {
|
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.
|
//This took way too much fiddling around. I'm not good with numbers.
|
||||||
// private static final float F = 1 / 16F;
|
// 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);
|
// 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
|
@Override
|
||||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
|
@ -251,6 +208,11 @@ public class BlockLaserRelay extends FullyDirectionalBlock.Container implements
|
||||||
}
|
}
|
||||||
super.onRemove(state, world, pos, newState, isMoving);
|
super.onRemove(state, world, pos, newState, isMoving);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
|
return HUD;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public void breakBlock(World world, BlockPos pos, BlockState state) {
|
// public void breakBlock(World world, BlockPos pos, BlockState state) {
|
||||||
|
|
|
@ -10,28 +10,23 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
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.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 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.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.Level;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class BlockLavaFactoryController extends DirectionalBlock.Container implements IHudDisplay {
|
public class BlockLavaFactoryController extends DirectionalBlock.Container implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new LavaFactoryControllerHud();
|
||||||
|
|
||||||
public BlockLavaFactoryController() {
|
public BlockLavaFactoryController() {
|
||||||
super(ActuallyBlocks.defaultPickProps(4.5F, 20.0F).sound(SoundType.METAL));
|
super(ActuallyBlocks.defaultPickProps(4.5F, 20.0F).sound(SoundType.METAL));
|
||||||
|
@ -50,22 +45,11 @@ public class BlockLavaFactoryController extends DirectionalBlock.Container imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @Override
|
/* @Override
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
||||||
|
|
|
@ -10,46 +10,30 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
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.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBreaker;
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomEnergyface;
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.PhantomHud;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomItemface;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
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 net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
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.InteractionHand;
|
||||||
import net.minecraft.world.ItemInteractionResult;
|
import net.minecraft.world.ItemInteractionResult;
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
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.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
|
public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new PhantomHud();
|
||||||
|
|
||||||
public final Type type;
|
public final Type type;
|
||||||
|
|
||||||
|
@ -141,44 +125,11 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
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 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 {
|
public enum Type {
|
||||||
ITEMFACE,
|
ITEMFACE,
|
||||||
PLACER,
|
PLACER,
|
||||||
|
|
|
@ -10,28 +10,24 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
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.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 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.core.BlockPos;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay {
|
public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new PlayerInterfaceHud();
|
||||||
public BlockPlayerInterface() {
|
public BlockPlayerInterface() {
|
||||||
super(ActuallyBlocks.defaultPickProps(4.5F, 10.0F));
|
super(ActuallyBlocks.defaultPickProps(4.5F, 10.0F));
|
||||||
}
|
}
|
||||||
|
@ -64,26 +60,7 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* @Override
|
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) {
|
|
||||||
return VoxelShapes.PLAYER_INTERFACE_SHAPE;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
|
@ -10,27 +10,25 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
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.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 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.core.BlockPos;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
public class BlockVerticalDigger extends DirectionalBlock.Container implements IHudDisplay {
|
public class BlockVerticalDigger extends DirectionalBlock.Container implements IHudDisplay {
|
||||||
|
private static final IBlockHud HUD = new MinerHud();
|
||||||
|
|
||||||
public BlockVerticalDigger() {
|
public BlockVerticalDigger() {
|
||||||
super(ActuallyBlocks.defaultPickProps(8F, 30F));
|
super(ActuallyBlocks.defaultPickProps(8F, 30F));
|
||||||
|
@ -54,20 +52,8 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public IBlockHud getHud() {
|
||||||
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
return HUD;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override
|
/* @Override
|
||||||
|
|
|
@ -10,16 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
|
|
||||||
public interface IHudDisplay {
|
public interface IHudDisplay {
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution);
|
IBlockHud getHud();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -233,7 +233,7 @@ public class ClientEvents {
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
if (stack.getItem() instanceof IHudDisplay) {
|
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());
|
BlockEntity tileHit = minecraft.level.getBlockEntity(rayCast.getBlockPos());
|
||||||
|
|
||||||
if (blockHit instanceof IHudDisplay) {
|
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) {
|
if (tileHit instanceof TileEntityBase base) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.advancements.AdvancementHolder;
|
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.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemBooklet extends ItemBase implements IHudDisplay {
|
public class ItemBooklet extends ItemBase {
|
||||||
|
|
||||||
|
|
||||||
public static IBookletPage forcedPage;
|
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) {
|
public void displayHud(GuiGraphics guiGraphics, Minecraft minecraft, Player player, ItemStack stack, HitResult rayCast, Window resolution) {
|
||||||
// if (rayCast != null && rayCast.getBlockPos() != null) {
|
// if (rayCast != null && rayCast.getBlockPos() != null) {
|
||||||
// BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
|
// BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
|
||||||
|
|
Loading…
Reference in a new issue