Added HWYLA
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -88,7 +88,6 @@ public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
|
||||
} else {
|
||||
ContainerOpener.openContainer(ChestContainer.TYPE, p,
|
||||
ContainerLocator.forTileEntitySide(tg, hit.getSide()));
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
return ActionResult.SUCCESS;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<ActionKey, KeyBinding> bindings = new EnumMap<>(ActionKey.class);
|
||||
private final EnumMap<ActionKey, KeyBinding> 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.<MEMonitorableContainer, MEMonitorableScreen<MEMonitorableContainer>>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.<CraftingCPUContainer, CraftingCPUScreen<CraftingCPUContainer>>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.<UpgradeableContainer, UpgradeableScreen<UpgradeableContainer>>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.<MEMonitorableContainer, MEMonitorableScreen<MEMonitorableContainer>>register(
|
||||
MEMonitorableContainer.TYPE, MEMonitorableScreen::new);
|
||||
ScreenRegistry.register(MEPortableCellContainer.TYPE, MEPortableCellScreen::new);
|
||||
ScreenRegistry.register(WirelessTermContainer.TYPE, WirelessTermScreen::new);
|
||||
ScreenRegistry.register(NetworkStatusContainer.TYPE, NetworkStatusScreen::new);
|
||||
ScreenRegistry.<CraftingCPUContainer, CraftingCPUScreen<CraftingCPUContainer>>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.<UpgradeableContainer, UpgradeableScreen<UpgradeableContainer>>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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<T extends AEBaseContainer> 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<T extends AEBaseContainer> 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<Text> 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<String> lines) {
|
||||
protected void drawTooltip(MatrixStack matrices, int x, int y, List<Text> lines) {
|
||||
if (lines.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<StringRenderable> renderableLines = new ArrayList<>(lines.size());
|
||||
|
||||
// Make the first line white
|
||||
// All lines after the first are colored gray
|
||||
List<Text> 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<T extends AEBaseContainer> 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<T extends AEBaseContainer> 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() {
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CopyMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.client.gui.widgets.ActionButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.client.gui.widgets.ToggleButton;
|
||||
import appeng.container.implementations.CellWorkbenchContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class CellWorkbenchScreen extends UpgradeableScreen<CellWorkbenchContainer> {
|
||||
|
||||
private ToggleButton copyMode;
|
||||
|
||||
public CellWorkbenchScreen(CellWorkbenchContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.fuzzyMode = this.addButton(new SettingToggleButton<>(this.x - 18, this.y + 68,
|
||||
Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::toggleFuzzyMode));
|
||||
this.addButton(
|
||||
new ActionButton(this.x - 18, this.y + 28, ActionItems.WRENCH, act1 -> 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.text(), GuiText.CopyModeDesc.text(), act -> action("CopyMode")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.handleButtonVisibility();
|
||||
|
||||
this.bindTexture(this.getBackground());
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, 211 - 34, this.backgroundHeight);
|
||||
if (this.drawUpgrades()) {
|
||||
if (this.handler.availableUpgrades() <= 8) {
|
||||
drawTexture(matrices, offsetX + 177, offsetY, 177, 0, 35,
|
||||
7 + this.handler.availableUpgrades() * 18);
|
||||
drawTexture(matrices, offsetX + 177, offsetY + (7 + (this.handler.availableUpgrades()) * 18),
|
||||
177, 151, 35, 7);
|
||||
} else if (this.handler.availableUpgrades() <= 16) {
|
||||
drawTexture(matrices, offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18);
|
||||
drawTexture(matrices, offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7);
|
||||
|
||||
final int dx = this.handler.availableUpgrades() - 8;
|
||||
drawTexture(matrices, offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18);
|
||||
if (dx == 8) {
|
||||
drawTexture(matrices, offsetX + 177 + 27, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7);
|
||||
} else {
|
||||
drawTexture(matrices, offsetX + 177 + 27 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151,
|
||||
35 - 8, 7);
|
||||
}
|
||||
} else {
|
||||
drawTexture(matrices, offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18);
|
||||
drawTexture(matrices, offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7);
|
||||
|
||||
drawTexture(matrices, offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18);
|
||||
drawTexture(matrices, offsetX + 177 + 27, offsetY + (7 + (8) * 18), 186, 151, 35 - 8, 7);
|
||||
|
||||
final int dx = this.handler.availableUpgrades() - 16;
|
||||
drawTexture(matrices, offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18);
|
||||
if (dx == 8) {
|
||||
drawTexture(matrices, offsetX + 177 + 27 + 18, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8,
|
||||
7);
|
||||
} else {
|
||||
drawTexture(matrices, offsetX + 177 + 27 + 18 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151,
|
||||
35 - 8, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hasToolbox()) {
|
||||
drawTexture(matrices, offsetX + 178, offsetY + this.backgroundHeight - 90, 178, 161, 68, 68);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility() {
|
||||
this.copyMode.setState(this.handler.getCopyMode() == CopyMode.CLEAR_ON_REMOVE);
|
||||
|
||||
boolean hasFuzzy = false;
|
||||
final FixedItemInv inv = this.handler.getCellUpgradeInventory();
|
||||
for (int x = 0; x < inv.getSlotCount(); x++) {
|
||||
final ItemStack is = inv.getInvStack(x);
|
||||
if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) {
|
||||
if (((IUpgradeModule) is.getItem()).getType(is) == Upgrades.FUZZY) {
|
||||
hasFuzzy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.fuzzyMode.setVisibility(hasFuzzy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/cellworkbench.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades() {
|
||||
return this.handler.availableUpgrades() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.CellWorkbench;
|
||||
}
|
||||
|
||||
private void action(String type) {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("CellWorkbench.Action", type));
|
||||
}
|
||||
|
||||
private void toggleFuzzyMode(SettingToggleButton<FuzzyMode> button, boolean backwards) {
|
||||
FuzzyMode fz = button.getNextValue(backwards);
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("CellWorkbench.Fuzzy", fz.name()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class ChestScreen extends AEBaseScreen<ChestContainer> {
|
||||
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<ChestContainer> {
|
||||
|
||||
@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
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.ProgressBar;
|
||||
import appeng.client.gui.widgets.ProgressBar.Direction;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.container.implementations.CondenserContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class CondenserScreen extends AEBaseScreen<CondenserContainer> {
|
||||
|
||||
private SettingToggleButton<CondenserOutput> mode;
|
||||
|
||||
public CondenserScreen(CondenserContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.mode = new ServerSettingToggleButton<>(128 + this.x, 52 + this.y, Settings.CONDENSER_OUTPUT,
|
||||
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.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.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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/condenser.png");
|
||||
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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;
|
||||
import appeng.client.gui.widgets.NumberBox;
|
||||
import appeng.container.implementations.CraftAmountContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.CraftRequestPacket;
|
||||
|
||||
public class CraftAmountScreen extends AEBaseScreen<CraftAmountContainer> {
|
||||
private final AESubScreen subGui;
|
||||
|
||||
private NumberBox amountToCraft;
|
||||
|
||||
private ButtonWidget next;
|
||||
|
||||
public CraftAmountScreen(CraftAmountContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubScreen(this, container.getTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final int a = AEConfig.instance().craftItemsByStackAmounts(0);
|
||||
final int b = AEConfig.instance().craftItemsByStackAmounts(1);
|
||||
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, 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, 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.text(), this::confirm));
|
||||
|
||||
subGui.addBackButton(this::addButton, 154, 0);
|
||||
|
||||
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);
|
||||
this.amountToCraft.setEditableColor(0xFFFFFF);
|
||||
this.amountToCraft.setVisible(true);
|
||||
this.amountToCraft.setFocused(true);
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
|
||||
private void confirm(ButtonWidget button) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new CraftRequestPacket(Integer.parseInt(this.amountToCraft.getText()), hasShiftDown()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
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.text() : GuiText.Next.text());
|
||||
|
||||
this.bindTexture("guis/craft_amt.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
|
||||
try {
|
||||
Long.parseLong(this.amountToCraft.getText());
|
||||
this.next.active = !this.amountToCraft.getText().isEmpty();
|
||||
} catch (final NumberFormatException e) {
|
||||
this.next.active = false;
|
||||
}
|
||||
|
||||
this.amountToCraft.render(matrices, offsetX, offsetY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char ch, int p_charTyped_2_) {
|
||||
// Forward entered text to the craft amount text-field
|
||||
return this.amountToCraft.charTyped(ch, p_charTyped_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(keyCode, scanCode)) {
|
||||
if (keyCode == 28) {
|
||||
this.next.onPress();
|
||||
}
|
||||
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
|
||||
&& this.amountToCraft.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
final long result = Long.parseLong(out);
|
||||
if (result < 0) {
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
long result = Integer.parseInt(out);
|
||||
|
||||
if (result == 1 && i > 1) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
result += i;
|
||||
if (result < 1) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
out = Long.toString(result);
|
||||
Integer.parseInt(out);
|
||||
this.amountToCraft.setText(out);
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.container.implementations.CraftConfirmContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
|
||||
|
||||
private final AESubScreen subGui;
|
||||
|
||||
private final int rows = 5;
|
||||
|
||||
private final IItemList<IAEItemStack> storage = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IItemList<IAEItemStack> pending = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IItemList<IAEItemStack> missing = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
private final List<IAEItemStack> visual = new ArrayList<>();
|
||||
|
||||
private ButtonWidget start;
|
||||
private ButtonWidget selectCPU;
|
||||
private int tooltip = -1;
|
||||
|
||||
public CraftConfirmScreen(CraftConfirmContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubScreen(this, container.getTarget());
|
||||
this.backgroundWidth = 238;
|
||||
this.backgroundHeight = 206;
|
||||
|
||||
final Scrollbar scrollbar = new Scrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
}
|
||||
|
||||
boolean isAutoStart() {
|
||||
return this.handler.isAutoStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
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.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.text(),
|
||||
btn -> subGui.goBack()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, final int mouseX, final int mouseY, final float btn) {
|
||||
this.updateCPUButtonText();
|
||||
|
||||
this.start.active = !(this.handler.hasNoCPU() || this.isSimulation());
|
||||
this.selectCPU.active = !this.isSimulation();
|
||||
|
||||
final int gx = (this.width - this.backgroundWidth) / 2;
|
||||
final int gy = (this.height - this.backgroundHeight) / 2;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for (int z = 0; z <= 4 * 5; z++) {
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
|
||||
if (minX < mouseX && minX + 67 > mouseX) {
|
||||
if (minY < mouseY && minY + offY - 2 > mouseY) {
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.render(matrices, mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
private void updateCPUButtonText() {
|
||||
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().asTruncatedString(20);
|
||||
btnTextText = GuiText.CraftingCPU.withSuffix(": " + name);
|
||||
} else {
|
||||
btnTextText = GuiText.CraftingCPU.withSuffix(": #" + this.handler.getSelectedCpu());
|
||||
}
|
||||
}
|
||||
|
||||
if (this.handler.hasNoCPU()) {
|
||||
btnTextText = GuiText.NoCraftingCPUs.text();
|
||||
}
|
||||
|
||||
this.selectCPU.setMessage(btnTextText);
|
||||
}
|
||||
|
||||
private boolean isSimulation() {
|
||||
return this.handler.isSimulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
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 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);
|
||||
|
||||
Text dsp;
|
||||
|
||||
if (this.isSimulation()) {
|
||||
dsp = GuiText.Simulation.text();
|
||||
} else {
|
||||
dsp = this.handler.getCpuAvailableBytes() > 0
|
||||
? (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;
|
||||
this.textRenderer.draw(matrices, dsp, offset, 165, 4210752);
|
||||
|
||||
final int sectionLength = 67;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int xo = 9;
|
||||
final int yo = 22;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * this.rows;
|
||||
|
||||
List<Text> dspToolTip = new ArrayList<>();
|
||||
final List<Text> lineList = new ArrayList<>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
final int offY = 23;
|
||||
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
|
||||
final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z );
|
||||
if (refStack != null) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise(refStack);
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
|
||||
final IAEItemStack missingStack = this.missing.findPrecise(refStack);
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
if (missingStack != null && missingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
|
||||
final int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
String str = Long.toString(stored.getStackSize());
|
||||
if (stored.getStackSize() >= 10000) {
|
||||
str = Long.toString(stored.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (stored.getStackSize() >= 10000000) {
|
||||
str = Long.toString(stored.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
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.withSuffix(": " + stored.getStackSize()));
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
boolean red = false;
|
||||
if (missingStack != null && missingStack.getStackSize() > 0) {
|
||||
String str = Long.toString(missingStack.getStackSize());
|
||||
if (missingStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(missingStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (missingStack.getStackSize() >= 10000000) {
|
||||
str = Long.toString(missingStack.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
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.withSuffix(": " + missingStack.getStackSize()));
|
||||
}
|
||||
|
||||
red = true;
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
String str = Long.toString(pendingStack.getStackSize());
|
||||
if (pendingStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(pendingStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (pendingStack.getStackSize() >= 10000000) {
|
||||
str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
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.withSuffix(": " + pendingStack.getStackSize()));
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
final int posY = y * offY + yo;
|
||||
|
||||
final ItemStack is = refStack.asItemStackRepresentation();
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
dspToolTip.add(Platform.getItemDisplayName(refStack));
|
||||
|
||||
if (lineList.size() > 0) {
|
||||
dspToolTip.addAll(lineList);
|
||||
}
|
||||
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
this.drawItem(posX, posY, is);
|
||||
|
||||
if (red) {
|
||||
final int startX = x * (1 + sectionLength) + xo;
|
||||
final int startY = posY - 4;
|
||||
fill(matrices, startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip >= 0 && !dspToolTip.isEmpty()) {
|
||||
this.drawTooltip(matrices, toolPosX, toolPosY + 10, dspToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.setScrollBar();
|
||||
this.bindTexture("guis/craftingreport.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
final int size = this.visual.size();
|
||||
|
||||
this.getScrollBar().setTop(19).setLeft(218).setHeight(114);
|
||||
this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
switch (ref) {
|
||||
case 0:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.storage, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.pending, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.missing, l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (final IAEItemStack l : list) {
|
||||
final long amt = this.getTotal(l);
|
||||
|
||||
if (amt <= 0) {
|
||||
this.deleteVisualStack(l);
|
||||
} else {
|
||||
final IAEItemStack is = this.findVisualStack(l);
|
||||
is.setStackSize(amt);
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
|
||||
IAEItemStack a = s.findPrecise(l);
|
||||
|
||||
if (l.getStackSize() <= 0) {
|
||||
if (a != null) {
|
||||
a.reset();
|
||||
}
|
||||
} else {
|
||||
if (a == null) {
|
||||
s.add(l.copy());
|
||||
a = s.findPrecise(l);
|
||||
}
|
||||
|
||||
if (a != null) {
|
||||
a.setStackSize(l.getStackSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal(final IAEItemStack is) {
|
||||
final IAEItemStack a = this.storage.findPrecise(is);
|
||||
final IAEItemStack c = this.pending.findPrecise(is);
|
||||
final IAEItemStack m = this.missing.findPrecise(is);
|
||||
|
||||
long total = 0;
|
||||
|
||||
if (a != null) {
|
||||
total += a.getStackSize();
|
||||
}
|
||||
|
||||
if (c != null) {
|
||||
total += c.getStackSize();
|
||||
}
|
||||
|
||||
if (m != null) {
|
||||
total += m.getStackSize();
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(final IAEItemStack l) {
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
while (i.hasNext()) {
|
||||
final IAEItemStack o = i.next();
|
||||
if (o.equals(l)) {
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(final IAEItemStack l) {
|
||||
for (final IAEItemStack o : this.visual) {
|
||||
if (o.equals(l)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add(stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(keyCode, scanCode)) {
|
||||
if (keyCode == 28) {
|
||||
this.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
private void selectNextCpu() {
|
||||
final boolean backwards = getClient().mouse.wasRightButtonClicked();
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("Terminal.Cpu", backwards ? "Prev" : "Next"));
|
||||
}
|
||||
|
||||
private void start() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("Terminal.Start", "Start"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.container.implementations.CraftingCPUContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
|
||||
public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScreen<T> implements ISortSource {
|
||||
private static final int GUI_HEIGHT = 184;
|
||||
private static final int GUI_WIDTH = 238;
|
||||
|
||||
private static final int DISPLAYED_ROWS = 6;
|
||||
|
||||
private static final int TEXT_COLOR = 0x404040;
|
||||
private static final int BACKGROUND_ALPHA = 0x5A000000;
|
||||
|
||||
private static final int SECTION_LENGTH = 67;
|
||||
|
||||
private static final int SCROLLBAR_TOP = 19;
|
||||
private static final int SCROLLBAR_LEFT = 218;
|
||||
private static final int SCROLLBAR_HEIGHT = 137;
|
||||
|
||||
private static final int CANCEL_LEFT_OFFSET = 163;
|
||||
private static final int CANCEL_TOP_OFFSET = 25;
|
||||
private static final int CANCEL_HEIGHT = 20;
|
||||
private static final int CANCEL_WIDTH = 50;
|
||||
|
||||
private static final int TITLE_TOP_OFFSET = 7;
|
||||
private static final int TITLE_LEFT_OFFSET = 8;
|
||||
|
||||
private static final int ITEMSTACK_LEFT_OFFSET = 9;
|
||||
private static final int ITEMSTACK_TOP_OFFSET = 22;
|
||||
|
||||
private IItemList<IAEItemStack> storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
private IItemList<IAEItemStack> active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
private IItemList<IAEItemStack> pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
|
||||
private List<IAEItemStack> visual = new ArrayList<>();
|
||||
private ButtonWidget cancel;
|
||||
private int tooltip = -1;
|
||||
|
||||
public CraftingCPUScreen(T container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = GUI_HEIGHT;
|
||||
this.backgroundWidth = GUI_WIDTH;
|
||||
|
||||
final Scrollbar scrollbar = new Scrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
this.storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.visual = new ArrayList<>();
|
||||
}
|
||||
|
||||
private void cancel() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("TileCrafting.Cancel", "Cancel"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
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.text(), btn -> cancel());
|
||||
this.addButton(this.cancel);
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
final int size = this.visual.size();
|
||||
|
||||
this.getScrollBar().setTop(SCROLLBAR_TOP).setLeft(SCROLLBAR_LEFT).setHeight(SCROLLBAR_HEIGHT);
|
||||
this.getScrollBar().setRange(0, (size + 2) / 3 - DISPLAYED_ROWS, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, final int mouseX, final int mouseY, final float btn) {
|
||||
this.cancel.active = !this.visual.isEmpty();
|
||||
|
||||
final int gx = (this.width - this.backgroundWidth) / 2;
|
||||
final int gy = (this.height - this.backgroundHeight) / 2;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for (int z = 0; z <= 4 * 5; z++) {
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
|
||||
if (minX < mouseX && minX + 67 > mouseX) {
|
||||
if (minY < mouseY && minY + offY - 2 > mouseY) {
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.render(matrices, mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
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.text().getString());
|
||||
title = title.copy().append(" - " + etaTimeText);
|
||||
}
|
||||
|
||||
this.textRenderer.draw(matrices, title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR);
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * 6;
|
||||
|
||||
List<Text> dspToolTip = new ArrayList<>();
|
||||
final List<Text> lineList = new ArrayList<>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
final int offY = 23;
|
||||
|
||||
final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
|
||||
final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z );
|
||||
if (refStack != null) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise(refStack);
|
||||
final IAEItemStack activeStack = this.active.findPrecise(refStack);
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
boolean active = false;
|
||||
if (activeStack != null && activeStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
active = true;
|
||||
}
|
||||
boolean scheduled = false;
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
scheduled = true;
|
||||
}
|
||||
|
||||
if (AEConfig.instance().isUseColoredCraftingStatus() && (active || scheduled)) {
|
||||
final int bgColor = (active ? AEColor.GREEN.blackVariant : AEColor.YELLOW.blackVariant)
|
||||
| BACKGROUND_ALPHA;
|
||||
final int startX = (x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET) * 2;
|
||||
final int startY = ((y * offY + ITEMSTACK_TOP_OFFSET) - 3) * 2;
|
||||
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.text() + ": "
|
||||
+ converter.toWideReadableForm(stored.getStackSize());
|
||||
final int w = 4 + this.textRenderer.getWidth(str);
|
||||
this.textRenderer.draw(matrices, str,
|
||||
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
|
||||
* 2),
|
||||
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Stored.withSuffix(": " + stored.getStackSize()));
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if (activeStack != null && activeStack.getStackSize() > 0) {
|
||||
final String str = GuiText.Crafting.text() + ": "
|
||||
+ converter.toWideReadableForm(activeStack.getStackSize());
|
||||
final int w = 4 + this.textRenderer.getWidth(str);
|
||||
|
||||
this.textRenderer.draw(matrices, str,
|
||||
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
|
||||
* 2),
|
||||
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Crafting.withSuffix(": " + activeStack.getStackSize()));
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
final String str = GuiText.Scheduled.text() + ": "
|
||||
+ converter.toWideReadableForm(pendingStack.getStackSize());
|
||||
final int w = 4 + this.textRenderer.getWidth(str);
|
||||
|
||||
this.textRenderer.draw(matrices, str,
|
||||
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
|
||||
* 2),
|
||||
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Scheduled.withSuffix(": " + pendingStack.getStackSize()));
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
|
||||
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
|
||||
final ItemStack is = refStack.asItemStackRepresentation();
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
dspToolTip.add(Platform.getItemDisplayName(refStack));
|
||||
|
||||
if (lineList.size() > 0) {
|
||||
dspToolTip.addAll(lineList);
|
||||
}
|
||||
|
||||
toolPosX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
|
||||
toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
}
|
||||
|
||||
this.drawItem(posX, posY, is);
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip >= 0 && !dspToolTip.isEmpty()) {
|
||||
this.drawTooltip(matrices, toolPosX, toolPosY + 10, dspToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/craftingcpu.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
switch (ref) {
|
||||
case 0:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.storage, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.active, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.pending, l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (final IAEItemStack l : list) {
|
||||
final long amt = this.getTotal(l);
|
||||
|
||||
if (amt <= 0) {
|
||||
this.deleteVisualStack(l);
|
||||
} else {
|
||||
final IAEItemStack is = this.findVisualStack(l);
|
||||
is.setStackSize(amt);
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
|
||||
IAEItemStack a = s.findPrecise(l);
|
||||
|
||||
if (l.getStackSize() <= 0) {
|
||||
if (a != null) {
|
||||
a.reset();
|
||||
}
|
||||
} else {
|
||||
if (a == null) {
|
||||
s.add(l.copy());
|
||||
a = s.findPrecise(l);
|
||||
}
|
||||
|
||||
if (a != null) {
|
||||
a.setStackSize(l.getStackSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal(final IAEItemStack is) {
|
||||
final IAEItemStack a = this.storage.findPrecise(is);
|
||||
final IAEItemStack b = this.active.findPrecise(is);
|
||||
final IAEItemStack c = this.pending.findPrecise(is);
|
||||
|
||||
long total = 0;
|
||||
|
||||
if (a != null) {
|
||||
total += a.getStackSize();
|
||||
}
|
||||
|
||||
if (b != null) {
|
||||
total += b.getStackSize();
|
||||
}
|
||||
|
||||
if (c != null) {
|
||||
total += c.getStackSize();
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(final IAEItemStack l) {
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
final IAEItemStack o = i.next();
|
||||
if (o.equals(l)) {
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(final IAEItemStack l) {
|
||||
for (final IAEItemStack o : this.visual) {
|
||||
if (o.equals(l)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add(stack);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy() {
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortDir getSortDir() {
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewItems getSortDisplay() {
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
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.Text;
|
||||
|
||||
import appeng.container.implementations.CraftingStatusContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class CraftingStatusScreen extends CraftingCPUScreen<CraftingStatusContainer> {
|
||||
|
||||
private final AESubScreen subGui;
|
||||
|
||||
private ButtonWidget selectCPU;
|
||||
|
||||
public CraftingStatusScreen(CraftingStatusContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubScreen(this, container.getTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.selectCPU = new ButtonWidget(this.x + 8, this.y + this.backgroundHeight - 25, 150, 20,
|
||||
GuiText.CraftingCPU.withSuffix(": ").append(GuiText.NoCraftingCPUs.text()), btn -> selectNextCpu());
|
||||
this.addButton(this.selectCPU);
|
||||
|
||||
subGui.addBackButton(btn -> {
|
||||
addButton(btn);
|
||||
btn.setHideEdge(13);
|
||||
}, 213, -4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, final int mouseX, final int mouseY, final float btn) {
|
||||
this.updateCPUButtonText();
|
||||
super.render(matrices, mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
private void updateCPUButtonText() {
|
||||
Text btnTextText = GuiText.NoCraftingJobs.text();
|
||||
|
||||
if (this.handler.selectedCpu >= 0)// && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if (this.handler.myName != null) {
|
||||
final String name = this.handler.myName.asTruncatedString(20);
|
||||
btnTextText = GuiText.CPUs.withSuffix(": " + name);
|
||||
} else {
|
||||
btnTextText = GuiText.CPUs.withSuffix(": #" + this.handler.selectedCpu);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.handler.noCPU) {
|
||||
btnTextText = GuiText.NoCraftingJobs.text();
|
||||
}
|
||||
|
||||
this.selectCPU.setMessage(btnTextText);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 = client.mouse.wasRightButtonClicked();
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("Terminal.Cpu", backwards ? "Prev" : "Next"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.client.gui.widgets.ActionButton;
|
||||
import appeng.container.implementations.CraftingTermContainer;
|
||||
import appeng.container.slot.CraftingMatrixSlot;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.InventoryActionPacket;
|
||||
import appeng.helpers.InventoryAction;
|
||||
|
||||
public class CraftingTermScreen extends MEMonitorableScreen<CraftingTermContainer> {
|
||||
|
||||
public CraftingTermScreen(CraftingTermContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setReservedSpace(73);
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
Slot s = null;
|
||||
for (final Object j : this.handler.slots) {
|
||||
if (j instanceof CraftingMatrixSlot) {
|
||||
s = (Slot) j;
|
||||
}
|
||||
}
|
||||
|
||||
if (s != null) {
|
||||
final InventoryActionPacket p = new InventoryActionPacket(InventoryAction.MOVE_REGION, s.id, 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
ActionButton clearBtn = this.addButton(
|
||||
new ActionButton(this.x + 92, this.y + this.backgroundHeight - 156, ActionItems.STASH, btn -> clear()));
|
||||
clearBtn.setHalfSize(true);
|
||||
}
|
||||
|
||||
@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.CraftingTerminal.text(), 8, this.backgroundHeight - 96 + 1 - this.getReservedSpace(),
|
||||
4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.container.implementations.DriveContainer;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
|
||||
public class DriveScreen extends AEBaseScreen<DriveContainer> {
|
||||
|
||||
public DriveScreen(DriveContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 199;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.text(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
|
||||
}
|
||||
|
||||
@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.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/drive.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.container.implementations.FormationPlaneContainer;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
|
||||
public class FormationPlaneScreen extends UpgradeableScreen<FormationPlaneContainer> {
|
||||
|
||||
private SettingToggleButton<YesNo> placeMode;
|
||||
|
||||
public FormationPlaneScreen(FormationPlaneContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.placeMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 28, Settings.PLACE_BLOCK,
|
||||
YesNo.YES);
|
||||
this.fuzzyMode = new ServerSettingToggleButton<>(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.text(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
|
||||
this.addButton(this.placeMode);
|
||||
this.addButton(this.fuzzyMode);
|
||||
}
|
||||
|
||||
@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.FormationPlane.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());
|
||||
}
|
||||
|
||||
if (this.placeMode != null) {
|
||||
this.placeMode.set(((FormationPlaneContainer) this.cvb).getPlaceMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,8 +36,8 @@ public class GrinderScreen extends AEBaseScreen<GrinderContainer> {
|
||||
|
||||
@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
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.container.implementations.IOPortContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class IOPortScreen extends UpgradeableScreen<IOPortContainer> {
|
||||
|
||||
private SettingToggleButton<FullnessMode> fullMode;
|
||||
private SettingToggleButton<OperationMode> operationMode;
|
||||
|
||||
public IOPortScreen(IOPortContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.fullMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 8, Settings.FULLNESS_MODE,
|
||||
FullnessMode.EMPTY);
|
||||
this.operationMode = new ServerSettingToggleButton<>(this.x + 80, this.y + 17,
|
||||
Settings.OPERATION_MODE, OperationMode.EMPTY);
|
||||
|
||||
this.addButton(this.operationMode);
|
||||
this.addButton(this.fullMode);
|
||||
this.redstoneMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 28,
|
||||
Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
addButton(this.redstoneMode);
|
||||
}
|
||||
|
||||
@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.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());
|
||||
}
|
||||
|
||||
if (this.operationMode != null) {
|
||||
this.operationMode.set(((IOPortContainer) this.cvb).getOperationMode());
|
||||
}
|
||||
|
||||
if (this.fullMode != null) {
|
||||
this.fullMode.set(((IOPortContainer) this.cvb).getFullMode());
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
definitions.items().cell1k().maybeStack(1)
|
||||
.ifPresent(cell1kStack -> this.drawItem(offsetX + 66 - 8, offsetY + 17, cell1kStack));
|
||||
|
||||
definitions.blocks().drive().maybeStack(1)
|
||||
.ifPresent(driveStack -> this.drawItem(offsetX + 94 + 8, offsetY + 17, driveStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/io_port.png";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.ProgressBar;
|
||||
import appeng.client.gui.widgets.ProgressBar.Direction;
|
||||
import appeng.container.implementations.InscriberContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class InscriberScreen extends AEBaseScreen<InscriberContainer> {
|
||||
|
||||
private ProgressBar pb;
|
||||
|
||||
public InscriberScreen(InscriberContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 176;
|
||||
this.backgroundWidth = this.hasToolbox() ? 246 : 211;
|
||||
}
|
||||
|
||||
private boolean hasToolbox() {
|
||||
return this.handler.hasToolbox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.pb = new ProgressBar(this.handler, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL);
|
||||
this.addButton(this.pb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.pb.setFullMsg(new LiteralText(this.handler.getCurrentProgress() * 100 / this.handler.getMaxProgress() + "%"));
|
||||
|
||||
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
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/inscriber.png");
|
||||
this.pb.x = 135 + this.x;
|
||||
this.pb.y = 39 + this.y;
|
||||
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, 211 - 34, this.backgroundHeight);
|
||||
|
||||
if (this.drawUpgrades()) {
|
||||
drawTexture(matrices, offsetX + 177, offsetY, 177, 0, 35,
|
||||
14 + this.handler.availableUpgrades() * 18);
|
||||
}
|
||||
if (this.hasToolbox()) {
|
||||
drawTexture(matrices, offsetX + 178, offsetY + this.backgroundHeight - 90, 178, this.backgroundHeight - 90, 68, 68);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean drawUpgrades() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.client.gui.widgets.ToggleButton;
|
||||
import appeng.container.implementations.InterfaceContainer;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigButtonPacket;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
|
||||
public class InterfaceScreen extends UpgradeableScreen<InterfaceContainer> {
|
||||
|
||||
private SettingToggleButton<YesNo> blockMode;
|
||||
private ToggleButton interfaceMode;
|
||||
|
||||
public InterfaceScreen(InterfaceContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 211;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
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.text(), GuiText.InterfaceTerminalHint.text(),
|
||||
btn -> selectNextInterfaceMode());
|
||||
this.addButton(this.interfaceMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
if (this.blockMode != null) {
|
||||
this.blockMode.set(((InterfaceContainer) this.cvb).getBlockingMode());
|
||||
}
|
||||
|
||||
if (this.interfaceMode != null) {
|
||||
this.interfaceMode.setState(((InterfaceContainer) this.cvb).getInterfaceTerminalMode() == YesNo.YES);
|
||||
}
|
||||
|
||||
this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.Interface.text()), 8, 6, 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.text(), 8, this.backgroundHeight - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/interface.png";
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
|
||||
}
|
||||
|
||||
private void selectNextInterfaceMode() {
|
||||
final boolean backwards = getClient().mouse.wasRightButtonClicked();
|
||||
NetworkHandler.instance().sendToServer(new ConfigButtonPacket(Settings.INTERFACE_TERMINAL, backwards));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.AETextField;
|
||||
import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.client.me.ClientDCInternalInv;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.container.implementations.InterfaceTerminalContainer;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalContainer> {
|
||||
|
||||
private static final int LINES_ON_PAGE = 6;
|
||||
|
||||
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
|
||||
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
|
||||
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
|
||||
|
||||
private boolean refreshList = false;
|
||||
private AETextField searchField;
|
||||
|
||||
public InterfaceTerminalScreen(InterfaceTerminalContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
final Scrollbar scrollbar = new Scrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
this.backgroundWidth = 195;
|
||||
this.backgroundHeight = 222;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.getScrollBar().setLeft(175);
|
||||
this.getScrollBar().setHeight(106);
|
||||
this.getScrollBar().setTop(18);
|
||||
|
||||
this.searchField = new AETextField(this.textRenderer, this.x + 104, this.y + 4, 65, 12);
|
||||
this.searchField.setHasBorder(false);
|
||||
this.searchField.setMaxLength(25);
|
||||
this.searchField.setEditableColor(0xFFFFFF);
|
||||
this.searchField.setVisible(true);
|
||||
this.searchField.setFocused(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.InterfaceTerminal.text()), 8, 6, 4210752);
|
||||
this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752);
|
||||
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
|
||||
this.handler.slots.removeIf(slot -> slot instanceof SlotDisconnected);
|
||||
|
||||
int offset = 17;
|
||||
for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++) {
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
for (int z = 0; z < inv.getInventory().getSlotCount(); z++) {
|
||||
this.handler.slots.add(new SlotDisconnected(inv, z, z * 18 + 8, 1 + offset));
|
||||
}
|
||||
} else if (lineObj instanceof String) {
|
||||
String name = (String) lineObj;
|
||||
final int rows = this.byName.get(name).size();
|
||||
if (rows > 1) {
|
||||
name = name + " (" + rows + ')';
|
||||
}
|
||||
|
||||
while (name.length() > 2 && this.textRenderer.getWidth(name) > 155) {
|
||||
name = name.substring(0, name.length() - 1);
|
||||
}
|
||||
|
||||
this.textRenderer.draw(matrices, name, 10, 6 + offset, 4210752);
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
|
||||
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.refreshList();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/interfaceterminal.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
|
||||
int offset = 17;
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
|
||||
for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++) {
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
final int width = inv.getInventory().getSlotCount() * 18;
|
||||
drawTexture(matrices, offsetX + 7, offsetY + offset, 7, 139, width, 18);
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
|
||||
if (this.searchField != null) {
|
||||
this.searchField.render(matrices, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (this.searchField.charTyped(character, key)) {
|
||||
this.refreshList();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
|
||||
if (keyCode != GLFW.GLFW_KEY_ESCAPE) {
|
||||
if (AppEng.instance().isActionKey(ActionKey.TOGGLE_FOCUS, keyCode, scanCode)) {
|
||||
this.searchField.setFocused(!this.searchField.isFocused());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Forward keypresses to the search field
|
||||
if (this.searchField.isFocused()) {
|
||||
if (keyCode == GLFW.GLFW_KEY_ENTER) {
|
||||
this.searchField.setFocused(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.searchField.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
|
||||
// We need to swallow key presses if the field is focused because typing 'e'
|
||||
// would otherwise close the screen
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
public void postUpdate(final CompoundTag in) {
|
||||
if (in.getBoolean("clear")) {
|
||||
this.byId.clear();
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
for (final Object oKey : in.getKeys()) {
|
||||
final String key = (String) oKey;
|
||||
if (key.startsWith("=")) {
|
||||
try {
|
||||
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
|
||||
final CompoundTag invData = in.getCompound(key);
|
||||
Text un = Text.Serializer.fromJson(invData.getString("un"));
|
||||
final ClientDCInternalInv current = this.getById(id, invData.getLong("sortBy"), un);
|
||||
|
||||
for (int x = 0; x < current.getInventory().getSlotCount(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.contains(which)) {
|
||||
current.getInventory().setInvStack(x, ItemStack.fromTag(invData.getCompound(which)), Simulation.ACTION);
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.refreshList) {
|
||||
this.refreshList = false;
|
||||
// invalid caches on refresh
|
||||
this.cachedSearches.clear();
|
||||
this.refreshList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the list of interfaces.
|
||||
*
|
||||
* Respects a search term if present (ignores case) and adding only matching
|
||||
* patterns.
|
||||
*/
|
||||
private void refreshList() {
|
||||
this.byName.clear();
|
||||
|
||||
final String searchFilterLowerCase = this.searchField.getText().toLowerCase();
|
||||
|
||||
final Set<Object> cachedSearch = this.getCacheForSearchTerm(searchFilterLowerCase);
|
||||
final boolean rebuild = cachedSearch.isEmpty();
|
||||
|
||||
for (final ClientDCInternalInv entry : this.byId.values()) {
|
||||
// ignore inventory if not doing a full rebuild or cache already marks it as
|
||||
// miss.
|
||||
if (!rebuild && !cachedSearch.contains(entry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Shortcut to skip any filter if search term is ""/empty
|
||||
boolean found = searchFilterLowerCase.isEmpty();
|
||||
|
||||
// Search if the current inventory holds a pattern containing the search term.
|
||||
if (!found && !searchFilterLowerCase.isEmpty()) {
|
||||
for (final ItemStack itemStack : entry.getInventory()) {
|
||||
found = this.itemStackMatchesSearchTerm(itemStack, searchFilterLowerCase);
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if found, filter skipped or machine name matching the search term, add it
|
||||
if (found || entry.getSearchName().contains(searchFilterLowerCase)) {
|
||||
this.byName.put(entry.getFormattedName(), entry);
|
||||
cachedSearch.add(entry);
|
||||
} else {
|
||||
cachedSearch.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
this.names.clear();
|
||||
this.names.addAll(this.byName.keySet());
|
||||
|
||||
Collections.sort(this.names);
|
||||
|
||||
this.lines.clear();
|
||||
this.lines.ensureCapacity(this.getMaxRows());
|
||||
|
||||
for (final String n : this.names) {
|
||||
this.lines.add(n);
|
||||
|
||||
List<ClientDCInternalInv> clientInventories = new ArrayList<>(this.byName.get(n));
|
||||
|
||||
Collections.sort(clientInventories);
|
||||
this.lines.addAll(clientInventories);
|
||||
}
|
||||
|
||||
this.getScrollBar().setRange(0, this.lines.size() - LINES_ON_PAGE, 2);
|
||||
}
|
||||
|
||||
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm) {
|
||||
if (itemStack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final CompoundTag encodedValue = itemStack.getTag();
|
||||
|
||||
if (encodedValue == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Potential later use to filter by input
|
||||
// ListNBT inTag = encodedValue.getTagList( "in", 10 );
|
||||
final ListTag outTag = encodedValue.getList("out", 10);
|
||||
|
||||
for (int i = 0; i < outTag.size(); i++) {
|
||||
|
||||
final ItemStack parsedItemStack = ItemStack.fromTag(outTag.getCompound(i));
|
||||
if (!parsedItemStack.isEmpty()) {
|
||||
final String displayName = Platform.getItemDisplayName(AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString()
|
||||
.toLowerCase();
|
||||
if (displayName.contains(searchTerm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to retrieve a cache for a with search term as keyword.
|
||||
*
|
||||
* If this cache should be empty, it will populate it with an earlier cache if
|
||||
* available or at least the cache for the empty string.
|
||||
*
|
||||
* @param searchTerm the corresponding search
|
||||
*
|
||||
* @return a Set matching a superset of the search term
|
||||
*/
|
||||
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
|
||||
if (!this.cachedSearches.containsKey(searchTerm)) {
|
||||
this.cachedSearches.put(searchTerm, new HashSet<>());
|
||||
}
|
||||
|
||||
final Set<Object> cache = this.cachedSearches.get(searchTerm);
|
||||
|
||||
if (cache.isEmpty() && searchTerm.length() > 1) {
|
||||
cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1)));
|
||||
return cache;
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* The max amount of unique names and each inv row. Not affected by the
|
||||
* filtering.
|
||||
*
|
||||
* @return max amount of unique names and each inv row
|
||||
*/
|
||||
private int getMaxRows() {
|
||||
return this.names.size() + this.byId.size();
|
||||
}
|
||||
|
||||
private ClientDCInternalInv getById(final long id, final long sortBy, final Text name) {
|
||||
ClientDCInternalInv o = this.byId.get(id);
|
||||
|
||||
if (o == null) {
|
||||
this.byId.put(id, o = new ClientDCInternalInv(9, id, sortBy, name));
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.NumberBox;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.container.implementations.LevelEmitterContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer> {
|
||||
|
||||
private NumberBox level;
|
||||
|
||||
private ButtonWidget plus1;
|
||||
private ButtonWidget plus10;
|
||||
private ButtonWidget plus100;
|
||||
private ButtonWidget plus1000;
|
||||
private ButtonWidget minus1;
|
||||
private ButtonWidget minus10;
|
||||
private ButtonWidget minus100;
|
||||
private ButtonWidget minus1000;
|
||||
|
||||
private SettingToggleButton<LevelType> levelMode;
|
||||
private SettingToggleButton<YesNo> craftingMode;
|
||||
|
||||
public LevelEmitterScreen(LevelEmitterContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
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);
|
||||
handler.setTextField(this.level);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.levelMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 8, Settings.LEVEL_TYPE,
|
||||
LevelType.ITEM_LEVEL);
|
||||
this.redstoneMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 28,
|
||||
Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL);
|
||||
this.fuzzyMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 48, Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
this.craftingMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 48,
|
||||
Settings.CRAFT_VIA_REDSTONE, YesNo.NO);
|
||||
|
||||
final int a = AEConfig.instance().levelByStackAmounts(0);
|
||||
final int b = AEConfig.instance().levelByStackAmounts(1);
|
||||
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, new LiteralText("+" + a), btn -> addQty(a)));
|
||||
this.addButton(
|
||||
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, new LiteralText("+" + c), btn -> addQty(c)));
|
||||
this.addButton(
|
||||
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, new LiteralText("-" + a), btn -> addQty(-a)));
|
||||
this.addButton(
|
||||
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, new LiteralText("-" + c), btn -> addQty(-c)));
|
||||
this.addButton(
|
||||
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);
|
||||
this.addButton(this.craftingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
final boolean notCraftingMode = this.bc.getInstalledUpgrades(Upgrades.CRAFTING) == 0;
|
||||
|
||||
// configure enabled status...
|
||||
this.level.active = notCraftingMode;
|
||||
this.plus1.active = notCraftingMode;
|
||||
this.plus10.active = notCraftingMode;
|
||||
this.plus100.active = notCraftingMode;
|
||||
this.plus1000.active = notCraftingMode;
|
||||
this.minus1.active = notCraftingMode;
|
||||
this.minus10.active = notCraftingMode;
|
||||
this.minus100.active = notCraftingMode;
|
||||
this.minus1000.active = notCraftingMode;
|
||||
this.levelMode.active = notCraftingMode;
|
||||
this.redstoneMode.active = notCraftingMode;
|
||||
|
||||
super.drawFG(matrices, offsetX, offsetY, mouseX, mouseY);
|
||||
|
||||
if (this.craftingMode != null) {
|
||||
this.craftingMode.set(this.cvb.getCraftingMode());
|
||||
}
|
||||
|
||||
if (this.levelMode != null) {
|
||||
this.levelMode.set(((LevelEmitterContainer) this.cvb).getLevelMode());
|
||||
}
|
||||
}
|
||||
|
||||
@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(matrices, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility() {
|
||||
this.craftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.CRAFTING) > 0);
|
||||
this.fuzzyMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.LevelEmitter;
|
||||
}
|
||||
|
||||
private void addQty(final long i) {
|
||||
try {
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
long result = Long.parseLong(Out);
|
||||
result += i;
|
||||
if (result < 0) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
this.level.setText(Out = Long.toString(result));
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("LevelEmitter.Value", Out));
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.level.setText("0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
// Forward entered characters to the number-text-field
|
||||
return level.charTyped(character, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(keyCode, scanCode)) {
|
||||
if (keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14) {
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("LevelEmitter.Value", Out));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,511 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseMEScreen;
|
||||
import appeng.client.gui.widgets.*;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.container.implementations.CraftingStatusContainer;
|
||||
import appeng.container.implementations.MEMonitorableContainer;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.CraftingMatrixSlot;
|
||||
import appeng.container.slot.FakeCraftingMatrixSlot;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.integration.abstraction.JEIFacade;
|
||||
import appeng.parts.reporting.AbstractTerminalPart;
|
||||
import appeng.tile.misc.SecurityStationBlockEntity;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class MEMonitorableScreen<T extends MEMonitorableContainer> extends AEBaseMEScreen<T>
|
||||
implements ISortSource, IConfigManagerHost {
|
||||
|
||||
private static int craftingGridOffsetX;
|
||||
private static int craftingGridOffsetY;
|
||||
|
||||
private static String memoryText = "";
|
||||
private final ItemRepo repo;
|
||||
private final int offsetX = 9;
|
||||
private final int lowerTextureOffset = 0;
|
||||
private final IConfigManager configSrc;
|
||||
private final boolean viewCell;
|
||||
private final ItemStack[] myCurrentViewCells = new ItemStack[5];
|
||||
private TabButton craftingStatusBtn;
|
||||
private AETextField searchField;
|
||||
private GuiText myName;
|
||||
private int perRow = 9;
|
||||
private int reservedSpace = 0;
|
||||
private boolean customSortOrder = true;
|
||||
private int rows = 0;
|
||||
private int maxRows = Integer.MAX_VALUE;
|
||||
private int standardSize;
|
||||
private SettingToggleButton<ViewItems> viewModeToggle;
|
||||
private SettingToggleButton<SortOrder> sortByToggle;
|
||||
private SettingToggleButton<SortDir> sortDirToggle;
|
||||
private boolean isAutoFocus = false;
|
||||
private int currentMouseX = 0;
|
||||
private int currentMouseY = 0;
|
||||
|
||||
public MEMonitorableScreen(T container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
|
||||
final Scrollbar scrollbar = new Scrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
this.repo = new ItemRepo(scrollbar, this);
|
||||
setScrollBar();
|
||||
|
||||
this.backgroundWidth = 185;
|
||||
this.backgroundHeight = 204;
|
||||
|
||||
Object te = container.getTarget();
|
||||
if (te instanceof IViewCellStorage) {
|
||||
this.backgroundWidth += 33;
|
||||
}
|
||||
|
||||
this.standardSize = this.backgroundWidth;
|
||||
|
||||
this.configSrc = ((IConfigurableObject) this.handler).getConfigManager();
|
||||
this.handler.setGui(this);
|
||||
|
||||
this.viewCell = te instanceof IViewCellStorage;
|
||||
|
||||
if (te instanceof SecurityStationBlockEntity) {
|
||||
this.myName = GuiText.Security;
|
||||
} else if (te instanceof WirelessTerminalGuiObject) {
|
||||
this.myName = GuiText.WirelessTerminal;
|
||||
} else if (te instanceof IPortableCell) {
|
||||
this.myName = GuiText.PortableCell;
|
||||
} else if (te instanceof IMEChest) {
|
||||
this.myName = GuiText.Chest;
|
||||
} else if (te instanceof AbstractTerminalPart) {
|
||||
this.myName = GuiText.Terminal;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid GUI target given: " + te);
|
||||
}
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list) {
|
||||
for (final IAEItemStack is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
|
||||
this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows,
|
||||
Math.max(1, this.rows / 6));
|
||||
}
|
||||
|
||||
private void showCraftingStatus() {
|
||||
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(CraftingStatusContainer.TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
getClient().keyboard.enableRepeatEvents(true);
|
||||
|
||||
this.maxRows = this.getMaxRows();
|
||||
TerminalStyle terminalStyle = AEConfig.instance().getTerminalStyle();
|
||||
|
||||
if (terminalStyle != TerminalStyle.FULL) {
|
||||
this.perRow = 9;
|
||||
} else {
|
||||
this.perRow = 9 + ((this.width - this.standardSize) / 18);
|
||||
}
|
||||
this.backgroundWidth = this.standardSize + ((this.perRow - 9) * 18);
|
||||
|
||||
final int magicNumber = 114 + 1;
|
||||
final int extraSpace = this.height - magicNumber - this.reservedSpace;
|
||||
|
||||
this.rows = extraSpace / 18;
|
||||
if (this.rows > this.maxRows) {
|
||||
this.rows = this.maxRows;
|
||||
}
|
||||
|
||||
if (this.rows < 3) {
|
||||
this.rows = 3;
|
||||
}
|
||||
|
||||
// Size the container according to the number of rows we decided to have
|
||||
this.backgroundHeight = magicNumber + this.rows * 18 + this.reservedSpace;
|
||||
|
||||
this.getMeSlots().clear();
|
||||
for (int y = 0; y < this.rows; y++) {
|
||||
for (int x = 0; x < this.perRow; x++) {
|
||||
this.getMeSlots()
|
||||
.add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
super.init();
|
||||
// full size : 204
|
||||
// extra slots : 72
|
||||
// slot 18
|
||||
|
||||
int offset = this.y + 8;
|
||||
|
||||
if (this.customSortOrder) {
|
||||
this.sortByToggle = this.addButton(new SettingToggleButton<>(this.x - 18, offset, Settings.SORT_BY,
|
||||
getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting));
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
if (this.viewCell || this instanceof WirelessTermScreen) {
|
||||
this.viewModeToggle = this.addButton(new SettingToggleButton<>(this.x - 18, offset,
|
||||
Settings.VIEW_MODE, getSortDisplay(), this::toggleServerSetting));
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
this.addButton(this.sortDirToggle = new SettingToggleButton<>(this.x - 18, offset,
|
||||
Settings.SORT_DIRECTION, getSortDir(), this::toggleServerSetting));
|
||||
offset += 20;
|
||||
|
||||
SearchBoxMode searchMode = AEConfig.instance().getTerminalSearchMode();
|
||||
this.addButton(new SettingToggleButton<>(this.x - 18, offset, Settings.SEARCH_MODE, searchMode,
|
||||
Platform::isSearchModeAvailable, this::toggleTerminalSearchMode));
|
||||
|
||||
offset += 20;
|
||||
|
||||
if (!(this instanceof MEPortableCellScreen) || this instanceof WirelessTermScreen) {
|
||||
this.addButton(new SettingToggleButton<>(this.x - 18, offset, Settings.TERMINAL_STYLE, terminalStyle,
|
||||
this::toggleTerminalStyle));
|
||||
}
|
||||
|
||||
this.searchField = new AETextField(this.textRenderer, this.x + Math.max(80, this.offsetX), this.y + 4, 90,
|
||||
12);
|
||||
this.searchField.setHasBorder(false);
|
||||
this.searchField.setMaxLength(25);
|
||||
this.searchField.setEditableColor(0xFFFFFF);
|
||||
this.searchField.setSelectionColor(0xFF008000);
|
||||
this.searchField.setVisible(true);
|
||||
|
||||
if (this.viewCell || this instanceof WirelessTermScreen) {
|
||||
this.craftingStatusBtn = this.addButton(new TabButton(this.x + 170, this.y - 4, 2 + 11 * 16,
|
||||
GuiText.CraftingStatus.text(), this.itemRenderer, btn -> showCraftingStatus()));
|
||||
this.craftingStatusBtn.setHideEdge(13);
|
||||
}
|
||||
|
||||
this.isAutoFocus = SearchBoxMode.AUTOSEARCH == searchMode || SearchBoxMode.JEI_AUTOSEARCH == searchMode
|
||||
|| SearchBoxMode.AUTOSEARCH_KEEP == searchMode || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchMode;
|
||||
final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchMode
|
||||
|| SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchMode || SearchBoxMode.MANUAL_SEARCH_KEEP == searchMode
|
||||
|| SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchMode;
|
||||
final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchMode
|
||||
|| SearchBoxMode.JEI_MANUAL_SEARCH == searchMode;
|
||||
|
||||
this.searchField.setFocused(this.isAutoFocus);
|
||||
|
||||
if (isJEIEnabled) {
|
||||
memoryText = JEIFacade.instance().getSearchText();
|
||||
}
|
||||
|
||||
if (isKeepFilter && memoryText != null && !memoryText.isEmpty()) {
|
||||
this.searchField.setText(memoryText);
|
||||
this.searchField.selectAll();
|
||||
this.repo.setSearchString(memoryText);
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
craftingGridOffsetX = Integer.MAX_VALUE;
|
||||
craftingGridOffsetY = Integer.MAX_VALUE;
|
||||
|
||||
for (final Slot s : this.handler.slots) {
|
||||
if (s instanceof AppEngSlot) {
|
||||
if (s.x < 197) {
|
||||
this.repositionSlot((AppEngSlot) s);
|
||||
}
|
||||
}
|
||||
|
||||
if (s instanceof CraftingMatrixSlot || s instanceof FakeCraftingMatrixSlot) {
|
||||
if (s.x > 0 && s.y > 0) {
|
||||
craftingGridOffsetX = Math.min(craftingGridOffsetX, s.x);
|
||||
craftingGridOffsetY = Math.min(craftingGridOffsetY, s.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
craftingGridOffsetX -= 25;
|
||||
craftingGridOffsetY -= 6;
|
||||
|
||||
}
|
||||
|
||||
@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.text()), 8, 6, 4210752);
|
||||
this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752);
|
||||
|
||||
this.currentMouseX = mouseX;
|
||||
this.currentMouseY = mouseY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
|
||||
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
super.removed();
|
||||
getClient().keyboard.enableRepeatEvents(false);
|
||||
memoryText = this.searchField.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
|
||||
this.bindTexture(this.getBackground());
|
||||
final int x_width = 197;
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, x_width, 18);
|
||||
|
||||
if (this.viewCell || (this instanceof SecurityStationScreen)) {
|
||||
drawTexture(matrices, offsetX + x_width, offsetY, x_width, 0, 46, 128);
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.rows; x++) {
|
||||
drawTexture(matrices, offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
|
||||
}
|
||||
|
||||
drawTexture(matrices, offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width,
|
||||
99 + this.reservedSpace - this.lowerTextureOffset);
|
||||
|
||||
if (this.viewCell) {
|
||||
boolean update = false;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (this.myCurrentViewCells[i] != this.handler.getCellViewSlot(i).getStack()) {
|
||||
update = true;
|
||||
this.myCurrentViewCells[i] = this.handler.getCellViewSlot(i).getStack();
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
this.repo.setViewCell(this.myCurrentViewCells);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.searchField != null) {
|
||||
this.searchField.render(matrices, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/terminal.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPowered() {
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
int getMaxRows() {
|
||||
return AEConfig.instance().getTerminalStyle() == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
protected void repositionSlot(final AppEngSlot s) {
|
||||
((SlotMixin) s).setY(s.getY() + this.backgroundHeight - 78 - 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int p_charTyped_2_) {
|
||||
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.isAutoFocus && !this.searchField.isFocused() && isHovered()) {
|
||||
this.searchField.setFocused(true);
|
||||
}
|
||||
|
||||
if (this.searchField.isFocused() && this.searchField.charTyped(character, p_charTyped_2_)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
|
||||
if (keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(keyCode, scanCode)) {
|
||||
if (AppEng.instance().isActionKey(ActionKey.TOGGLE_FOCUS, keyCode, scanCode)) {
|
||||
this.searchField.setFocused(!this.searchField.isFocused());
|
||||
return true;
|
||||
}
|
||||
if (!this.searchField.isFocused() && this.isAutoFocus && isHovered()) {
|
||||
this.searchField.setFocused(true);
|
||||
}
|
||||
|
||||
if (this.searchField.isFocused()) {
|
||||
if (keyCode == GLFW.GLFW_KEY_ENTER) {
|
||||
this.searchField.setFocused(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.searchField.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
// We need to swallow key presses if the field is focused because typing 'e'
|
||||
// would otherwise close
|
||||
// the screen
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
private boolean isHovered() {
|
||||
return isPointWithinBounds(0, 0, this.backgroundWidth, this.backgroundHeight, currentMouseX, currentMouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.repo.setPower(this.handler.isPowered());
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy() {
|
||||
return (SortOrder) this.configSrc.getSetting(Settings.SORT_BY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortDir getSortDir() {
|
||||
return (SortDir) this.configSrc.getSetting(Settings.SORT_DIRECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewItems getSortDisplay() {
|
||||
return (ViewItems) this.configSrc.getSetting(Settings.VIEW_MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue) {
|
||||
if (this.sortByToggle != null) {
|
||||
this.sortByToggle.set(getSortBy());
|
||||
}
|
||||
|
||||
if (this.sortDirToggle != null) {
|
||||
this.sortDirToggle.set(getSortDir());
|
||||
}
|
||||
|
||||
if (this.viewModeToggle != null) {
|
||||
this.viewModeToggle.set(getSortDisplay());
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
}
|
||||
|
||||
int getReservedSpace() {
|
||||
return this.reservedSpace;
|
||||
}
|
||||
|
||||
void setReservedSpace(final int reservedSpace) {
|
||||
this.reservedSpace = reservedSpace;
|
||||
}
|
||||
|
||||
public boolean isCustomSortOrder() {
|
||||
return this.customSortOrder;
|
||||
}
|
||||
|
||||
void setCustomSortOrder(final boolean customSortOrder) {
|
||||
this.customSortOrder = customSortOrder;
|
||||
}
|
||||
|
||||
public int getStandardSize() {
|
||||
return this.standardSize;
|
||||
}
|
||||
|
||||
void setStandardSize(final int standardSize) {
|
||||
this.standardSize = standardSize;
|
||||
}
|
||||
|
||||
private void toggleTerminalSearchMode(SettingToggleButton<SearchBoxMode> btn, boolean backwards) {
|
||||
SearchBoxMode next = btn.getNextValue(backwards);
|
||||
AEConfig.instance().setTerminalSearchMode(next);
|
||||
btn.set(next);
|
||||
this.reinitalize();
|
||||
}
|
||||
|
||||
private void toggleTerminalStyle(SettingToggleButton<TerminalStyle> btn, boolean backwards) {
|
||||
TerminalStyle next = btn.getNextValue(backwards);
|
||||
AEConfig.instance().setTerminalStyle(next);
|
||||
btn.set(next);
|
||||
this.reinitalize();
|
||||
}
|
||||
|
||||
private <S extends Enum<S>> void toggleServerSetting(SettingToggleButton<S> btn, boolean backwards) {
|
||||
S next = btn.getNextValue(backwards);
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket(btn.getSetting().name(), next.name()));
|
||||
btn.set(next);
|
||||
}
|
||||
|
||||
private void reinitalize() {
|
||||
this.children.removeAll(this.buttons);
|
||||
this.buttons.clear();
|
||||
this.init();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.container.implementations.MEPortableCellContainer;
|
||||
|
||||
public class MEPortableCellScreen extends MEMonitorableScreen<MEPortableCellContainer> {
|
||||
|
||||
public MEPortableCellScreen(MEPortableCellContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.ProgressBar;
|
||||
import appeng.client.gui.widgets.ProgressBar.Direction;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.container.implementations.MolecularAssemblerContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class MolecularAssemblerScreen extends UpgradeableScreen<MolecularAssemblerContainer> {
|
||||
|
||||
private ProgressBar pb;
|
||||
|
||||
public MolecularAssemblerScreen(MolecularAssemblerContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.pb = new ProgressBar(this.handler, "guis/molecular_assembler.png", 139, 36, 148, 201, 6, 18,
|
||||
Direction.VERTICAL);
|
||||
this.addButton(this.pb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.redstoneMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 8,
|
||||
Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
addButton(this.redstoneMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.pb.setFullMsg(new LiteralText(this.handler.getCurrentProgress() + "%"));
|
||||
super.drawFG(matrices, offsetX, offsetY, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.pb.x = 148 + this.x;
|
||||
this.pb.y = 48 + this.y;
|
||||
super.drawBG(matrices, offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/molecular_assembler.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.MolecularAssembler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.CommonButtons;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.implementations.NetworkStatusContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class NetworkStatusScreen extends AEBaseScreen<NetworkStatusContainer> implements ISortSource {
|
||||
|
||||
private final ItemRepo repo;
|
||||
private final int rows = 4;
|
||||
private int tooltip = -1;
|
||||
|
||||
public NetworkStatusScreen(NetworkStatusContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
final Scrollbar scrollbar = new Scrollbar();
|
||||
|
||||
this.setScrollBar(scrollbar);
|
||||
this.repo = new ItemRepo(scrollbar, this);
|
||||
this.backgroundHeight = 153;
|
||||
this.backgroundWidth = 195;
|
||||
this.repo.setRowSize(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.addButton(CommonButtons.togglePowerUnit(this.x - 18, this.y + 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, final int mouseX, final int mouseY, final float btn) {
|
||||
|
||||
final int gx = (this.width - this.backgroundWidth) / 2;
|
||||
final int gy = (this.height - this.backgroundHeight) / 2;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for (int z = 0; z <= 4 * 5; z++) {
|
||||
final int minX = gx + 14 + x * 31;
|
||||
final int minY = gy + 41 + y * 18;
|
||||
|
||||
if (minX < mouseX && minX + 28 > mouseX) {
|
||||
if (minY < mouseY && minY + 20 > mouseY) {
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 4) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.render(matrices, mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.textRenderer.draw(matrices, GuiText.NetworkDetails.text(), 8, 6, 4210752);
|
||||
|
||||
this.textRenderer.draw(matrices,
|
||||
GuiText.StoredPower.text() + ": " + Platform.formatPowerLong(handler.getCurrentPower(), false),
|
||||
13, 16, 4210752);
|
||||
this.textRenderer.draw(matrices,
|
||||
GuiText.MaxPower.text() + ": " + Platform.formatPowerLong(handler.getMaxPower(), false), 13, 26,
|
||||
4210752);
|
||||
|
||||
this.textRenderer.draw(matrices, GuiText.PowerInputRate.text() + ": "
|
||||
+ Platform.formatPowerLong(handler.getAverageAddition(), true), 13, 143 - 10, 4210752);
|
||||
this.textRenderer.draw(matrices,
|
||||
GuiText.PowerUsageRate.text() + ": " + Platform.formatPowerLong(handler.getPowerUsage(), true),
|
||||
13, 143 - 20, 4210752);
|
||||
|
||||
final int sectionLength = 30;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int xo = 12;
|
||||
final int yo = 42;
|
||||
final int viewStart = 0;
|
||||
final int viewEnd = viewStart + 5 * 4;
|
||||
|
||||
List<Text> toolTip = new ArrayList<>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.repo.size()); z++) {
|
||||
final IAEItemStack refStack = this.repo.getReferenceItem(z);
|
||||
if (refStack != null) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
String str = Long.toString(refStack.getStackSize());
|
||||
if (refStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(refStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
|
||||
final int w = this.textRenderer.getWidth(str);
|
||||
this.textRenderer.draw(matrices, str, (int) ((x * sectionLength + xo + sectionLength - 19 - (w * 0.5)) * 2),
|
||||
(y * 18 + yo + 6) * 2, 4210752);
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * sectionLength + xo + sectionLength - 18;
|
||||
final int posY = y * 18 + yo;
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
toolTip.add(Platform.getItemDisplayName(refStack));
|
||||
|
||||
toolTip.add(GuiText.Installed.withSuffix(": " + (refStack.getStackSize())));
|
||||
if (refStack.getCountRequestable() > 0) {
|
||||
toolTip.add(GuiText.EnergyDrain.withSuffix(": "
|
||||
+ Platform.formatPowerLong(refStack.getCountRequestable(), true)));
|
||||
}
|
||||
|
||||
toolPosX = x * sectionLength + xo + sectionLength - 8;
|
||||
toolPosY = y * 18 + yo;
|
||||
}
|
||||
|
||||
this.drawItem(posX, posY, refStack.asItemStackRepresentation());
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 4) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip >= 0 && toolTip.isEmpty()) {
|
||||
this.drawTooltip(matrices, toolPosX, toolPosY + 10, toolTip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/networkstatus.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list) {
|
||||
this.repo.clear();
|
||||
|
||||
for (final IAEItemStack is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
final int size = this.repo.size();
|
||||
this.getScrollBar().setTop(39).setLeft(175).setHeight(78);
|
||||
this.getScrollBar().setRange(0, (size + 4) / 5 - this.rows, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
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()) {
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try {
|
||||
final SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
} catch (final Throwable ignore) {
|
||||
}
|
||||
|
||||
if (myStack != null) {
|
||||
List<Text> currentToolTip = getTooltipFromItem(stack);
|
||||
|
||||
while (currentToolTip.size() > 1) {
|
||||
currentToolTip.remove(1);
|
||||
}
|
||||
|
||||
currentToolTip.add(GuiText.Installed.withSuffix(": " + myStack.getStackSize()));
|
||||
currentToolTip.add(GuiText.EnergyDrain.withSuffix(": "
|
||||
+ Platform.formatPowerLong(myStack.getCountRequestable(), true)));
|
||||
|
||||
this.drawTooltip(matrices, x, y, currentToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
super.renderTooltip(matrices, stack, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy() {
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortDir getSortDir() {
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewItems getSortDisplay() {
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.ToggleButton;
|
||||
import appeng.container.implementations.NetworkToolContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class NetworkToolScreen extends AEBaseScreen<NetworkToolContainer> {
|
||||
|
||||
private ToggleButton tFacades;
|
||||
|
||||
public NetworkToolScreen(NetworkToolContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.tFacades = new ToggleButton(this.x - 18, this.y + 8, 23, 22,
|
||||
GuiText.TransparentFacades.text(), GuiText.TransparentFacadesHint.text(),
|
||||
btn -> toggleFacades());
|
||||
|
||||
this.addButton(this.tFacades);
|
||||
}
|
||||
|
||||
private void toggleFacades() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("NetworkTool", "Toggle"));
|
||||
}
|
||||
|
||||
@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(handler.isFacadeMode());
|
||||
}
|
||||
|
||||
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
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/toolbox.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.client.gui.widgets.ActionButton;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.container.implementations.PatternTermContainer;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class PatternTermScreen extends MEMonitorableScreen<PatternTermContainer> {
|
||||
|
||||
private static final String BACKGROUND_CRAFTING_MODE = "guis/pattern.png";
|
||||
private static final String BACKGROUND_PROCESSING_MODE = "guis/pattern2.png";
|
||||
|
||||
private static final String SUBSITUTION_DISABLE = "0";
|
||||
private static final String SUBSITUTION_ENABLE = "1";
|
||||
|
||||
private static final String CRAFTMODE_CRFTING = "1";
|
||||
private static final String CRAFTMODE_PROCESSING = "0";
|
||||
|
||||
private TabButton tabCraftButton;
|
||||
private TabButton tabProcessButton;
|
||||
private ActionButton substitutionsEnabledBtn;
|
||||
private ActionButton substitutionsDisabledBtn;
|
||||
|
||||
public PatternTermScreen(PatternTermContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setReservedSpace(81);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.tabCraftButton = new TabButton(this.x + 173, this.y + this.backgroundHeight - 177,
|
||||
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.text(), this.itemRenderer,
|
||||
btn -> toggleCraftMode(CRAFTMODE_CRFTING));
|
||||
this.addButton(this.tabProcessButton);
|
||||
|
||||
this.substitutionsEnabledBtn = new ActionButton(this.x + 84, this.y + this.backgroundHeight - 163,
|
||||
ActionItems.ENABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_DISABLE));
|
||||
this.substitutionsEnabledBtn.setHalfSize(true);
|
||||
this.addButton(this.substitutionsEnabledBtn);
|
||||
|
||||
this.substitutionsDisabledBtn = new ActionButton(this.x + 84, this.y + this.backgroundHeight - 163,
|
||||
ActionItems.DISABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_ENABLE));
|
||||
this.substitutionsDisabledBtn.setHalfSize(true);
|
||||
this.addButton(this.substitutionsDisabledBtn);
|
||||
|
||||
ActionButton clearBtn = new ActionButton(this.x + 74, this.y + this.backgroundHeight - 163, ActionItems.CLOSE,
|
||||
act -> clear());
|
||||
clearBtn.setHalfSize(true);
|
||||
this.addButton(clearBtn);
|
||||
|
||||
ActionButton encodeBtn = new ActionButton(this.x + 147, this.y + this.backgroundHeight - 142,
|
||||
ActionItems.ENCODE, act -> encode());
|
||||
this.addButton(encodeBtn);
|
||||
}
|
||||
|
||||
private void toggleCraftMode(String mode) {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PatternTerminal.CraftMode", mode));
|
||||
}
|
||||
|
||||
private void toggleSubstitutions(String mode) {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PatternTerminal.Substitute", mode));
|
||||
}
|
||||
|
||||
private void encode() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PatternTerminal.Encode", "1"));
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PatternTerminal.Clear", "1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
if (this.handler.isCraftingMode()) {
|
||||
this.tabCraftButton.visible = true;
|
||||
this.tabProcessButton.visible = false;
|
||||
|
||||
if (this.handler.substitute) {
|
||||
this.substitutionsEnabledBtn.visible = true;
|
||||
this.substitutionsDisabledBtn.visible = false;
|
||||
} else {
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
this.substitutionsDisabledBtn.visible = true;
|
||||
}
|
||||
} else {
|
||||
this.tabCraftButton.visible = false;
|
||||
this.tabProcessButton.visible = true;
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
this.substitutionsDisabledBtn.visible = false;
|
||||
}
|
||||
|
||||
super.drawFG(matrices, offsetX, offsetY, mouseX, mouseY);
|
||||
this.textRenderer.draw(matrices, GuiText.PatternTerminal.text(), 8, this.backgroundHeight - 96 + 2 - this.getReservedSpace(),
|
||||
4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
if (this.handler.isCraftingMode()) {
|
||||
return BACKGROUND_CRAFTING_MODE;
|
||||
}
|
||||
|
||||
return BACKGROUND_PROCESSING_MODE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repositionSlot(final AppEngSlot s) {
|
||||
final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3;
|
||||
|
||||
((SlotMixin) s).setY(s.getY() + this.backgroundHeight - 78 - offsetPlayerSide);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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;
|
||||
import appeng.client.gui.widgets.NumberBox;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
|
||||
|
||||
private final AESubScreen subGui;
|
||||
|
||||
private NumberBox priority;
|
||||
|
||||
public PriorityScreen(PriorityContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubScreen(this, container.getPriorityHost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final int a = AEConfig.instance().priorityByStacksAmounts(0);
|
||||
final int b = AEConfig.instance().priorityByStacksAmounts(1);
|
||||
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, 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, 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.fontHeight,
|
||||
Long.class);
|
||||
this.priority.setHasBorder(false);
|
||||
this.priority.setMaxLength(16);
|
||||
this.priority.setEditableColor(0xFFFFFF);
|
||||
this.priority.setVisible(true);
|
||||
this.priority.setFocused(true);
|
||||
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.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.bindTexture(getBackground());
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
|
||||
this.priority.render(matrices, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
long result = Long.parseLong(out);
|
||||
result += i;
|
||||
|
||||
this.priority.setText(out = Long.toString(result));
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PriorityHost.Priority", out));
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.priority.setText("0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (priority.charTyped(character, key)) {
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PriorityHost.Priority", out));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(keyCode, scanCode)) {
|
||||
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
|
||||
&& this.priority.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PriorityHost.Priority", out));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/priority.png";
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,8 @@ public class QNBScreen extends AEBaseScreen<QNBContainer> {
|
||||
|
||||
@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
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.container.implementations.QuartzKnifeContainer;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class QuartzKnifeScreen extends AEBaseScreen<QuartzKnifeContainer> {
|
||||
|
||||
private TextFieldWidget name;
|
||||
|
||||
public QuartzKnifeScreen(QuartzKnifeContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 184;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
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.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.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(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();
|
||||
handler.setName(Out);
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("QuartzKnife.Name", Out));
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.charTyped(character, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
|
||||
if (keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(keyCode, scanCode)) {
|
||||
if (AppEng.instance().isActionKey(ActionKey.TOGGLE_FOCUS, keyCode, scanCode)) {
|
||||
this.name.setSelected(!this.name.isFocused());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.name.isFocused()) {
|
||||
if (keyCode == GLFW.GLFW_KEY_ENTER) {
|
||||
this.name.setSelected(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.name.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
final String Out = this.name.getText();
|
||||
handler.setName(Out);
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("QuartzKnife.Name", Out));
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to swallow key presses if the field is focused because typing 'e'
|
||||
// would otherwise close
|
||||
// the screen
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.client.gui.widgets.ToggleButton;
|
||||
import appeng.container.implementations.SecurityStationContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class SecurityStationScreen extends MEMonitorableScreen<SecurityStationContainer> {
|
||||
|
||||
private ToggleButton inject;
|
||||
private ToggleButton extract;
|
||||
private ToggleButton craft;
|
||||
private ToggleButton build;
|
||||
private ToggleButton security;
|
||||
|
||||
public SecurityStationScreen(SecurityStationContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setCustomSortOrder(false);
|
||||
this.setReservedSpace(33);
|
||||
|
||||
// increase size so that the slot is over the gui.
|
||||
this.backgroundWidth += 56;
|
||||
this.setStandardSize(this.backgroundWidth);
|
||||
}
|
||||
|
||||
private void toggleOption(SecurityPermissions permission) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new ConfigValuePacket("TileSecurityStation.ToggleOption", permission.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final int top = this.y + this.backgroundHeight - 116;
|
||||
this.inject = this.addButton(new ToggleButton(this.x + 56, top, 11 * 16, 12 * 16,
|
||||
SecurityPermissions.INJECT.nameText(), SecurityPermissions.INJECT.tooltipText(),
|
||||
btn -> toggleOption(SecurityPermissions.INJECT)));
|
||||
|
||||
this.extract = this.addButton(new ToggleButton(this.x + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1,
|
||||
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.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.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.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.text(), 8, this.backgroundHeight - 96 + 1 - this.getReservedSpace(),
|
||||
4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
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";
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy() {
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
}
|
||||
@@ -40,8 +40,8 @@ public class SkyChestScreen extends AEBaseScreen<SkyChestContainer> {
|
||||
|
||||
@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
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.CommonButtons;
|
||||
import appeng.container.implementations.SpatialIOPortContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class SpatialIOPortScreen extends AEBaseScreen<SpatialIOPortContainer> {
|
||||
|
||||
public SpatialIOPortScreen(SpatialIOPortContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 199;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
this.addButton(CommonButtons.togglePowerUnit(this.x - 18, this.y + 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.textRenderer.draw(matrices, GuiText.StoredPower.text() + ": "
|
||||
+ Platform.formatPowerLong(this.handler.getCurrentPower(), false), 13, 21, 4210752);
|
||||
this.textRenderer.draw(matrices,
|
||||
GuiText.MaxPower.text() + ": " + Platform.formatPowerLong(this.handler.getMaxPower(), false), 13,
|
||||
31, 4210752);
|
||||
this.textRenderer.draw(matrices, GuiText.RequiredPower.text() + ": "
|
||||
+ Platform.formatPowerLong(this.handler.getRequiredPower(), false), 13, 73, 4210752);
|
||||
this.textRenderer.draw(matrices,
|
||||
GuiText.Efficiency.text() + ": " + (((float) this.handler.getEfficency()) / 100) + '%', 13, 83,
|
||||
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.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.text() + ": " + GuiText.SCSInvalid.text(), 13, 93, 4210752);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/spatialio.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.client.gui.widgets.ActionButton;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.container.implementations.StorageBusContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
|
||||
public class StorageBusScreen extends UpgradeableScreen<StorageBusContainer> {
|
||||
|
||||
private SettingToggleButton<AccessRestriction> rwMode;
|
||||
private SettingToggleButton<StorageFilter> storageFilter;
|
||||
|
||||
public StorageBusScreen(StorageBusContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
addButton(new ActionButton(this.x - 18, this.y + 8, ActionItems.CLOSE, btn -> clear()));
|
||||
addButton(new ActionButton(this.x - 18, this.y + 28, ActionItems.WRENCH, btn -> partition()));
|
||||
this.rwMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 48, Settings.ACCESS,
|
||||
AccessRestriction.READ_WRITE);
|
||||
this.storageFilter = new ServerSettingToggleButton<>(this.x - 18, this.y + 68,
|
||||
Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
|
||||
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.text(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
|
||||
this.addButton(this.storageFilter);
|
||||
this.addButton(this.fuzzyMode);
|
||||
this.addButton(this.rwMode);
|
||||
}
|
||||
|
||||
@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.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());
|
||||
}
|
||||
|
||||
if (this.storageFilter != null) {
|
||||
this.storageFilter.set(((StorageBusContainer) this.cvb).getStorageFilter());
|
||||
}
|
||||
|
||||
if (this.rwMode != null) {
|
||||
this.rwMode.set(((StorageBusContainer) this.cvb).getReadWriteMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
private void partition() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("StorageBus.Action", "Partition"));
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("StorageBus.Action", "Clear"));
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.container.implementations.UpgradeableContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.parts.automation.ExportBusPart;
|
||||
import appeng.parts.automation.ImportBusPart;
|
||||
|
||||
public class UpgradeableScreen<T extends UpgradeableContainer> extends AEBaseScreen<T> {
|
||||
|
||||
protected final UpgradeableContainer cvb;
|
||||
protected final IUpgradeableHost bc;
|
||||
|
||||
protected SettingToggleButton<RedstoneMode> redstoneMode;
|
||||
protected SettingToggleButton<FuzzyMode> fuzzyMode;
|
||||
protected SettingToggleButton<YesNo> craftMode;
|
||||
protected SettingToggleButton<SchedulingMode> schedulingMode;
|
||||
|
||||
public UpgradeableScreen(T container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.cvb = container;
|
||||
|
||||
this.bc = (IUpgradeableHost) container.getTarget();
|
||||
this.backgroundWidth = this.hasToolbox() ? 246 : 211;
|
||||
this.backgroundHeight = 184;
|
||||
}
|
||||
|
||||
protected boolean hasToolbox() {
|
||||
return (this.handler).hasToolbox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
this.addButtons();
|
||||
}
|
||||
|
||||
protected void addButtons() {
|
||||
this.redstoneMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 8,
|
||||
Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
addButton(this.redstoneMode);
|
||||
this.fuzzyMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 28, Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
addButton(this.fuzzyMode);
|
||||
this.craftMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 48, Settings.CRAFT_ONLY,
|
||||
YesNo.NO);
|
||||
addButton(this.craftMode);
|
||||
this.schedulingMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 68,
|
||||
Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
|
||||
addButton(this.schedulingMode);
|
||||
}
|
||||
|
||||
@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().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());
|
||||
}
|
||||
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.set(this.cvb.getFuzzyMode());
|
||||
}
|
||||
|
||||
if (this.craftMode != null) {
|
||||
this.craftMode.set(this.cvb.getCraftingMode());
|
||||
}
|
||||
|
||||
if (this.schedulingMode != null) {
|
||||
this.schedulingMode.set(this.cvb.getSchedulingMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.handleButtonVisibility();
|
||||
|
||||
this.bindTexture(this.getBackground());
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, 211 - 34, this.backgroundHeight);
|
||||
if (this.drawUpgrades()) {
|
||||
drawTexture(matrices, offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18);
|
||||
}
|
||||
if (this.hasToolbox()) {
|
||||
drawTexture(matrices, offsetX + 178, offsetY + this.backgroundHeight - 90, 178, this.backgroundHeight - 90, 68, 68);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleButtonVisibility() {
|
||||
if (this.redstoneMode != null) {
|
||||
this.redstoneMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.REDSTONE) > 0);
|
||||
}
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0);
|
||||
}
|
||||
if (this.craftMode != null) {
|
||||
this.craftMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.CRAFTING) > 0);
|
||||
}
|
||||
if (this.schedulingMode != null) {
|
||||
this.schedulingMode.setVisibility(
|
||||
this.bc.getInstalledUpgrades(Upgrades.CAPACITY) > 0 && this.bc instanceof ExportBusPart);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/bus.png";
|
||||
}
|
||||
|
||||
protected boolean drawUpgrades() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected GuiText getName() {
|
||||
return this.bc instanceof ImportBusPart ? GuiText.ImportBus : GuiText.ExportBus;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.ProgressBar;
|
||||
import appeng.client.gui.widgets.ProgressBar.Direction;
|
||||
import appeng.container.implementations.VibrationChamberContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.misc.VibrationChamberBlockEntity;
|
||||
|
||||
public class VibrationChamberScreen extends AEBaseScreen<VibrationChamberContainer> {
|
||||
|
||||
private ProgressBar pb;
|
||||
|
||||
public VibrationChamberScreen(VibrationChamberContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.pb = new ProgressBar(this.handler, "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL);
|
||||
this.addButton(this.pb);
|
||||
}
|
||||
|
||||
@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.VibrationChamber.text()), 8, 6, 4210752);
|
||||
this.textRenderer.draw(matrices, GuiText.inventory.text(), 8, this.backgroundHeight - 96 + 3, 4210752);
|
||||
|
||||
this.pb.setFullMsg(new LiteralText(VibrationChamberBlockEntity.POWER_PER_TICK * this.handler.getCurrentProgress()
|
||||
/ VibrationChamberBlockEntity.DILATION_SCALING + " AE/t"));
|
||||
|
||||
if (this.handler.getRemainingBurnTime() > 0) {
|
||||
final int i1 = this.handler.getRemainingBurnTime() * 12 / 100;
|
||||
this.bindTexture("guis/vibchamber.png");
|
||||
RenderSystem.color3f(1, 1, 1);
|
||||
final int l = -15;
|
||||
final int k = 25;
|
||||
drawTexture(matrices, k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/vibchamber.png");
|
||||
this.pb.x = 99 + this.x;
|
||||
this.pb.y = 36 + this.y;
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
}
|
||||
@@ -45,12 +45,12 @@ public class WirelessScreen extends AEBaseScreen<WirelessContainer> {
|
||||
|
||||
@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),
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.container.implementations.MEPortableCellContainer;
|
||||
|
||||
// FIXME: Extended from GuiPortableCell before... Why?
|
||||
public class WirelessTermScreen extends MEMonitorableScreen<MEPortableCellContainer> {
|
||||
|
||||
public WirelessTermScreen(MEPortableCellContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<FacingToRotation, RenderContext.QuadTransform> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Random> 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<Random> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,10 +84,9 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
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<C extends AEBaseContainer, I> {
|
||||
|
||||
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<C extends AEBaseContainer, I> {
|
||||
|
||||
@Override
|
||||
public Text getDisplayName() {
|
||||
return null;
|
||||
return title;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
import appeng.fluids.client.gui.widgets.FluidSlotWidget;
|
||||
import appeng.fluids.client.gui.widgets.OptionalFluidSlotWidget;
|
||||
import appeng.fluids.container.FluidFormationPlaneContainer;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
public class FluidFormationPlaneScreen extends UpgradeableScreen<FluidFormationPlaneContainer> {
|
||||
public FluidFormationPlaneScreen(FluidFormationPlaneContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
final IAEFluidTank config = handler.getFluidConfigInventory();
|
||||
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
final int idx = y * 9 + x;
|
||||
if (y < 2) {
|
||||
this.guiSlots.add(new FluidSlotWidget(config, idx, idx, xo + x * 18, yo + y * 18));
|
||||
} else {
|
||||
this.guiSlots.add(new OptionalFluidSlotWidget(config, handler, idx, idx, y - 2, xo, yo, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.addButton(new TabButton(this.x + 154, this.y, 2 + 4 * 16, GuiText.Priority.text(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.FluidFormationPlane;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.fluids.client.gui.widgets.FluidSlotWidget;
|
||||
import appeng.fluids.client.gui.widgets.OptionalFluidSlotWidget;
|
||||
import appeng.fluids.container.FluidIOContainer;
|
||||
import appeng.fluids.parts.FluidImportBusPart;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv5 - 1/05/2018
|
||||
* @since rv5 1/05/2018
|
||||
*/
|
||||
public class FluidIOScreen extends UpgradeableScreen<FluidIOContainer> {
|
||||
|
||||
public FluidIOScreen(FluidIOContainer container, PlayerInventory playerInventory, Text title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final IAEFluidTank inv = this.handler.getFluidConfigInventory();
|
||||
final int y = 40;
|
||||
final int x = 80;
|
||||
|
||||
this.guiSlots.add(new FluidSlotWidget(inv, 0, 0, x, y));
|
||||
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, 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
|
||||
protected GuiText getName() {
|
||||
return this.bc instanceof FluidImportBusPart ? GuiText.ImportBusFluids : GuiText.ExportBusFluids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
import appeng.fluids.client.gui.widgets.FluidSlotWidget;
|
||||
import appeng.fluids.client.gui.widgets.FluidTankWidget;
|
||||
import appeng.fluids.container.FluidInterfaceContainer;
|
||||
import appeng.fluids.helper.DualityFluidInterface;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
public class FluidInterfaceScreen extends UpgradeableScreen<FluidInterfaceContainer> {
|
||||
public FluidInterfaceScreen(FluidInterfaceContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 231;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final IAEFluidTank configFluids = this.handler.getFluidConfigInventory();
|
||||
final IAEFluidTank fluidTank = this.handler.getTanks();
|
||||
|
||||
for (int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i) {
|
||||
final FluidTankWidget guiTank = new FluidTankWidget(fluidTank, i, this.getX() + 35 + 18 * i,
|
||||
this.getY() + 53, 16, 68);
|
||||
this.addButton(guiTank);
|
||||
this.guiSlots.add(new FluidSlotWidget(configFluids, i, i, 35 + 18 * i, 35));
|
||||
}
|
||||
|
||||
this.addButton(new TabButton(this.getX() + 154, this.getY(), 2 + 4 * 16, GuiText.Priority.text(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(MatrixStack matrices, int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
this.textRenderer.draw(matrices, this.getGuiDisplayName(GuiText.FluidInterface.text()), 8, 6, 4210752);
|
||||
this.textRenderer.draw(matrices, GuiText.Config.getLocal(), 35, 6 + 11 + 7, 4210752);
|
||||
this.textRenderer.draw(matrices, GuiText.StoredFluids.getLocal(), 35, 6 + 112 + 7, 4210752);
|
||||
this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(MatrixStack matrices, int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/interfacefluid.png");
|
||||
drawTexture(matrices, offsetX, offsetY, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
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.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.widgets.NumberBox;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
import appeng.fluids.client.gui.widgets.FluidSlotWidget;
|
||||
import appeng.fluids.container.FluidLevelEmitterContainer;
|
||||
|
||||
public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitterContainer> {
|
||||
private NumberBox level;
|
||||
|
||||
public FluidLevelEmitterScreen(FluidLevelEmitterContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
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.changeFocus(true);
|
||||
handler.setTextField(this.level);
|
||||
|
||||
final int y = 40;
|
||||
final int x = 80 + 44;
|
||||
this.guiSlots.add(new FluidSlotWidget(this.handler.getFluidConfigInventory(), 0, 0, x, y));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.redstoneMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 28,
|
||||
Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL);
|
||||
|
||||
final int a = AEConfig.instance().levelByMillyBuckets(0);
|
||||
final int b = AEConfig.instance().levelByMillyBuckets(1);
|
||||
final int c = AEConfig.instance().levelByMillyBuckets(2);
|
||||
final int d = AEConfig.instance().levelByMillyBuckets(3);
|
||||
|
||||
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, 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);
|
||||
}
|
||||
|
||||
@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(matrices, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.FluidLevelEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility() {
|
||||
}
|
||||
|
||||
private void addQty(final long i) {
|
||||
try {
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
long result = Long.parseLong(Out);
|
||||
result += i;
|
||||
if (result < 0) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
this.level.setText(Out = Long.toString(result));
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("FluidLevelEmitter.Value", Out));
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.level.setText("0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int keyCode) {
|
||||
if (level.charTyped(character, keyCode)) {
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("FluidLevelEmitter.Value", Out));
|
||||
return true;
|
||||
}
|
||||
return super.charTyped(character, keyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(keyCode, scanCode)) {
|
||||
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
|
||||
&& this.level.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("FluidLevelEmitter.Value", Out));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.widgets.ActionButton;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
import appeng.fluids.client.gui.widgets.FluidSlotWidget;
|
||||
import appeng.fluids.client.gui.widgets.OptionalFluidSlotWidget;
|
||||
import appeng.fluids.container.FluidStorageBusContainer;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class FluidStorageBusScreen extends UpgradeableScreen<FluidStorageBusContainer> {
|
||||
private SettingToggleButton<AccessRestriction> rwMode;
|
||||
private SettingToggleButton<StorageFilter> storageFilter;
|
||||
|
||||
public FluidStorageBusScreen(FluidStorageBusContainer container, PlayerInventory playerInventory,
|
||||
Text title) {
|
||||
super(container, playerInventory, title);
|
||||
this.backgroundHeight = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
final IAEFluidTank config = this.handler.getFluidConfigInventory();
|
||||
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
final int idx = y * 9 + x;
|
||||
if (y < 2) {
|
||||
this.guiSlots.add(new FluidSlotWidget(config, idx, idx, xo + x * 18, yo + y * 18));
|
||||
} else {
|
||||
this.guiSlots.add(new OptionalFluidSlotWidget(config, handler, idx, idx, y - 2, xo, yo, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
addButton(new ActionButton(this.x - 18, this.y + 8, ActionItems.CLOSE, btn -> clear()));
|
||||
addButton(new ActionButton(this.x - 18, this.y + 28, ActionItems.WRENCH, btn -> partition()));
|
||||
this.rwMode = new ServerSettingToggleButton<>(this.x - 18, this.y + 48, Settings.ACCESS,
|
||||
AccessRestriction.READ_WRITE);
|
||||
this.storageFilter = new ServerSettingToggleButton<>(this.x - 18, this.y + 68,
|
||||
Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
|
||||
this.fuzzyMode = new ServerSettingToggleButton<>(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.text(),
|
||||
this.itemRenderer, btn -> openPriorityGui())));
|
||||
|
||||
this.addButton(this.storageFilter);
|
||||
this.addButton(this.fuzzyMode);
|
||||
this.addButton(this.rwMode);
|
||||
}
|
||||
|
||||
@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().text()), 8, 6, 4210752);
|
||||
this.textRenderer.draw(matrices, GuiText.inventory.getLocal(), 8, this.backgroundHeight - 96 + 3, 4210752);
|
||||
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.set(this.cvb.getFuzzyMode());
|
||||
}
|
||||
|
||||
if (this.storageFilter != null) {
|
||||
this.storageFilter.set(((FluidStorageBusContainer) this.cvb).getStorageFilter());
|
||||
}
|
||||
|
||||
if (this.rwMode != null) {
|
||||
this.rwMode.set(((FluidStorageBusContainer) this.cvb).getReadWriteMode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
private void partition() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("StorageBus.Action", "Partition"));
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("StorageBus.Action", "Clear"));
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.StorageBusFluids;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class FluidTerminalScreen extends AEBaseMEScreen<FluidTerminalContainer>
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Collections;
|
||||
|
||||
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.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.text.Text;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.gui.widgets.CustomSlotWidget;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.FluidSlotPacket;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
public class FluidSlotWidget extends CustomSlotWidget {
|
||||
private final IAEFluidTank fluids;
|
||||
private final int slot;
|
||||
|
||||
public FluidSlotWidget(final IAEFluidTank fluids, final int slot, final int id, final int x, final int y) {
|
||||
super(id, x, y);
|
||||
this.fluids = fluids;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawContent(final MinecraftClient mc, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
final IAEFluidStack fs = this.getFluidStack();
|
||||
if (fs != null) {
|
||||
fs.getFluidStack().renderGuiRect(xPos(), yPos(), xPos() + getWidth(), yPos() + getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canClick(final PlayerEntity player) {
|
||||
final ItemStack mouseStack = player.inventory.getCursorStack();
|
||||
return mouseStack.isEmpty()
|
||||
|| FluidAttributes.EXTRACTABLE.getFirstOrNull(mouseStack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slotClicked(final ItemStack clickStack, int mouseButton) {
|
||||
if (clickStack.isEmpty() || mouseButton == 1) {
|
||||
this.setFluidStack(null);
|
||||
} else if (mouseButton == 0) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getMessage() {
|
||||
final IAEFluidStack fluid = this.getFluidStack();
|
||||
if (fluid != null) {
|
||||
return fluid.getFluidStack().getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public IAEFluidStack getFluidStack() {
|
||||
return this.fluids.getFluidInSlot(this.slot);
|
||||
}
|
||||
|
||||
public void setFluidStack(final IAEFluidStack stack) {
|
||||
this.fluids.setFluidInSlot(this.slot, stack);
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new FluidSlotPacket(Collections.singletonMap(this.getId(), this.getFluidStack())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, 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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
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 {
|
||||
private final IAEFluidTank tank;
|
||||
private final int slot;
|
||||
|
||||
public FluidTankWidget(IAEFluidTank tank, int slot, int x, int y, int w, int h) {
|
||||
super(x, y, w, h, LiteralText.EMPTY);
|
||||
this.tank = tank;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
|
||||
if (this.visible) {
|
||||
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) {
|
||||
|
||||
FluidVolume volume = fluidStack.getFluidStack();
|
||||
FluidAmount maxAmount = this.tank.getMaxAmount_F(this.slot);
|
||||
double fillRatio = volume.amount().div(maxAmount).asInexactDouble();
|
||||
|
||||
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) {
|
||||
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++) {
|
||||
int x1 = this.x;
|
||||
int y1 = top - (i + 1) * 16;
|
||||
int x2 = x1 + 16;
|
||||
int y2 = y1 + 16;
|
||||
volume.renderGuiRect(x1, y2, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getMessage() {
|
||||
final IAEFluidStack fluid = this.tank.getFluidInSlot(this.slot);
|
||||
if (fluid != null && fluid.getStackSize() > 0) {
|
||||
Text desc = fluid.getFluidStack().getName();
|
||||
String amountToText = fluid.getStackSize() + "mB";
|
||||
|
||||
return desc.copy().append("\n").append(amountToText);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
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;
|
||||
private final int groupNum;
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
|
||||
public OptionalFluidSlotWidget(IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id,
|
||||
int groupNum, int x, int y, int xoffs, int yoffs) {
|
||||
super(fluids, slot, id, x + xoffs * 18, y + yoffs * 18);
|
||||
this.containerBus = containerBus;
|
||||
this.groupNum = groupNum;
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.containerBus == null) {
|
||||
return false;
|
||||
}
|
||||
return this.containerBus.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getFluidStack() {
|
||||
if (!this.isSlotEnabled() && super.getFluidStack() != null) {
|
||||
this.setFluidStack(null);
|
||||
}
|
||||
return super.getFluidStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
setZOffset(oldZOffset);
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<BlockEntity> {
|
||||
|
||||
@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<Text> tooltip, IDataAccessor accessor, IPluginConfig config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendBody(List<Text> tooltip, IDataAccessor accessor, IPluginConfig config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTail(List<Text> tooltip, IDataAccessor accessor, IPluginConfig config) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<BlockEntity> {
|
||||
/**
|
||||
* Contains all providers
|
||||
*/
|
||||
private final List<IPartWailaDataProvider> 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<IPart> 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<Text> currentToolTip, final IDataAccessor accessor,
|
||||
final IPluginConfig config) {
|
||||
final BlockEntity te = accessor.getBlockEntity();
|
||||
final HitResult mop = accessor.getHitResult();
|
||||
|
||||
final Optional<IPart> 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<Text> tooltip, final IDataAccessor accessor, final IPluginConfig config) {
|
||||
final BlockEntity te = accessor.getBlockEntity();
|
||||
final HitResult mop = accessor.getHitResult();
|
||||
|
||||
final Optional<IPart> 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<Text> tooltip, final IDataAccessor accessor, final IPluginConfig config) {
|
||||
final BlockEntity te = accessor.getBlockEntity();
|
||||
final HitResult mop = accessor.getHitResult();
|
||||
|
||||
final Optional<IPart> 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<IPart> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<BlockEntity> {
|
||||
/**
|
||||
* Contains all providers
|
||||
*/
|
||||
private final List<BaseWailaDataProvider> 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<Text> currentToolTip, final IDataAccessor accessor,
|
||||
final IPluginConfig config) {
|
||||
for (final BaseWailaDataProvider provider : this.providers) {
|
||||
provider.appendHead(currentToolTip, accessor, config);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendBody(List<Text> currentToolTip, final IDataAccessor accessor,
|
||||
final IPluginConfig config) {
|
||||
for (final BaseWailaDataProvider provider : this.providers) {
|
||||
provider.appendBody(currentToolTip, accessor, config);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTail(List<Text> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<Text> tooltip, final IDataAccessor accessor,
|
||||
final IPluginConfig config) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendBody(final IPart part, final List<Text> tooltip, final IDataAccessor accessor,
|
||||
final IPluginConfig config) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendTail(final IPart part, final List<Text> tooltip, final IDataAccessor accessor,
|
||||
final IPluginConfig config) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendServerData(ServerPlayerEntity player, IPart part, BlockEntity te, CompoundTag tag, World world,
|
||||
BlockPos pos) {
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile and thus just
|
||||
* requested the new information from the server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final Object2ByteMap<IPart> 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<Text> 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.
|
||||
* <p/>
|
||||
* 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<IPart> 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.
|
||||
* <p/>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<Text> tooltip, IDataAccessor accessor, IPluginConfig config);
|
||||
|
||||
void appendBody(IPart part, List<Text> tooltip, IDataAccessor accessor, IPluginConfig config);
|
||||
|
||||
void appendTail(IPart part, List<Text> tooltip, IDataAccessor accessor, IPluginConfig config);
|
||||
|
||||
void appendServerData(ServerPlayerEntity player, IPart part, BlockEntity te, CompoundTag tag, World world,
|
||||
BlockPos pos);
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<Text> 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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}.
|
||||
* <p/>
|
||||
* 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<IPart> 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();
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<Text> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+73
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<Text> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<Text> 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+55
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<Text> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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<Text> 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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+140
@@ -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 <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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.
|
||||
* <p/>
|
||||
* This is useful, when a player just started to look at a tile and thus just
|
||||
* requested the new information from the server.
|
||||
* <p/>
|
||||
* The cache will be updated from the server.
|
||||
*/
|
||||
private final Object2LongMap<BlockEntity> cache = new Object2LongOpenHashMap<>();
|
||||
|
||||
@Override
|
||||
public void appendBody(List<Text> tooltip, IDataAccessor accessor, IPluginConfig config) {
|
||||
// Removes RF tooltip on WAILA 1.5.9+
|
||||
// FIXME ( (ITaggedList<String, String>) 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.
|
||||
* <p/>
|
||||
* 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.
|
||||
* <p/>
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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<ItemStack> {
|
||||
public class AppEngInternalInventory extends DirectFixedItemInv implements Iterable<ItemStack> {
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<AESharedItemStack, WeakReference<AESharedItemStack>> SERVER_REGISTRY = new WeakHashMap<>();
|
||||
private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> CLIENT_REGISTRY = new WeakHashMap<>();
|
||||
private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> REGISTRY = new WeakHashMap<>();
|
||||
|
||||
private AEItemStackRegistry() {
|
||||
}
|
||||
|
||||
private static WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> 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<AESharedItemStack> weak = registry().get(search);
|
||||
WeakReference<AESharedItemStack> 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user