Post-merge fixes. Reformat. Optimize Imports.

This commit is contained in:
Sebastian Hartte
2020-09-20 14:47:25 +02:00
parent f3c44c64c2
commit 5da5315a5b
26 changed files with 94 additions and 106 deletions
@@ -642,7 +642,7 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends HandledScr
this.itemRenderer.zOffset = 0.0F; this.itemRenderer.zOffset = 0.0F;
} }
protected ITextComponent getGuiDisplayName(final Text in) { protected Text getGuiDisplayName(final Text in) {
return title.getString().isEmpty() ? in : title; return title.getString().isEmpty() ? in : title;
} }
@@ -136,16 +136,16 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
this.selectCPU.setMessage(getNextCpuButtonLabel()); this.selectCPU.setMessage(getNextCpuButtonLabel());
} }
private ITextComponent getNextCpuButtonLabel() { private Text getNextCpuButtonLabel() {
if (this.container.hasNoCPU()) { if (this.handler.hasNoCPU()) {
return GuiText.NoCraftingCPUs.text(); return GuiText.NoCraftingCPUs.text();
} }
ITextComponent cpuName; Text cpuName;
if (this.container.cpuName == null) { if (this.handler.cpuName == null) {
cpuName = GuiText.Automatic.text(); cpuName = GuiText.Automatic.text();
} else { } else {
cpuName = this.container.cpuName; cpuName = this.handler.cpuName;
} }
return GuiText.CraftingCPU.withSuffix(": ").append(cpuName); return GuiText.CraftingCPU.withSuffix(": ").append(cpuName);
@@ -63,11 +63,11 @@ public class CraftingStatusScreen extends CraftingCPUScreen<CraftingStatusContai
this.selectCPU.setMessage(getNextCpuButtonLabel()); this.selectCPU.setMessage(getNextCpuButtonLabel());
} }
private ITextComponent getNextCpuButtonLabel() { private Text getNextCpuButtonLabel() {
if (this.handler.noCPU) { if (this.handler.noCPU) {
return GuiText.NoCraftingJobs.text(); return GuiText.NoCraftingJobs.text();
} }
return GuiText.CraftingCPU.withSuffix(": ").append(container.cpuName); return GuiText.CraftingCPU.withSuffix(": ").append(handler.cpuName);
} }
@Override @Override
@@ -52,15 +52,15 @@ public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer>
this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_ITEM_COUNT); this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_ITEM_COUNT);
this.level.setTextFieldBounds(25, 44, 75); this.level.setTextFieldBounds(25, 44, 75);
this.level.addButtons(children::add, this::addButton); this.level.addButtons(children::add, this::addButton);
this.level.setValue(container.getReportingValue()); this.level.setValue(handler.getReportingValue());
this.level.setOnChange(this::saveReportingValue); this.level.setOnChange(this::saveReportingValue);
this.level.setOnConfirm(this::closeScreen); this.level.setOnConfirm(this::onClose);
this.changeFocus(true); this.changeFocus(true);
} }
private void saveReportingValue() { private void saveReportingValue() {
this.level.getLongValue().ifPresent(container::setReportingValue); this.level.getLongValue().ifPresent(handler::setReportingValue);
} }
@Override @Override
@@ -26,6 +26,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import me.shedaniel.math.Rectangle; import me.shedaniel.math.Rectangle;
@@ -297,13 +298,13 @@ public class MEMonitorableScreen<T extends MEMonitorableContainer> extends AEBas
this.currentMouseY = mouseY; this.currentMouseY = mouseY;
// Show the number of active crafting jobs // Show the number of active crafting jobs
if (this.craftingStatusBtn != null && container.activeCraftingJobs != -1) { if (this.craftingStatusBtn != null && handler.activeCraftingJobs != -1) {
// The stack size renderer expects a 16x16 slot, while the button is normally // The stack size renderer expects a 16x16 slot, while the button is normally
// bigger // bigger
int x = this.craftingStatusBtn.x + (this.craftingStatusBtn.getWidth() - 16) / 2; int x = this.craftingStatusBtn.x + (this.craftingStatusBtn.getWidth() - 16) / 2;
int y = this.craftingStatusBtn.y + (this.craftingStatusBtn.getHeightRealms() - 16) / 2; int y = this.craftingStatusBtn.y + (this.craftingStatusBtn.getHeight() - 16) / 2;
StackSizeRenderer.renderSizeLabel(font, x - this.guiLeft, y - this.guiTop, StackSizeRenderer.renderSizeLabel(textRenderer, x - this.x, y - this.y,
String.valueOf(container.activeCraftingJobs)); new LiteralText(String.valueOf(handler.activeCraftingJobs)));
} }
} }
@@ -6,14 +6,14 @@ import java.util.OptionalInt;
import java.util.OptionalLong; import java.util.OptionalLong;
import java.util.function.Consumer; import java.util.function.Consumer;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.Element; import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.text.TranslatableText;
import appeng.client.gui.AEBaseScreen; import appeng.client.gui.AEBaseScreen;
import appeng.client.gui.NumberEntryType; import appeng.client.gui.NumberEntryType;
@@ -27,8 +27,7 @@ import appeng.core.AEConfig;
*/ */
public class NumberEntryWidget extends DrawableHelper { public class NumberEntryWidget extends DrawableHelper {
private static final ITextComponent INVALID_NUMBER = new TranslationTextComponent( private static final Text INVALID_NUMBER = new TranslatableText("gui.appliedenergistics2.validation.InvalidNumber");
"gui.appliedenergistics2.validation.InvalidNumber");
private static final String NUMBER_LESS_THAN_MIN_VALUE = "gui.appliedenergistics2.validation.NumberLessThanMinValue"; private static final String NUMBER_LESS_THAN_MIN_VALUE = "gui.appliedenergistics2.validation.NumberLessThanMinValue";
private static final Text PLUS = Text.of("+"); private static final Text PLUS = Text.of("+");
private static final Text MINUS = Text.of("-"); private static final Text MINUS = Text.of("-");
@@ -60,18 +59,17 @@ public class NumberEntryWidget extends DrawableHelper {
this.y = y; this.y = y;
this.type = type; this.type = type;
FontRenderer font = parent.getMinecraft().fontRenderer; TextRenderer font = parent.getClient().textRenderer;
int inputX = parent.getGuiLeft() + x; int inputX = parent.getX() + x;
int inputY = parent.getGuiTop() + y; int inputY = parent.getY() + y;
this.textField = new ConfirmableTextField(font, inputX, inputY, width, font.FONT_HEIGHT, this.textField = new ConfirmableTextField(font, inputX, inputY, width, font.fontHeight, LiteralText.EMPTY);
StringTextComponent.EMPTY); this.textField.setHasBorder(false);
this.textField.setEnableBackgroundDrawing(false); this.textField.setMaxLength(16);
this.textField.setMaxStringLength(16); this.textField.setEditableColor(TEXT_COLOR_NORMAL);
this.textField.setTextColor(TEXT_COLOR_NORMAL);
this.textField.setVisible(true); this.textField.setVisible(true);
this.textField.setFocused2(true); this.textField.setSelected(true);
parent.setFocusedDefault(this.textField); parent.setInitialFocus(this.textField);
this.textField.setResponder(text -> { this.textField.setChangedListener(text -> {
validate(); validate();
if (onChange != null) { if (onChange != null) {
this.onChange.run(); this.onChange.run();
@@ -190,8 +188,8 @@ public class NumberEntryWidget extends DrawableHelper {
public void setValue(long value) { public void setValue(long value) {
this.textField.setText(String.valueOf(Math.max(minValue, value))); this.textField.setText(String.valueOf(Math.max(minValue, value)));
this.textField.setCursorPositionEnd(); this.textField.setCursorToEnd();
this.textField.setSelectionPos(0); this.textField.setSelectionStart(0);
validate(); validate();
} }
@@ -204,20 +202,20 @@ public class NumberEntryWidget extends DrawableHelper {
} }
private void validate() { private void validate() {
List<ITextComponent> validationErrors = new ArrayList<>(); List<Text> validationErrors = new ArrayList<>();
String text = textField.getText().trim(); String text = textField.getText().trim();
try { try {
long value = Long.parseLong(text, 10); long value = Long.parseLong(text, 10);
if (value < minValue) { if (value < minValue) {
validationErrors.add(new TranslationTextComponent(NUMBER_LESS_THAN_MIN_VALUE, minValue)); validationErrors.add(new TranslatableText(NUMBER_LESS_THAN_MIN_VALUE, minValue));
} }
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
validationErrors.add(INVALID_NUMBER); validationErrors.add(INVALID_NUMBER);
} }
boolean valid = validationErrors.isEmpty(); boolean valid = validationErrors.isEmpty();
this.textField.setTextColor(valid ? TEXT_COLOR_NORMAL : TEXT_COLOR_ERROR); this.textField.setEditableColor(valid ? TEXT_COLOR_NORMAL : TEXT_COLOR_ERROR);
if (this.validationIcon != null) { if (this.validationIcon != null) {
this.validationIcon.setValid(valid); this.validationIcon.setValid(valid);
this.validationIcon.setTooltip(validationErrors); this.validationIcon.setTooltip(validationErrors);
@@ -40,8 +40,8 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
this.subGui = new AESubScreen(this, container.getPriorityHost()); this.subGui = new AESubScreen(this, container.getPriorityHost());
// This is the effective size of the background image // This is the effective size of the background image
xSize = 175; backgroundWidth = 175;
ySize = 128; backgroundHeight = 128;
} }
@Override @Override
@@ -51,7 +51,7 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
this.priority = new NumberEntryWidget(this, 20, 30, 138, 62, NumberEntryType.PRIORITY); this.priority = new NumberEntryWidget(this, 20, 30, 138, 62, NumberEntryType.PRIORITY);
this.priority.setTextFieldBounds(62, 57, 50); this.priority.setTextFieldBounds(62, 57, 50);
this.priority.setMinValue(Integer.MIN_VALUE); this.priority.setMinValue(Integer.MIN_VALUE);
this.priority.setValue(this.container.getPriorityValue()); this.priority.setValue(this.handler.getPriorityValue());
this.priority.addButtons(children::add, this::addButton); this.priority.addButtons(children::add, this::addButton);
this.subGui.addBackButton(this::addButton, 154, 0); this.subGui.addBackButton(this::addButton, 154, 0);
@@ -68,7 +68,7 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
private void savePriority() { private void savePriority() {
OptionalInt priority = this.priority.getIntValue(); OptionalInt priority = this.priority.getIntValue();
if (priority.isPresent()) { if (priority.isPresent()) {
container.setPriority(priority.getAsInt()); handler.setPriority(priority.getAsInt());
} }
} }
@@ -20,21 +20,21 @@ package appeng.client.gui.widgets;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.util.text.ITextComponent; import net.minecraft.text.Text;
public class ConfirmableTextField extends TextFieldWidget { public class ConfirmableTextField extends TextFieldWidget {
private Runnable onConfirm; private Runnable onConfirm;
public ConfirmableTextField(FontRenderer fontRenderer, int x, int y, int width, int height, ITextComponent text) { public ConfirmableTextField(TextRenderer fontRenderer, int x, int y, int width, int height, Text text) {
super(fontRenderer, x, y, width, height, text); super(fontRenderer, x, y, width, height, text);
} }
@Override @Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) { public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (canWrite() && (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER)) { if (isActive() && (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER)) {
if (this.onConfirm != null) { if (this.onConfirm != null) {
this.onConfirm.run(); this.onConfirm.run();
} }
@@ -21,8 +21,8 @@ package appeng.client.gui.widgets;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.sound.SoundManager;
import net.minecraft.client.texture.TextureManager; import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
@@ -48,9 +48,9 @@ public abstract class IconButton extends ButtonWidget implements ITooltip {
} }
@Override @Override
public void playDownSound(SoundHandler soundHandler) { public void playDownSound(SoundManager soundManager) {
if (!disableClickSound) { if (!disableClickSound) {
super.playDownSound(soundHandler); super.playDownSound(soundManager);
} }
} }
@@ -108,7 +108,7 @@ public abstract class IconButton extends ButtonWidget implements ITooltip {
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
if (isHovered()) { if (isHovered()) {
renderToolTip(matrixStack, mouseX, mouseY); renderToolTip(matrices, mouseX, mouseY);
} }
} }
} }
@@ -3,18 +3,17 @@ package appeng.client.gui.widgets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.text.ITextComponent; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
/** /**
* Displays a small icon that shows validation errors for some input control. * Displays a small icon that shows validation errors for some input control.
*/ */
public class ValidationIcon extends IconButton { public class ValidationIcon extends IconButton {
private final List<ITextComponent> tooltip = new ArrayList<>(); private final List<Text> tooltip = new ArrayList<>();
private boolean valid; private boolean valid;
@@ -33,7 +32,7 @@ public class ValidationIcon extends IconButton {
} }
} }
public void setTooltip(List<ITextComponent> lines) { public void setTooltip(List<Text> lines) {
this.tooltip.clear(); this.tooltip.clear();
this.tooltip.addAll(lines); this.tooltip.addAll(lines);
} }
@@ -54,12 +53,12 @@ public class ValidationIcon extends IconButton {
return; return;
} }
Minecraft client = Minecraft.getInstance(); MinecraftClient client = MinecraftClient.getInstance();
Screen screen = client.currentScreen; Screen screen = client.currentScreen;
if (screen == null) { if (screen == null) {
return; return;
} }
screen.func_243308_b(matrices, this.tooltip, x, y); screen.renderTooltip(matrices, this.tooltip, x, y);
} }
} }
@@ -1001,7 +1001,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
* Returns whether this container instance lives on the client. * Returns whether this container instance lives on the client.
*/ */
protected boolean isClient() { protected boolean isClient() {
return invPlayer.player.getEntityWorld().isRemote(); return invPlayer.player.getEntityWorld().isClient();
} }
/** /**
@@ -1,11 +1,11 @@
package appeng.container.implementations; package appeng.container.implementations;
import java.util.function.Function;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory; import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import java.util.function.Function;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -14,12 +14,7 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.network.NetworkHooks;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
@@ -49,7 +44,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
private final SecurityPermissions requiredPermission; private final SecurityPermissions requiredPermission;
private Function<I, ITextComponent> containerTitleStrategy = this::getDefaultContainerTitle; private Function<I, Text> containerTitleStrategy = this::getDefaultContainerTitle;
public ContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass) { public ContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass) {
this(factory, interfaceClass, null); this(factory, interfaceClass, null);
@@ -64,11 +59,11 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
/** /**
* Specifies a custom strategy for obtaining a custom container name. * Specifies a custom strategy for obtaining a custom container name.
* * <p>
* The stratgy should return {@link StringTextComponent#EMPTY} if there's no * The stratgy should return {@link LiteralText#EMPTY} if there's no custom
* custom name. * name.
*/ */
public ContainerHelper<C, I> withContainerTitle(Function<I, ITextComponent> containerTitleStrategy) { public ContainerHelper<C, I> withContainerTitle(Function<I, Text> containerTitleStrategy) {
this.containerTitleStrategy = containerTitleStrategy; this.containerTitleStrategy = containerTitleStrategy;
return this; return this;
} }
@@ -86,7 +81,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
* Same as {@link #open}, but allows or additional data to be read from the * Same as {@link #open}, but allows or additional data to be read from the
* packet, and passed onto the container. * packet, and passed onto the container.
*/ */
public C fromNetwork(int windowId, PlayerInventory inv, PacketBuffer packetBuf, public C fromNetwork(int windowId, PlayerInventory inv, PacketByteBuf packetBuf,
InitialDataDeserializer<C, I> initialDataDeserializer) { InitialDataDeserializer<C, I> initialDataDeserializer) {
I host = getHostFromLocator(inv.player, ContainerLocator.read(packetBuf)); I host = getHostFromLocator(inv.player, ContainerLocator.read(packetBuf));
if (host != null) { if (host != null) {
@@ -121,7 +116,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
Text title = containerTitleStrategy.apply(accessInterface); Text title = containerTitleStrategy.apply(accessInterface);
player.openHandledScreen(new HandlerFactory(locator, title, accessInterface)); player.openHandledScreen(new HandlerFactory(locator, title, accessInterface, initialDataSerializer));
return true; return true;
} }
@@ -134,10 +129,14 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
private final Text title; private final Text title;
public HandlerFactory(ContainerLocator locator, Text title, I accessInterface) { private final InitialDataSerializer<I> initialDataSerializer;
public HandlerFactory(ContainerLocator locator, Text title, I accessInterface,
InitialDataSerializer<I> initialDataSerializer) {
this.locator = locator; this.locator = locator;
this.title = title; this.title = title;
this.accessInterface = accessInterface; this.accessInterface = accessInterface;
this.initialDataSerializer = initialDataSerializer;
} }
@Override @Override
@@ -245,7 +244,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
*/ */
@FunctionalInterface @FunctionalInterface
public interface InitialDataSerializer<I> { public interface InitialDataSerializer<I> {
void serializeInitialData(I host, PacketBuffer buffer); void serializeInitialData(I host, PacketByteBuf buffer);
} }
/** /**
@@ -254,7 +253,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
*/ */
@FunctionalInterface @FunctionalInterface
public interface InitialDataDeserializer<C, I> { public interface InitialDataDeserializer<C, I> {
void deserializeInitialData(I host, C container, PacketBuffer buffer); void deserializeInitialData(I host, C container, PacketByteBuf buffer);
} }
private boolean checkPermission(PlayerEntity player, Object accessInterface) { private boolean checkPermission(PlayerEntity player, Object accessInterface) {
@@ -26,7 +26,7 @@ import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.ScreenHandlerListener; import net.minecraft.screen.ScreenHandlerListener;
import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text; import net.minecraft.text.LiteralText;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
@@ -61,7 +61,7 @@ public class CraftingCPUContainer extends AEBaseContainer implements IMEMonitorH
if (cluster != null && cluster.getName() != null) { if (cluster != null && cluster.getName() != null) {
return cluster.getName(); return cluster.getName();
} }
return StringTextComponent.EMPTY; return LiteralText.EMPTY;
}); });
private final IItemList<IAEItemStack> list = Api.instance().storage().getStorageChannel(IItemStorageChannel.class) private final IItemList<IAEItemStack> list = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
@@ -7,7 +7,7 @@ import java.util.function.Predicate;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.text.LiteralText;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.ICraftingCPU; import appeng.api.networking.crafting.ICraftingCPU;
@@ -75,7 +75,7 @@ class CraftingCPUCycler {
for (int i = 0; i < this.cpus.size(); i++) { for (int i = 0; i < this.cpus.size(); i++) {
CraftingCPURecord cpu = cpus.get(i); CraftingCPURecord cpu = cpus.get(i);
if (cpu.getName() == null) { if (cpu.getName() == null) {
cpu.setName(new StringTextComponent("#" + (i + 1))); cpu.setName(new LiteralText("#" + (i + 1)));
} }
} }
@@ -36,7 +36,6 @@ import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api; import appeng.core.Api;
import appeng.tile.misc.InscriberBlockEntity; import appeng.tile.misc.InscriberBlockEntity;
import appeng.tile.misc.InscriberRecipes; import appeng.tile.misc.InscriberRecipes;
import appeng.tile.misc.InscriberTileEntity;
/** /**
* @author AlgorithmX2 * @author AlgorithmX2
@@ -18,13 +18,12 @@
package appeng.container.implementations; package appeng.container.implementations;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.PacketBuffer; import net.minecraft.screen.ScreenHandlerType;
import net.minecraftforge.items.IItemHandler;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType; import appeng.api.config.LevelType;
@@ -18,8 +18,6 @@
package appeng.container.implementations; package appeng.container.implementations;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
@@ -34,7 +34,7 @@ import appeng.core.sync.network.INetworkInfo;
public abstract class BasePacket { public abstract class BasePacket {
/** /**
* Sadly {@link PacketBuffer#readString()} gets inlined by Proguard which means * Sadly {@link PacketByteBuf#readString()} gets inlined by Proguard which means
* it's not available on the Server. This field has the default string length * it's not available on the Server. This field has the default string length
* that is used for writeString, which then also should be used for readString * that is used for writeString, which then also should be used for readString
* when it has no special length requirements. * when it has no special length requirements.
@@ -29,9 +29,9 @@ public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitter
this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_FLUID_VOLUME); this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_FLUID_VOLUME);
this.level.setTextFieldBounds(25, 44, 75); this.level.setTextFieldBounds(25, 44, 75);
this.level.addButtons(children::add, this::addButton); this.level.addButtons(children::add, this::addButton);
this.level.setValue(container.getReportingValue()); this.level.setValue(handler.getReportingValue());
this.level.setOnChange(this::saveReportingValue); this.level.setOnChange(this::saveReportingValue);
this.level.setOnConfirm(this::closeScreen); this.level.setOnConfirm(this::onClose);
this.changeFocus(true); this.changeFocus(true);
@@ -41,7 +41,7 @@ public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitter
} }
private void saveReportingValue() { private void saveReportingValue() {
this.level.getLongValue().ifPresent(container::setReportingValue); this.level.getLongValue().ifPresent(handler::setReportingValue);
} }
@Override @Override
@@ -21,7 +21,6 @@ import appeng.container.implementations.UpgradeableContainer;
import appeng.fluids.helper.FluidSyncHelper; import appeng.fluids.helper.FluidSyncHelper;
import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform;
public abstract class FluidConfigurableContainer extends UpgradeableContainer implements IFluidSyncContainer { public abstract class FluidConfigurableContainer extends UpgradeableContainer implements IFluidSyncContainer {
private FluidSyncHelper sync = null; private FluidSyncHelper sync = null;
@@ -36,7 +36,6 @@ import appeng.fluids.helper.DualityFluidInterface;
import appeng.fluids.helper.FluidSyncHelper; import appeng.fluids.helper.FluidSyncHelper;
import appeng.fluids.helper.IFluidInterfaceHost; import appeng.fluids.helper.IFluidInterfaceHost;
import appeng.fluids.util.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform;
public class FluidInterfaceContainer extends FluidConfigurableContainer { public class FluidInterfaceContainer extends FluidConfigurableContainer {
@@ -1,7 +1,5 @@
package appeng.fluids.container; package appeng.fluids.container;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
@@ -16,7 +14,6 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.fluids.parts.FluidLevelEmitterPart; import appeng.fluids.parts.FluidLevelEmitterPart;
import appeng.fluids.util.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform;
public class FluidLevelEmitterContainer extends FluidConfigurableContainer { public class FluidLevelEmitterContainer extends FluidConfigurableContainer {
public static ScreenHandlerType<FluidLevelEmitterContainer> TYPE; public static ScreenHandlerType<FluidLevelEmitterContainer> TYPE;
@@ -44,7 +44,6 @@ import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api; import appeng.core.Api;
import appeng.fluids.parts.FluidStorageBusPart; import appeng.fluids.parts.FluidStorageBusPart;
import appeng.fluids.util.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator; import appeng.util.iterators.NullIterator;
/** /**
@@ -18,13 +18,14 @@
package appeng.fluids.helper; package appeng.fluids.helper;
import java.math.RoundingMode;
import java.util.Optional; import java.util.Optional;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import alexiil.mc.lib.attributes.AttributeList; import alexiil.mc.lib.attributes.AttributeList;
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume; import alexiil.mc.lib.attributes.fluid.amount.FluidAmount;
import alexiil.mc.lib.attributes.item.FixedItemInv; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
@@ -319,8 +320,8 @@ public class DualityFluidInterface
toStore.setStackSize(-toStore.getStackSize()); toStore.setStackSize(-toStore.getStackSize());
// make sure strange things didn't happen... // make sure strange things didn't happen...
final FluidVolume canExtract = this.tanks.drain(slot, toStore.getFluidStack(), false); final FluidAmount canExtract = this.tanks.drain(slot, toStore.getFluidStack(), false);
if (canExtract.isEmpty() || canExtract.getAmount() != toStore.getStackSize()) { if (canExtract.isZero() || canExtract.asLong(1000, RoundingMode.DOWN) != toStore.getStackSize()) {
changed = true; changed = true;
} else { } else {
IAEFluidStack notStored = Platform.poweredInsert(src, dest, toStore, this.interfaceRequestSource); IAEFluidStack notStored = Platform.poweredInsert(src, dest, toStore, this.interfaceRequestSource);
@@ -329,8 +330,8 @@ public class DualityFluidInterface
if (toStore.getStackSize() > 0) { if (toStore.getStackSize() > 0) {
// extract items! // extract items!
changed = true; changed = true;
final FluidVolume removed = this.tanks.drain(slot, toStore.getFluidStack(), true); final FluidAmount removed = this.tanks.drain(slot, toStore.getFluidStack(), true);
if (removed.isEmpty() || toStore.getStackSize() != removed.getAmount()) { if (removed.isZero() || toStore.getStackSize() != removed.asLong(1000, RoundingMode.DOWN)) {
throw new IllegalStateException("bad attempt at managing tanks. ( drain )"); throw new IllegalStateException("bad attempt at managing tanks. ( drain )");
} }
} }
@@ -151,19 +151,19 @@ public class AEFluidInventory implements IAEFluidTank {
return amountToStore; return amountToStore;
} }
public FluidVolume drain(final int slot, final FluidVolume resource, final boolean doDrain) { public FluidAmount drain(final int slot, final FluidVolume resource, final boolean doDrain) {
final IAEFluidStack fluid = this.fluids[slot]; final IAEFluidStack fluid = this.fluids[slot];
if (resource.isEmpty() || fluid == EMPTY_AE_FLUIDSTACK || !fluid.getFluidStack().equals(resource)) { if (resource.isEmpty() || fluid == EMPTY_AE_FLUIDSTACK || !fluid.getFluidStack().equals(resource)) {
return FluidStack.EMPTY; return FluidAmount.ZERO;
} }
int toDrain = (int) resource.getAmount_F().asLong(1000, RoundingMode.DOWN); int toDrain = (int) resource.getAmount_F().asLong(1000, RoundingMode.DOWN);
return this.drain(slot, toDrain, doDrain); return this.drain(slot, toDrain, doDrain);
} }
public FluidVolume drain(final int slot, final int maxDrain, boolean doDrain) { public FluidAmount drain(final int slot, final int maxDrain, boolean doDrain) {
final IAEFluidStack fluid = this.fluids[slot]; final IAEFluidStack fluid = this.fluids[slot];
if (fluid == EMPTY_AE_FLUIDSTACK || maxDrain <= 0) { if (fluid == EMPTY_AE_FLUIDSTACK || maxDrain <= 0) {
return FluidStack.EMPTY; return FluidAmount.ZERO;
} }
int drained = maxDrain; int drained = maxDrain;
@@ -171,7 +171,7 @@ public class AEFluidInventory implements IAEFluidTank {
drained = (int) fluid.getStackSize(); drained = (int) fluid.getStackSize();
} }
FluidVolume stack = fluid.getFluidStack().withAmount(FluidAmount.of(drained, 1000)); FluidAmount amount = FluidAmount.of(drained, 1000);
if (doDrain) { if (doDrain) {
fluid.setStackSize(fluid.getStackSize() - drained); fluid.setStackSize(fluid.getStackSize() - drained);
if (fluid.getStackSize() <= 0) { if (fluid.getStackSize() <= 0) {
@@ -179,7 +179,7 @@ public class AEFluidInventory implements IAEFluidTank {
} }
this.onContentChanged(slot); this.onContentChanged(slot);
} }
return stack; return amount;
} }
public void writeToNBT(final CompoundTag data, final String name) { public void writeToNBT(final CompoundTag data, final String name) {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB