diff --git a/build.gradle b/build.gradle index ae99852c8..e4d2647f5 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,10 @@ repositories { name = "BuildCraft" url = "https://mod-buildcraft.com/maven" } + maven { + name = "HYWLA" + url = "https://maven.tehnut.info/" + } } sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 @@ -90,9 +94,11 @@ dependencies { modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" - modCompile "alexiil.mc.lib:libblockattributes-all:0.7.0" + modImplementation "alexiil.mc.lib:libblockattributes-all:0.7.0" + modImplementation "me.shedaniel:RoughlyEnoughItems:4.6.6" + modImplementation "mcp.mobius.waila:Hwyla:1.16.1-1.9.22-75" - compile 'com.google.code.findbugs:jsr305:3.0.2' + implementation 'com.google.code.findbugs:jsr305:3.0.2' // unit test dependencies testCompile "junit:junit:4.13" diff --git a/src/api/java/appeng/api/config/SecurityPermissions.java b/src/api/java/appeng/api/config/SecurityPermissions.java index 4e595f1ad..f13350639 100644 --- a/src/api/java/appeng/api/config/SecurityPermissions.java +++ b/src/api/java/appeng/api/config/SecurityPermissions.java @@ -23,6 +23,9 @@ package appeng.api.config; +import net.minecraft.text.Text; +import net.minecraft.text.TranslatableText; + /** * Represent the security systems basic permissions, these are not for * anti-griefing, they are part of the mod as a gameplay feature. @@ -64,7 +67,17 @@ public enum SecurityPermissions { return this.translationKey + ".name"; } + public Text nameText() { + return new TranslatableText(getTranslatedName()); + } + public String getTranslatedTip() { return this.translationKey + ".tip"; } + + + public Text tooltipText() { + return new TranslatableText(getTranslatedTip()); + } + } diff --git a/src/main/java/appeng/block/AEBaseBlockItemChargeable.java b/src/main/java/appeng/block/AEBaseBlockItemChargeable.java index ff7f2c742..e1248acac 100644 --- a/src/main/java/appeng/block/AEBaseBlockItemChargeable.java +++ b/src/main/java/appeng/block/AEBaseBlockItemChargeable.java @@ -73,7 +73,7 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte final double percent = internalCurrentPower / internalMaxPower; - lines.add(GuiText.StoredEnergy.textComponent() + lines.add(GuiText.StoredEnergy.text() .copy() .append(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower)) .append(new TranslatableText(PowerUnits.AE.unlocalizedName)) diff --git a/src/main/java/appeng/block/storage/ChestBlock.java b/src/main/java/appeng/block/storage/ChestBlock.java index a76086c43..8923eb99a 100644 --- a/src/main/java/appeng/block/storage/ChestBlock.java +++ b/src/main/java/appeng/block/storage/ChestBlock.java @@ -88,7 +88,6 @@ public class ChestBlock extends AEBaseTileBlock { } else { ContainerOpener.openContainer(ChestContainer.TYPE, p, ContainerLocator.forTileEntitySide(tg, hit.getSide())); - throw new IllegalStateException(); } return ActionResult.SUCCESS; diff --git a/src/main/java/appeng/bootstrap/BlockRendering.java b/src/main/java/appeng/bootstrap/BlockRendering.java index 5b6a901c8..ef0369ab8 100644 --- a/src/main/java/appeng/bootstrap/BlockRendering.java +++ b/src/main/java/appeng/bootstrap/BlockRendering.java @@ -20,6 +20,7 @@ package appeng.bootstrap; import java.util.function.BiFunction; +import appeng.client.render.model.AutoRotatingBakedModel; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; @@ -77,7 +78,7 @@ class BlockRendering implements IBlockRendering { // This is a default rotating model if the base-block uses an AE block entity // which exposes UP/FRONT as // extended props - // FIXME FABRIC factory.addModelOverride(id.getPath(), (l, m) -> new AutoRotatingBakedModel(m)); + factory.addModelOverride(id.getPath(), (l, m) -> new AutoRotatingBakedModel(m)); } if (this.blockColor != null) { diff --git a/src/main/java/appeng/client/AppEngClient.java b/src/main/java/appeng/client/AppEngClient.java index b61b6d9b6..70e105003 100644 --- a/src/main/java/appeng/client/AppEngClient.java +++ b/src/main/java/appeng/client/AppEngClient.java @@ -5,7 +5,6 @@ import appeng.bootstrap.ModelsReloadCallback; import appeng.bootstrap.components.IClientSetupComponent; import appeng.bootstrap.components.IItemColorRegistrationComponent; import appeng.bootstrap.components.IModelBakeComponent; -import appeng.bootstrap.components.ITileEntityRegistrationComponent; import appeng.client.gui.implementations.*; import appeng.client.render.cablebus.CableBusModelLoader; import appeng.client.render.effects.*; @@ -20,22 +19,23 @@ import appeng.core.features.registries.PartModels; import appeng.core.sync.network.ClientNetworkHandler; import appeng.core.worlddata.WorldData; import appeng.entity.*; +import appeng.fluids.client.gui.*; +import appeng.fluids.container.*; import appeng.hooks.ClientTickHandler; import appeng.util.Platform; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; import net.minecraft.client.MinecraftClient; import net.minecraft.client.options.KeyBinding; import net.minecraft.client.render.entity.ItemEntityRenderer; import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.util.InputUtil; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.MinecraftServer; @@ -52,13 +52,15 @@ import java.util.stream.Stream; @Environment(EnvType.CLIENT) public final class AppEngClient extends AppEngBase { + private final static String KEY_CATEGORY = "key.appliedenergistics2.category"; + private final MinecraftClient client; private final ClientNetworkHandler networkHandler; private final ClientTickHandler tickHandler; - private final EnumMap bindings = new EnumMap<>(ActionKey.class); + private final EnumMap bindings; public static AppEngClient instance() { return (AppEngClient) AppEng.instance(); @@ -87,6 +89,13 @@ public final class AppEngClient extends AppEngBase { ServerLifecycleEvents.SERVER_STARTED.register(WorldData::onServerStarting); ServerLifecycleEvents.SERVER_STOPPING.register(server -> WorldData.instance().onServerStopping()); ServerLifecycleEvents.SERVER_STOPPED.register(server -> WorldData.instance().onServerStoppped()); + + this.bindings = new EnumMap<>(ActionKey.class); + for (ActionKey key : ActionKey.values()) { + final KeyBinding binding = new KeyBinding(key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY); + KeyBindingHelper.registerKeyBinding(binding); + this.bindings.put(key, binding); + } } @Override @@ -253,43 +262,43 @@ public final class AppEngClient extends AppEngBase { ScreenRegistry.register(SkyChestContainer.TYPE, SkyChestScreen::new); ScreenRegistry.register(ChestContainer.TYPE, ChestScreen::new); ScreenRegistry.register(WirelessContainer.TYPE, WirelessScreen::new); -// FIXME FABRIC ScreenRegistry.>register( -// FIXME FABRIC MEMonitorableContainer.TYPE, MEMonitorableScreen::new); -// FIXME FABRIC ScreenRegistry.register(MEPortableCellContainer.TYPE, MEPortableCellScreen::new); -// FIXME FABRIC ScreenRegistry.register(WirelessTermContainer.TYPE, WirelessTermScreen::new); -// FIXME FABRIC ScreenRegistry.register(NetworkStatusContainer.TYPE, NetworkStatusScreen::new); -// FIXME FABRIC ScreenRegistry.>register( -// FIXME FABRIC CraftingCPUContainer.TYPE, CraftingCPUScreen::new); -// FIXME FABRIC ScreenRegistry.register(NetworkToolContainer.TYPE, NetworkToolScreen::new); -// FIXME FABRIC ScreenRegistry.register(QuartzKnifeContainer.TYPE, QuartzKnifeScreen::new); -// FIXME FABRIC ScreenRegistry.register(DriveContainer.TYPE, DriveScreen::new); -// FIXME FABRIC ScreenRegistry.register(VibrationChamberContainer.TYPE, VibrationChamberScreen::new); -// FIXME FABRIC ScreenRegistry.register(CondenserContainer.TYPE, CondenserScreen::new); -// FIXME FABRIC ScreenRegistry.register(InterfaceContainer.TYPE, InterfaceScreen::new); -// FIXME FABRIC ScreenRegistry.register(FluidInterfaceContainer.TYPE, FluidInterfaceScreen::new); -// FIXME FABRIC ScreenRegistry.>register( -// FIXME FABRIC UpgradeableContainer.TYPE, UpgradeableScreen::new); -// FIXME FABRIC ScreenRegistry.register(FluidIOContainer.TYPE, FluidIOScreen::new); -// FIXME FABRIC ScreenRegistry.register(IOPortContainer.TYPE, IOPortScreen::new); -// FIXME FABRIC ScreenRegistry.register(StorageBusContainer.TYPE, StorageBusScreen::new); -// FIXME FABRIC ScreenRegistry.register(FluidStorageBusContainer.TYPE, FluidStorageBusScreen::new); -// FIXME FABRIC ScreenRegistry.register(FormationPlaneContainer.TYPE, FormationPlaneScreen::new); -// FIXME FABRIC ScreenRegistry.register(FluidFormationPlaneContainer.TYPE, FluidFormationPlaneScreen::new); -// FIXME FABRIC ScreenRegistry.register(PriorityContainer.TYPE, PriorityScreen::new); -// FIXME FABRIC ScreenRegistry.register(SecurityStationContainer.TYPE, SecurityStationScreen::new); -// FIXME FABRIC ScreenRegistry.register(CraftingTermContainer.TYPE, CraftingTermScreen::new); -// FIXME FABRIC ScreenRegistry.register(PatternTermContainer.TYPE, PatternTermScreen::new); -// FIXME FABRIC ScreenRegistry.register(FluidTerminalContainer.TYPE, FluidTerminalScreen::new); -// FIXME FABRIC ScreenRegistry.register(LevelEmitterContainer.TYPE, LevelEmitterScreen::new); -// FIXME FABRIC ScreenRegistry.register(FluidLevelEmitterContainer.TYPE, FluidLevelEmitterScreen::new); -// FIXME FABRIC ScreenRegistry.register(SpatialIOPortContainer.TYPE, SpatialIOPortScreen::new); -// FIXME FABRIC ScreenRegistry.register(InscriberContainer.TYPE, InscriberScreen::new); -// FIXME FABRIC ScreenRegistry.register(CellWorkbenchContainer.TYPE, CellWorkbenchScreen::new); -// FIXME FABRIC ScreenRegistry.register(MolecularAssemblerContainer.TYPE, MolecularAssemblerScreen::new); -// FIXME FABRIC ScreenRegistry.register(CraftAmountContainer.TYPE, CraftAmountScreen::new); -// FIXME FABRIC ScreenRegistry.register(CraftConfirmContainer.TYPE, CraftConfirmScreen::new); -// FIXME FABRIC ScreenRegistry.register(InterfaceTerminalContainer.TYPE, InterfaceTerminalScreen::new); -// FIXME FABRIC ScreenRegistry.register(CraftingStatusContainer.TYPE, CraftingStatusScreen::new); + ScreenRegistry.>register( + MEMonitorableContainer.TYPE, MEMonitorableScreen::new); + ScreenRegistry.register(MEPortableCellContainer.TYPE, MEPortableCellScreen::new); + ScreenRegistry.register(WirelessTermContainer.TYPE, WirelessTermScreen::new); + ScreenRegistry.register(NetworkStatusContainer.TYPE, NetworkStatusScreen::new); + ScreenRegistry.>register( + CraftingCPUContainer.TYPE, CraftingCPUScreen::new); + ScreenRegistry.register(NetworkToolContainer.TYPE, NetworkToolScreen::new); + ScreenRegistry.register(QuartzKnifeContainer.TYPE, QuartzKnifeScreen::new); + ScreenRegistry.register(DriveContainer.TYPE, DriveScreen::new); + ScreenRegistry.register(VibrationChamberContainer.TYPE, VibrationChamberScreen::new); + ScreenRegistry.register(CondenserContainer.TYPE, CondenserScreen::new); + ScreenRegistry.register(InterfaceContainer.TYPE, InterfaceScreen::new); + ScreenRegistry.register(FluidInterfaceContainer.TYPE, FluidInterfaceScreen::new); + ScreenRegistry.>register( + UpgradeableContainer.TYPE, UpgradeableScreen::new); + ScreenRegistry.register(FluidIOContainer.TYPE, FluidIOScreen::new); + ScreenRegistry.register(IOPortContainer.TYPE, IOPortScreen::new); + ScreenRegistry.register(StorageBusContainer.TYPE, StorageBusScreen::new); + ScreenRegistry.register(FluidStorageBusContainer.TYPE, FluidStorageBusScreen::new); + ScreenRegistry.register(FormationPlaneContainer.TYPE, FormationPlaneScreen::new); + ScreenRegistry.register(FluidFormationPlaneContainer.TYPE, FluidFormationPlaneScreen::new); + ScreenRegistry.register(PriorityContainer.TYPE, PriorityScreen::new); + ScreenRegistry.register(SecurityStationContainer.TYPE, SecurityStationScreen::new); + ScreenRegistry.register(CraftingTermContainer.TYPE, CraftingTermScreen::new); + ScreenRegistry.register(PatternTermContainer.TYPE, PatternTermScreen::new); + ScreenRegistry.register(FluidTerminalContainer.TYPE, FluidTerminalScreen::new); + ScreenRegistry.register(LevelEmitterContainer.TYPE, LevelEmitterScreen::new); + ScreenRegistry.register(FluidLevelEmitterContainer.TYPE, FluidLevelEmitterScreen::new); + ScreenRegistry.register(SpatialIOPortContainer.TYPE, SpatialIOPortScreen::new); + ScreenRegistry.register(InscriberContainer.TYPE, InscriberScreen::new); + ScreenRegistry.register(CellWorkbenchContainer.TYPE, CellWorkbenchScreen::new); + ScreenRegistry.register(MolecularAssemblerContainer.TYPE, MolecularAssemblerScreen::new); + ScreenRegistry.register(CraftAmountContainer.TYPE, CraftAmountScreen::new); + ScreenRegistry.register(CraftConfirmContainer.TYPE, CraftConfirmScreen::new); + ScreenRegistry.register(InterfaceTerminalContainer.TYPE, InterfaceTerminalScreen::new); + ScreenRegistry.register(CraftingStatusContainer.TYPE, CraftingStatusScreen::new); } } diff --git a/src/main/java/appeng/client/gui/AEBaseScreen.java b/src/main/java/appeng/client/gui/AEBaseScreen.java index 886aebca4..f7b6c6e25 100644 --- a/src/main/java/appeng/client/gui/AEBaseScreen.java +++ b/src/main/java/appeng/client/gui/AEBaseScreen.java @@ -24,6 +24,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import appeng.mixins.SlotMixin; import com.google.common.base.Preconditions; @@ -40,7 +41,7 @@ import net.minecraft.client.render.VertexFormats; import net.minecraft.client.util.InputUtil; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.screen.slot.Slot; -import net.minecraft.text.StringRenderable; +import net.minecraft.text.LiteralText; import net.minecraft.text.Style; import net.minecraft.util.Formatting; import org.lwjgl.glfw.GLFW; @@ -175,8 +176,8 @@ public abstract class AEBaseScreen extends HandledScr } private void drawTooltip(MatrixStack matrices, ITooltip tooltip, int mouseX, int mouseY) { - final int x = tooltip.xPos(); // ((GuiImgButton) c).x; - int y = tooltip.yPos(); // ((GuiImgButton) c).y; + final int x = tooltip.xPos(); + int y = tooltip.yPos(); if (x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible()) { if (y < mouseY && y + tooltip.getHeight() > mouseY) { @@ -194,28 +195,28 @@ public abstract class AEBaseScreen extends HandledScr protected void drawTooltip(MatrixStack matrices, int x, int y, Text message) { String[] lines = message.getString().split("\n"); // FIXME FABRIC - this.drawTooltip(matrices, x, y, Arrays.asList(lines)); + List textLines = Arrays.stream(lines).map(LiteralText::new).collect(Collectors.toList()); + this.drawTooltip(matrices, x, y, textLines); } // FIXME FABRIC: move out to json (?) private static final Style TOOLTIP_HEADER = Style.EMPTY.withColor(Formatting.WHITE); private static final Style TOOLTIP_BODY = Style.EMPTY.withColor(Formatting.GRAY); - protected void drawTooltip(MatrixStack matrices, int x, int y, List lines) { + protected void drawTooltip(MatrixStack matrices, int x, int y, List lines) { if (lines.isEmpty()) { return; } - List renderableLines = new ArrayList<>(lines.size()); - // Make the first line white // All lines after the first are colored gray + List styledLines = new ArrayList<>(lines.size()); for (int i = 0; i < lines.size(); i++) { Style style = (i == 0) ? TOOLTIP_HEADER : TOOLTIP_BODY; - renderableLines.add(StringRenderable.styled(lines.get(0), style)); + styledLines.add(lines.get(i).copy().styled(s -> style)); } - this.renderTooltip(matrices, renderableLines, x, y); + this.renderTooltip(matrices, styledLines, x, y); } @Override @@ -261,7 +262,7 @@ public abstract class AEBaseScreen extends HandledScr } for (final CustomSlotWidget slot : this.guiSlots) { - slot.drawBackground(ox, oy, getZOffset()); + slot.drawBackground(matrices, ox, oy, getZOffset()); } } @@ -608,8 +609,8 @@ public abstract class AEBaseScreen extends HandledScr this.itemRenderer.zOffset = 0.0F; } - protected String getGuiDisplayName(final String in) { - return this.hasCustomInventoryName() ? this.getInventoryName() : in; + protected Text getGuiDisplayName(final Text in) { + return this.hasCustomInventoryName() ? new LiteralText(this.getInventoryName()) : in; } private boolean hasCustomInventoryName() { diff --git a/src/unported/java/appeng/client/gui/implementations/CellWorkbenchScreen.java b/src/main/java/appeng/client/gui/implementations/CellWorkbenchScreen.java similarity index 95% rename from src/unported/java/appeng/client/gui/implementations/CellWorkbenchScreen.java rename to src/main/java/appeng/client/gui/implementations/CellWorkbenchScreen.java index c5bdff621..9aee3ff83 100644 --- a/src/unported/java/appeng/client/gui/implementations/CellWorkbenchScreen.java +++ b/src/main/java/appeng/client/gui/implementations/CellWorkbenchScreen.java @@ -57,7 +57,7 @@ public class CellWorkbenchScreen extends UpgradeableScreen action("Partition"))); this.addButton(new ActionButton(this.x - 18, this.y + 8, ActionItems.CLOSE, act -> action("Clear"))); this.copyMode = this.addButton(new ToggleButton(this.x - 18, this.y + 48, 11 * 16 + 5, 12 * 16 + 5, - GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc.getLocal(), act -> action("CopyMode"))); + GuiText.CopyMode.text(), GuiText.CopyModeDesc.text(), act -> action("CopyMode"))); } @Override @@ -69,9 +69,9 @@ public class CellWorkbenchScreen extends UpgradeableScreen { public void init() { super.init(); - this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.textComponent(), + this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.text(), this.itemRenderer, btn -> openPriority())); } @@ -52,8 +52,8 @@ public class ChestScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Chest.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Chest.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/CondenserScreen.java b/src/main/java/appeng/client/gui/implementations/CondenserScreen.java similarity index 94% rename from src/unported/java/appeng/client/gui/implementations/CondenserScreen.java rename to src/main/java/appeng/client/gui/implementations/CondenserScreen.java index 026574c21..69cd29a93 100644 --- a/src/unported/java/appeng/client/gui/implementations/CondenserScreen.java +++ b/src/main/java/appeng/client/gui/implementations/CondenserScreen.java @@ -50,14 +50,14 @@ public class CondenserScreen extends AEBaseScreen { this.handler.getOutput()); this.addButton(new ProgressBar(this.handler, "guis/condenser.png", 120 + this.x, 25 + this.y, 178, - 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy.getLocal())); + 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy.text())); this.addButton(this.mode); } @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Condenser.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Condenser.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); this.mode.set(this.handler.getOutput()); this.mode.setFillVar(String.valueOf(this.handler.getOutput().requiredPower)); diff --git a/src/unported/java/appeng/client/gui/implementations/CraftAmountScreen.java b/src/main/java/appeng/client/gui/implementations/CraftAmountScreen.java similarity index 88% rename from src/unported/java/appeng/client/gui/implementations/CraftAmountScreen.java rename to src/main/java/appeng/client/gui/implementations/CraftAmountScreen.java index 2e16dcfc9..e86e0af61 100644 --- a/src/unported/java/appeng/client/gui/implementations/CraftAmountScreen.java +++ b/src/main/java/appeng/client/gui/implementations/CraftAmountScreen.java @@ -21,6 +21,7 @@ package appeng.client.gui.implementations; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; @@ -53,22 +54,22 @@ public class CraftAmountScreen extends AEBaseScreen { final int c = AEConfig.instance().craftItemsByStackAmounts(2); final int d = AEConfig.instance().craftItemsByStackAmounts(3); - this.addButton(new ButtonWidget(this.x + 20, this.y + 26, 22, 20, "+" + a, btn -> addQty(a))); - this.addButton(new ButtonWidget(this.x + 48, this.y + 26, 28, 20, "+" + b, btn -> addQty(b))); - this.addButton(new ButtonWidget(this.x + 82, this.y + 26, 32, 20, "+" + c, btn -> addQty(c))); - this.addButton(new ButtonWidget(this.x + 120, this.y + 26, 38, 20, "+" + d, btn -> addQty(d))); + this.addButton(new ButtonWidget(this.x + 20, this.y + 26, 22, 20, new LiteralText("+" + a), btn -> addQty(a))); + this.addButton(new ButtonWidget(this.x + 48, this.y + 26, 28, 20, new LiteralText("+" + b), btn -> addQty(b))); + this.addButton(new ButtonWidget(this.x + 82, this.y + 26, 32, 20, new LiteralText("+" + c), btn -> addQty(c))); + this.addButton(new ButtonWidget(this.x + 120, this.y + 26, 38, 20, new LiteralText("+" + d), btn -> addQty(d))); - this.addButton(new ButtonWidget(this.x + 20, this.y + 75, 22, 20, "-" + a, btn -> addQty(-a))); - this.addButton(new ButtonWidget(this.x + 48, this.y + 75, 28, 20, "-" + b, btn -> addQty(-b))); - this.addButton(new ButtonWidget(this.x + 82, this.y + 75, 32, 20, "-" + c, btn -> addQty(-c))); - this.addButton(new ButtonWidget(this.x + 120, this.y + 75, 38, 20, "-" + d, btn -> addQty(-d))); + this.addButton(new ButtonWidget(this.x + 20, this.y + 75, 22, 20, new LiteralText("-" + a), btn -> addQty(-a))); + this.addButton(new ButtonWidget(this.x + 48, this.y + 75, 28, 20, new LiteralText("-" + b), btn -> addQty(-b))); + this.addButton(new ButtonWidget(this.x + 82, this.y + 75, 32, 20, new LiteralText("-" + c), btn -> addQty(-c))); + this.addButton(new ButtonWidget(this.x + 120, this.y + 75, 38, 20, new LiteralText("-" + d), btn -> addQty(-d))); this.next = this.addButton( - new ButtonWidget(this.x + 128, this.y + 51, 38, 20, GuiText.Next.getLocal(), this::confirm)); + new ButtonWidget(this.x + 128, this.y + 51, 38, 20, GuiText.Next.text(), this::confirm)); subGui.addBackButton(this::addButton, 154, 0); - this.amountToCraft = new NumberBox(this.textRenderer, this.x + 62, this.y + 57, 59, this.textRenderer.FONT_HEIGHT, + this.amountToCraft = new NumberBox(this.textRenderer, this.x + 62, this.y + 57, 59, this.textRenderer.fontHeight, Integer.class); this.amountToCraft.setHasBorder(false); this.amountToCraft.setMaxLength(16); @@ -85,12 +86,12 @@ public class CraftAmountScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, GuiText.SelectAmount.getLocal(), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.SelectAmount.text(), 8, 6, 4210752); } @Override public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { - this.next.setMessage(hasShiftDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal()); + this.next.setMessage(hasShiftDown() ? GuiText.Start.text() : GuiText.Next.text()); this.bindTexture("guis/craft_amt.png"); drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight); @@ -102,7 +103,7 @@ public class CraftAmountScreen extends AEBaseScreen { this.next.active = false; } - this.amountToCraft.render(offsetX, offsetY, partialTicks); + this.amountToCraft.render(matrices, offsetX, offsetY, partialTicks); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/CraftConfirmScreen.java b/src/main/java/appeng/client/gui/implementations/CraftConfirmScreen.java similarity index 86% rename from src/unported/java/appeng/client/gui/implementations/CraftConfirmScreen.java rename to src/main/java/appeng/client/gui/implementations/CraftConfirmScreen.java index 3c1db10b5..56bf5d46a 100644 --- a/src/unported/java/appeng/client/gui/implementations/CraftConfirmScreen.java +++ b/src/main/java/appeng/client/gui/implementations/CraftConfirmScreen.java @@ -30,6 +30,7 @@ import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; @@ -82,17 +83,17 @@ public class CraftConfirmScreen extends AEBaseScreen { public void init() { super.init(); - this.start = new ButtonWidget(this.x + 162, this.y + this.backgroundHeight - 25, 50, 20, GuiText.Start.getLocal(), + this.start = new ButtonWidget(this.x + 162, this.y + this.backgroundHeight - 25, 50, 20, GuiText.Start.text(), btn -> start()); this.start.active = false; this.addButton(this.start); this.selectCPU = new ButtonWidget(this.x + (219 - 180) / 2, this.y + this.backgroundHeight - 68, 180, 20, - GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic, btn -> selectNextCpu()); + GuiText.CraftingCPU.withSuffix(": ").append(GuiText.Automatic.text()), btn -> selectNextCpu()); this.selectCPU.active = false; this.addButton(this.selectCPU); - addButton(new ButtonWidget(this.x + 6, this.y + this.backgroundHeight - 25, 50, 20, GuiText.Cancel.getLocal(), + addButton(new ButtonWidget(this.x + 6, this.y + this.backgroundHeight - 25, 50, 20, GuiText.Cancel.text(), btn -> subGui.goBack())); } @@ -134,19 +135,19 @@ public class CraftConfirmScreen extends AEBaseScreen { } private void updateCPUButtonText() { - String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal(); + Text btnTextText = GuiText.CraftingCPU.withSuffix(": ").append(GuiText.Automatic.text()); if (this.handler.getSelectedCpu() >= 0)// && status.selectedCpu < status.cpus.size() ) { if (this.handler.getName() != null) { - final String name = this.handler.getName().getStringTruncated(20); - btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name; + final String name = this.handler.getName().asTruncatedString(20); + btnTextText = GuiText.CraftingCPU.withSuffix(": " + name); } else { - btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.handler.getSelectedCpu(); + btnTextText = GuiText.CraftingCPU.withSuffix(": #" + this.handler.getSelectedCpu()); } } if (this.handler.hasNoCPU()) { - btnTextText = GuiText.NoCraftingCPUs.getLocal(); + btnTextText = GuiText.NoCraftingCPUs.text(); } this.selectCPU.setMessage(btnTextText); @@ -160,19 +161,19 @@ public class CraftConfirmScreen extends AEBaseScreen { public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { final long BytesUsed = this.handler.getUsedBytes(); final String byteUsed = NumberFormat.getInstance().format(BytesUsed); - final String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) - : GuiText.CalculatingWait.getLocal(); - this.textRenderer.draw(matrices, GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752); + final Text Add = BytesUsed > 0 ? new LiteralText(byteUsed + " ").append(GuiText.BytesUsed.text()) + : GuiText.CalculatingWait.text(); + this.textRenderer.draw(matrices, GuiText.CraftingPlan.withSuffix(" - ").append(Add), 8, 7, 4210752); - String dsp = null; + Text dsp; if (this.isSimulation()) { - dsp = GuiText.Simulation.getLocal(); + dsp = GuiText.Simulation.text(); } else { dsp = this.handler.getCpuAvailableBytes() > 0 - ? (GuiText.Bytes.getLocal() + ": " + this.handler.getCpuAvailableBytes() + " : " - + GuiText.CoProcessors.getLocal() + ": " + this.handler.getCpuCoProcessors()) - : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; + ? (GuiText.Bytes.withSuffix(": " + this.handler.getCpuAvailableBytes() + " : ").append( + GuiText.CoProcessors.text()).append(": " + this.handler.getCpuCoProcessors())) + : GuiText.Bytes.withSuffix(": N/A : ").append(GuiText.CoProcessors.text()).append(": N/A"); } final int offset = (219 - this.textRenderer.getWidth(dsp)) / 2; @@ -187,8 +188,8 @@ public class CraftConfirmScreen extends AEBaseScreen { final int viewStart = this.getScrollBar().getCurrentScroll() * 3; final int viewEnd = viewStart + 3 * this.rows; - String dspToolTip = ""; - final List lineList = new ArrayList<>(); + List dspToolTip = new ArrayList<>(); + final List lineList = new ArrayList<>(); int toolPosX = 0; int toolPosY = 0; @@ -228,14 +229,14 @@ public class CraftConfirmScreen extends AEBaseScreen { str = Long.toString(stored.getStackSize() / 1000000) + 'm'; } - str = GuiText.FromStorage.getLocal() + ": " + str; + str = GuiText.FromStorage.text() + ": " + str; final int w = 4 + this.textRenderer.getWidth(str); this.textRenderer.draw(matrices, str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752); if (this.tooltip == z - viewStart) { - lineList.add(GuiText.FromStorage.getLocal() + ": " + Long.toString(stored.getStackSize())); + lineList.add(GuiText.FromStorage.withSuffix(": " + stored.getStackSize())); } downY += 5; @@ -251,14 +252,14 @@ public class CraftConfirmScreen extends AEBaseScreen { str = Long.toString(missingStack.getStackSize() / 1000000) + 'm'; } - str = GuiText.Missing.getLocal() + ": " + str; + str = GuiText.Missing.text() + ": " + str; final int w = 4 + this.textRenderer.getWidth(str); this.textRenderer.draw(matrices, str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752); if (this.tooltip == z - viewStart) { - lineList.add(GuiText.Missing.getLocal() + ": " + Long.toString(missingStack.getStackSize())); + lineList.add(GuiText.Missing.withSuffix(": " + missingStack.getStackSize())); } red = true; @@ -274,14 +275,14 @@ public class CraftConfirmScreen extends AEBaseScreen { str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm'; } - str = GuiText.ToCraft.getLocal() + ": " + str; + str = GuiText.ToCraft.text() + ": " + str; final int w = 4 + this.textRenderer.getWidth(str); this.textRenderer.draw(matrices, str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752); if (this.tooltip == z - viewStart) { - lineList.add(GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize())); + lineList.add(GuiText.ToCraft.withSuffix(": " + pendingStack.getStackSize())); } } @@ -292,10 +293,10 @@ public class CraftConfirmScreen extends AEBaseScreen { final ItemStack is = refStack.asItemStackRepresentation(); if (this.tooltip == z - viewStart) { - dspToolTip = Platform.getItemDisplayName(refStack).getFormattedText(); + dspToolTip.add(Platform.getItemDisplayName(refStack)); if (lineList.size() > 0) { - dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList); + dspToolTip.addAll(lineList); } toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8; @@ -307,7 +308,7 @@ public class CraftConfirmScreen extends AEBaseScreen { if (red) { final int startX = x * (1 + sectionLength) + xo; final int startY = posY - 4; - fill(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000); + fill(matrices, startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000); } x++; @@ -320,7 +321,7 @@ public class CraftConfirmScreen extends AEBaseScreen { } if (this.tooltip >= 0 && !dspToolTip.isEmpty()) { - this.drawTooltip(, toolPosX, toolPosY + 10, dspToolTip); + this.drawTooltip(matrices, toolPosX, toolPosY + 10, dspToolTip); } } @@ -449,7 +450,7 @@ public class CraftConfirmScreen extends AEBaseScreen { } private void selectNextCpu() { - final boolean backwards = minecraft.mouse.wasRightButtonClicked(); + final boolean backwards = getClient().mouse.wasRightButtonClicked(); NetworkHandler.instance().sendToServer(new ConfigValuePacket("Terminal.Cpu", backwards ? "Prev" : "Next")); } diff --git a/src/unported/java/appeng/client/gui/implementations/CraftingCPUScreen.java b/src/main/java/appeng/client/gui/implementations/CraftingCPUScreen.java similarity index 91% rename from src/unported/java/appeng/client/gui/implementations/CraftingCPUScreen.java rename to src/main/java/appeng/client/gui/implementations/CraftingCPUScreen.java index 71055d1f5..2e389ddb4 100644 --- a/src/unported/java/appeng/client/gui/implementations/CraftingCPUScreen.java +++ b/src/main/java/appeng/client/gui/implementations/CraftingCPUScreen.java @@ -116,7 +116,7 @@ public class CraftingCPUScreen extends AEBaseScr super.init(); this.setScrollBar(); this.cancel = new ButtonWidget(this.x + CANCEL_LEFT_OFFSET, this.y + this.backgroundHeight - CANCEL_TOP_OFFSET, - CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.getLocal(), btn -> cancel()); + CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.text(), btn -> cancel()); this.addButton(this.cancel); } @@ -163,14 +163,14 @@ public class CraftingCPUScreen extends AEBaseScr @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - String title = this.getGuiDisplayName(GuiText.CraftingStatus.getLocal()); + Text title = this.getGuiDisplayName(GuiText.CraftingStatus.text()); if (this.handler.getEstimatedTime() > 0 && !this.visual.isEmpty()) { final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert(this.handler.getEstimatedTime(), TimeUnit.NANOSECONDS); final String etaTimeText = DurationFormatUtils.formatDuration(etaInMilliseconds, - GuiText.ETAFormat.getLocal()); - title += " - " + etaTimeText; + GuiText.ETAFormat.text().getString()); + title = title.copy().append(" - " + etaTimeText); } this.textRenderer.draw(matrices, title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR); @@ -180,8 +180,8 @@ public class CraftingCPUScreen extends AEBaseScr final int viewStart = this.getScrollBar().getCurrentScroll() * 3; final int viewEnd = viewStart + 3 * 6; - String dspToolTip = ""; - final List lineList = new ArrayList<>(); + List dspToolTip = new ArrayList<>(); + final List lineList = new ArrayList<>(); int toolPosX = 0; int toolPosY = 0; @@ -219,14 +219,14 @@ public class CraftingCPUScreen extends AEBaseScr | BACKGROUND_ALPHA; final int startX = (x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET) * 2; final int startY = ((y * offY + ITEMSTACK_TOP_OFFSET) - 3) * 2; - fill(startX, startY, startX + (SECTION_LENGTH * 2), startY + (offY * 2) - 2, bgColor); + fill(matrices, startX, startY, startX + (SECTION_LENGTH * 2), startY + (offY * 2) - 2, bgColor); } final int negY = ((lines - 1) * 5) / 2; int downY = 0; if (stored != null && stored.getStackSize() > 0) { - final String str = GuiText.Stored.getLocal() + ": " + final String str = GuiText.Stored.text() + ": " + converter.toWideReadableForm(stored.getStackSize()); final int w = 4 + this.textRenderer.getWidth(str); this.textRenderer.draw(matrices, str, @@ -235,14 +235,14 @@ public class CraftingCPUScreen extends AEBaseScr (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR); if (this.tooltip == z - viewStart) { - lineList.add(GuiText.Stored.getLocal() + ": " + Long.toString(stored.getStackSize())); + lineList.add(GuiText.Stored.withSuffix(": " + stored.getStackSize())); } downY += 5; } if (activeStack != null && activeStack.getStackSize() > 0) { - final String str = GuiText.Crafting.getLocal() + ": " + final String str = GuiText.Crafting.text() + ": " + converter.toWideReadableForm(activeStack.getStackSize()); final int w = 4 + this.textRenderer.getWidth(str); @@ -252,14 +252,14 @@ public class CraftingCPUScreen extends AEBaseScr (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR); if (this.tooltip == z - viewStart) { - lineList.add(GuiText.Crafting.getLocal() + ": " + Long.toString(activeStack.getStackSize())); + lineList.add(GuiText.Crafting.withSuffix(": " + activeStack.getStackSize())); } downY += 5; } if (pendingStack != null && pendingStack.getStackSize() > 0) { - final String str = GuiText.Scheduled.getLocal() + ": " + final String str = GuiText.Scheduled.text() + ": " + converter.toWideReadableForm(pendingStack.getStackSize()); final int w = 4 + this.textRenderer.getWidth(str); @@ -269,7 +269,7 @@ public class CraftingCPUScreen extends AEBaseScr (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR); if (this.tooltip == z - viewStart) { - lineList.add(GuiText.Scheduled.getLocal() + ": " + Long.toString(pendingStack.getStackSize())); + lineList.add(GuiText.Scheduled.withSuffix(": " + pendingStack.getStackSize())); } } @@ -280,10 +280,10 @@ public class CraftingCPUScreen extends AEBaseScr final ItemStack is = refStack.asItemStackRepresentation(); if (this.tooltip == z - viewStart) { - dspToolTip = Platform.getItemDisplayName(refStack).getFormattedText(); + dspToolTip.add(Platform.getItemDisplayName(refStack)); if (lineList.size() > 0) { - dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList); + dspToolTip.addAll(lineList); } toolPosX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8; @@ -302,7 +302,7 @@ public class CraftingCPUScreen extends AEBaseScr } if (this.tooltip >= 0 && !dspToolTip.isEmpty()) { - this.drawTooltip(, toolPosX, toolPosY + 10, dspToolTip); + this.drawTooltip(matrices, toolPosX, toolPosY + 10, dspToolTip); } } diff --git a/src/unported/java/appeng/client/gui/implementations/CraftingStatusScreen.java b/src/main/java/appeng/client/gui/implementations/CraftingStatusScreen.java similarity index 82% rename from src/unported/java/appeng/client/gui/implementations/CraftingStatusScreen.java rename to src/main/java/appeng/client/gui/implementations/CraftingStatusScreen.java index 6d9fc2537..466162021 100644 --- a/src/unported/java/appeng/client/gui/implementations/CraftingStatusScreen.java +++ b/src/main/java/appeng/client/gui/implementations/CraftingStatusScreen.java @@ -49,7 +49,7 @@ public class CraftingStatusScreen extends CraftingCPUScreen selectNextCpu()); + GuiText.CraftingCPU.withSuffix(": ").append(GuiText.NoCraftingCPUs.text()), btn -> selectNextCpu()); this.addButton(this.selectCPU); subGui.addBackButton(btn -> { @@ -65,33 +65,33 @@ public class CraftingStatusScreen extends CraftingCPUScreen= 0)// && status.selectedCpu < status.cpus.size() ) { if (this.handler.myName != null) { - final String name = this.handler.myName.getStringTruncated(20); - btnTextText = GuiText.CPUs.getLocal() + ": " + name; + final String name = this.handler.myName.asTruncatedString(20); + btnTextText = GuiText.CPUs.withSuffix(": " + name); } else { - btnTextText = GuiText.CPUs.getLocal() + ": #" + this.handler.selectedCpu; + btnTextText = GuiText.CPUs.withSuffix(": #" + this.handler.selectedCpu); } } if (this.handler.noCPU) { - btnTextText = GuiText.NoCraftingJobs.getLocal(); + btnTextText = GuiText.NoCraftingJobs.text(); } this.selectCPU.setMessage(btnTextText); } @Override - protected String getGuiDisplayName(final String in) { + protected Text getGuiDisplayName(final Text in) { return in; // the cup name is on the button } // FIXME: Extract to separate class? Shared with GuiCraftConfirm private void selectNextCpu() { - final boolean backwards = minecraft.mouse.wasRightButtonClicked(); + final boolean backwards = client.mouse.wasRightButtonClicked(); NetworkHandler.instance().sendToServer(new ConfigValuePacket("Terminal.Cpu", backwards ? "Prev" : "Next")); } diff --git a/src/unported/java/appeng/client/gui/implementations/CraftingTermScreen.java b/src/main/java/appeng/client/gui/implementations/CraftingTermScreen.java similarity index 97% rename from src/unported/java/appeng/client/gui/implementations/CraftingTermScreen.java rename to src/main/java/appeng/client/gui/implementations/CraftingTermScreen.java index f830a02f1..66163399f 100644 --- a/src/unported/java/appeng/client/gui/implementations/CraftingTermScreen.java +++ b/src/main/java/appeng/client/gui/implementations/CraftingTermScreen.java @@ -64,7 +64,7 @@ public class CraftingTermScreen extends MEMonitorableScreen { public void init() { super.init(); - this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.text(), this.itemRenderer, btn -> openPriorityGui())); } @@ -52,8 +52,8 @@ public class DriveScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Drive.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Drive.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/FormationPlaneScreen.java b/src/main/java/appeng/client/gui/implementations/FormationPlaneScreen.java similarity index 93% rename from src/unported/java/appeng/client/gui/implementations/FormationPlaneScreen.java rename to src/main/java/appeng/client/gui/implementations/FormationPlaneScreen.java index 306ad6e48..07b952888 100644 --- a/src/unported/java/appeng/client/gui/implementations/FormationPlaneScreen.java +++ b/src/main/java/appeng/client/gui/implementations/FormationPlaneScreen.java @@ -51,7 +51,7 @@ public class FormationPlaneScreen extends UpgradeableScreen(this.x - 18, this.y + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL); - this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.text(), this.itemRenderer, btn -> openPriorityGui())); this.addButton(this.placeMode); @@ -60,8 +60,8 @@ public class FormationPlaneScreen extends UpgradeableScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.GrindStone.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.GrindStone.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/IOPortScreen.java b/src/main/java/appeng/client/gui/implementations/IOPortScreen.java similarity index 95% rename from src/unported/java/appeng/client/gui/implementations/IOPortScreen.java rename to src/main/java/appeng/client/gui/implementations/IOPortScreen.java index 711ef285b..206005b47 100644 --- a/src/unported/java/appeng/client/gui/implementations/IOPortScreen.java +++ b/src/main/java/appeng/client/gui/implementations/IOPortScreen.java @@ -59,8 +59,8 @@ public class IOPortScreen extends UpgradeableScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.IOPort.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.IOPort.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); if (this.redstoneMode != null) { this.redstoneMode.set(this.cvb.getRedStoneMode()); diff --git a/src/unported/java/appeng/client/gui/implementations/InscriberScreen.java b/src/main/java/appeng/client/gui/implementations/InscriberScreen.java similarity index 88% rename from src/unported/java/appeng/client/gui/implementations/InscriberScreen.java rename to src/main/java/appeng/client/gui/implementations/InscriberScreen.java index bc2dbc31b..fde9fa2f6 100644 --- a/src/unported/java/appeng/client/gui/implementations/InscriberScreen.java +++ b/src/main/java/appeng/client/gui/implementations/InscriberScreen.java @@ -20,6 +20,7 @@ package appeng.client.gui.implementations; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; @@ -53,10 +54,10 @@ public class InscriberScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.pb.setFullMsg(this.handler.getCurrentProgress() * 100 / this.handler.getMaxProgress() + "%"); + this.pb.setFullMsg(new LiteralText(this.handler.getCurrentProgress() * 100 / this.handler.getMaxProgress() + "%")); - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Inscriber.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Inscriber.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); } @Override @@ -69,7 +70,7 @@ public class InscriberScreen extends AEBaseScreen { if (this.drawUpgrades()) { drawTexture(matrices, offsetX + 177, offsetY, 177, 0, 35, - 14 + this.handler.availableUpgrades() * 18, getZOffset()); + 14 + this.handler.availableUpgrades() * 18); } if (this.hasToolbox()) { drawTexture(matrices, offsetX + 178, offsetY + this.backgroundHeight - 90, 178, this.backgroundHeight - 90, 68, 68); diff --git a/src/unported/java/appeng/client/gui/implementations/InterfaceScreen.java b/src/main/java/appeng/client/gui/implementations/InterfaceScreen.java similarity index 85% rename from src/unported/java/appeng/client/gui/implementations/InterfaceScreen.java rename to src/main/java/appeng/client/gui/implementations/InterfaceScreen.java index 6860cac16..744222b64 100644 --- a/src/unported/java/appeng/client/gui/implementations/InterfaceScreen.java +++ b/src/main/java/appeng/client/gui/implementations/InterfaceScreen.java @@ -47,14 +47,14 @@ public class InterfaceScreen extends UpgradeableScreen { @Override protected void addButtons() { - this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.text(), this.itemRenderer, btn -> openPriorityGui())); this.blockMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 8, Settings.BLOCK, YesNo.NO); this.addButton(this.blockMode); this.interfaceMode = new ToggleButton(this.x - 18, this.y + 26, 84, 85, - GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal(), + GuiText.InterfaceTerminal.text(), GuiText.InterfaceTerminalHint.text(), btn -> selectNextInterfaceMode()); this.addButton(this.interfaceMode); } @@ -69,13 +69,13 @@ public class InterfaceScreen extends UpgradeableScreen { this.interfaceMode.setState(((InterfaceContainer) this.cvb).getInterfaceTerminalMode() == YesNo.YES); } - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Interface.getLocal()), 8, 6, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Interface.text()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752); - this.textRenderer.draw(matrices, GuiText.StoredItems.getLocal(), 8, 6 + 60 + 7, 4210752); - this.textRenderer.draw(matrices, GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752); + this.textRenderer.draw(matrices, GuiText.Config.text(), 8, 6 + 11 + 7, 4210752); + this.textRenderer.draw(matrices, GuiText.StoredItems.text(), 8, 6 + 60 + 7, 4210752); + this.textRenderer.draw(matrices, GuiText.Patterns.text(), 8, 6 + 73 + 7, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/InterfaceTerminalScreen.java b/src/main/java/appeng/client/gui/implementations/InterfaceTerminalScreen.java similarity index 97% rename from src/unported/java/appeng/client/gui/implementations/InterfaceTerminalScreen.java rename to src/main/java/appeng/client/gui/implementations/InterfaceTerminalScreen.java index 6002539bb..bbcc32ad3 100644 --- a/src/unported/java/appeng/client/gui/implementations/InterfaceTerminalScreen.java +++ b/src/main/java/appeng/client/gui/implementations/InterfaceTerminalScreen.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; +import alexiil.mc.lib.attributes.Simulation; import com.google.common.collect.HashMultimap; import com.mojang.blaze3d.systems.RenderSystem; @@ -95,8 +96,8 @@ public class InterfaceTerminalScreen extends AEBaseScreen public void init() { super.init(); - this.level = new NumberBox(this.textRenderer, this.x + 24, this.y + 43, 79, this.textRenderer.FONT_HEIGHT, + this.level = new NumberBox(this.textRenderer, this.x + 24, this.y + 43, 79, this.textRenderer.fontHeight, Long.class); this.level.setHasBorder(false); this.level.setMaxLength(16); this.level.setEditableColor(0xFFFFFF); this.level.setVisible(true); this.level.setFocused(true); - container.setTextField(this.level); + handler.setTextField(this.level); } @Override @@ -88,22 +89,22 @@ public class LevelEmitterScreen extends UpgradeableScreen final int c = AEConfig.instance().levelByStackAmounts(2); final int d = AEConfig.instance().levelByStackAmounts(3); - this.addButton(this.plus1 = new ButtonWidget(this.x + 20, this.y + 17, 22, 20, "+" + a, btn -> addQty(a))); + this.addButton(this.plus1 = new ButtonWidget(this.x + 20, this.y + 17, 22, 20, new LiteralText("+" + a), btn -> addQty(a))); this.addButton( - this.plus10 = new ButtonWidget(this.x + 48, this.y + 17, 28, 20, "+" + b, btn -> addQty(b))); + this.plus10 = new ButtonWidget(this.x + 48, this.y + 17, 28, 20, new LiteralText("+" + b), btn -> addQty(b))); this.addButton( - this.plus100 = new ButtonWidget(this.x + 82, this.y + 17, 32, 20, "+" + c, btn -> addQty(c))); + this.plus100 = new ButtonWidget(this.x + 82, this.y + 17, 32, 20, new LiteralText("+" + c), btn -> addQty(c))); this.addButton( - this.plus1000 = new ButtonWidget(this.x + 120, this.y + 17, 38, 20, "+" + d, btn -> addQty(d))); + this.plus1000 = new ButtonWidget(this.x + 120, this.y + 17, 38, 20, new LiteralText("+" + d), btn -> addQty(d))); this.addButton( - this.minus1 = new ButtonWidget(this.x + 20, this.y + 59, 22, 20, "-" + a, btn -> addQty(-a))); + this.minus1 = new ButtonWidget(this.x + 20, this.y + 59, 22, 20, new LiteralText("-" + a), btn -> addQty(-a))); this.addButton( - this.minus10 = new ButtonWidget(this.x + 48, this.y + 59, 28, 20, "-" + b, btn -> addQty(-b))); + this.minus10 = new ButtonWidget(this.x + 48, this.y + 59, 28, 20, new LiteralText("-" + b), btn -> addQty(-b))); this.addButton( - this.minus100 = new ButtonWidget(this.x + 82, this.y + 59, 32, 20, "-" + c, btn -> addQty(-c))); + this.minus100 = new ButtonWidget(this.x + 82, this.y + 59, 32, 20, new LiteralText("-" + c), btn -> addQty(-c))); this.addButton( - this.minus1000 = new ButtonWidget(this.x + 120, this.y + 59, 38, 20, "-" + d, btn -> addQty(-d))); + this.minus1000 = new ButtonWidget(this.x + 120, this.y + 59, 38, 20, new LiteralText("-" + d), btn -> addQty(-d))); this.addButton(this.levelMode); this.addButton(this.redstoneMode); @@ -115,7 +116,7 @@ public class LevelEmitterScreen extends UpgradeableScreen final boolean notCraftingMode = this.bc.getInstalledUpgrades(Upgrades.CRAFTING) == 0; // configure enabled status... - this.level.setEnabled(notCraftingMode); + this.level.active = notCraftingMode; this.plus1.active = notCraftingMode; this.plus10.active = notCraftingMode; this.plus100.active = notCraftingMode; @@ -141,7 +142,7 @@ public class LevelEmitterScreen extends UpgradeableScreen @Override public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { super.drawBG(matrices, offsetX, offsetY, mouseX, mouseY, partialTicks); - this.level.render(mouseX, mouseY, partialTicks); + this.level.render(matrices, mouseX, mouseY, partialTicks); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/MEMonitorableScreen.java b/src/main/java/appeng/client/gui/implementations/MEMonitorableScreen.java similarity index 97% rename from src/unported/java/appeng/client/gui/implementations/MEMonitorableScreen.java rename to src/main/java/appeng/client/gui/implementations/MEMonitorableScreen.java index ad7393488..9fb79ed1b 100644 --- a/src/unported/java/appeng/client/gui/implementations/MEMonitorableScreen.java +++ b/src/main/java/appeng/client/gui/implementations/MEMonitorableScreen.java @@ -20,6 +20,7 @@ package appeng.client.gui.implementations; import java.util.List; +import appeng.mixins.SlotMixin; import net.minecraft.client.util.InputUtil; import net.minecraft.client.util.math.MatrixStack; import org.lwjgl.glfw.GLFW; @@ -147,7 +148,7 @@ public class MEMonitorableScreen extends AEBas @Override public void init() { - getClient().keyboardListener.enableRepeatEvents(true); + getClient().keyboard.enableRepeatEvents(true); this.maxRows = this.getMaxRows(); TerminalStyle terminalStyle = AEConfig.instance().getTerminalStyle(); @@ -226,7 +227,7 @@ public class MEMonitorableScreen extends AEBas if (this.viewCell || this instanceof WirelessTermScreen) { this.craftingStatusBtn = this.addButton(new TabButton(this.x + 170, this.y - 4, 2 + 11 * 16, - GuiText.CraftingStatus.getLocal(), this.itemRenderer, btn -> showCraftingStatus())); + GuiText.CraftingStatus.text(), this.itemRenderer, btn -> showCraftingStatus())); this.craftingStatusBtn.setHideEdge(13); } @@ -277,8 +278,8 @@ public class MEMonitorableScreen extends AEBas @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(this.myName.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(this.myName.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); this.currentMouseX = mouseX; this.currentMouseY = mouseY; @@ -302,7 +303,7 @@ public class MEMonitorableScreen extends AEBas @Override public void removed() { super.removed(); - getClient().keyboardListener.enableRepeatEvents(false); + getClient().keyboard.enableRepeatEvents(false); memoryText = this.searchField.getText(); } @@ -358,7 +359,7 @@ public class MEMonitorableScreen extends AEBas } protected void repositionSlot(final AppEngSlot s) { - s.y = s.getY() + this.backgroundHeight - 78 - 5; + ((SlotMixin) s).setY(s.getY() + this.backgroundHeight - 78 - 5); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/MEPortableCellScreen.java b/src/main/java/appeng/client/gui/implementations/MEPortableCellScreen.java similarity index 100% rename from src/unported/java/appeng/client/gui/implementations/MEPortableCellScreen.java rename to src/main/java/appeng/client/gui/implementations/MEPortableCellScreen.java diff --git a/src/unported/java/appeng/client/gui/implementations/MolecularAssemblerScreen.java b/src/main/java/appeng/client/gui/implementations/MolecularAssemblerScreen.java similarity index 95% rename from src/unported/java/appeng/client/gui/implementations/MolecularAssemblerScreen.java rename to src/main/java/appeng/client/gui/implementations/MolecularAssemblerScreen.java index 437ed1762..ddb029c36 100644 --- a/src/unported/java/appeng/client/gui/implementations/MolecularAssemblerScreen.java +++ b/src/main/java/appeng/client/gui/implementations/MolecularAssemblerScreen.java @@ -20,6 +20,7 @@ package appeng.client.gui.implementations; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import appeng.api.config.RedstoneMode; @@ -58,7 +59,7 @@ public class MolecularAssemblerScreen extends UpgradeableScreen im @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, GuiText.NetworkDetails.getLocal(), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.NetworkDetails.text(), 8, 6, 4210752); this.textRenderer.draw(matrices, - GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong(container.getCurrentPower(), false), + GuiText.StoredPower.text() + ": " + Platform.formatPowerLong(handler.getCurrentPower(), false), 13, 16, 4210752); this.textRenderer.draw(matrices, - GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(container.getMaxPower(), false), 13, 26, + GuiText.MaxPower.text() + ": " + Platform.formatPowerLong(handler.getMaxPower(), false), 13, 26, 4210752); - this.textRenderer.draw(matrices, GuiText.PowerInputRate.getLocal() + ": " - + Platform.formatPowerLong(container.getAverageAddition(), true), 13, 143 - 10, 4210752); + this.textRenderer.draw(matrices, GuiText.PowerInputRate.text() + ": " + + Platform.formatPowerLong(handler.getAverageAddition(), true), 13, 143 - 10, 4210752); this.textRenderer.draw(matrices, - GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong(container.getPowerUsage(), true), + GuiText.PowerUsageRate.text() + ": " + Platform.formatPowerLong(handler.getPowerUsage(), true), 13, 143 - 20, 4210752); final int sectionLength = 30; @@ -123,10 +124,10 @@ public class NetworkStatusScreen extends AEBaseScreen im int y = 0; final int xo = 12; final int yo = 42; - final int viewStart = 0;// myScrollBar.getCurrentScroll() * 5; + final int viewStart = 0; final int viewEnd = viewStart + 5 * 4; - String toolTip = ""; + List toolTip = new ArrayList<>(); int toolPosX = 0; int toolPosY = 0; @@ -150,12 +151,12 @@ public class NetworkStatusScreen extends AEBaseScreen im final int posY = y * 18 + yo; if (this.tooltip == z - viewStart) { - toolTip = Platform.getItemDisplayName(refStack).getFormattedText(); + toolTip.add(Platform.getItemDisplayName(refStack)); - toolTip += ('\n' + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize())); + toolTip.add(GuiText.Installed.withSuffix(": " + (refStack.getStackSize()))); if (refStack.getCountRequestable() > 0) { - toolTip += ('\n' + GuiText.EnergyDrain.getLocal() + ": " - + Platform.formatPowerLong(refStack.getCountRequestable(), true)); + toolTip.add(GuiText.EnergyDrain.withSuffix(": " + + Platform.formatPowerLong(refStack.getCountRequestable(), true))); } toolPosX = x * sectionLength + xo + sectionLength - 8; @@ -173,8 +174,8 @@ public class NetworkStatusScreen extends AEBaseScreen im } } - if (this.tooltip >= 0 && toolTip.length() > 0) { - this.drawTooltip(, toolPosX, toolPosY + 10, toolTip); + if (this.tooltip >= 0 && toolTip.isEmpty()) { + this.drawTooltip(matrices, toolPosX, toolPosY + 10, toolTip); } } @@ -202,7 +203,7 @@ public class NetworkStatusScreen extends AEBaseScreen im } @Override - protected void renderTooltip(final ItemStack stack, final int x, final int y) { + protected void renderTooltip(MatrixStack matrices, final ItemStack stack, final int x, final int y) { final Slot s = this.getSlot(x, y); if (s instanceof SlotME && !stack.isEmpty()) { @@ -215,21 +216,21 @@ public class NetworkStatusScreen extends AEBaseScreen im } if (myStack != null) { - List currentToolTip = getTooltipFromItem(stack); + List currentToolTip = getTooltipFromItem(stack); while (currentToolTip.size() > 1) { currentToolTip.remove(1); } - currentToolTip.add(GuiText.Installed.getLocal() + ": " + (myStack.getStackSize())); - currentToolTip.add(GuiText.EnergyDrain.getLocal() + ": " - + Platform.formatPowerLong(myStack.getCountRequestable(), true)); + currentToolTip.add(GuiText.Installed.withSuffix(": " + myStack.getStackSize())); + currentToolTip.add(GuiText.EnergyDrain.withSuffix(": " + + Platform.formatPowerLong(myStack.getCountRequestable(), true))); - this.drawTooltip(, x, y, currentToolTip); + this.drawTooltip(matrices, x, y, currentToolTip); } } - super.renderTooltip(stack, x, y); + super.renderTooltip(matrices, stack, x, y); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/NetworkToolScreen.java b/src/main/java/appeng/client/gui/implementations/NetworkToolScreen.java similarity index 88% rename from src/unported/java/appeng/client/gui/implementations/NetworkToolScreen.java rename to src/main/java/appeng/client/gui/implementations/NetworkToolScreen.java index e7853a038..53c54e807 100644 --- a/src/unported/java/appeng/client/gui/implementations/NetworkToolScreen.java +++ b/src/main/java/appeng/client/gui/implementations/NetworkToolScreen.java @@ -44,7 +44,7 @@ public class NetworkToolScreen extends AEBaseScreen { super.init(); this.tFacades = new ToggleButton(this.x - 18, this.y + 8, 23, 22, - GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint.getLocal(), + GuiText.TransparentFacades.text(), GuiText.TransparentFacadesHint.text(), btn -> toggleFacades()); this.addButton(this.tFacades); @@ -57,11 +57,11 @@ public class NetworkToolScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { if (this.tFacades != null) { - this.tFacades.setState(container.isFacadeMode()); + this.tFacades.setState(handler.isFacadeMode()); } - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.NetworkTool.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.NetworkTool.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/PatternTermScreen.java b/src/main/java/appeng/client/gui/implementations/PatternTermScreen.java similarity index 95% rename from src/unported/java/appeng/client/gui/implementations/PatternTermScreen.java rename to src/main/java/appeng/client/gui/implementations/PatternTermScreen.java index 0847ad1c1..28c327d69 100644 --- a/src/unported/java/appeng/client/gui/implementations/PatternTermScreen.java +++ b/src/main/java/appeng/client/gui/implementations/PatternTermScreen.java @@ -18,6 +18,7 @@ package appeng.client.gui.implementations; +import appeng.mixins.SlotMixin; import net.minecraft.block.Blocks; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; @@ -59,12 +60,12 @@ public class PatternTermScreen extends MEMonitorableScreen super.init(); this.tabCraftButton = new TabButton(this.x + 173, this.y + this.backgroundHeight - 177, - new ItemStack(Blocks.CRAFTING_TABLE), GuiText.CraftingPattern.getLocal(), this.itemRenderer, + new ItemStack(Blocks.CRAFTING_TABLE), GuiText.CraftingPattern.text(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_PROCESSING)); this.addButton(this.tabCraftButton); this.tabProcessButton = new TabButton(this.x + 173, this.y + this.backgroundHeight - 177, - new ItemStack(Blocks.FURNACE), GuiText.ProcessingPattern.getLocal(), this.itemRenderer, + new ItemStack(Blocks.FURNACE), GuiText.ProcessingPattern.text(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_CRFTING)); this.addButton(this.tabProcessButton); @@ -125,7 +126,7 @@ public class PatternTermScreen extends MEMonitorableScreen } super.drawFG(matrices, offsetX, offsetY, mouseX, mouseY); - this.textRenderer.draw(matrices, GuiText.PatternTerminal.getLocal(), 8, this.backgroundHeight - 96 + 2 - this.getReservedSpace(), + this.textRenderer.draw(matrices, GuiText.PatternTerminal.text(), 8, this.backgroundHeight - 96 + 2 - this.getReservedSpace(), 4210752); } @@ -142,7 +143,7 @@ public class PatternTermScreen extends MEMonitorableScreen protected void repositionSlot(final AppEngSlot s) { final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3; - s.y = s.getY() + this.backgroundHeight - 78 - offsetPlayerSide; + ((SlotMixin) s).setY(s.getY() + this.backgroundHeight - 78 - offsetPlayerSide); } } diff --git a/src/unported/java/appeng/client/gui/implementations/PriorityScreen.java b/src/main/java/appeng/client/gui/implementations/PriorityScreen.java similarity index 88% rename from src/unported/java/appeng/client/gui/implementations/PriorityScreen.java rename to src/main/java/appeng/client/gui/implementations/PriorityScreen.java index 2125cf66f..96ed32a39 100644 --- a/src/unported/java/appeng/client/gui/implementations/PriorityScreen.java +++ b/src/main/java/appeng/client/gui/implementations/PriorityScreen.java @@ -21,6 +21,7 @@ package appeng.client.gui.implementations; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import appeng.client.gui.AEBaseScreen; @@ -51,31 +52,31 @@ public class PriorityScreen extends AEBaseScreen { final int c = AEConfig.instance().priorityByStacksAmounts(2); final int d = AEConfig.instance().priorityByStacksAmounts(3); - this.addButton(new ButtonWidget(this.x + 20, this.y + 32, 22, 20, "+" + a, btn -> addQty(a))); - this.addButton(new ButtonWidget(this.x + 48, this.y + 32, 28, 20, "+" + b, btn -> addQty(b))); - this.addButton(new ButtonWidget(this.x + 82, this.y + 32, 32, 20, "+" + c, btn -> addQty(c))); - this.addButton(new ButtonWidget(this.x + 120, this.y + 32, 38, 20, "+" + d, btn -> addQty(d))); + this.addButton(new ButtonWidget(this.x + 20, this.y + 32, 22, 20, new LiteralText("+" + a), btn -> addQty(a))); + this.addButton(new ButtonWidget(this.x + 48, this.y + 32, 28, 20, new LiteralText("+" + b), btn -> addQty(b))); + this.addButton(new ButtonWidget(this.x + 82, this.y + 32, 32, 20, new LiteralText("+" + c), btn -> addQty(c))); + this.addButton(new ButtonWidget(this.x + 120, this.y + 32, 38, 20, new LiteralText("+" + d), btn -> addQty(d))); - this.addButton(new ButtonWidget(this.x + 20, this.y + 69, 22, 20, "-" + a, btn -> addQty(-a))); - this.addButton(new ButtonWidget(this.x + 48, this.y + 69, 28, 20, "-" + b, btn -> addQty(-b))); - this.addButton(new ButtonWidget(this.x + 82, this.y + 69, 32, 20, "-" + c, btn -> addQty(-c))); - this.addButton(new ButtonWidget(this.x + 120, this.y + 69, 38, 20, "-" + d, btn -> addQty(-d))); + this.addButton(new ButtonWidget(this.x + 20, this.y + 69, 22, 20, new LiteralText("-" + a), btn -> addQty(-a))); + this.addButton(new ButtonWidget(this.x + 48, this.y + 69, 28, 20, new LiteralText("-" + b), btn -> addQty(-b))); + this.addButton(new ButtonWidget(this.x + 82, this.y + 69, 32, 20, new LiteralText("-" + c), btn -> addQty(-c))); + this.addButton(new ButtonWidget(this.x + 120, this.y + 69, 38, 20, new LiteralText("-" + d), btn -> addQty(-d))); this.subGui.addBackButton(this::addButton, 154, 0); - this.priority = new NumberBox(this.textRenderer, this.x + 62, this.y + 57, 59, this.textRenderer.FONT_HEIGHT, + this.priority = new NumberBox(this.textRenderer, this.x + 62, this.y + 57, 59, this.textRenderer.fontHeight, Long.class); this.priority.setHasBorder(false); this.priority.setMaxLength(16); this.priority.setEditableColor(0xFFFFFF); this.priority.setVisible(true); this.priority.setFocused(true); - container.setTextField(this.priority); + handler.setTextField(this.priority); } @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, GuiText.Priority.getLocal(), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.Priority.text(), 8, 6, 4210752); } @Override @@ -83,7 +84,7 @@ public class PriorityScreen extends AEBaseScreen { this.bindTexture(getBackground()); drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight); - this.priority.render(mouseX, mouseY, partialTicks); + this.priority.render(matrices, mouseX, mouseY, partialTicks); } private void addQty(final int i) { diff --git a/src/main/java/appeng/client/gui/implementations/QNBScreen.java b/src/main/java/appeng/client/gui/implementations/QNBScreen.java index 172e682b2..c5d05b310 100644 --- a/src/main/java/appeng/client/gui/implementations/QNBScreen.java +++ b/src/main/java/appeng/client/gui/implementations/QNBScreen.java @@ -36,8 +36,8 @@ public class QNBScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.QuantumLinkChamber.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.QuantumLinkChamber.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/QuartzKnifeScreen.java b/src/main/java/appeng/client/gui/implementations/QuartzKnifeScreen.java similarity index 87% rename from src/unported/java/appeng/client/gui/implementations/QuartzKnifeScreen.java rename to src/main/java/appeng/client/gui/implementations/QuartzKnifeScreen.java index 8f7dcfe60..c6712d7d0 100644 --- a/src/unported/java/appeng/client/gui/implementations/QuartzKnifeScreen.java +++ b/src/main/java/appeng/client/gui/implementations/QuartzKnifeScreen.java @@ -20,6 +20,7 @@ package appeng.client.gui.implementations; import net.minecraft.client.util.InputUtil; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.LiteralText; import org.lwjgl.glfw.GLFW; import net.minecraft.client.gui.widget.TextFieldWidget; @@ -48,32 +49,32 @@ public class QuartzKnifeScreen extends AEBaseScreen { public void init() { super.init(); - this.name = new TextFieldWidget(this.textRenderer, this.x + 24, this.y + 32, 79, this.textRenderer.FONT_HEIGHT, ""); + this.name = new TextFieldWidget(this.textRenderer, this.x + 24, this.y + 32, 79, this.textRenderer.fontHeight, LiteralText.EMPTY); this.name.setHasBorder(false); this.name.setMaxLength(32); this.name.setEditableColor(0xFFFFFF); this.name.setVisible(true); - this.name.setFocused(true); + this.name.setSelected(true); } @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.QuartzCuttingKnife.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.QuartzCuttingKnife.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); } @Override public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { this.bindTexture("guis/quartzknife.png"); drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight); - this.name.render(mouseX, mouseY, partialTicks); + this.name.render(matrices, mouseX, mouseY, partialTicks); } @Override public boolean charTyped(char character, int key) { if (this.name.isFocused() && this.name.charTyped(character, key)) { final String Out = this.name.getText(); - container.setName(Out); + handler.setName(Out); NetworkHandler.instance().sendToServer(new ConfigValuePacket("QuartzKnife.Name", Out)); return true; } @@ -86,19 +87,19 @@ public class QuartzKnifeScreen extends AEBaseScreen { if (keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(keyCode, scanCode)) { if (AppEng.instance().isActionKey(ActionKey.TOGGLE_FOCUS, keyCode, scanCode)) { - this.name.setFocused(!this.name.isFocused()); + this.name.setSelected(!this.name.isFocused()); return true; } if (this.name.isFocused()) { if (keyCode == GLFW.GLFW_KEY_ENTER) { - this.name.setFocused(false); + this.name.setSelected(false); return true; } if (this.name.keyPressed(keyCode, scanCode, p_keyPressed_3_)) { final String Out = this.name.getText(); - container.setName(Out); + handler.setName(Out); NetworkHandler.instance().sendToServer(new ConfigValuePacket("QuartzKnife.Name", Out)); return true; } diff --git a/src/unported/java/appeng/client/gui/implementations/SecurityStationScreen.java b/src/main/java/appeng/client/gui/implementations/SecurityStationScreen.java similarity index 75% rename from src/unported/java/appeng/client/gui/implementations/SecurityStationScreen.java rename to src/main/java/appeng/client/gui/implementations/SecurityStationScreen.java index a094f0dd6..07a39dc9c 100644 --- a/src/unported/java/appeng/client/gui/implementations/SecurityStationScreen.java +++ b/src/main/java/appeng/client/gui/implementations/SecurityStationScreen.java @@ -60,40 +60,40 @@ public class SecurityStationScreen extends MEMonitorableScreen toggleOption(SecurityPermissions.INJECT))); this.extract = this.addButton(new ToggleButton(this.x + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, - SecurityPermissions.EXTRACT.getTranslatedName(), SecurityPermissions.EXTRACT.getTranslatedTip(), + SecurityPermissions.EXTRACT.nameText(), SecurityPermissions.EXTRACT.tooltipText(), btn -> toggleOption(SecurityPermissions.EXTRACT))); this.craft = this.addButton(new ToggleButton(this.x + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, - SecurityPermissions.CRAFT.getTranslatedName(), SecurityPermissions.CRAFT.getTranslatedTip(), + SecurityPermissions.CRAFT.nameText(), SecurityPermissions.CRAFT.tooltipText(), btn -> toggleOption(SecurityPermissions.CRAFT))); this.build = this.addButton(new ToggleButton(this.x + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, - SecurityPermissions.BUILD.getTranslatedName(), SecurityPermissions.BUILD.getTranslatedTip(), + SecurityPermissions.BUILD.nameText(), SecurityPermissions.BUILD.tooltipText(), btn -> toggleOption(SecurityPermissions.BUILD))); this.security = this.addButton(new ToggleButton(this.x + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, - SecurityPermissions.SECURITY.getTranslatedName(), SecurityPermissions.SECURITY.getTranslatedTip(), + SecurityPermissions.SECURITY.nameText(), SecurityPermissions.SECURITY.tooltipText(), btn -> toggleOption(SecurityPermissions.SECURITY))); } @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { super.drawFG(matrices, offsetX, offsetY, mouseX, mouseY); - this.textRenderer.draw(matrices, GuiText.SecurityCardEditor.getLocal(), 8, this.backgroundHeight - 96 + 1 - this.getReservedSpace(), + this.textRenderer.draw(matrices, GuiText.SecurityCardEditor.text(), 8, this.backgroundHeight - 96 + 1 - this.getReservedSpace(), 4210752); } @Override protected String getBackground() { - this.inject.setState((container.getPermissionMode() & (1 << SecurityPermissions.INJECT.ordinal())) > 0); - this.extract.setState((container.getPermissionMode() & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0); - this.craft.setState((container.getPermissionMode() & (1 << SecurityPermissions.CRAFT.ordinal())) > 0); - this.build.setState((container.getPermissionMode() & (1 << SecurityPermissions.BUILD.ordinal())) > 0); - this.security.setState((container.getPermissionMode() & (1 << SecurityPermissions.SECURITY.ordinal())) > 0); + this.inject.setState((handler.getPermissionMode() & (1 << SecurityPermissions.INJECT.ordinal())) > 0); + this.extract.setState((handler.getPermissionMode() & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0); + this.craft.setState((handler.getPermissionMode() & (1 << SecurityPermissions.CRAFT.ordinal())) > 0); + this.build.setState((handler.getPermissionMode() & (1 << SecurityPermissions.BUILD.ordinal())) > 0); + this.security.setState((handler.getPermissionMode() & (1 << SecurityPermissions.SECURITY.ordinal())) > 0); return "guis/security_station.png"; } diff --git a/src/main/java/appeng/client/gui/implementations/SkyChestScreen.java b/src/main/java/appeng/client/gui/implementations/SkyChestScreen.java index decf5ed00..e89f82ddc 100644 --- a/src/main/java/appeng/client/gui/implementations/SkyChestScreen.java +++ b/src/main/java/appeng/client/gui/implementations/SkyChestScreen.java @@ -40,8 +40,8 @@ public class SkyChestScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.SkyChest.getLocal()), 8, 8, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 2, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.SkyChest.text()), 8, 8, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 2, 4210752); } @Override diff --git a/src/unported/java/appeng/client/gui/implementations/SpatialIOPortScreen.java b/src/main/java/appeng/client/gui/implementations/SpatialIOPortScreen.java similarity index 77% rename from src/unported/java/appeng/client/gui/implementations/SpatialIOPortScreen.java rename to src/main/java/appeng/client/gui/implementations/SpatialIOPortScreen.java index cb035c0d5..8a078f425 100644 --- a/src/unported/java/appeng/client/gui/implementations/SpatialIOPortScreen.java +++ b/src/main/java/appeng/client/gui/implementations/SpatialIOPortScreen.java @@ -45,26 +45,26 @@ public class SpatialIOPortScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, GuiText.StoredPower.getLocal() + ": " + this.textRenderer.draw(matrices, GuiText.StoredPower.text() + ": " + Platform.formatPowerLong(this.handler.getCurrentPower(), false), 13, 21, 4210752); this.textRenderer.draw(matrices, - GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(this.handler.getMaxPower(), false), 13, + GuiText.MaxPower.text() + ": " + Platform.formatPowerLong(this.handler.getMaxPower(), false), 13, 31, 4210752); - this.textRenderer.draw(matrices, GuiText.RequiredPower.getLocal() + ": " + this.textRenderer.draw(matrices, GuiText.RequiredPower.text() + ": " + Platform.formatPowerLong(this.handler.getRequiredPower(), false), 13, 73, 4210752); this.textRenderer.draw(matrices, - GuiText.Efficiency.getLocal() + ": " + (((float) this.handler.getEfficency()) / 100) + '%', 13, 83, + GuiText.Efficiency.text() + ": " + (((float) this.handler.getEfficency()) / 100) + '%', 13, 83, 4210752); - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.SpatialIOPort.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.SpatialIOPort.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96, 4210752); if (this.handler.xSize != 0 && this.handler.ySize != 0 && this.handler.zSize != 0) { - final String text = GuiText.SCSSize.getLocal() + ": " + this.handler.xSize + "x" + this.handler.ySize + final String text = GuiText.SCSSize.text() + ": " + this.handler.xSize + "x" + this.handler.ySize + "x" + this.handler.zSize; this.textRenderer.draw(matrices, text, 13, 93, 4210752); } else { - this.textRenderer.draw(matrices, GuiText.SCSSize.getLocal() + ": " + GuiText.SCSInvalid.getLocal(), 13, 93, 4210752); + this.textRenderer.draw(matrices, GuiText.SCSSize.text() + ": " + GuiText.SCSInvalid.text(), 13, 93, 4210752); } } diff --git a/src/unported/java/appeng/client/gui/implementations/StorageBusScreen.java b/src/main/java/appeng/client/gui/implementations/StorageBusScreen.java similarity index 95% rename from src/unported/java/appeng/client/gui/implementations/StorageBusScreen.java rename to src/main/java/appeng/client/gui/implementations/StorageBusScreen.java index 5ae3465a3..9264259f5 100644 --- a/src/unported/java/appeng/client/gui/implementations/StorageBusScreen.java +++ b/src/main/java/appeng/client/gui/implementations/StorageBusScreen.java @@ -59,7 +59,7 @@ public class StorageBusScreen extends UpgradeableScreen { this.fuzzyMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL); - this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.getLocal(), + this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.text(), this.itemRenderer, btn -> openPriorityGui())); this.addButton(this.storageFilter); @@ -69,8 +69,8 @@ public class StorageBusScreen extends UpgradeableScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.StorageBus.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.StorageBus.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); if (this.fuzzyMode != null) { this.fuzzyMode.set(this.cvb.getFuzzyMode()); diff --git a/src/unported/java/appeng/client/gui/implementations/UpgradeableScreen.java b/src/main/java/appeng/client/gui/implementations/UpgradeableScreen.java similarity index 97% rename from src/unported/java/appeng/client/gui/implementations/UpgradeableScreen.java rename to src/main/java/appeng/client/gui/implementations/UpgradeableScreen.java index 8ee2e13aa..5ba022c91 100644 --- a/src/unported/java/appeng/client/gui/implementations/UpgradeableScreen.java +++ b/src/main/java/appeng/client/gui/implementations/UpgradeableScreen.java @@ -84,8 +84,8 @@ public class UpgradeableScreen extends AEBaseScr @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(this.getName().getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(this.getName().text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); if (this.redstoneMode != null) { this.redstoneMode.set(this.cvb.getRedStoneMode()); diff --git a/src/unported/java/appeng/client/gui/implementations/VibrationChamberScreen.java b/src/main/java/appeng/client/gui/implementations/VibrationChamberScreen.java similarity index 89% rename from src/unported/java/appeng/client/gui/implementations/VibrationChamberScreen.java rename to src/main/java/appeng/client/gui/implementations/VibrationChamberScreen.java index 66cae0cbe..c913ca6c2 100644 --- a/src/unported/java/appeng/client/gui/implementations/VibrationChamberScreen.java +++ b/src/main/java/appeng/client/gui/implementations/VibrationChamberScreen.java @@ -22,6 +22,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; @@ -52,11 +53,11 @@ public class VibrationChamberScreen extends AEBaseScreen 0) { final int i1 = this.handler.getRemainingBurnTime() * 12 / 100; diff --git a/src/main/java/appeng/client/gui/implementations/WirelessScreen.java b/src/main/java/appeng/client/gui/implementations/WirelessScreen.java index 2caab3b86..500cdb9b3 100644 --- a/src/main/java/appeng/client/gui/implementations/WirelessScreen.java +++ b/src/main/java/appeng/client/gui/implementations/WirelessScreen.java @@ -45,12 +45,12 @@ public class WirelessScreen extends AEBaseScreen { @Override public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Wireless.getLocal()), 8, 6, 4210752); - this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Wireless.text()), 8, 6, 4210752); + this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752); if (handler.getRange() > 0) { - final String firstMessage = GuiText.Range.getLocal() + ": " + (handler.getRange() / 10.0) + " m"; - final String secondMessage = GuiText.PowerUsageRate.getLocal() + ": " + final String firstMessage = GuiText.Range.text() + ": " + (handler.getRange() / 10.0) + " m"; + final String secondMessage = GuiText.PowerUsageRate.text() + ": " + Platform.formatPowerLong(handler.getDrain(), true); final int strWidth = Math.max(this.textRenderer.getWidth(firstMessage), diff --git a/src/unported/java/appeng/client/gui/implementations/WirelessTermScreen.java b/src/main/java/appeng/client/gui/implementations/WirelessTermScreen.java similarity index 100% rename from src/unported/java/appeng/client/gui/implementations/WirelessTermScreen.java rename to src/main/java/appeng/client/gui/implementations/WirelessTermScreen.java diff --git a/src/main/java/appeng/client/gui/widgets/CustomSlotWidget.java b/src/main/java/appeng/client/gui/widgets/CustomSlotWidget.java index 5009c0f6b..952fa471b 100644 --- a/src/main/java/appeng/client/gui/widgets/CustomSlotWidget.java +++ b/src/main/java/appeng/client/gui/widgets/CustomSlotWidget.java @@ -3,6 +3,7 @@ package appeng.client.gui.widgets; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; @@ -31,7 +32,7 @@ public abstract class CustomSlotWidget extends DrawableHelper implements IToolti public abstract void drawContent(final MinecraftClient mc, final int mouseX, final int mouseY, final float partialTicks); - public void drawBackground(int guileft, int guitop, int currentZIndex) { + public void drawBackground(MatrixStack matrices, int guileft, int guitop, int currentZIndex) { } @Override diff --git a/src/main/java/appeng/client/gui/widgets/NumberBox.java b/src/main/java/appeng/client/gui/widgets/NumberBox.java index bf0545cd1..c7d23158d 100644 --- a/src/main/java/appeng/client/gui/widgets/NumberBox.java +++ b/src/main/java/appeng/client/gui/widgets/NumberBox.java @@ -25,10 +25,10 @@ import net.minecraft.text.LiteralText; // FIXME: Fix this piece of crap (i.e. onChange listener) public class NumberBox extends TextFieldWidget { - private final Class type; + private final Class type; public NumberBox(final TextRenderer fontRenderer, final int x, final int y, final int width, final int height, - final Class type) { + final Class type) { super(fontRenderer, x, y, width, height, new LiteralText("0")); this.type = type; } @@ -50,4 +50,10 @@ public class NumberBox extends TextFieldWidget { this.setText(original); } } + + @Override + public void setFocused(boolean focused) { + super.setFocused(focused); + } + } diff --git a/src/main/java/appeng/client/gui/widgets/ProgressBar.java b/src/main/java/appeng/client/gui/widgets/ProgressBar.java index 6983c3b12..2f72514b7 100644 --- a/src/main/java/appeng/client/gui/widgets/ProgressBar.java +++ b/src/main/java/appeng/client/gui/widgets/ProgressBar.java @@ -84,7 +84,7 @@ public class ProgressBar extends AbstractButtonWidget implements ITooltip { Text text = this.titleName != null ? this.titleName : LiteralText.EMPTY; return text.copy().append("\n" + this.source.getCurrentProgress() + " ") - .append(GuiText.Of.textComponent()) + .append(GuiText.Of.text()) .append(" " + this.source.getMaxProgress()); } diff --git a/src/main/java/appeng/client/render/FacingToRotation.java b/src/main/java/appeng/client/render/FacingToRotation.java index 13a0741f4..5b037cbff 100644 --- a/src/main/java/appeng/client/render/FacingToRotation.java +++ b/src/main/java/appeng/client/render/FacingToRotation.java @@ -63,7 +63,7 @@ public enum FacingToRotation implements StringIdentifiable { private final Quaternion combinedRotation; private final Matrix4f mat; - private FacingToRotation(Vector3f rot) { + FacingToRotation(Vector3f rot) { this.rot = rot; this.mat = new Matrix4f(); this.mat.loadIdentity(); diff --git a/src/main/java/appeng/client/render/cablebus/QuadRotator.java b/src/main/java/appeng/client/render/cablebus/QuadRotator.java index c5a99f6d7..7c8398112 100644 --- a/src/main/java/appeng/client/render/cablebus/QuadRotator.java +++ b/src/main/java/appeng/client/render/cablebus/QuadRotator.java @@ -24,10 +24,7 @@ import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; import net.minecraft.client.util.math.Vector3f; -import net.minecraft.client.util.math.Vector4f; import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Matrix3f; -import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Quaternion; import java.util.EnumMap; @@ -39,7 +36,7 @@ import java.util.EnumMap; @Environment(EnvType.CLIENT) public class QuadRotator implements RenderContext.QuadTransform { - private static final RenderContext.QuadTransform NULL_TRANSFORM = quad -> true; + public static final RenderContext.QuadTransform NULL_TRANSFORM = quad -> true; private static final EnumMap TRANSFORMS = new EnumMap<>(FacingToRotation.class); @@ -58,16 +55,20 @@ public class QuadRotator implements RenderContext.QuadTransform { private final Quaternion quaternion; - public QuadRotator(FacingToRotation rotation) { + private QuadRotator(FacingToRotation rotation) { this.rotation = rotation; this.quaternion = rotation.getRot(); } public static RenderContext.QuadTransform get(Direction newForward, Direction newUp) { - if (newForward == Direction.NORTH && newUp == Direction.UP) { + return get(getRotation(newForward, newUp)); + } + + public static RenderContext.QuadTransform get(FacingToRotation rotation) { + if (rotation.isRedundant()) { return NULL_TRANSFORM; // This is the default orientation } - return TRANSFORMS.get(getRotation(newForward, newUp)); + return TRANSFORMS.get(rotation); } @Override @@ -85,12 +86,17 @@ public class QuadRotator implements RenderContext.QuadTransform { // Transform the normal quad.copyNormal(i, tmp); - tmp.rotate(rotation.getRot()); + tmp.rotate(quaternion); quad.normal(i, tmp); - - // Transform the nominal face - quad.nominalFace(rotation.rotate(quad.nominalFace())); } + + // Transform the nominal face + quad.nominalFace(rotation.rotate(quad.nominalFace())); + Direction cullFace = quad.cullFace(); + if (cullFace != null) { + quad.cullFace(rotation.rotate(cullFace)); + } + return true; } diff --git a/src/main/java/appeng/client/render/model/AutoRotatingBakedModel.java b/src/main/java/appeng/client/render/model/AutoRotatingBakedModel.java new file mode 100644 index 000000000..156cf9275 --- /dev/null +++ b/src/main/java/appeng/client/render/model/AutoRotatingBakedModel.java @@ -0,0 +1,69 @@ +package appeng.client.render.model; + +import appeng.client.render.cablebus.QuadRotator; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; +import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel; +import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; +import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView; +import net.minecraft.block.BlockState; +import net.minecraft.client.render.model.BakedModel; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockRenderView; + +import java.util.Random; +import java.util.function.Supplier; + +@Environment(EnvType.CLIENT) +public class AutoRotatingBakedModel extends ForwardingBakedModel implements FabricBakedModel { + + public AutoRotatingBakedModel(BakedModel wrapped) { + this.wrapped = wrapped; + } + + @Override + public boolean isVanillaAdapter() { + return false; + } + + @Override + public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { + RenderContext.QuadTransform transform = getTransform(blockView, pos); + + if (transform != null) { + context.pushTransform(transform); + } + + super.emitBlockQuads(blockView, state, pos, randomSupplier, context); + + if (transform != null) { + context.popTransform(); + } + } + + @Override + public void emitItemQuads(ItemStack stack, Supplier randomSupplier, RenderContext context) { + super.emitItemQuads(stack, randomSupplier, context); + } + + private RenderContext.QuadTransform getTransform(BlockRenderView view, BlockPos pos) { + if (!(view instanceof RenderAttachedBlockView)) { + return null; + } + + Object data = ((RenderAttachedBlockView) view).getBlockEntityRenderAttachment(pos); + if (!(data instanceof AEModelData)) { + return null; + } + + AEModelData aeModelData = (AEModelData) data; + RenderContext.QuadTransform transform = QuadRotator.get(aeModelData.getForward(), aeModelData.getUp()); + if (transform == QuadRotator.NULL_TRANSFORM) { + return null; + } + return transform; + } + +} diff --git a/src/main/java/appeng/container/implementations/ContainerHelper.java b/src/main/java/appeng/container/implementations/ContainerHelper.java index ecba190f1..b1af6764c 100644 --- a/src/main/java/appeng/container/implementations/ContainerHelper.java +++ b/src/main/java/appeng/container/implementations/ContainerHelper.java @@ -84,10 +84,9 @@ public final class ContainerHelper { return false; } - // FIXME FABRIC The containers usually handle this themselves... Text title = findContainerTitle(player.world, locator, accessInterface); - player.openHandledScreen(new HandlerFactory(locator, accessInterface)); + player.openHandledScreen(new HandlerFactory(locator, title, accessInterface)); return true; } @@ -98,8 +97,11 @@ public final class ContainerHelper { private final I accessInterface; - public HandlerFactory(ContainerLocator locator, I accessInterface) { + private final Text title; + + public HandlerFactory(ContainerLocator locator, Text title, I accessInterface) { this.locator = locator; + this.title = title; this.accessInterface = accessInterface; } @@ -110,7 +112,7 @@ public final class ContainerHelper { @Override public Text getDisplayName() { - return null; + return title; } @Nullable diff --git a/src/main/java/appeng/core/AppEngBase.java b/src/main/java/appeng/core/AppEngBase.java index b5cb8ddbc..1e1328523 100644 --- a/src/main/java/appeng/core/AppEngBase.java +++ b/src/main/java/appeng/core/AppEngBase.java @@ -2,9 +2,11 @@ package appeng.core; import appeng.api.features.IRegistryContainer; import appeng.api.networking.IGridCacheRegistry; +import appeng.api.networking.crafting.ICraftingGrid; import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.pathing.IPathingGrid; import appeng.api.networking.security.ISecurityGrid; +import appeng.api.networking.spatial.ISpatialCache; import appeng.api.networking.storage.IStorageGrid; import appeng.api.networking.ticking.ITickManager; import appeng.api.parts.CableRenderMode; @@ -22,7 +24,11 @@ import appeng.core.stats.AeStats; import appeng.core.sync.BasePacket; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.TargetPoint; +import appeng.fluids.container.*; +import appeng.fluids.registries.BasicFluidCellGuiHandler; import appeng.hooks.ToolItemHook; +import appeng.items.parts.FacadeItem; +import appeng.items.tools.NetworkToolItem; import appeng.me.cache.*; import appeng.mixins.CriteriaRegisterMixin; import appeng.recipes.handlers.*; @@ -31,6 +37,7 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundTag; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeType; import net.minecraft.screen.ScreenHandlerType; @@ -84,15 +91,15 @@ public abstract class AppEngBase implements AppEng { gcr.registerGridCache(IEnergyGrid.class, EnergyGridCache::new); gcr.registerGridCache(IPathingGrid.class, PathGridCache::new); gcr.registerGridCache(IStorageGrid.class, GridStorageCache::new); -// FIXME FABRIC gcr.registerGridCache(P2PCache.class, P2PCache.class); -// FIXME FABRIC gcr.registerGridCache(ISpatialCache.class, SpatialPylonCache.class); + gcr.registerGridCache(P2PCache.class, P2PCache::new); + gcr.registerGridCache(ISpatialCache.class, SpatialPylonCache::new); gcr.registerGridCache(ISecurityGrid.class, SecurityCache::new); -// FIXME FABRIC gcr.registerGridCache(ICraftingGrid.class, CraftingGridCache.class); + gcr.registerGridCache(ICraftingGrid.class, CraftingGridCache::new); registries.cell().addCellHandler(new BasicCellHandler()); registries.cell().addCellHandler(new CreativeCellHandler()); registries.cell().addCellGuiHandler(new BasicItemCellGuiHandler()); -// FIXME FABRIC registries.cell().addCellGuiHandler(new BasicFluidCellGuiHandler()); + registries.cell().addCellGuiHandler(new BasicFluidCellGuiHandler()); registries.matterCannon().registerAmmoItem(api.definitions().materials().matterBall().item(), 32); } @@ -175,12 +182,12 @@ public abstract class AppEngBase implements AppEng { for (int x = 0; x < PlayerInventory.getHotbarSize(); x++) { final ItemStack is = player.inventory.getStack(x); - // FIXME FABRIC if (!is.isEmpty() && is.getItem() instanceof NetworkToolItem) { - // FIXME FABRIC final CompoundTag c = is.getTag(); - // FIXME FABRIC if (c != null && c.getBoolean("hideFacades")) { - // FIXME FABRIC return CableRenderMode.CABLE_VIEW; - // FIXME FABRIC } - // FIXME FABRIC } + if (!is.isEmpty() && is.getItem() instanceof NetworkToolItem) { + final CompoundTag c = is.getTag(); + if (c != null && c.getBoolean("hideFacades")) { + return CableRenderMode.CABLE_VIEW; + } + } } } @@ -253,18 +260,18 @@ public abstract class AppEngBase implements AppEng { WirelessTermContainer.TYPE = registerScreenHandler("wirelessterm", WirelessTermContainer::fromNetwork, WirelessTermContainer::open); -// FIXME FABRIC FluidFormationPlaneContainer.TYPE = registerScreenHandler("fluid_formation_plane", -// FIXME FABRIC FluidFormationPlaneContainer::fromNetwork, FluidFormationPlaneContainer::open); -// FIXME FABRIC FluidIOContainer.TYPE = registerScreenHandler("fluid_io", FluidIOContainer::fromNetwork, -// FIXME FABRIC FluidIOContainer::open); -// FIXME FABRIC FluidInterfaceContainer.TYPE = registerScreenHandler("fluid_interface", -// FIXME FABRIC FluidInterfaceContainer::fromNetwork, FluidInterfaceContainer::open); -// FIXME FABRIC FluidLevelEmitterContainer.TYPE = registerScreenHandler("fluid_level_emitter", -// FIXME FABRIC FluidLevelEmitterContainer::fromNetwork, FluidLevelEmitterContainer::open); -// FIXME FABRIC FluidStorageBusContainer.TYPE = registerScreenHandler("fluid_storage_bus", -// FIXME FABRIC FluidStorageBusContainer::fromNetwork, FluidStorageBusContainer::open); -// FIXME FABRIC FluidTerminalContainer.TYPE = registerScreenHandler("fluid_terminal", FluidTerminalContainer::fromNetwork, -// FIXME FABRIC FluidTerminalContainer::open); + FluidFormationPlaneContainer.TYPE = registerScreenHandler("fluid_formation_plane", + FluidFormationPlaneContainer::fromNetwork, FluidFormationPlaneContainer::open); + FluidIOContainer.TYPE = registerScreenHandler("fluid_io", FluidIOContainer::fromNetwork, + FluidIOContainer::open); + FluidInterfaceContainer.TYPE = registerScreenHandler("fluid_interface", + FluidInterfaceContainer::fromNetwork, FluidInterfaceContainer::open); + FluidLevelEmitterContainer.TYPE = registerScreenHandler("fluid_level_emitter", + FluidLevelEmitterContainer::fromNetwork, FluidLevelEmitterContainer::open); + FluidStorageBusContainer.TYPE = registerScreenHandler("fluid_storage_bus", + FluidStorageBusContainer::fromNetwork, FluidStorageBusContainer::open); + FluidTerminalContainer.TYPE = registerScreenHandler("fluid_terminal", FluidTerminalContainer::fromNetwork, + FluidTerminalContainer::open); } diff --git a/src/main/java/appeng/core/api/ApiClientHelper.java b/src/main/java/appeng/core/api/ApiClientHelper.java index 7a9e778ca..65d02b65e 100644 --- a/src/main/java/appeng/core/api/ApiClientHelper.java +++ b/src/main/java/appeng/core/api/ApiClientHelper.java @@ -42,12 +42,12 @@ public class ApiClientHelper implements IClientHelper { if (cellInventory != null) { lines.add(new LiteralText(cellInventory.getUsedBytes() + " ") - .append(GuiText.Of.textComponent()).append(" " + cellInventory.getTotalBytes() + " ") - .append(GuiText.BytesUsed.textComponent())); + .append(GuiText.Of.text()).append(" " + cellInventory.getTotalBytes() + " ") + .append(GuiText.BytesUsed.text())); lines.add(new LiteralText(cellInventory.getStoredItemTypes() + " ") - .append(GuiText.Of.textComponent()).append(" " + cellInventory.getTotalItemTypes() + " ") - .append(GuiText.Types.textComponent())); + .append(GuiText.Of.text()).append(" " + cellInventory.getTotalItemTypes() + " ") + .append(GuiText.Types.text())); } if (handler.isPreformatted()) { @@ -55,11 +55,11 @@ public class ApiClientHelper implements IClientHelper { : GuiText.Excluded).getLocal(); if (handler.isFuzzy()) { - lines.add(GuiText.Partitioned.textComponent().copy().append(" - " + list + " ") - .append(GuiText.Fuzzy.textComponent())); + lines.add(GuiText.Partitioned.text().copy().append(" - " + list + " ") + .append(GuiText.Fuzzy.text())); } else { - lines.add(GuiText.Partitioned.textComponent().copy().append(" - " + list + " ") - .append(GuiText.Precise.textComponent())); + lines.add(GuiText.Partitioned.text().copy().append(" - " + list + " ") + .append(GuiText.Precise.text())); } } diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java index ffd448690..445f40593 100644 --- a/src/main/java/appeng/core/api/definitions/ApiBlocks.java +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -43,6 +43,7 @@ import static appeng.block.crafting.AbstractCraftingUnitBlock.CraftingUnitType; import appeng.bootstrap.components.IInitComponent; import appeng.bootstrap.definitions.TileEntityDefinition; import appeng.client.render.crafting.CraftingCubeRendering; +import appeng.client.render.model.AutoRotatingBakedModel; import appeng.client.render.spatial.SpatialPylonRendering; import appeng.client.render.tesr.CrankTESR; import appeng.client.render.tesr.DriveLedTileEntityRenderer; @@ -51,6 +52,8 @@ import appeng.decorative.AEDecorativeBlock; import appeng.decorative.solid.*; import appeng.decorative.solid.SkyStoneBlock.SkystoneType; import appeng.entity.TinyTNTPrimedEntity; +import appeng.fluids.block.FluidInterfaceBlock; +import appeng.fluids.tile.FluidInterfaceBlockEntity; import appeng.hooks.TinyTNTDispenseItemBehavior; import appeng.tile.crafting.*; import appeng.tile.grindstone.CrankBlockEntity; @@ -365,12 +368,12 @@ public final class ApiBlocks implements IBlocks { .tileEntity( registry.tileEntity("interface", InterfaceBlockEntity.class, InterfaceBlockEntity::new).build()) .build(); -// FIXME this.fluidIface = registry.block("fluid_interface", FluidInterfaceBlock::new) -// FIXME .features(AEFeature.FLUID_INTERFACE) -// FIXME .tileEntity(registry -// FIXME .tileEntity("fluid_interface", FluidInterfaceBlockEntity.class, FluidInterfaceBlockEntity::new) -// FIXME .build()) -// FIXME .build(); + this.fluidIface = registry.block("fluid_interface", FluidInterfaceBlock::new) + .features(AEFeature.FLUID_INTERFACE) + .tileEntity(registry + .tileEntity("fluid_interface", FluidInterfaceBlockEntity.class, FluidInterfaceBlockEntity::new) + .build()) + .build(); this.cellWorkbench = registry.block("cell_workbench", CellWorkbenchBlock::new).features(AEFeature.STORAGE_CELLS) .tileEntity(registry .tileEntity("cell_workbench", CellWorkbenchBlockEntity.class, CellWorkbenchBlockEntity::new) @@ -462,13 +465,13 @@ public final class ApiBlocks implements IBlocks { @Environment(EnvType.CLIENT) public void customize(IBlockRendering rendering, IItemRendering itemRendering) { rendering.renderType(RenderLayer.getCutout()); - // FIXME FABRIC rendering.modelCustomizer((path, model) -> { - // FIXME FABRIC // The formed model handles rotations itself, the unformed one does not - // FIXME FABRIC if (model instanceof MonitorBakedModel) { - // FIXME FABRIC return model; - // FIXME FABRIC } - // FIXME FABRIC return new AutoRotatingBakedModel(model); - // FIXME FABRIC }); + rendering.modelCustomizer((path, model) -> { + // The formed model handles rotations itself, the unformed one does not + // FIXME FABRIC if (model instanceof MonitorBakedModel) { + // FIXME FABRIC return model; + // FIXME FABRIC } + return new AutoRotatingBakedModel(model); + }); } }).build(); diff --git a/src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java b/src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java index 097bfb9b2..b5982b34c 100644 --- a/src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java +++ b/src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java @@ -1,6 +1,9 @@ package appeng.core.features.registries.cell; +import appeng.container.ContainerLocator; +import appeng.container.ContainerOpener; +import appeng.container.implementations.MEMonitorableContainer; import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -23,7 +26,7 @@ public class BasicItemCellGuiHandler implements ICellGuiHandler { @Override public void openChestGui(final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan) { - // FIXME FABRIC ContainerOpener.openContainer(MEMonitorableContainer.TYPE, player, - // FIXME FABRIC ContainerLocator.forTileEntitySide((BlockEntity) chest, chest.getUp())); + ContainerOpener.openContainer(MEMonitorableContainer.TYPE, player, + ContainerLocator.forTileEntitySide((BlockEntity) chest, chest.getUp())); } } diff --git a/src/main/java/appeng/core/localization/GuiText.java b/src/main/java/appeng/core/localization/GuiText.java index bb30ee2ab..bc6b3df76 100644 --- a/src/main/java/appeng/core/localization/GuiText.java +++ b/src/main/java/appeng/core/localization/GuiText.java @@ -18,6 +18,7 @@ package appeng.core.localization; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; @@ -85,14 +86,16 @@ public enum GuiText { private final String root; - private final Text text = new TranslatableText(getTranslationKey()); + private final Text text; GuiText() { this.root = "gui.appliedenergistics2"; + this.text = new TranslatableText(getTranslationKey()); } GuiText(final String r) { this.root = r; + this.text = new TranslatableText(getTranslationKey()); } public String getLocal() { @@ -103,11 +106,19 @@ public enum GuiText { return this.root + '.' + this.toString(); } - public Text textComponent() { + public Text text() { return text; } - public Text textComponent(Object... args) { + public MutableText withSuffix(String text) { + return text().copy().append(text); + } + + public MutableText withSuffix(Text text) { + return text().copy().append(text); + } + + public MutableText text(Object... args) { return new TranslatableText(getTranslationKey(), args); } diff --git a/src/main/java/appeng/core/localization/WailaText.java b/src/main/java/appeng/core/localization/WailaText.java index 143659673..4e57c8825 100644 --- a/src/main/java/appeng/core/localization/WailaText.java +++ b/src/main/java/appeng/core/localization/WailaText.java @@ -18,6 +18,7 @@ package appeng.core.localization; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; @@ -43,18 +44,18 @@ public enum WailaText { } public String getLocal() { - return textComponent().getString(); + return text().getString(); } public String getTranslationKey() { return this.root + '.' + this.toString(); } - public Text textComponent() { + public Text text() { return new TranslatableText(this.root + '.' + this.toString()); } - public Text textComponent(Object... args) { + public MutableText text(Object... args) { return new TranslatableText(this.root + '.' + this.toString(), args); } diff --git a/src/main/java/appeng/core/sync/packets/CompressedNBTPacket.java b/src/main/java/appeng/core/sync/packets/CompressedNBTPacket.java index 863e09238..506e40ccf 100644 --- a/src/main/java/appeng/core/sync/packets/CompressedNBTPacket.java +++ b/src/main/java/appeng/core/sync/packets/CompressedNBTPacket.java @@ -26,6 +26,7 @@ import java.io.OutputStream; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; +import appeng.client.gui.implementations.InterfaceTerminalScreen; import io.netty.buffer.Unpooled; import net.minecraft.client.MinecraftClient; @@ -97,9 +98,8 @@ public class CompressedNBTPacket extends BasePacket { public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { final Screen gs = MinecraftClient.getInstance().currentScreen; - throw new IllegalStateException(); - // FIXME FABRIC if (gs instanceof InterfaceTerminalScreen) { - // FIXME FABRIC ((InterfaceTerminalScreen) gs).postUpdate(this.in); - // FIXME FABRIC } + if (gs instanceof InterfaceTerminalScreen) { + ((InterfaceTerminalScreen) gs).postUpdate(this.in); + } } } diff --git a/src/main/java/appeng/core/sync/packets/ConfigValuePacket.java b/src/main/java/appeng/core/sync/packets/ConfigValuePacket.java index fe19c32ff..6a6f11e15 100644 --- a/src/main/java/appeng/core/sync/packets/ConfigValuePacket.java +++ b/src/main/java/appeng/core/sync/packets/ConfigValuePacket.java @@ -22,12 +22,13 @@ import appeng.api.config.FuzzyMode; import appeng.api.config.Settings; import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; +import appeng.client.gui.implementations.CraftingCPUScreen; import appeng.container.AEBaseContainer; -import appeng.container.implementations.CellWorkbenchContainer; -import appeng.container.implementations.NetworkToolContainer; -import appeng.container.implementations.PatternTermContainer; +import appeng.container.implementations.*; import appeng.core.sync.BasePacket; import appeng.core.sync.network.INetworkInfo; +import appeng.fluids.container.FluidLevelEmitterContainer; +import appeng.fluids.container.FluidStorageBusContainer; import appeng.helpers.IMouseWheelItem; import io.netty.buffer.Unpooled; import net.minecraft.client.MinecraftClient; @@ -84,33 +85,33 @@ public class ConfigValuePacket extends BasePacket { final ItemStack is = player.getStackInHand(hand); final IMouseWheelItem si = (IMouseWheelItem) is.getItem(); si.onWheel(is, this.Value.equals("WheelUp")); -// FIXME FABRIC } else if (this.Name.equals("Terminal.Cpu") && c instanceof CraftingStatusContainer) { -// FIXME FABRIC final CraftingStatusContainer qk = (CraftingStatusContainer) c; -// FIXME FABRIC qk.cycleCpu(this.Value.equals("Next")); -// FIXME FABRIC } else if (this.Name.equals("Terminal.Cpu") && c instanceof CraftConfirmContainer) { -// FIXME FABRIC final CraftConfirmContainer qk = (CraftConfirmContainer) c; -// FIXME FABRIC qk.cycleCpu(this.Value.equals("Next")); -// FIXME FABRIC } else if (this.Name.equals("Terminal.Start") && c instanceof CraftConfirmContainer) { -// FIXME FABRIC final CraftConfirmContainer qk = (CraftConfirmContainer) c; -// FIXME FABRIC qk.startJob(); -// FIXME FABRIC } else if (this.Name.equals("TileCrafting.Cancel") && c instanceof CraftingCPUContainer) { -// FIXME FABRIC final CraftingCPUContainer qk = (CraftingCPUContainer) c; -// FIXME FABRIC qk.cancelCrafting(); -// FIXME FABRIC } else if (this.Name.equals("QuartzKnife.Name") && c instanceof QuartzKnifeContainer) { -// FIXME FABRIC final QuartzKnifeContainer qk = (QuartzKnifeContainer) c; -// FIXME FABRIC qk.setName(this.Value); -// FIXME FABRIC } else if (this.Name.equals("TileSecurityStation.ToggleOption") && c instanceof SecurityStationContainer) { -// FIXME FABRIC final SecurityStationContainer sc = (SecurityStationContainer) c; -// FIXME FABRIC sc.toggleSetting(this.Value, player); -// FIXME FABRIC } else if (this.Name.equals("PriorityHost.Priority") && c instanceof PriorityContainer) { -// FIXME FABRIC final PriorityContainer pc = (PriorityContainer) c; -// FIXME FABRIC pc.setPriority(Integer.parseInt(this.Value), player); -// FIXME FABRIC } else if (this.Name.equals("LevelEmitter.Value") && c instanceof LevelEmitterContainer) { -// FIXME FABRIC final LevelEmitterContainer lvc = (LevelEmitterContainer) c; -// FIXME FABRIC lvc.setLevel(Long.parseLong(this.Value), player); -// FIXME FABRIC } else if (this.Name.equals("FluidLevelEmitter.Value") && c instanceof FluidLevelEmitterContainer) { -// FIXME FABRIC final FluidLevelEmitterContainer lvc = (FluidLevelEmitterContainer) c; -// FIXME FABRIC lvc.setLevel(Long.parseLong(this.Value), player); + } else if (this.Name.equals("Terminal.Cpu") && c instanceof CraftingStatusContainer) { + final CraftingStatusContainer qk = (CraftingStatusContainer) c; + qk.cycleCpu(this.Value.equals("Next")); + } else if (this.Name.equals("Terminal.Cpu") && c instanceof CraftConfirmContainer) { + final CraftConfirmContainer qk = (CraftConfirmContainer) c; + qk.cycleCpu(this.Value.equals("Next")); + } else if (this.Name.equals("Terminal.Start") && c instanceof CraftConfirmContainer) { + final CraftConfirmContainer qk = (CraftConfirmContainer) c; + qk.startJob(); + } else if (this.Name.equals("TileCrafting.Cancel") && c instanceof CraftingCPUContainer) { + final CraftingCPUContainer qk = (CraftingCPUContainer) c; + qk.cancelCrafting(); + } else if (this.Name.equals("QuartzKnife.Name") && c instanceof QuartzKnifeContainer) { + final QuartzKnifeContainer qk = (QuartzKnifeContainer) c; + qk.setName(this.Value); + } else if (this.Name.equals("TileSecurityStation.ToggleOption") && c instanceof SecurityStationContainer) { + final SecurityStationContainer sc = (SecurityStationContainer) c; + sc.toggleSetting(this.Value, player); + } else if (this.Name.equals("PriorityHost.Priority") && c instanceof PriorityContainer) { + final PriorityContainer pc = (PriorityContainer) c; + pc.setPriority(Integer.parseInt(this.Value), player); + } else if (this.Name.equals("LevelEmitter.Value") && c instanceof LevelEmitterContainer) { + final LevelEmitterContainer lvc = (LevelEmitterContainer) c; + lvc.setLevel(Long.parseLong(this.Value), player); + } else if (this.Name.equals("FluidLevelEmitter.Value") && c instanceof FluidLevelEmitterContainer) { + final FluidLevelEmitterContainer lvc = (FluidLevelEmitterContainer) c; + lvc.setLevel(Long.parseLong(this.Value), player); } else if (this.Name.startsWith("PatternTerminal.") && c instanceof PatternTermContainer) { final PatternTermContainer cpt = (PatternTermContainer) c; if (this.Name.equals("PatternTerminal.CraftMode")) { @@ -122,22 +123,22 @@ public class ConfigValuePacket extends BasePacket { } else if (this.Name.equals("PatternTerminal.Substitute")) { cpt.getPatternTerminal().setSubstitution(this.Value.equals("1")); } -// FIXME FABRIC } else if (this.Name.startsWith("StorageBus.")) { -// FIXME FABRIC if (this.Name.equals("StorageBus.Action")) { -// FIXME FABRIC if (this.Value.equals("Partition")) { -// FIXME FABRIC if (c instanceof StorageBusContainer) { -// FIXME FABRIC ((StorageBusContainer) c).partition(); -// FIXME FABRIC } else if (c instanceof FluidStorageBusContainer) { -// FIXME FABRIC ((FluidStorageBusContainer) c).partition(); -// FIXME FABRIC } -// FIXME FABRIC } else if (this.Value.equals("Clear")) { -// FIXME FABRIC if (c instanceof StorageBusContainer) { -// FIXME FABRIC ((StorageBusContainer) c).clear(); -// FIXME FABRIC } else if (c instanceof FluidStorageBusContainer) { -// FIXME FABRIC ((FluidStorageBusContainer) c).clear(); -// FIXME FABRIC } -// FIXME FABRIC } -// FIXME FABRIC } + } else if (this.Name.startsWith("StorageBus.")) { + if (this.Name.equals("StorageBus.Action")) { + if (this.Value.equals("Partition")) { + if (c instanceof StorageBusContainer) { + ((StorageBusContainer) c).partition(); + } else if (c instanceof FluidStorageBusContainer) { + ((FluidStorageBusContainer) c).partition(); + } + } else if (this.Value.equals("Clear")) { + if (c instanceof StorageBusContainer) { + ((StorageBusContainer) c).clear(); + } else if (c instanceof FluidStorageBusContainer) { + ((FluidStorageBusContainer) c).clear(); + } + } + } } else if (this.Name.startsWith("CellWorkbench.") && c instanceof CellWorkbenchContainer) { final CellWorkbenchContainer ccw = (CellWorkbenchContainer) c; if (this.Name.equals("CellWorkbench.Action")) { @@ -172,7 +173,6 @@ public class ConfigValuePacket extends BasePacket { } } } - throw new IllegalStateException(); } @Override @@ -185,10 +185,9 @@ public class ConfigValuePacket extends BasePacket { ((AEBaseContainer) c).stringSync(Integer.parseInt(this.Name.substring(8)), this.Value); } else if (this.Name.equals("CraftingStatus") && this.Value.equals("Clear")) { final Screen gs = MinecraftClient.getInstance().currentScreen; -// FIXME FABRIC if (gs instanceof CraftingCPUScreen) { -// FIXME FABRIC ((CraftingCPUScreen) gs).clearItems(); -// FIXME FABRIC } - throw new IllegalStateException(); + if (gs instanceof CraftingCPUScreen) { + ((CraftingCPUScreen) gs).clearItems(); + } } else if (c instanceof IConfigurableObject) { final IConfigManager cm = ((IConfigurableObject) c).getConfigManager(); diff --git a/src/main/java/appeng/core/sync/packets/MEInventoryUpdatePacket.java b/src/main/java/appeng/core/sync/packets/MEInventoryUpdatePacket.java index c6e54d675..33a81b8ee 100644 --- a/src/main/java/appeng/core/sync/packets/MEInventoryUpdatePacket.java +++ b/src/main/java/appeng/core/sync/packets/MEInventoryUpdatePacket.java @@ -29,6 +29,10 @@ import java.util.zip.GZIPOutputStream; import javax.annotation.Nullable; +import appeng.client.gui.implementations.CraftConfirmScreen; +import appeng.client.gui.implementations.CraftingCPUScreen; +import appeng.client.gui.implementations.MEMonitorableScreen; +import appeng.client.gui.implementations.NetworkStatusScreen; import io.netty.buffer.Unpooled; import net.minecraft.client.MinecraftClient; @@ -132,22 +136,21 @@ public class MEInventoryUpdatePacket extends BasePacket { public void clientPacketData(final INetworkInfo network, final PlayerEntity player) { final Screen gs = MinecraftClient.getInstance().currentScreen; - throw new IllegalStateException(); -// FIXME FABRIC if (gs instanceof CraftConfirmScreen) { -// FIXME FABRIC ((CraftConfirmScreen) gs).postUpdate(this.list, this.ref); -// FIXME FABRIC } -// FIXME FABRIC -// FIXME FABRIC if (gs instanceof CraftingCPUScreen) { -// FIXME FABRIC ((CraftingCPUScreen) gs).postUpdate(this.list, this.ref); -// FIXME FABRIC } -// FIXME FABRIC -// FIXME FABRIC if (gs instanceof MEMonitorableScreen) { -// FIXME FABRIC ((MEMonitorableScreen) gs).postUpdate(this.list); -// FIXME FABRIC } -// FIXME FABRIC -// FIXME FABRIC if (gs instanceof NetworkStatusScreen) { -// FIXME FABRIC ((NetworkStatusScreen) gs).postUpdate(this.list); -// FIXME FABRIC } + if (gs instanceof CraftConfirmScreen) { + ((CraftConfirmScreen) gs).postUpdate(this.list, this.ref); + } + + if (gs instanceof CraftingCPUScreen) { + ((CraftingCPUScreen) gs).postUpdate(this.list, this.ref); + } + + if (gs instanceof MEMonitorableScreen) { + ((MEMonitorableScreen) gs).postUpdate(this.list); + } + + if (gs instanceof NetworkStatusScreen) { + ((NetworkStatusScreen) gs).postUpdate(this.list); + } } @Nullable diff --git a/src/unported/java/appeng/fluids/client/gui/FluidFormationPlaneScreen.java b/src/main/java/appeng/fluids/client/gui/FluidFormationPlaneScreen.java similarity index 92% rename from src/unported/java/appeng/fluids/client/gui/FluidFormationPlaneScreen.java rename to src/main/java/appeng/fluids/client/gui/FluidFormationPlaneScreen.java index e53d9b25a..1eeac83d8 100644 --- a/src/unported/java/appeng/fluids/client/gui/FluidFormationPlaneScreen.java +++ b/src/main/java/appeng/fluids/client/gui/FluidFormationPlaneScreen.java @@ -29,7 +29,7 @@ public class FluidFormationPlaneScreen extends UpgradeableScreen openPriorityGui())); } diff --git a/src/unported/java/appeng/fluids/client/gui/FluidIOScreen.java b/src/main/java/appeng/fluids/client/gui/FluidIOScreen.java similarity index 73% rename from src/unported/java/appeng/fluids/client/gui/FluidIOScreen.java rename to src/main/java/appeng/fluids/client/gui/FluidIOScreen.java index d0ccb1f38..47777a4d0 100644 --- a/src/unported/java/appeng/fluids/client/gui/FluidIOScreen.java +++ b/src/main/java/appeng/fluids/client/gui/FluidIOScreen.java @@ -49,15 +49,15 @@ public class FluidIOScreen extends UpgradeableScreen { final int x = 80; this.guiSlots.add(new FluidSlotWidget(inv, 0, 0, x, y)); - this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 1, 1, 1, x, y, -1, 0)); - this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 2, 2, 1, x, y, 1, 0)); - this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 3, 3, 1, x, y, 0, -1)); - this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 4, 4, 1, x, y, 0, 1)); + this.guiSlots.add(new OptionalFluidSlotWidget(inv, handler, 1, 1, 1, x, y, -1, 0)); + this.guiSlots.add(new OptionalFluidSlotWidget(inv, handler, 2, 2, 1, x, y, 1, 0)); + this.guiSlots.add(new OptionalFluidSlotWidget(inv, handler, 3, 3, 1, x, y, 0, -1)); + this.guiSlots.add(new OptionalFluidSlotWidget(inv, handler, 4, 4, 1, x, y, 0, 1)); - this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 5, 5, 2, x, y, -1, -1)); - this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 6, 6, 2, x, y, 1, -1)); - this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 7, 7, 2, x, y, -1, 1)); - this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 8, 8, 2, x, y, 1, 1)); + this.guiSlots.add(new OptionalFluidSlotWidget(inv, handler, 5, 5, 2, x, y, -1, -1)); + this.guiSlots.add(new OptionalFluidSlotWidget(inv, handler, 6, 6, 2, x, y, 1, -1)); + this.guiSlots.add(new OptionalFluidSlotWidget(inv, handler, 7, 7, 2, x, y, -1, 1)); + this.guiSlots.add(new OptionalFluidSlotWidget(inv, handler, 8, 8, 2, x, y, 1, 1)); } @Override diff --git a/src/unported/java/appeng/fluids/client/gui/FluidInterfaceScreen.java b/src/main/java/appeng/fluids/client/gui/FluidInterfaceScreen.java similarity index 91% rename from src/unported/java/appeng/fluids/client/gui/FluidInterfaceScreen.java rename to src/main/java/appeng/fluids/client/gui/FluidInterfaceScreen.java index 737cd8caa..71a8fe334 100644 --- a/src/unported/java/appeng/fluids/client/gui/FluidInterfaceScreen.java +++ b/src/main/java/appeng/fluids/client/gui/FluidInterfaceScreen.java @@ -50,13 +50,13 @@ public class FluidInterfaceScreen extends UpgradeableScreen openPriorityGui())); } @@ -66,7 +66,7 @@ public class FluidInterfaceScreen extends UpgradeableScreen addQty(a))); - this.addButton(new ButtonWidget(this.x + 48, this.y + 17, 28, 20, "+" + b, btn -> addQty(b))); - this.addButton(new ButtonWidget(this.x + 82, this.y + 17, 32, 20, "+" + c, btn -> addQty(c))); - this.addButton(new ButtonWidget(this.x + 120, this.y + 17, 38, 20, "+" + d, btn -> addQty(d))); + this.addButton(new ButtonWidget(this.x + 20, this.y + 17, 22, 20, new LiteralText("+" + a), btn -> addQty(a))); + this.addButton(new ButtonWidget(this.x + 48, this.y + 17, 28, 20, new LiteralText("+" + b), btn -> addQty(b))); + this.addButton(new ButtonWidget(this.x + 82, this.y + 17, 32, 20, new LiteralText("+" + c), btn -> addQty(c))); + this.addButton(new ButtonWidget(this.x + 120, this.y + 17, 38, 20, new LiteralText("+" + d), btn -> addQty(d))); - this.addButton(new ButtonWidget(this.x + 20, this.y + 59, 22, 20, "-" + a, btn -> addQty(-a))); - this.addButton(new ButtonWidget(this.x + 48, this.y + 59, 28, 20, "-" + b, btn -> addQty(-b))); - this.addButton(new ButtonWidget(this.x + 82, this.y + 59, 32, 20, "-" + c, btn -> addQty(-c))); - this.addButton(new ButtonWidget(this.x + 120, this.y + 59, 38, 20, "-" + d, btn -> addQty(-d))); + this.addButton(new ButtonWidget(this.x + 20, this.y + 59, 22, 20, new LiteralText("-" + a), btn -> addQty(-a))); + this.addButton(new ButtonWidget(this.x + 48, this.y + 59, 28, 20, new LiteralText("-" + b), btn -> addQty(-b))); + this.addButton(new ButtonWidget(this.x + 82, this.y + 59, 32, 20, new LiteralText("-" + c), btn -> addQty(-c))); + this.addButton(new ButtonWidget(this.x + 120, this.y + 59, 38, 20, new LiteralText("-" + d), btn -> addQty(-d))); this.addButton(this.redstoneMode); } @@ -70,7 +71,7 @@ public class FluidLevelEmitterScreen extends UpgradeableScreen(this.x - 18, this.y + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL); - addButton(this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.getLocal(), + addButton(this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.text(), this.itemRenderer, btn -> openPriorityGui()))); this.addButton(this.storageFilter); @@ -99,7 +99,7 @@ public class FluidStorageBusScreen extends UpgradeableScreen @Override public void drawFG(MatrixStack matrices, int offsetX, int offsetY, int mouseX, int mouseY) { - this.textRenderer.draw(matrices, this.getGuiDisplayName("Fluid Terminal"), 8, 6, 4210752); + this.textRenderer.draw(matrices, this.getGuiDisplayName(new LiteralText("Fluid Terminal")), 8, 6, 4210752); this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752); } diff --git a/src/unported/java/appeng/fluids/client/gui/widgets/FluidSlotWidget.java b/src/main/java/appeng/fluids/client/gui/widgets/FluidSlotWidget.java similarity index 57% rename from src/unported/java/appeng/fluids/client/gui/widgets/FluidSlotWidget.java rename to src/main/java/appeng/fluids/client/gui/widgets/FluidSlotWidget.java index 7c03b29b9..87f3536d3 100644 --- a/src/unported/java/appeng/fluids/client/gui/widgets/FluidSlotWidget.java +++ b/src/main/java/appeng/fluids/client/gui/widgets/FluidSlotWidget.java @@ -1,22 +1,17 @@ package appeng.fluids.client.gui.widgets; +import java.math.RoundingMode; import java.util.Collections; -import com.mojang.blaze3d.systems.RenderSystem; - +import alexiil.mc.lib.attributes.Simulation; +import alexiil.mc.lib.attributes.fluid.FluidAttributes; +import alexiil.mc.lib.attributes.fluid.FluidExtractable; +import alexiil.mc.lib.attributes.fluid.amount.FluidAmount; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.fluid.Fluid; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.fluids.FluidAttributes; import alexiil.mc.lib.attributes.fluid.volume.FluidVolume; -import net.minecraftforge.fluids.FluidUtil; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import appeng.api.storage.data.IAEFluidStack; import appeng.client.gui.widgets.CustomSlotWidget; @@ -39,21 +34,7 @@ public class FluidSlotWidget extends CustomSlotWidget { public void drawContent(final MinecraftClient mc, final int mouseX, final int mouseY, final float partialTicks) { final IAEFluidStack fs = this.getFluidStack(); if (fs != null) { - RenderSystem.disableBlend(); - final Fluid fluid = fs.getFluid(); - final FluidAttributes attributes = fluid.getAttributes(); - mc.getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX); - final Sprite sprite = mc.getAtlasSpriteGetter(SpriteAtlasTexture.BLOCK_ATLAS_TEX) - .apply(attributes.getStillTexture(fs.getFluidStack())); - - // Set color for dynamic fluids - // Convert int color to RGB - final float red = (attributes.getColor() >> 16 & 255) / 255.0F; - final float green = (attributes.getColor() >> 8 & 255) / 255.0F; - final float blue = (attributes.getColor() & 255) / 255.0F; - RenderSystem.color3f(red, green, blue); - - drawTexture(matrices, xPos(), yPos(), this.getZOffset(), getWidth(), getHeight(), sprite); + fs.getFluidStack().renderGuiRect(xPos(), yPos(), xPos() + getWidth(), yPos() + getHeight()); } } @@ -61,7 +42,7 @@ public class FluidSlotWidget extends CustomSlotWidget { public boolean canClick(final PlayerEntity player) { final ItemStack mouseStack = player.inventory.getCursorStack(); return mouseStack.isEmpty() - || mouseStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).isPresent(); + || FluidAttributes.EXTRACTABLE.getFirstOrNull(mouseStack) != null; } @Override @@ -69,10 +50,11 @@ public class FluidSlotWidget extends CustomSlotWidget { if (clickStack.isEmpty() || mouseButton == 1) { this.setFluidStack(null); } else if (mouseButton == 0) { - final LazyOptional fluidOpt = FluidUtil.getFluidContained(clickStack); - fluidOpt.ifPresent(fluid -> { - this.setFluidStack(AEFluidStack.fromFluidVolume(fluid)); - }); + FluidExtractable extractable = FluidAttributes.EXTRACTABLE.getFirstOrNull(clickStack); + if (extractable != null && extractable.couldExtractAnything()) { + FluidVolume volume = extractable.attemptAnyExtraction(FluidAmount.MAX_VALUE, Simulation.ACTION); + this.setFluidStack(AEFluidStack.fromFluidVolume(volume, RoundingMode.DOWN)); + } } } @@ -80,7 +62,7 @@ public class FluidSlotWidget extends CustomSlotWidget { public Text getMessage() { final IAEFluidStack fluid = this.getFluidStack(); if (fluid != null) { - return I18n.format(fluid.getFluidStack().getTranslationKey()); + return fluid.getFluidStack().getName(); } return null; } diff --git a/src/unported/java/appeng/fluids/client/gui/widgets/FluidTankWidget.java b/src/main/java/appeng/fluids/client/gui/widgets/FluidTankWidget.java similarity index 59% rename from src/unported/java/appeng/fluids/client/gui/widgets/FluidTankWidget.java rename to src/main/java/appeng/fluids/client/gui/widgets/FluidTankWidget.java index 92d902728..4abae9fda 100644 --- a/src/unported/java/appeng/fluids/client/gui/widgets/FluidTankWidget.java +++ b/src/main/java/appeng/fluids/client/gui/widgets/FluidTankWidget.java @@ -18,23 +18,18 @@ package appeng.fluids.client.gui.widgets; -import com.mojang.blaze3d.systems.RenderSystem; - -import net.fabricmc.api.EnvType; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.widget.AbstractButtonWidget; -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.fluid.Fluid; -import net.fabricmc.api.Environment; -import net.minecraft.text.Text; -import net.minecraftforge.fluids.FluidAttributes; - +import alexiil.mc.lib.attributes.fluid.amount.FluidAmount; +import alexiil.mc.lib.attributes.fluid.volume.FluidVolume; import appeng.api.storage.data.IAEFluidStack; import appeng.api.util.AEColor; import appeng.client.gui.widgets.ITooltip; import appeng.fluids.util.IAEFluidTank; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.gui.widget.AbstractButtonWidget; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; @Environment(EnvType.CLIENT) public class FluidTankWidget extends AbstractButtonWidget implements ITooltip { @@ -42,7 +37,7 @@ public class FluidTankWidget extends AbstractButtonWidget implements ITooltip { private final int slot; public FluidTankWidget(IAEFluidTank tank, int slot, int x, int y, int w, int h) { - super(x, y, w, h, ""); + super(x, y, w, h, LiteralText.EMPTY); this.tank = tank; this.slot = slot; } @@ -50,36 +45,34 @@ public class FluidTankWidget extends AbstractButtonWidget implements ITooltip { @Override public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { if (this.visible) { - RenderSystem.disableBlend(); - - fill(this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000); + fill(matrices, this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000); final IAEFluidStack fluidStack = this.tank.getFluidInSlot(this.slot); if (fluidStack != null && fluidStack.getStackSize() > 0) { - Fluid fluid = fluidStack.getFluid(); - FluidAttributes attributes = fluid.getAttributes(); - float red = (attributes.getColor() >> 16 & 255) / 255.0F; - float green = (attributes.getColor() >> 8 & 255) / 255.0F; - float blue = (attributes.getColor() & 255) / 255.0F; - RenderSystem.color3f(red, green, blue); + FluidVolume volume = fluidStack.getFluidStack(); + FluidAmount maxAmount = this.tank.getMaxAmount_F(this.slot); + double fillRatio = volume.amount().div(maxAmount).asInexactDouble(); - MinecraftClient mc = MinecraftClient.getInstance(); - mc.getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX); - final Sprite sprite = mc.getAtlasSpriteGetter(SpriteAtlasTexture.BLOCK_ATLAS_TEX) - .apply(attributes.getStillTexture(fluidStack.getFluidStack())); - - final int scaledHeight = (int) (this.height - * ((float) fluidStack.getStackSize() / this.tank.getTankCapacity(this.slot))); + final int scaledHeight = (int) (this.height * fillRatio); + // Render the tank's content unstretched in patches of 16x16 squares, + // with a partial square for the remainder int iconHeightRemainder = scaledHeight % 16; + int top = this.y + this.height - iconHeightRemainder; if (iconHeightRemainder > 0) { - drawTexture(matrices, this.x, this.y + this.height - iconHeightRemainder, getZOffset(), 16, iconHeightRemainder, - sprite); + int x1 = this.x; + int y1 = top; + int x2 = x1 + 16; + int y2 = y1 + iconHeightRemainder; + volume.renderGuiRect(x1, y2, x2, y2); } for (int i = 0; i < scaledHeight / 16; i++) { - drawTexture(matrices, this.x, this.y + this.height - iconHeightRemainder - (i + 1) * 16, getZOffset(), 16, 16, - sprite); + int x1 = this.x; + int y1 = top - (i + 1) * 16; + int x2 = x1 + 16; + int y2 = y1 + 16; + volume.renderGuiRect(x1, y2, x2, y2); } } @@ -90,10 +83,10 @@ public class FluidTankWidget extends AbstractButtonWidget implements ITooltip { public Text getMessage() { final IAEFluidStack fluid = this.tank.getFluidInSlot(this.slot); if (fluid != null && fluid.getStackSize() > 0) { - String desc = fluid.getFluid().getAttributes().getName(fluid.getFluidStack()).getFormattedText(); + Text desc = fluid.getFluidStack().getName(); String amountToText = fluid.getStackSize() + "mB"; - return desc + "\n" + amountToText; + return desc.copy().append("\n").append(amountToText); } return null; } diff --git a/src/unported/java/appeng/fluids/client/gui/widgets/OptionalFluidSlotWidget.java b/src/main/java/appeng/fluids/client/gui/widgets/OptionalFluidSlotWidget.java similarity index 85% rename from src/unported/java/appeng/fluids/client/gui/widgets/OptionalFluidSlotWidget.java rename to src/main/java/appeng/fluids/client/gui/widgets/OptionalFluidSlotWidget.java index 39a4fd3d1..d38c425c9 100644 --- a/src/unported/java/appeng/fluids/client/gui/widgets/OptionalFluidSlotWidget.java +++ b/src/main/java/appeng/fluids/client/gui/widgets/OptionalFluidSlotWidget.java @@ -8,6 +8,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import appeng.api.storage.data.IAEFluidStack; import appeng.container.slot.IOptionalSlotHost; import appeng.fluids.util.IAEFluidTank; +import net.minecraft.client.util.math.MatrixStack; public class OptionalFluidSlotWidget extends FluidSlotWidget { private final IOptionalSlotHost containerBus; @@ -41,14 +42,17 @@ public class OptionalFluidSlotWidget extends FluidSlotWidget { } @Override - public void drawBackground(int guileft, int guitop, int currentZIndex) { + public void drawBackground(MatrixStack matrices, int guileft, int guitop, int currentZIndex) { RenderSystem.enableBlend(); if (this.isSlotEnabled()) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); } else { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 0.4F); } + int oldZOffset = getZOffset(); + setZOffset(currentZIndex); drawTexture(matrices, guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, - this.srcY - 1, this.getWidth() + 2, this.getHeight() + 2, currentZIndex); + this.srcY - 1, this.getWidth() + 2, this.getHeight() + 2); + setZOffset(oldZOffset); } } diff --git a/src/main/java/appeng/integration/modules/waila/BaseWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/BaseWailaDataProvider.java new file mode 100644 index 000000000..9f9106bb7 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/BaseWailaDataProvider.java @@ -0,0 +1,69 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila; + +import mcp.mobius.waila.api.IComponentProvider; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import mcp.mobius.waila.api.IServerDataProvider; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; + +/** + * Base implementation for {@link mcp.mobius.waila.api.IComponentProvider} + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public abstract class BaseWailaDataProvider implements IComponentProvider, IServerDataProvider { + + @Override + public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) { + return ItemStack.EMPTY; + } + + @Override + public void appendServerData(CompoundTag compoundNBT, ServerPlayerEntity serverPlayerEntity, World world, + BlockEntity tileEntity) { + + } + + @Override + public void appendHead(List tooltip, IDataAccessor accessor, IPluginConfig config) { + + } + + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + + } + + @Override + public void appendTail(List tooltip, IDataAccessor accessor, IPluginConfig config) { + + } + +} diff --git a/src/main/java/appeng/integration/modules/waila/PartWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/PartWailaDataProvider.java new file mode 100644 index 000000000..8692468ff --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/PartWailaDataProvider.java @@ -0,0 +1,165 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila; + +import appeng.api.parts.IPart; +import appeng.api.parts.PartItemStack; +import appeng.integration.modules.waila.part.*; +import com.google.common.collect.Lists; +import mcp.mobius.waila.Waila; +import mcp.mobius.waila.api.*; +import mcp.mobius.waila.api.impl.config.WailaConfig; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.text.LiteralText; +import net.minecraft.util.hit.HitResult; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Optional; + +/** + * Delegation provider for parts through {@link IPartWailaDataProvider} + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class PartWailaDataProvider implements IComponentProvider, IServerDataProvider { + /** + * Contains all providers + */ + private final List providers; + + /** + * Can access parts through view-hits + */ + private final PartAccessor accessor = new PartAccessor(); + + /** + * Traces views hit on blocks + */ + private final Tracer tracer = new Tracer(); + + /** + * Initializes the provider list with all wanted providers + */ + public PartWailaDataProvider() { + final IPartWailaDataProvider channel = new ChannelWailaDataProvider(); + final IPartWailaDataProvider storageMonitor = new StorageMonitorWailaDataProvider(); + final IPartWailaDataProvider powerState = new PowerStateWailaDataProvider(); + final IPartWailaDataProvider p2pState = new P2PStateWailaDataProvider(); + final IPartWailaDataProvider partStack = new PartStackWailaDataProvider(); + + this.providers = Lists.newArrayList(channel, storageMonitor, powerState, partStack, p2pState); + } + + @Override + public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) { + final BlockEntity te = accessor.getBlockEntity(); + final HitResult mop = accessor.getHitResult(); + + final Optional maybePart = this.accessor.getMaybePart(te, mop); + + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); + + ItemStack wailaStack = ItemStack.EMPTY; + + for (final IPartWailaDataProvider provider : this.providers) { + wailaStack = provider.getStack(part, config, wailaStack); + } + return wailaStack; + } + + return ItemStack.EMPTY; + } + + @Override + public void appendHead(List currentToolTip, final IDataAccessor accessor, + final IPluginConfig config) { + final BlockEntity te = accessor.getBlockEntity(); + final HitResult mop = accessor.getHitResult(); + + final Optional maybePart = this.accessor.getMaybePart(te, mop); + + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); + + currentToolTip.clear(); + currentToolTip.add(part.getItemStack(PartItemStack.PICK).getName()); + + for (final IPartWailaDataProvider provider : this.providers) { + provider.appendHead(part, currentToolTip, accessor, config); + } + } + } + + @Override + public void appendBody(List tooltip, final IDataAccessor accessor, final IPluginConfig config) { + final BlockEntity te = accessor.getBlockEntity(); + final HitResult mop = accessor.getHitResult(); + + final Optional maybePart = this.accessor.getMaybePart(te, mop); + + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); + + for (final IPartWailaDataProvider provider : this.providers) { + provider.appendBody(part, tooltip, accessor, config); + } + } + } + + @Override + public void appendTail(List tooltip, final IDataAccessor accessor, final IPluginConfig config) { + final BlockEntity te = accessor.getBlockEntity(); + final HitResult mop = accessor.getHitResult(); + + final Optional maybePart = this.accessor.getMaybePart(te, mop); + + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); + + for (final IPartWailaDataProvider provider : this.providers) { + provider.appendTail(part, tooltip, accessor, config); + } + } + } + + @Override + public void appendServerData(CompoundTag tag, ServerPlayerEntity player, World world, BlockEntity te) { + final HitResult mop = this.tracer.retraceBlock(world, player, te.getPos()); + + if (mop != null) { + final Optional maybePart = this.accessor.getMaybePart(te, mop); + + if (maybePart.isPresent()) { + final IPart part = maybePart.get(); + + for (final IPartWailaDataProvider provider : this.providers) { + provider.appendServerData(player, part, te, tag, world, te.getPos()); + } + } + } + } +} diff --git a/src/main/java/appeng/integration/modules/waila/TileWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/TileWailaDataProvider.java new file mode 100644 index 000000000..76c6d68b3 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/TileWailaDataProvider.java @@ -0,0 +1,101 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila; + +import appeng.integration.modules.waila.tile.ChargerWailaDataProvider; +import appeng.integration.modules.waila.tile.CraftingMonitorWailaDataProvider; +import appeng.integration.modules.waila.tile.PowerStateWailaDataProvider; +import appeng.integration.modules.waila.tile.PowerStorageWailaDataProvider; +import com.google.common.collect.Lists; +import mcp.mobius.waila.api.IComponentProvider; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import mcp.mobius.waila.api.IServerDataProvider; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; + +/** + * Delegation provider for tiles through + * {@link mcp.mobius.waila.api.IComponentProvider} + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class TileWailaDataProvider implements IComponentProvider, IServerDataProvider { + /** + * Contains all providers + */ + private final List providers; + + /** + * Initializes the provider list with all wanted providers + */ + public TileWailaDataProvider() { + final BaseWailaDataProvider charger = new ChargerWailaDataProvider(); + final BaseWailaDataProvider energyCell = new PowerStorageWailaDataProvider(); + final BaseWailaDataProvider craftingBlock = new PowerStateWailaDataProvider(); + final BaseWailaDataProvider craftingMonitor = new CraftingMonitorWailaDataProvider(); + + this.providers = Lists.newArrayList(charger, energyCell, craftingBlock, craftingMonitor); + } + + @Override + public ItemStack getStack(final IDataAccessor accessor, final IPluginConfig config) { + return ItemStack.EMPTY; + } + + @Override + public void appendHead(List currentToolTip, final IDataAccessor accessor, + final IPluginConfig config) { + for (final BaseWailaDataProvider provider : this.providers) { + provider.appendHead(currentToolTip, accessor, config); + } + } + + @Override + public void appendBody(List currentToolTip, final IDataAccessor accessor, + final IPluginConfig config) { + for (final BaseWailaDataProvider provider : this.providers) { + provider.appendBody(currentToolTip, accessor, config); + } + } + + @Override + public void appendTail(List currentToolTip, final IDataAccessor accessor, + final IPluginConfig config) { + for (final BaseWailaDataProvider provider : this.providers) { + provider.appendTail(currentToolTip, accessor, config); + } + } + + @Override + public void appendServerData(CompoundTag tag, ServerPlayerEntity player, World world, BlockEntity te) { + + for (final BaseWailaDataProvider provider : this.providers) { + provider.appendServerData(tag, player, world, te); + } + } +} diff --git a/src/main/java/appeng/integration/modules/waila/WailaModule.java b/src/main/java/appeng/integration/modules/waila/WailaModule.java new file mode 100644 index 000000000..dc8f019f3 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/WailaModule.java @@ -0,0 +1,42 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila; + +import appeng.tile.AEBaseBlockEntity; +import mcp.mobius.waila.api.*; + +public class WailaModule implements IWailaPlugin { + + public void register(final IRegistrar registrar) { + final PartWailaDataProvider partHost = new PartWailaDataProvider(); + + registrar.registerStackProvider(partHost, AEBaseBlockEntity.class); + registrar.registerComponentProvider(partHost, TooltipPosition.HEAD, AEBaseBlockEntity.class); + registrar.registerComponentProvider(partHost, TooltipPosition.BODY, AEBaseBlockEntity.class); + registrar.registerComponentProvider(partHost, TooltipPosition.TAIL, AEBaseBlockEntity.class); + registrar.registerBlockDataProvider(partHost, AEBaseBlockEntity.class); + + final TileWailaDataProvider tile = new TileWailaDataProvider(); + registrar.registerComponentProvider(tile, TooltipPosition.HEAD, AEBaseBlockEntity.class); + registrar.registerComponentProvider(tile, TooltipPosition.BODY, AEBaseBlockEntity.class); + registrar.registerComponentProvider(tile, TooltipPosition.TAIL, AEBaseBlockEntity.class); + registrar.registerBlockDataProvider(tile, AEBaseBlockEntity.class); + } + +} diff --git a/src/main/java/appeng/integration/modules/waila/part/BasePartWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/BasePartWailaDataProvider.java new file mode 100644 index 000000000..d81a5992f --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/BasePartWailaDataProvider.java @@ -0,0 +1,67 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.api.parts.IPart; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; + +/** + * Default implementation of + * {@link IPartWailaDataProvider} + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public abstract class BasePartWailaDataProvider implements IPartWailaDataProvider { + @Override + public ItemStack getStack(final IPart part, final IPluginConfig config, final ItemStack partStack) { + return partStack; + } + + @Override + public void appendHead(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + } + + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + } + + @Override + public void appendTail(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + } + + @Override + public void appendServerData(ServerPlayerEntity player, IPart part, BlockEntity te, CompoundTag tag, World world, + BlockPos pos) { + } +} diff --git a/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java new file mode 100644 index 000000000..ce7432208 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/ChannelWailaDataProvider.java @@ -0,0 +1,143 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.api.parts.IPart; +import appeng.core.localization.WailaText; +import appeng.parts.networking.SmartCablePart; +import appeng.parts.networking.SmartDenseCablePart; +import it.unimi.dsi.fastutil.objects.Object2ByteMap; +import it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; + +/** + * Channel-information provider for WAILA + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class ChannelWailaDataProvider extends BasePartWailaDataProvider { + /** + * Channel key used for the transferred {@link net.minecraft.nbt.CompoundTag} + */ + private static final String ID_USED_CHANNELS = "usedChannels"; + + /** + * Used cache for channels if the channel was not transmitted through the + * server. + *

+ * This is useful, when a player just started to look at a tile and thus just + * requested the new information from the server. + *

+ * The cache will be updated from the server. + */ + private final Object2ByteMap cache = new Object2ByteOpenHashMap<>(); + + /** + * Adds the used and max channel to the tool tip + * + * @param part being looked at part + * @param tooltip current tool tip + * @param accessor wrapper for various world information + * @param config config to react to various settings + */ + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + if (part instanceof SmartCablePart || part instanceof SmartDenseCablePart) { + final CompoundTag tag = accessor.getServerData(); + + final byte usedChannels = this.getUsedChannels(part, tag, this.cache); + + if (usedChannels >= 0) { + final byte maxChannels = (byte) ((part instanceof SmartDenseCablePart) ? 32 : 8); + + final Text formattedToolTip = WailaText.Channels.text(usedChannels, maxChannels); + tooltip.add(formattedToolTip); + } + } + } + + /** + * Determines the source of the channel. + *

+ * If the client received information of the channels on the server, they are + * used, else if the cache contains a previous stored value, this will be used. + * Default value is 0. + * + * @param part part to be looked at + * @param tag tag maybe containing the channel information + * @param cache cache with previous knowledge + * + * @return used channels on the cable + */ + private byte getUsedChannels(final IPart part, final CompoundTag tag, final Object2ByteMap cache) { + final byte usedChannels; + + if (tag.contains(ID_USED_CHANNELS)) { + usedChannels = tag.getByte(ID_USED_CHANNELS); + this.cache.put(part, usedChannels); + } else if (this.cache.containsKey(part)) { + usedChannels = this.cache.get(part); + } else { + usedChannels = -1; + } + + return usedChannels; + } + + /** + * Called on server to transfer information from server to client. + *

+ * If the part is a cable, it writes the channel information in the {@code #tag} + * using the {@code ID_USED_CHANNELS} key. + * + * @param player player looking at the part + * @param part part being looked at + * @param te host of the part + * @param tag transferred tag which is send to the client + * @param world world of the part + * @param pos pos of the part + */ + @Override + public void appendServerData(ServerPlayerEntity player, IPart part, BlockEntity te, CompoundTag tag, World world, + BlockPos pos) { + if (part instanceof SmartCablePart || part instanceof SmartDenseCablePart) { + final CompoundTag tempTag = new CompoundTag(); + + part.writeToNBT(tempTag); + + if (tempTag.contains(ID_USED_CHANNELS)) { + final byte usedChannels = tempTag.getByte(ID_USED_CHANNELS); + + tag.putByte(ID_USED_CHANNELS, usedChannels); + } + } + } +} diff --git a/src/main/java/appeng/integration/modules/waila/part/IPartWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/IPartWailaDataProvider.java new file mode 100644 index 000000000..9419bfa3b --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/IPartWailaDataProvider.java @@ -0,0 +1,54 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.api.parts.IPart; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; + +/** + * An abstraction layer of the + * {@link IPartWailaDataProvider} for + * {@link IPart}. + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public interface IPartWailaDataProvider { + ItemStack getStack(IPart part, IPluginConfig config, ItemStack partStack); + + void appendHead(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config); + + void appendBody(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config); + + void appendTail(IPart part, List tooltip, IDataAccessor accessor, IPluginConfig config); + + void appendServerData(ServerPlayerEntity player, IPart part, BlockEntity te, CompoundTag tag, World world, + BlockPos pos); +} diff --git a/src/main/java/appeng/integration/modules/waila/part/P2PStateWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/P2PStateWailaDataProvider.java new file mode 100644 index 000000000..0149c9d5f --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/P2PStateWailaDataProvider.java @@ -0,0 +1,142 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.api.parts.IPart; +import appeng.core.localization.WailaText; +import appeng.me.GridAccessException; +import appeng.parts.p2p.P2PTunnelPart; +import appeng.util.Platform; +import com.google.common.collect.Iterators; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.text.TranslatableText; +import net.minecraft.util.math.BlockPos; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; + +/** + * Provides information about a P2P tunnel to WAILA. + */ +public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider { + + private static final int STATE_UNLINKED = 0; + private static final int STATE_OUTPUT = 1; + private static final int STATE_INPUT = 2; + public static final String TAG_P2P_STATE = "p2p_state"; + public static final String TAG_P2P_FREQUENCY = "p2p_frequency"; + + /** + * Adds state to the tooltip + * + * @param part part with state + * @param tooltip to be added to tooltip + * @param accessor wrapper for various information + * @param config config settings + */ + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + if (part instanceof P2PTunnelPart) { + CompoundTag nbtData = accessor.getServerData(); + if (nbtData.contains(TAG_P2P_STATE)) { + int[] stateArr = nbtData.getIntArray(TAG_P2P_STATE); + if (stateArr.length == 2) { + int state = stateArr[0]; + int outputs = stateArr[1]; + + switch (state) { + case STATE_UNLINKED: + tooltip.add(WailaText.P2PUnlinked.text()); + break; + case STATE_OUTPUT: + tooltip.add(WailaText.P2POutput.text()); + break; + case STATE_INPUT: + tooltip.add(getOutputText(outputs)); + break; + } + } + + final short freq = nbtData.getShort(TAG_P2P_FREQUENCY); + final String freqTooltip = Platform.p2p().toHexString(freq); + tooltip.add(new TranslatableText("gui.tooltips.appliedenergistics2.P2PFrequency", freqTooltip)); + } + } + } + + @Override + public void appendServerData(ServerPlayerEntity player, IPart part, BlockEntity te, CompoundTag tag, World world, + BlockPos pos) { + if (part instanceof P2PTunnelPart) { + final P2PTunnelPart tunnel = (P2PTunnelPart) part; + + if (!tunnel.isPowered()) { + return; + } + + // Frquency + final short frequency = tunnel.getFrequency(); + tag.putShort(TAG_P2P_FREQUENCY, frequency); + + // The default state + int state = STATE_UNLINKED; + int outputCount = 0; + + if (!tunnel.isOutput()) { + outputCount = getOutputCount(tunnel); + if (outputCount > 0) { + // Only set it to INPUT if we know there are any outputs + state = STATE_INPUT; + } + } else { + P2PTunnelPart input = tunnel.getInput(); + if (input != null) { + state = STATE_OUTPUT; + } + } + + tag.putIntArray(TAG_P2P_STATE, new int[] { state, outputCount }); + + } + } + + private static int getOutputCount(P2PTunnelPart tunnel) { + try { + return Iterators.size(tunnel.getOutputs().iterator()); + } catch (GridAccessException e) { + // Well... unknown size it is! + return 0; + } + } + + private static Text getOutputText(int outputs) { + if (outputs <= 1) { + return WailaText.P2PInputOneOutput.text(); + } else { + return WailaText.P2PInputManyOutputs.text(outputs); + } + } + +} diff --git a/src/main/java/appeng/integration/modules/waila/part/PartAccessor.java b/src/main/java/appeng/integration/modules/waila/part/PartAccessor.java new file mode 100644 index 000000000..9ff06d77a --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/PartAccessor.java @@ -0,0 +1,65 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.api.parts.IPart; +import appeng.api.parts.IPartHost; +import appeng.api.parts.SelectedPart; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.Vec3d; + +import java.util.Optional; + +/** + * Accessor to access specific parts for WAILA + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class PartAccessor { + /** + * Hits a {@link IPartHost} with {@link BlockPos}. + *

+ * You can derive the looked at {@link IPart} by doing that. If a facade is + * being looked at, it is defined as being absent. + * + * @param te being looked at {@link BlockEntity} + * @param rtr type of ray-trace + * + * @return maybe the looked at {@link IPart} + */ + public Optional getMaybePart(final BlockEntity te, final HitResult rtr) { + if (te instanceof IPartHost && rtr instanceof BlockHitResult) { + BlockPos pos = ((BlockHitResult) rtr).getBlockPos(); + final Vec3d position = rtr.getPos().add(-pos.getX(), -pos.getY(), -pos.getZ()); + final IPartHost host = (IPartHost) te; + final SelectedPart sp = host.selectPart(position); + + if (sp.part != null) { + return Optional.of(sp.part); + } + } + + return Optional.empty(); + } +} diff --git a/src/main/java/appeng/integration/modules/waila/part/PartStackWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/PartStackWailaDataProvider.java new file mode 100644 index 000000000..2f34a7a8c --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/PartStackWailaDataProvider.java @@ -0,0 +1,41 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.api.parts.IPart; +import appeng.api.parts.PartItemStack; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.item.ItemStack; + +/** + * Part ItemStack provider for WAILA + * + * @author TheJulianJES + * @version rv2 + * @since rv2 + */ +public class PartStackWailaDataProvider extends BasePartWailaDataProvider { + + @Override + public ItemStack getStack(final IPart part, final IPluginConfig config, ItemStack partStack) { + partStack = part.getItemStack(PartItemStack.PICK); + return partStack; + } + +} diff --git a/src/main/java/appeng/integration/modules/waila/part/PowerStateWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/PowerStateWailaDataProvider.java new file mode 100644 index 000000000..e9cfce933 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/PowerStateWailaDataProvider.java @@ -0,0 +1,74 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.api.implementations.IPowerChannelState; +import appeng.api.parts.IPart; +import appeng.core.localization.WailaText; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.text.Text; + +import java.util.List; + +/** + * Power state provider for WAILA + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class PowerStateWailaDataProvider extends BasePartWailaDataProvider { + /** + * Adds state to the tooltip + * + * @param part part with state + * @param tooltip to be added to tooltip + * @param accessor wrapper for various information + * @param config config settings + */ + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + if (part instanceof IPowerChannelState) { + final IPowerChannelState state = (IPowerChannelState) part; + + tooltip.add(this.getToolTip(state.isActive(), state.isPowered())); + } + } + + /** + * Gets the corresponding tool tip for different values of {@code #isActive} and + * {@code #isPowered} + * + * @param isActive if part is active + * @param isPowered if part is powered + * + * @return tooltip of the state + */ + private Text getToolTip(final boolean isActive, final boolean isPowered) { + if (isActive && isPowered) { + return WailaText.DeviceOnline.text(); + } else if (isPowered) { + return WailaText.DeviceMissingChannel.text(); + } else { + return WailaText.DeviceOffline.text(); + } + } +} diff --git a/src/main/java/appeng/integration/modules/waila/part/StorageMonitorWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/part/StorageMonitorWailaDataProvider.java new file mode 100644 index 000000000..e75984a17 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/StorageMonitorWailaDataProvider.java @@ -0,0 +1,73 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.api.implementations.parts.IStorageMonitorPart; +import appeng.api.parts.IPart; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IAEStack; +import appeng.core.localization.WailaText; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.text.Text; + +import java.util.List; + +/** + * Storage monitor provider for WAILA + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class StorageMonitorWailaDataProvider extends BasePartWailaDataProvider { + /** + * Displays the stack if present and if the monitor is locked. Can handle fluids + * and items. + * + * @param part maybe storage monitor + * @param tooltip to be written to tooltip + * @param accessor information wrapper + * @param config config option + */ + @Override + public void appendBody(final IPart part, final List tooltip, final IDataAccessor accessor, + final IPluginConfig config) { + if (part instanceof IStorageMonitorPart) { + final IStorageMonitorPart monitor = (IStorageMonitorPart) part; + + final IAEStack displayed = monitor.getDisplayed(); + final boolean isLocked = monitor.isLocked(); + + // TODO: generalize + if (displayed instanceof IAEItemStack) { + final IAEItemStack ais = (IAEItemStack) displayed; + tooltip.add(WailaText.Showing.text().copy().append(": ") + .append(ais.asItemStackRepresentation().getName())); + } else if (displayed instanceof IAEFluidStack) { + final IAEFluidStack ais = (IAEFluidStack) displayed; + tooltip.add(WailaText.Showing.text().copy().append(": ") + .append(ais.getFluidStack().getName())); + } + + tooltip.add((isLocked) ? WailaText.Locked.text() : WailaText.Unlocked.text()); + } + } +} diff --git a/src/main/java/appeng/integration/modules/waila/part/Tracer.java b/src/main/java/appeng/integration/modules/waila/part/Tracer.java new file mode 100644 index 000000000..8e9255647 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/part/Tracer.java @@ -0,0 +1,54 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.part; + +import appeng.util.LookDirection; +import appeng.util.Platform; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +/** + * Tracer for players hitting blocks + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class Tracer { + /** + * Trace view of players to blocks. Ignore all which are out of reach. + * + * @param world word of block + * @param player player viewing block + * @param pos pos of block + * + * @return trace movement. Can be null + */ + public HitResult retraceBlock(final World world, final PlayerEntity player, BlockPos pos) { + BlockState blockState = world.getBlockState(pos); + + LookDirection playerRay = Platform.getPlayerRay(player); + return blockState.getCollisionShape(world, pos).rayTrace(playerRay.getA(), playerRay.getB(), pos); + } +} diff --git a/src/main/java/appeng/integration/modules/waila/tile/ChargerWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/tile/ChargerWailaDataProvider.java new file mode 100644 index 000000000..2e0db0f53 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/tile/ChargerWailaDataProvider.java @@ -0,0 +1,67 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.tile; + +import alexiil.mc.lib.attributes.item.FixedItemInvView; +import appeng.core.localization.WailaText; +import appeng.integration.modules.waila.BaseWailaDataProvider; +import appeng.tile.misc.ChargerBlockEntity; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.text.Text; + +import java.util.List; + +/** + * Charger provider for WAILA + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class ChargerWailaDataProvider extends BaseWailaDataProvider { + + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + + final BlockEntity te = accessor.getBlockEntity(); + if (te instanceof ChargerBlockEntity) { + final ChargerBlockEntity charger = (ChargerBlockEntity) te; + final FixedItemInvView chargerInventory = charger.getInternalInventory(); + final ItemStack chargingItem = chargerInventory.getInvStack(0); + + if (!chargingItem.isEmpty()) { + final Text currentInventory = chargingItem.getName(); + final PlayerEntity player = accessor.getPlayer(); + + tooltip.add(WailaText.Contains.text().copy().append(": ").append(currentInventory)); + TooltipContext tooltipFlag = MinecraftClient.getInstance().options.advancedItemTooltips + ? TooltipContext.Default.ADVANCED + : TooltipContext.Default.NORMAL; + chargingItem.getItem().appendTooltip(chargingItem, player.world, tooltip, tooltipFlag); + } + } + + } +} diff --git a/src/main/java/appeng/integration/modules/waila/tile/CraftingMonitorWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/tile/CraftingMonitorWailaDataProvider.java new file mode 100644 index 000000000..b3d5f6401 --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/tile/CraftingMonitorWailaDataProvider.java @@ -0,0 +1,55 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.tile; + +import appeng.api.storage.data.IAEItemStack; +import appeng.core.localization.WailaText; +import appeng.integration.modules.waila.BaseWailaDataProvider; +import appeng.tile.crafting.CraftingMonitorBlockEntity; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.text.Text; + +import java.util.List; + +/** + * Crafting-monitor provider for WAILA + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class CraftingMonitorWailaDataProvider extends BaseWailaDataProvider { + + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + final BlockEntity te = accessor.getBlockEntity(); + if (te instanceof CraftingMonitorBlockEntity) { + final CraftingMonitorBlockEntity monitor = (CraftingMonitorBlockEntity) te; + final IAEItemStack displayStack = monitor.getJobProgress(); + + if (displayStack != null) { + final Text currentCrafting = displayStack.asItemStackRepresentation().getName(); + + tooltip.add(WailaText.Crafting.text().copy().append(": ").append(currentCrafting)); + } + } + } +} diff --git a/src/main/java/appeng/integration/modules/waila/tile/PowerStateWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/tile/PowerStateWailaDataProvider.java new file mode 100644 index 000000000..073dda6bc --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/tile/PowerStateWailaDataProvider.java @@ -0,0 +1,60 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.tile; + +import appeng.api.implementations.IPowerChannelState; +import appeng.core.localization.WailaText; +import appeng.integration.modules.waila.BaseWailaDataProvider; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.text.Text; + +import java.util.List; + +/** + * Power state provider for WAILA + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class PowerStateWailaDataProvider extends BaseWailaDataProvider { + + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + final BlockEntity te = accessor.getBlockEntity(); + + if (te instanceof IPowerChannelState) { + final IPowerChannelState state = (IPowerChannelState) te; + + final boolean isActive = state.isActive(); + final boolean isPowered = state.isPowered(); + + if (isActive && isPowered) { + tooltip.add(WailaText.DeviceOnline.text()); + } else if (isPowered) { + tooltip.add(WailaText.DeviceMissingChannel.text()); + } else { + tooltip.add(WailaText.DeviceOffline.text()); + } + } + + } +} \ No newline at end of file diff --git a/src/main/java/appeng/integration/modules/waila/tile/PowerStorageWailaDataProvider.java b/src/main/java/appeng/integration/modules/waila/tile/PowerStorageWailaDataProvider.java new file mode 100644 index 000000000..2cd3976ec --- /dev/null +++ b/src/main/java/appeng/integration/modules/waila/tile/PowerStorageWailaDataProvider.java @@ -0,0 +1,140 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.modules.waila.tile; + +import appeng.api.networking.energy.IAEPowerStorage; +import appeng.core.localization.WailaText; +import appeng.integration.modules.waila.BaseWailaDataProvider; +import appeng.util.Platform; +import it.unimi.dsi.fastutil.objects.Object2LongMap; +import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; +import mcp.mobius.waila.api.IDataAccessor; +import mcp.mobius.waila.api.IPluginConfig; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.text.Text; +import net.minecraft.world.World; + +import java.util.List; + +/** + * Power storage provider for WAILA + * + * @author thatsIch + * @version rv2 + * @since rv2 + */ +public final class PowerStorageWailaDataProvider extends BaseWailaDataProvider { + /** + * Power key used for the transferred {@link net.minecraft.nbt.CompoundTag} + */ + private static final String ID_CURRENT_POWER = "currentPower"; + + /** + * Used cache for power if the power was not transmitted through the server. + *

+ * This is useful, when a player just started to look at a tile and thus just + * requested the new information from the server. + *

+ * The cache will be updated from the server. + */ + private final Object2LongMap cache = new Object2LongOpenHashMap<>(); + + @Override + public void appendBody(List tooltip, IDataAccessor accessor, IPluginConfig config) { + // Removes RF tooltip on WAILA 1.5.9+ + // FIXME ( (ITaggedList) tooltip ).removeEntries( + // "RFEnergyStorage" ); + + final BlockEntity te = accessor.getBlockEntity(); + if (te instanceof IAEPowerStorage) { + final IAEPowerStorage storage = (IAEPowerStorage) te; + + final double maxPower = storage.getAEMaxPower(); + if (maxPower > 0) { + final CompoundTag tag = accessor.getServerData(); + + final long internalCurrentPower = this.getInternalCurrentPower(tag, te); + + if (internalCurrentPower >= 0) { + final long internalMaxPower = (long) (100 * maxPower); + + final String formatCurrentPower = Platform.formatPowerLong(internalCurrentPower, false); + final String formatMaxPower = Platform.formatPowerLong(internalMaxPower, false); + + tooltip.add(WailaText.Contains.text().copy() + .append(": " + formatCurrentPower + " / " + formatMaxPower)); + } + } + } + } + + /** + * Called on server to transfer information from server to client. + *

+ * If the {@link net.minecraft.block.entity.BlockEntity} is a + * {@link IAEPowerStorage}, it writes the power + * information to the {@code #tag} using the {@code #ID_CURRENT_POWER} key. + * + * @param serverPlayerEntity player looking at the power storage + * @param te power storage + * @param tag transferred tag which is send to the client + * @param world world of the power storage + */ + @Override + public void appendServerData(CompoundTag tag, ServerPlayerEntity serverPlayerEntity, World world, BlockEntity te) { + if (te instanceof IAEPowerStorage) { + final IAEPowerStorage storage = (IAEPowerStorage) te; + + if (storage.getAEMaxPower() > 0) { + final long internalCurrentPower = (long) (100 * storage.getAECurrentPower()); + + tag.putLong(ID_CURRENT_POWER, internalCurrentPower); + } + } + } + + /** + * Determines the current power. + *

+ * If the client received power information on the server, they are used, else + * if the cache contains a previous stored value, this will be used. Default + * value is 0. + * + * @param te te to be looked at + * @param tag tag maybe containing the channel information + * + * @return used channels on the cable + */ + private long getInternalCurrentPower(final CompoundTag tag, final BlockEntity te) { + final long internalCurrentPower; + + if (tag.contains(ID_CURRENT_POWER)) { + internalCurrentPower = tag.getLong(ID_CURRENT_POWER); + this.cache.put(te, internalCurrentPower); + } else if (this.cache.containsKey(te)) { + internalCurrentPower = this.cache.get(te); + } else { + internalCurrentPower = -1; + } + + return internalCurrentPower; + } +} diff --git a/src/main/java/appeng/items/contents/CellConfig.java b/src/main/java/appeng/items/contents/CellConfig.java index b53c6044a..0f654b25c 100644 --- a/src/main/java/appeng/items/contents/CellConfig.java +++ b/src/main/java/appeng/items/contents/CellConfig.java @@ -34,7 +34,7 @@ public class CellConfig extends AppEngInternalInventory { } @Override - protected void onContentsChanged(FixedItemInvView inv, int slot, ItemStack previous, ItemStack current) { + protected void onContentsChanged(int slot, ItemStack previous, ItemStack current) { this.writeToNBT(this.is.getOrCreateTag(), "list"); } } \ No newline at end of file diff --git a/src/main/java/appeng/items/contents/CellUpgrades.java b/src/main/java/appeng/items/contents/CellUpgrades.java index 2a1004456..1b4e0d0bf 100644 --- a/src/main/java/appeng/items/contents/CellUpgrades.java +++ b/src/main/java/appeng/items/contents/CellUpgrades.java @@ -33,7 +33,7 @@ public final class CellUpgrades extends StackUpgradeInventory { } @Override - protected void onContentsChanged(FixedItemInvView inv, int slot, ItemStack previous, ItemStack current) { + protected void onContentsChanged(int slot, ItemStack previous, ItemStack current) { this.writeToNBT(this.is.getOrCreateTag(), "upgrades"); } } \ No newline at end of file diff --git a/src/main/java/appeng/items/misc/EncodedPatternItem.java b/src/main/java/appeng/items/misc/EncodedPatternItem.java index 9d8f98cc2..e0bbd4e7c 100644 --- a/src/main/java/appeng/items/misc/EncodedPatternItem.java +++ b/src/main/java/appeng/items/misc/EncodedPatternItem.java @@ -43,7 +43,6 @@ import appeng.api.AEApi; import appeng.api.implementations.ICraftingPatternItem; import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.storage.data.IAEItemStack; -import appeng.core.AppEng; import appeng.core.localization.GuiText; import appeng.helpers.InvalidPatternHelper; import appeng.helpers.PatternHelper; @@ -104,15 +103,15 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt return; } - stack.setCustomName(GuiText.InvalidPattern.textComponent().copy().formatted(Formatting.RED)); + stack.setCustomName(GuiText.InvalidPattern.text().copy().formatted(Formatting.RED)); InvalidPatternHelper invalid = new InvalidPatternHelper(stack); - final Text label = (invalid.isCraftable() ? GuiText.Crafts.textComponent() - : GuiText.Creates.textComponent()).copy().append(": "); - final Text and = new LiteralText(" ").append(GuiText.And.textComponent()) + final Text label = (invalid.isCraftable() ? GuiText.Crafts.text() + : GuiText.Creates.text()).copy().append(": "); + final Text and = new LiteralText(" ").append(GuiText.And.text()) .append(" "); - final Text with = GuiText.With.textComponent().copy().append(": "); + final Text with = GuiText.With.text().copy().append(": "); boolean first = true; for (final InvalidPatternHelper.PatternIngredient output : invalid.getOutputs()) { @@ -127,9 +126,9 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt } if (invalid.isCraftable()) { - final MutableText substitutionLabel = GuiText.Substitute.textComponent().copy().append(" "); - final Text canSubstitute = invalid.canSubstitute() ? GuiText.Yes.textComponent() - : GuiText.No.textComponent(); + final MutableText substitutionLabel = GuiText.Substitute.text().copy().append(" "); + final Text canSubstitute = invalid.canSubstitute() ? GuiText.Yes.text() + : GuiText.No.text(); lines.add(substitutionLabel.append(canSubstitute)); } @@ -147,11 +146,11 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt final IAEItemStack[] in = details.getCondensedInputs(); final IAEItemStack[] out = details.getCondensedOutputs(); - final Text label = (isCrafting ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent()) + final Text label = (isCrafting ? GuiText.Crafts.text() : GuiText.Creates.text()) .copy().append(": "); - final Text and = new LiteralText(" ").append(GuiText.And.textComponent()) + final Text and = new LiteralText(" ").append(GuiText.And.text()) .append(" "); - final Text with = GuiText.With.textComponent().copy().append(": "); + final Text with = GuiText.With.text().copy().append(": "); boolean first = true; for (final IAEItemStack anOut : out) { @@ -176,8 +175,8 @@ public class EncodedPatternItem extends AEBaseItem implements ICraftingPatternIt } if (isCrafting) { - final MutableText substitutionLabel = GuiText.Substitute.textComponent().copy().append(" "); - final Text canSubstitute = substitute ? GuiText.Yes.textComponent() : GuiText.No.textComponent(); + final MutableText substitutionLabel = GuiText.Substitute.text().copy().append(" "); + final Text canSubstitute = substitute ? GuiText.Yes.text() : GuiText.No.text(); lines.add(substitutionLabel.append(canSubstitute)); } diff --git a/src/main/java/appeng/items/tools/powered/ColorApplicatorItem.java b/src/main/java/appeng/items/tools/powered/ColorApplicatorItem.java index d6d8ec6e1..9b2e3efd8 100644 --- a/src/main/java/appeng/items/tools/powered/ColorApplicatorItem.java +++ b/src/main/java/appeng/items/tools/powered/ColorApplicatorItem.java @@ -197,7 +197,7 @@ public class ColorApplicatorItem extends AEBasePoweredItem @Override public Text getName(final ItemStack is) { - Text extra = GuiText.Empty.textComponent(); + Text extra = GuiText.Empty.text(); final AEColor selected = this.getActiveColor(is); diff --git a/src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java b/src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java index 17ad6d6c7..c6294484a 100644 --- a/src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java +++ b/src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java @@ -67,9 +67,9 @@ public class WirelessTerminalItem extends AEBasePoweredItem implements IWireless final String encKey = tag.getString("encryptionKey"); if (encKey == null || encKey.isEmpty()) { - lines.add(GuiText.Unlinked.textComponent()); + lines.add(GuiText.Unlinked.text()); } else { - lines.add(GuiText.Linked.textComponent()); + lines.add(GuiText.Linked.text()); } } } else { diff --git a/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java b/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java index bb6059aea..2c432f292 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java +++ b/src/main/java/appeng/items/tools/powered/powersink/AEBasePoweredItem.java @@ -66,7 +66,7 @@ public abstract class AEBasePoweredItem extends AEBaseItem implements IAEItemPow final double percent = internalCurrentPower / internalMaxPower; - lines.add(GuiText.StoredEnergy.textComponent().copy() + lines.add(GuiText.StoredEnergy.text().copy() .append(':' + MessageFormat.format(" {0,number,#} ", internalCurrentPower)) .append(new TranslatableText(PowerUnits.AE.unlocalizedName)) .append(" - " + MessageFormat.format(" {0,number,#.##%} ", percent))); diff --git a/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java b/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java index d8e39fdf0..3db9304c2 100644 --- a/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngInternalInventory.java @@ -19,10 +19,9 @@ package appeng.tile.inventory; import alexiil.mc.lib.attributes.Simulation; -import alexiil.mc.lib.attributes.item.FixedItemInvView; import alexiil.mc.lib.attributes.item.filter.ConstantItemFilter; import alexiil.mc.lib.attributes.item.filter.ItemFilter; -import alexiil.mc.lib.attributes.item.impl.FullFixedItemInv; +import alexiil.mc.lib.attributes.item.impl.DirectFixedItemInv; import appeng.util.Platform; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; @@ -30,13 +29,11 @@ import appeng.util.inv.filter.IAEItemFilter; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundTag; -import javax.annotation.Nonnull; import java.util.Arrays; -import java.util.Collections; import java.util.Iterator; // FIXME: the filtering is not correctly implemented and need to be reworked -public class AppEngInternalInventory extends FullFixedItemInv implements Iterable { +public class AppEngInternalInventory extends DirectFixedItemInv implements Iterable { private boolean enableClientEvents = false; private IAEAppEngInventory te; private final int[] maxStack; @@ -50,8 +47,6 @@ public class AppEngInternalInventory extends FullFixedItemInv implements Iterabl this.setFilter(filter); this.maxStack = new int[size]; Arrays.fill(this.maxStack, maxStack); - - setOwnerListener(this::onContentsChanged); } public AppEngInternalInventory(final IAEAppEngInventory inventory, final int size, final int maxStack) { @@ -71,7 +66,21 @@ public class AppEngInternalInventory extends FullFixedItemInv implements Iterabl return Math.min(maxStack[slot], super.getMaxAmount(slot, stack)); } - protected void onContentsChanged(FixedItemInvView inv, int slot, ItemStack previous, ItemStack current) { + @Override + public boolean setInvStack(int slot, ItemStack to, Simulation simulation) { + if (!simulation.isAction()) { + return super.setInvStack(slot, to, simulation); + } + + ItemStack previous = getInvStack(slot).copy(); + if (super.setInvStack(slot, to, simulation)) { + onContentsChanged(slot, previous, to); + return true; + } + return false; + } + + protected void onContentsChanged(int slot, ItemStack previous, ItemStack current) { if (this.getBlockEntity() != null && this.eventsEnabled() && !this.dirtyFlag) { this.dirtyFlag = true; ItemStack newStack = current.copy(); @@ -111,11 +120,14 @@ public class AppEngInternalInventory extends FullFixedItemInv implements Iterabl } if (this.filter != null) { return stack -> { - // FIXME: This is not correct... - if (stack == ItemStack.EMPTY) { - return filter.allowExtract(this, slot, this.getSlot(slot).get().getCount()); + if (stack.isEmpty()) { + ItemStack current = this.getInvStack(slot); + if (current.isEmpty()) { + return true; // Replacing empty with empty... okay + } + return filter.allowExtract(this, slot, current.getCount()); } else { - return filter.allowExtract(this, slot, this.getSlot(slot).get().getCount()); + return filter.allowInsert(this, slot, stack); } }; } @@ -128,6 +140,13 @@ public class AppEngInternalInventory extends FullFixedItemInv implements Iterabl return false; } if (this.filter != null) { + if (stack.isEmpty()) { + ItemStack current = this.getInvStack(slot); + if (current.isEmpty()) { + return true; // Replacing empty with empty... okay + } + return filter.allowExtract(this, slot, current.getCount()); + } return this.filter.allowInsert(this, slot, stack); } return true; diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index c4ea15580..cf9d9c568 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -49,6 +49,7 @@ import appeng.core.AELog; import appeng.core.stats.AeStats; import appeng.fluids.util.AEFluidStack; import appeng.hooks.TickHandler; +import appeng.integration.abstraction.JEIFacade; import appeng.me.GridAccessException; import appeng.me.GridNode; import appeng.me.helpers.AENetworkProxy; @@ -1141,8 +1142,7 @@ public class Platform { public static boolean isSearchModeAvailable(SearchBoxMode mode) { if (mode.isRequiresJei()) { - throw new IllegalStateException(); -// FIXME FABRIC return JEIFacade.instance().isEnabled(); + return JEIFacade.instance().isEnabled(); } return true; } diff --git a/src/main/java/appeng/util/item/AEItemStackRegistry.java b/src/main/java/appeng/util/item/AEItemStackRegistry.java index 011aaa23e..0fce27e36 100644 --- a/src/main/java/appeng/util/item/AEItemStackRegistry.java +++ b/src/main/java/appeng/util/item/AEItemStackRegistry.java @@ -30,23 +30,12 @@ import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; -import appeng.util.Platform; - public final class AEItemStackRegistry { - private static final WeakHashMap> SERVER_REGISTRY = new WeakHashMap<>(); - private static final WeakHashMap> CLIENT_REGISTRY = new WeakHashMap<>(); + private static final WeakHashMap> REGISTRY = new WeakHashMap<>(); private AEItemStackRegistry() { } - private static WeakHashMap> registry() { - if (Platform.isClient()) { - return CLIENT_REGISTRY; - } else { - return SERVER_REGISTRY; - } - } - static synchronized AESharedItemStack getRegisteredStack(final @Nonnull ItemStack itemStack) { if (itemStack.isEmpty()) { throw new IllegalArgumentException("stack cannot be empty"); @@ -56,7 +45,7 @@ public final class AEItemStackRegistry { itemStack.setCount(1); AESharedItemStack search = new AESharedItemStack(itemStack); - WeakReference weak = registry().get(search); + WeakReference weak = REGISTRY.get(search); AESharedItemStack ret = null; if (weak != null) { @@ -65,7 +54,7 @@ public final class AEItemStackRegistry { if (ret == null) { ret = new AESharedItemStack(itemStack.copy()); - registry().put(ret, new WeakReference<>(ret)); + REGISTRY.put(ret, new WeakReference<>(ret)); } itemStack.setCount(oldStackSize); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a0da82883..81e19af4f 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,5 +36,11 @@ "suggests": { "flamingo": "*" }, - "accessWidener" : "appliedenergistics2.accesswidener" + "accessWidener" : "appliedenergistics2.accesswidener", + "custom": { + "waila:plugins": { + "id": "appliedenergistics2:hwyla", + "initializer": "appeng.integration.modules.waila.WailaModule" + } + } } diff --git a/src/unported/java/appeng/client/ClientHelper.java b/src/unported/java/appeng/client/ClientHelper.java index a51ebe476..7d54e5b40 100644 --- a/src/unported/java/appeng/client/ClientHelper.java +++ b/src/unported/java/appeng/client/ClientHelper.java @@ -47,18 +47,11 @@ import appeng.server.ServerHelper; import appeng.util.Platform; public class ClientHelper extends ServerHelper { - private final static String KEY_CATEGORY = "key.appliedenergistics2.category"; - public void clientInit() { MinecraftForge.EVENT_BUS.addListener(this::postPlayerRender); MinecraftForge.EVENT_BUS.addListener(this::wheelEvent); - for (ActionKey key : ActionKey.values()) { - final KeyBinding binding = new KeyBinding(key.getTranslationKey(), key.getDefaultKey(), KEY_CATEGORY); - ClientRegistry.registerKeyBinding(binding); - this.bindings.put(key, binding); - } } @Override diff --git a/src/unported/java/appeng/core/Registration.java b/src/unported/java/appeng/core/Registration.java index 52978ac6c..39d5f2d81 100644 --- a/src/unported/java/appeng/core/Registration.java +++ b/src/unported/java/appeng/core/Registration.java @@ -22,19 +22,11 @@ import appeng.bootstrap.ModelsReloadCallback; import appeng.client.render.model.*; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.advancement.criterion.Criteria; import net.minecraft.block.BlockState; import net.minecraft.block.entity.*; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.ScreenManager; -import net.minecraft.client.particle.ParticleManager; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.screen.ScreenHandlerType; -import net.minecraft.particle.ParticleType; -import net.minecraft.recipe.RecipeSerializer; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.GenerationStep; @@ -57,41 +49,9 @@ import appeng.api.features.IRegistryContainer; import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWorldGen; import appeng.api.movable.IMovableRegistry; -import appeng.api.networking.IGridCacheRegistry; -import appeng.api.networking.crafting.ICraftingGrid; -import appeng.api.networking.energy.IEnergyGrid; -import appeng.api.networking.pathing.IPathingGrid; -import appeng.api.networking.security.ISecurityGrid; -import appeng.api.networking.spatial.ISpatialCache; -import appeng.api.networking.storage.IStorageGrid; -import appeng.api.networking.ticking.ITickManager; -import appeng.bootstrap.components.*; -import appeng.client.gui.implementations.*; -import appeng.client.render.effects.*; -import appeng.client.render.tesr.InscriberTESR; -import appeng.client.render.tesr.SkyChestTESR; -import appeng.container.AEBaseContainer; -import appeng.container.ContainerOpener; -import appeng.container.implementations.*; import appeng.core.features.registries.P2PTunnelRegistry; -import appeng.core.features.registries.PartModels; -import appeng.core.features.registries.cell.BasicCellHandler; -import appeng.core.features.registries.cell.BasicItemCellGuiHandler; -import appeng.core.features.registries.cell.CreativeCellHandler; import appeng.core.localization.GuiText; import appeng.core.stats.AdvancementTriggers; -import appeng.core.stats.AeStats; -import appeng.fluids.client.gui.*; -import appeng.fluids.container.*; -import appeng.fluids.registries.BasicFluidCellGuiHandler; -import appeng.items.parts.FacadeItem; -import appeng.me.cache.*; -import appeng.recipes.game.DisassembleRecipe; -import appeng.recipes.game.FacadeRecipe; -import appeng.recipes.handlers.GrinderRecipe; -import appeng.recipes.handlers.GrinderRecipeSerializer; -import appeng.recipes.handlers.InscriberRecipe; -import appeng.recipes.handlers.InscriberRecipeSerializer; import appeng.server.AECommand; import appeng.spatial.StorageCellBiome; import appeng.spatial.StorageCellModDimension; @@ -140,9 +100,9 @@ final class Registration { // Block and part interface have different translation keys, but support the // same upgrades Text interfaceGroup = parts.iface().asItem().getName(); - Text itemIoBusGroup = GuiText.IOBuses.textComponent(); - Text fluidIoBusGroup = GuiText.IOBusesFluids.textComponent(); - Text storageCellGroup = GuiText.IOBusesFluids.textComponent(); + Text itemIoBusGroup = GuiText.IOBuses.text(); + Text fluidIoBusGroup = GuiText.IOBusesFluids.text(); + Text storageCellGroup = GuiText.IOBusesFluids.text(); // default settings.. ((P2PTunnelRegistry) registries.p2pTunnel()).configure(); diff --git a/src/unported/java/appeng/integration/modules/jei/JeiRuntimeAdapter.java b/src/unported/java/appeng/integration/modules/jei/JeiRuntimeAdapter.java index d6e62787f..c8b7cfc44 100644 --- a/src/unported/java/appeng/integration/modules/jei/JeiRuntimeAdapter.java +++ b/src/unported/java/appeng/integration/modules/jei/JeiRuntimeAdapter.java @@ -26,7 +26,7 @@ import appeng.integration.abstraction.IJEI; class JeiRuntimeAdapter implements IJEI { - private final IJeiRuntime runtime; + private final IReiRuntime runtime; JeiRuntimeAdapter(IJeiRuntime jeiRuntime) { this.runtime = jeiRuntime; diff --git a/src/unported/java/appeng/items/storage/SpatialStorageCellItem.java b/src/unported/java/appeng/items/storage/SpatialStorageCellItem.java index 394107000..ab9a06a7a 100644 --- a/src/unported/java/appeng/items/storage/SpatialStorageCellItem.java +++ b/src/unported/java/appeng/items/storage/SpatialStorageCellItem.java @@ -60,8 +60,8 @@ public class SpatialStorageCellItem extends AEBaseItem implements ISpatialStorag final TooltipContext advancedTooltips) { final DimensionType dimType = this.getStoredDimension(stack); if (dimType == null) { - lines.add(GuiText.Unformatted.textComponent().formatted(Formatting.ITALIC)); - lines.add(GuiText.SpatialCapacity.textComponent(maxRegion, maxRegion, maxRegion)); + lines.add(GuiText.Unformatted.text().formatted(Formatting.ITALIC)); + lines.add(GuiText.SpatialCapacity.text(maxRegion, maxRegion, maxRegion)); } else { SpatialDimensionManager.INSTANCE.addCellDimensionTooltip(dimType, lines); } diff --git a/src/unported/java/appeng/spatial/SpatialDimensionManager.java b/src/unported/java/appeng/spatial/SpatialDimensionManager.java index fbe868f4c..0e863927d 100644 --- a/src/unported/java/appeng/spatial/SpatialDimensionManager.java +++ b/src/unported/java/appeng/spatial/SpatialDimensionManager.java @@ -139,7 +139,7 @@ public final class SpatialDimensionManager implements ISpatialDimension { // Add the actual stored size BlockPos size = SpatialDimensionManager.INSTANCE.getCellDimensionSize(cellDim); - lines.add(GuiText.StoredSize.textComponent(size.getX(), size.getY(), size.getZ())); + lines.add(GuiText.StoredSize.text(size.getX(), size.getY(), size.getZ())); // Add a serial number to allows players to keep different cells apart int dimId; @@ -152,7 +152,7 @@ public final class SpatialDimensionManager implements ISpatialDimension { // Try to make this a little more flavorful. String serialNumber = String.format(Locale.ROOT, "SP-%04d", dimId); - lines.add(GuiText.SerialNumber.textComponent(serialNumber)); + lines.add(GuiText.SerialNumber.text(serialNumber)); } @Nullable