Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/malilib/gui/BaseScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/malilib/overlay/InfoOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,8 +31,15 @@ public class InfoOverlay implements PostGameOverlayRenderer, PostScreenRenderer,
protected final List<InfoRendererWidget> enabledGuiWidgets = new ArrayList<>();
protected final List<InfoRendererWidget> allEnabledWidgets = new ArrayList<>();
protected final List<InfoArea> 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));
Expand Down Expand Up @@ -110,6 +118,8 @@ protected void fetchEnabledWidgets()
*/
public void tick()
{
this.geometryResizeNotifier.checkAndNotifyContainerOfChanges(false);

if (this.needsReFetch)
{
this.fetchEnabledWidgets();
Expand Down
28 changes: 21 additions & 7 deletions src/main/java/malilib/render/inventory/InventoryRenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -503,19 +505,31 @@ else if (item == Items.BREWING_STAND)
public static Pair<InventoryView, InventoryRenderDefinition> 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)
{
Expand Down