diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/SlotConfigGui.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/SlotConfigGui.java index 865bfbaab..c4b21b640 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/SlotConfigGui.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/SlotConfigGui.java @@ -50,7 +50,7 @@ import java.util.stream.Collectors; public class SlotConfigGui { - static HashMap slotElementMap = new HashMap<>(); + public static HashMap slotElementMap = new HashMap<>(); public static int selectedSlot = 0; diff --git a/src/client/java/techreborn/client/compat/rei/ReiPlugin.java b/src/client/java/techreborn/client/compat/rei/ReiPlugin.java index 1fd537877..652ff764c 100644 --- a/src/client/java/techreborn/client/compat/rei/ReiPlugin.java +++ b/src/client/java/techreborn/client/compat/rei/ReiPlugin.java @@ -264,6 +264,11 @@ public class ReiPlugin implements REIClientPlugin { }); } + @Override + public void registerExclusionZones(ExclusionZones zones) { + zones.register(GuiBase.class, new SlotConfigExclusionZones()); + } + public static Widget createProgressBar(int x, int y, double animationDuration, GuiBuilder.ProgressDirection direction) { return Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet); @@ -314,7 +319,7 @@ public class ReiPlugin implements REIClientPlugin { drawTexture(matrices, bounds.x - 1, bounds.y - 1, displayPower.xBar - 15, displayPower.yBar - 1, width, height); int innerDisplayHeight; if (animation.animationType != EntryAnimationType.NONE) { - innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight)); + innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / (float) innerHeight) % innerHeight)); if (animation.animationType == EntryAnimationType.DOWNWARDS) innerDisplayHeight = innerHeight - innerDisplayHeight; } else innerDisplayHeight = innerHeight; @@ -342,13 +347,12 @@ public class ReiPlugin implements REIClientPlugin { int width = bounds.width; int height = bounds.height; - PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower(); RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet); drawTexture(matrices, bounds.x - 4, bounds.y - 4, 194, 26, width + 8, height + 8); drawTexture(matrices, bounds.x - 1, bounds.y - 1, 194, 82, width + 2, height + 2); int innerDisplayHeight; if (animation.animationType != EntryAnimationType.NONE) { - innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / height) % height)); + innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / (float) height) % height)); if (animation.animationType == EntryAnimationType.DOWNWARDS) innerDisplayHeight = height - innerDisplayHeight; } else innerDisplayHeight = height; diff --git a/src/client/java/techreborn/client/compat/rei/SlotConfigExclusionZones.java b/src/client/java/techreborn/client/compat/rei/SlotConfigExclusionZones.java new file mode 100644 index 000000000..1d4c9241c --- /dev/null +++ b/src/client/java/techreborn/client/compat/rei/SlotConfigExclusionZones.java @@ -0,0 +1,38 @@ +package techreborn.client.compat.rei; + +import com.google.common.collect.Lists; +import me.shedaniel.math.Rectangle; +import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import reborncore.client.gui.builder.GuiBase; +import reborncore.client.gui.builder.slot.SlotConfigGui; +import reborncore.client.gui.builder.slot.elements.ConfigSlotElement; + +import java.util.Collection; +import java.util.Collections; + +@Environment(EnvType.CLIENT) +public class SlotConfigExclusionZones implements ExclusionZonesProvider> { + + @Override + public Collection provide(GuiBase screen) { + if (!screen.hideGuiElements()) { + return Collections.emptyList(); + } + if (SlotConfigGui.selectedSlot == -1){ + return Collections.emptyList(); + } + ConfigSlotElement element = SlotConfigGui.slotElementMap.get(SlotConfigGui.selectedSlot); + int slotX = element.x + screen.getGuiLeft() -50; + if (element.getWidth() + slotX > screen.getScreenWidth() ) { + int slotY = element.y + screen.getGuiTop() + 25; + int exclusionX = screen.getScreenWidth() + screen.getGuiLeft(); + int exclusionY = slotY + screen.getGuiTop() - (element.getHeight()/2); + int exclusionWidth = element.getWidth() + slotX - screen.getScreenWidth() + 15; + return Lists.newArrayList(new Rectangle(exclusionX, exclusionY, exclusionWidth, element.getHeight())); + } + + return Collections.emptyList(); + } +}