diff --git a/src/main/java/malilib/gui/BaseScreen.java b/src/main/java/malilib/gui/BaseScreen.java index ce26ad4828..a7d556cee8 100644 --- a/src/main/java/malilib/gui/BaseScreen.java +++ b/src/main/java/malilib/gui/BaseScreen.java @@ -1092,17 +1092,17 @@ public static void applyCustomScreenScaleChange() public static boolean isShiftDown() { - return isShiftKeyDown(); + return GuiScreen.isShiftKeyDown(); } public static boolean isCtrlDown() { - return isCtrlKeyDown(); + return GuiScreen.isCtrlKeyDown(); } public static boolean isAltDown() { - return isAltKeyDown(); + return GuiScreen.isAltKeyDown(); } public static void setStringToClipboard(String str) diff --git a/src/main/java/malilib/overlay/InfoOverlay.java b/src/main/java/malilib/overlay/InfoOverlay.java index 0878a93666..49acf9e536 100644 --- a/src/main/java/malilib/overlay/InfoOverlay.java +++ b/src/main/java/malilib/overlay/InfoOverlay.java @@ -13,6 +13,7 @@ import malilib.event.ClientTickHandler; import malilib.event.PostGameOverlayRenderer; import malilib.event.PostScreenRenderer; +import malilib.gui.util.GeometryResizeNotifier; import malilib.gui.util.GuiUtils; import malilib.gui.util.ScreenContext; import malilib.gui.widget.BaseWidget; @@ -30,8 +31,15 @@ public class InfoOverlay implements PostGameOverlayRenderer, PostScreenRenderer, protected final List enabledGuiWidgets = new ArrayList<>(); protected final List allEnabledWidgets = new ArrayList<>(); protected final List activeInfoAreas = new ArrayList<>(); + protected final GeometryResizeNotifier geometryResizeNotifier = + new GeometryResizeNotifier(GuiUtils::getScaledWindowWidth, GuiUtils::getScaledWindowHeight); protected boolean needsReFetch; + public InfoOverlay() { + super(); + this.geometryResizeNotifier.setGeometryChangeListener(() -> this.infoAreas.values().forEach(InfoArea::requestReLayout)); + } + public InfoArea getOrCreateInfoArea(ScreenLocation location) { return this.infoAreas.computeIfAbsent(location, (loc) -> new InfoArea(loc, this::notifyEnabledWidgetsChanged)); @@ -110,6 +118,8 @@ protected void fetchEnabledWidgets() */ public void tick() { + this.geometryResizeNotifier.checkAndNotifyContainerOfChanges(false); + if (this.needsReFetch) { this.fetchEnabledWidgets(); diff --git a/src/main/java/malilib/render/inventory/InventoryRenderUtils.java b/src/main/java/malilib/render/inventory/InventoryRenderUtils.java index a72883a5cf..5538891bcb 100644 --- a/src/main/java/malilib/render/inventory/InventoryRenderUtils.java +++ b/src/main/java/malilib/render/inventory/InventoryRenderUtils.java @@ -4,6 +4,8 @@ import java.util.Map; import javax.annotation.Nullable; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import org.apache.commons.lang3.tuple.Pair; import net.minecraft.block.Block; @@ -503,19 +505,31 @@ else if (item == Items.BREWING_STAND) public static Pair getPointedInventory() { World world = WorldWrap.getBestWorld(); + Entity cameraEntity = GameWrap.getCameraEntity(); EntityPlayer clientPlayer = GameWrap.getClientPlayer(); - // We need to get the player from the server world, - // so that the player itself won't be included in the ray trace - EntityPlayer player = world.getPlayerEntityByUUID(EntityWrap.getUuid(clientPlayer)); - - if (player == null) + if (cameraEntity == clientPlayer && world instanceof WorldServer) { - player = clientPlayer; + // We need to get the player from the server world, + // so that the player itself won't be included in the ray trace + EntityPlayer player = world.getPlayerEntityByUUID(EntityWrap.getUuid(clientPlayer)); + + if (player == null) + { + cameraEntity = player; + } } RayTraceUtils.RayTraceFluidHandling fluidHandling = RayTraceUtils.RayTraceFluidHandling.NONE; - HitResult trace = RayTraceUtils.getRayTraceFromEntity(world, player, fluidHandling, true, 6.0); + HitResult trace; + if (cameraEntity != clientPlayer) + { + trace = RayTraceUtils.getRayTraceFromEntity(world, cameraEntity, fluidHandling, true, 6.0); + } + else + { + trace = GameWrap.getHitResult(); + } if (trace == null) {