From 868a98358fafeb9e5218660d381f6eb1b686f40a Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Sun, 15 Jan 2023 17:46:31 +0100 Subject: [PATCH] Work on deprecations for 1.19.3+ --- .../behaviors}/ContainerItemContext.java | 3 +-- .../behaviors/ContainerItemStrategies.java} | 9 ++++--- .../api/behaviors/ContainerItemStrategy.java | 3 +-- .../behaviors}/EmptyingAction.java | 2 +- .../FluidContainerItemStrategy.java | 5 ++-- .../java/appeng/client/gui/AEBaseScreen.java | 6 ++--- .../client/gui/me/common/MEStorageScreen.java | 6 ++--- .../me/items/PatternEncodingTermScreen.java | 6 ++--- .../appeng/core/localization/Tooltips.java | 2 +- .../execution/ExecutingCraftingJob.java | 7 +---- .../crafting/pattern/AECraftingPattern.java | 5 ++-- .../java/appeng/facade/FacadeContainer.java | 14 +--------- .../items/misc/WrappedGenericStack.java | 4 +-- .../tools/powered/AbstractPortableCell.java | 6 ++--- src/main/java/appeng/menu/AEBaseMenu.java | 8 +++--- .../appeng/menu/me/common/MEStorageMenu.java | 6 ++--- .../java/appeng/parts/CableBusContainer.java | 26 ------------------- .../parts/reporting/AbstractMonitorPart.java | 4 +-- 18 files changed, 38 insertions(+), 84 deletions(-) rename src/main/java/appeng/{menu/me/interaction => api/behaviors}/ContainerItemContext.java (94%) rename src/main/java/appeng/{menu/me/interaction/StackInteractions.java => api/behaviors/ContainerItemStrategies.java} (96%) rename src/main/java/appeng/{menu/me/interaction => api/behaviors}/EmptyingAction.java (87%) rename src/main/java/appeng/{menu/me/interaction => api/behaviors}/FluidContainerItemStrategy.java (93%) diff --git a/src/main/java/appeng/menu/me/interaction/ContainerItemContext.java b/src/main/java/appeng/api/behaviors/ContainerItemContext.java similarity index 94% rename from src/main/java/appeng/menu/me/interaction/ContainerItemContext.java rename to src/main/java/appeng/api/behaviors/ContainerItemContext.java index 7cfd2844163..0e1e7ab8193 100644 --- a/src/main/java/appeng/menu/me/interaction/ContainerItemContext.java +++ b/src/main/java/appeng/api/behaviors/ContainerItemContext.java @@ -1,4 +1,4 @@ -package appeng.menu.me.interaction; +package appeng.api.behaviors; import com.google.common.base.Preconditions; @@ -6,7 +6,6 @@ import net.minecraft.world.entity.player.Player; -import appeng.api.behaviors.ContainerItemStrategy; import appeng.api.config.Actionable; import appeng.api.stacks.AEKey; import appeng.api.stacks.AEKeyType; diff --git a/src/main/java/appeng/menu/me/interaction/StackInteractions.java b/src/main/java/appeng/api/behaviors/ContainerItemStrategies.java similarity index 96% rename from src/main/java/appeng/menu/me/interaction/StackInteractions.java rename to src/main/java/appeng/api/behaviors/ContainerItemStrategies.java index 83cc0328217..c5ac33a3ea0 100644 --- a/src/main/java/appeng/menu/me/interaction/StackInteractions.java +++ b/src/main/java/appeng/api/behaviors/ContainerItemStrategies.java @@ -1,4 +1,4 @@ -package appeng.menu.me.interaction; +package appeng.api.behaviors; import java.util.List; import java.util.Set; @@ -11,15 +11,16 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; -import appeng.api.behaviors.ContainerItemStrategy; import appeng.api.stacks.AEFluidKey; import appeng.api.stacks.AEKey; import appeng.api.stacks.AEKeyType; import appeng.api.stacks.GenericStack; import appeng.util.CowMap; -// TODO 1.20: Rename -> ContainerItemStrategies, make API. This is not purely for UI now. -public class StackInteractions { +/** + * Manages {@link ContainerItemStrategy} registrations for {@linkplain AEKeyType key types}. + */ +public class ContainerItemStrategies { private static final CowMap> strategies = CowMap.identityHashMap(); static { diff --git a/src/main/java/appeng/api/behaviors/ContainerItemStrategy.java b/src/main/java/appeng/api/behaviors/ContainerItemStrategy.java index c1ce3fb837c..72e54ffee7b 100644 --- a/src/main/java/appeng/api/behaviors/ContainerItemStrategy.java +++ b/src/main/java/appeng/api/behaviors/ContainerItemStrategy.java @@ -11,7 +11,6 @@ import appeng.api.stacks.AEKey; import appeng.api.stacks.AEKeyType; import appeng.api.stacks.GenericStack; -import appeng.menu.me.interaction.StackInteractions; /** * Strategy to interact with the non-item keys held by container items, for example the fluid contained in a bucket. @@ -44,7 +43,7 @@ default C findPlayerSlotContext(Player player, int slot) { GenericStack getExtractableContent(C context); static void register(AEKeyType keyType, Class keyClass, ContainerItemStrategy strategy) { - StackInteractions.register(keyType, keyClass, strategy); + ContainerItemStrategies.register(keyType, keyClass, strategy); } } diff --git a/src/main/java/appeng/menu/me/interaction/EmptyingAction.java b/src/main/java/appeng/api/behaviors/EmptyingAction.java similarity index 87% rename from src/main/java/appeng/menu/me/interaction/EmptyingAction.java rename to src/main/java/appeng/api/behaviors/EmptyingAction.java index b92b59388b6..8d913697646 100644 --- a/src/main/java/appeng/menu/me/interaction/EmptyingAction.java +++ b/src/main/java/appeng/api/behaviors/EmptyingAction.java @@ -1,4 +1,4 @@ -package appeng.menu.me.interaction; +package appeng.api.behaviors; import net.minecraft.network.chat.Component; diff --git a/src/main/java/appeng/menu/me/interaction/FluidContainerItemStrategy.java b/src/main/java/appeng/api/behaviors/FluidContainerItemStrategy.java similarity index 93% rename from src/main/java/appeng/menu/me/interaction/FluidContainerItemStrategy.java rename to src/main/java/appeng/api/behaviors/FluidContainerItemStrategy.java index d8d32086db9..7faa0f74982 100644 --- a/src/main/java/appeng/menu/me/interaction/FluidContainerItemStrategy.java +++ b/src/main/java/appeng/api/behaviors/FluidContainerItemStrategy.java @@ -1,4 +1,4 @@ -package appeng.menu.me.interaction; +package appeng.api.behaviors; import org.jetbrains.annotations.Nullable; @@ -13,14 +13,13 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; -import appeng.api.behaviors.ContainerItemStrategy; import appeng.api.config.Actionable; import appeng.api.stacks.AEFluidKey; import appeng.api.stacks.GenericStack; import appeng.util.GenericContainerHelper; import appeng.util.fluid.FluidSoundHelper; -public class FluidContainerItemStrategy implements ContainerItemStrategy> { +class FluidContainerItemStrategy implements ContainerItemStrategy> { @Override public @Nullable GenericStack getContainedStack(ItemStack stack) { return GenericContainerHelper.getContainedFluidStack(stack); diff --git a/src/main/java/appeng/client/gui/AEBaseScreen.java b/src/main/java/appeng/client/gui/AEBaseScreen.java index bc3f16d07bc..39d87d670cd 100644 --- a/src/main/java/appeng/client/gui/AEBaseScreen.java +++ b/src/main/java/appeng/client/gui/AEBaseScreen.java @@ -55,6 +55,8 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; +import appeng.api.behaviors.ContainerItemStrategies; +import appeng.api.behaviors.EmptyingAction; import appeng.api.client.AEStackRendering; import appeng.api.stacks.GenericStack; import appeng.client.Point; @@ -79,8 +81,6 @@ import appeng.menu.AEBaseMenu; import appeng.menu.SlotSemantic; import appeng.menu.SlotSemantics; -import appeng.menu.me.interaction.EmptyingAction; -import appeng.menu.me.interaction.StackInteractions; import appeng.menu.slot.AppEngSlot; import appeng.menu.slot.CraftingTermSlot; import appeng.menu.slot.DisabledSlot; @@ -260,7 +260,7 @@ protected EmptyingAction getEmptyingAction(Slot slot, ItemStack carried) { } // See if we should offer the left-/right-click differentiation for setting a different filter - var emptyingAction = StackInteractions.getEmptyingAction(carried); + var emptyingAction = ContainerItemStrategies.getEmptyingAction(carried); if (emptyingAction != null) { var wrappedStack = GenericStack.wrapInItemStack(new GenericStack(emptyingAction.what(), 1)); if (configInv.isItemValid(slot.slot, wrappedStack)) { diff --git a/src/main/java/appeng/client/gui/me/common/MEStorageScreen.java b/src/main/java/appeng/client/gui/me/common/MEStorageScreen.java index 7646e3a7c0f..18177c76858 100644 --- a/src/main/java/appeng/client/gui/me/common/MEStorageScreen.java +++ b/src/main/java/appeng/client/gui/me/common/MEStorageScreen.java @@ -39,6 +39,7 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; +import appeng.api.behaviors.ContainerItemStrategies; import appeng.api.client.AEStackRendering; import appeng.api.config.ActionItems; import appeng.api.config.Setting; @@ -83,7 +84,6 @@ import appeng.menu.me.common.GridInventoryEntry; import appeng.menu.me.common.MEStorageMenu; import appeng.menu.me.crafting.CraftingStatusMenu; -import appeng.menu.me.interaction.StackInteractions; import appeng.util.ExternalSearch; import appeng.util.IConfigManagerListener; import appeng.util.Platform; @@ -219,7 +219,7 @@ protected void handleGridInventoryEntryMouseClick(@Nullable GridInventoryEntry e // Is there an emptying action? If so, send it to the server if (mouseButton == 1 && clickType == ClickType.PICKUP && !menu.getCarried().isEmpty()) { - var emptyingAction = StackInteractions.getEmptyingAction(menu.getCarried()); + var emptyingAction = ContainerItemStrategies.getEmptyingAction(menu.getCarried()); if (emptyingAction != null && menu.isKeyVisible(emptyingAction.what())) { menu.handleInteraction(-1, InventoryAction.EMPTY_ITEM); return; @@ -612,7 +612,7 @@ protected void renderTooltip(PoseStack poseStack, int x, int y) { if (this.hoveredSlot instanceof RepoSlot repoSlot) { var carried = menu.getCarried(); if (!carried.isEmpty()) { - var emptyingAction = StackInteractions.getEmptyingAction(carried); + var emptyingAction = ContainerItemStrategies.getEmptyingAction(carried); if (emptyingAction != null && menu.isKeyVisible(emptyingAction.what())) { drawTooltip( poseStack, diff --git a/src/main/java/appeng/client/gui/me/items/PatternEncodingTermScreen.java b/src/main/java/appeng/client/gui/me/items/PatternEncodingTermScreen.java index 068a41a46ec..23427c9fa39 100644 --- a/src/main/java/appeng/client/gui/me/items/PatternEncodingTermScreen.java +++ b/src/main/java/appeng/client/gui/me/items/PatternEncodingTermScreen.java @@ -31,6 +31,8 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; +import appeng.api.behaviors.ContainerItemStrategies; +import appeng.api.behaviors.EmptyingAction; import appeng.api.config.ActionItems; import appeng.api.stacks.GenericStack; import appeng.client.gui.me.common.MEStorageScreen; @@ -45,8 +47,6 @@ import appeng.core.sync.packets.InventoryActionPacket; import appeng.helpers.InventoryAction; import appeng.menu.SlotSemantics; -import appeng.menu.me.interaction.EmptyingAction; -import appeng.menu.me.interaction.StackInteractions; import appeng.menu.me.items.PatternEncodingTermMenu; import appeng.parts.encoding.EncodingMode; @@ -141,7 +141,7 @@ protected EmptyingAction getEmptyingAction(Slot slot, ItemStack carried) { // does not work out of the box. if (menu.isProcessingPatternSlot(slot)) { // See if we should offer the left-/right-click differentiation for setting a different filter - var emptyingAction = StackInteractions.getEmptyingAction(carried); + var emptyingAction = ContainerItemStrategies.getEmptyingAction(carried); if (emptyingAction != null) { return emptyingAction; } diff --git a/src/main/java/appeng/core/localization/Tooltips.java b/src/main/java/appeng/core/localization/Tooltips.java index 4b4d6da51d8..9d16dc85d37 100644 --- a/src/main/java/appeng/core/localization/Tooltips.java +++ b/src/main/java/appeng/core/localization/Tooltips.java @@ -17,13 +17,13 @@ import net.minecraft.network.chat.TextColor; import net.minecraft.world.item.ItemStack; +import appeng.api.behaviors.EmptyingAction; import appeng.api.config.PowerUnits; import appeng.api.stacks.AEItemKey; import appeng.api.stacks.AEKey; import appeng.api.stacks.AmountFormat; import appeng.api.stacks.GenericStack; import appeng.core.AEConfig; -import appeng.menu.me.interaction.EmptyingAction; /** * Static utilities for constructing tooltips in various places. diff --git a/src/main/java/appeng/crafting/execution/ExecutingCraftingJob.java b/src/main/java/appeng/crafting/execution/ExecutingCraftingJob.java index 74ef0a27408..ce958e4a4b7 100644 --- a/src/main/java/appeng/crafting/execution/ExecutingCraftingJob.java +++ b/src/main/java/appeng/crafting/execution/ExecutingCraftingJob.java @@ -94,12 +94,7 @@ interface CraftingDifferenceListener { } this.finalOutput = GenericStack.readTag(data.getCompound(NBT_FINAL_OUTPUT)); - // TODO 1.20: Remove - if (data.contains(NBT_REMAINING_AMOUNT)) { - this.remainingAmount = data.getLong(NBT_REMAINING_AMOUNT); - } else { - this.remainingAmount = this.finalOutput.amount(); - } + this.remainingAmount = data.getLong(NBT_REMAINING_AMOUNT); this.waitingFor = new ListCraftingInventory(postCraftingDifference::onCraftingDifference); this.waitingFor.readFromNBT(data.getList(NBT_WAITING_FOR, Tag.TAG_COMPOUND)); this.timeTracker = new ElapsedTimeTracker(data.getCompound(NBT_TIME_TRACKER)); diff --git a/src/main/java/appeng/crafting/pattern/AECraftingPattern.java b/src/main/java/appeng/crafting/pattern/AECraftingPattern.java index 54e9c0407ae..09c28d0848c 100644 --- a/src/main/java/appeng/crafting/pattern/AECraftingPattern.java +++ b/src/main/java/appeng/crafting/pattern/AECraftingPattern.java @@ -24,7 +24,6 @@ import javax.annotation.Nullable; -import net.minecraft.client.player.Input; import net.minecraft.core.NonNullList; import net.minecraft.world.Container; import net.minecraft.world.inventory.CraftingContainer; @@ -39,6 +38,7 @@ import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.level.Level; +import appeng.api.behaviors.ContainerItemStrategies; import appeng.api.crafting.IPatternDetails; import appeng.api.stacks.AEFluidKey; import appeng.api.stacks.AEItemKey; @@ -48,7 +48,6 @@ import appeng.api.stacks.KeyCounter; import appeng.blockentity.crafting.IMolecularAssemblerSupportedPattern; import appeng.menu.AutoCraftingMenu; -import appeng.menu.me.interaction.StackInteractions; public class AECraftingPattern implements IPatternDetails, IMolecularAssemblerSupportedPattern { public static final int CRAFTING_GRID_DIMENSION = 3; @@ -451,7 +450,7 @@ private GenericStack getItemOrFluidInput(int slot, GenericStack item) { return item; } - var containedFluid = StackInteractions.getContainedStack(itemKey.toStack(), AEKeyType.fluids()); + var containedFluid = ContainerItemStrategies.getContainedStack(itemKey.toStack(), AEKeyType.fluids()); // Milk is not natively a fluid container, but it might be made one by other mods var isBucket = itemKey.getItem() instanceof BucketItem || itemKey.getItem() instanceof MilkBucketItem; diff --git a/src/main/java/appeng/facade/FacadeContainer.java b/src/main/java/appeng/facade/FacadeContainer.java index eeb7aa5ce84..3e50827c1e5 100644 --- a/src/main/java/appeng/facade/FacadeContainer.java +++ b/src/main/java/appeng/facade/FacadeContainer.java @@ -25,7 +25,6 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -47,13 +46,6 @@ public class FacadeContainer implements IFacadeContainer { .map(d -> "facade" + StringUtils.capitalize(d.getSerializedName())) .toArray(String[]::new); - /** - * Key names to store facades (the old ones pre 1.20). TODO: Remove in 1.20 - */ - private static final String[] NBT_KEY_OLD_NAMES = Arrays.stream(Direction.values()) - .map(d -> "facade:" + d.ordinal()) - .toArray(String[]::new); - private final CableBusStorage storage; private final Consumer changeCallback; @@ -98,11 +90,7 @@ public void readFromNBT(CompoundTag c) { for (var side : Direction.values()) { this.storage.removeFacade(side); - Tag tag = c.get(NBT_KEY_NAMES[side.ordinal()]); - if (tag == null) { - tag = c.get(NBT_KEY_OLD_NAMES[side.ordinal()]); - } - + var tag = c.get(NBT_KEY_NAMES[side.ordinal()]); if (tag instanceof CompoundTag facadeTag) { var is = ItemStack.of(facadeTag); if (!is.isEmpty()) { diff --git a/src/main/java/appeng/items/misc/WrappedGenericStack.java b/src/main/java/appeng/items/misc/WrappedGenericStack.java index 1ef16e47b22..cff9c9dfaf1 100644 --- a/src/main/java/appeng/items/misc/WrappedGenericStack.java +++ b/src/main/java/appeng/items/misc/WrappedGenericStack.java @@ -32,13 +32,13 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import appeng.api.behaviors.ContainerItemStrategies; import appeng.api.config.Actionable; import appeng.api.stacks.AEKey; import appeng.api.stacks.GenericStack; import appeng.core.AppEng; import appeng.core.definitions.AEItems; import appeng.items.AEBaseItem; -import appeng.menu.me.interaction.StackInteractions; import appeng.util.Platform; /** @@ -136,7 +136,7 @@ public boolean overrideOtherStackedOnMe(ItemStack itemInSlot, ItemStack otherSta // Allow picking up fluids items with a fluid container, this is a special case for fluids var what = unwrapWhat(itemInSlot); if (clickAction == ClickAction.PRIMARY) { - var heldContainer = StackInteractions.findCarriedContextForKey(what, player, player.containerMenu); + var heldContainer = ContainerItemStrategies.findCarriedContextForKey(what, player, player.containerMenu); if (heldContainer != null) { long amount = unwrapAmount(itemInSlot); long inserted = heldContainer.insert(what, amount, Actionable.MODULATE); diff --git a/src/main/java/appeng/items/tools/powered/AbstractPortableCell.java b/src/main/java/appeng/items/tools/powered/AbstractPortableCell.java index 1727a79cb8f..54eb9611b9f 100644 --- a/src/main/java/appeng/items/tools/powered/AbstractPortableCell.java +++ b/src/main/java/appeng/items/tools/powered/AbstractPortableCell.java @@ -17,6 +17,7 @@ import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.level.Level; +import appeng.api.behaviors.ContainerItemStrategies; import appeng.api.config.Actionable; import appeng.api.implementations.menuobjects.IMenuItem; import appeng.api.stacks.AEItemKey; @@ -39,7 +40,6 @@ import appeng.me.helpers.PlayerSource; import appeng.menu.MenuOpener; import appeng.menu.locator.MenuLocators; -import appeng.menu.me.interaction.StackInteractions; import appeng.util.InteractionUtil; public abstract class AbstractPortableCell extends AEBasePoweredItem @@ -241,7 +241,7 @@ protected boolean tryInsertFromPlayerOwnedItem(Player player, ItemStack cellStack, ItemStack otherStack) { // Try all available strategies - for (var keyType : StackInteractions.getSupportedKeyTypes()) { + for (var keyType : ContainerItemStrategies.getSupportedKeyTypes()) { if (tryInsertFromPlayerOwnedItem(player, cellStack, otherStack, keyType)) { return true; } @@ -266,7 +266,7 @@ protected boolean tryInsertFromPlayerOwnedItem(Player player, ItemStack cellStack, ItemStack otherStack, AEKeyType keyType) { - var context = StackInteractions.findOwnedItemContext(keyType, player, otherStack); + var context = ContainerItemStrategies.findOwnedItemContext(keyType, player, otherStack); if (context != null) { var containedStack = context.getExtractableContent(); if (containedStack != null) { diff --git a/src/main/java/appeng/menu/AEBaseMenu.java b/src/main/java/appeng/menu/AEBaseMenu.java index a66965bf8e3..613b97dbeea 100644 --- a/src/main/java/appeng/menu/AEBaseMenu.java +++ b/src/main/java/appeng/menu/AEBaseMenu.java @@ -45,6 +45,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; +import appeng.api.behaviors.ContainerItemStrategies; import appeng.api.config.Actionable; import appeng.api.config.SecurityPermissions; import appeng.api.implementations.menuobjects.ItemMenuHost; @@ -63,7 +64,6 @@ import appeng.me.helpers.PlayerSource; import appeng.menu.guisync.DataSynchronization; import appeng.menu.locator.MenuLocator; -import appeng.menu.me.interaction.StackInteractions; import appeng.menu.slot.AppEngSlot; import appeng.menu.slot.CraftingMatrixSlot; import appeng.menu.slot.CraftingTermSlot; @@ -617,7 +617,7 @@ protected interface FillingSource { } protected final void handleFillingHeldItem(FillingSource source, AEKey what) { - var ctx = StackInteractions.findCarriedContextForKey(what, getPlayer(), this); + var ctx = ContainerItemStrategies.findCarriedContextForKey(what, getPlayer(), this); if (ctx == null) { return; } @@ -656,7 +656,7 @@ protected interface EmptyingSink { } protected final void handleEmptyHeldItem(EmptyingSink sink) { - var ctx = StackInteractions.findCarriedContext(null, getPlayer(), this); + var ctx = ContainerItemStrategies.findCarriedContext(null, getPlayer(), this); if (ctx == null) { return; } @@ -720,7 +720,7 @@ private void handleFakeSlotAction(FakeSlot fakeSlot, InventoryAction action) { break; case EMPTY_ITEM: { - var emptyingAction = StackInteractions.getEmptyingAction(hand); + var emptyingAction = ContainerItemStrategies.getEmptyingAction(hand); if (emptyingAction != null) { fakeSlot.set(GenericStack.wrapInItemStack(emptyingAction.what(), emptyingAction.maxAmount())); } diff --git a/src/main/java/appeng/menu/me/common/MEStorageMenu.java b/src/main/java/appeng/menu/me/common/MEStorageMenu.java index dc3a875a366..42d078d06f7 100644 --- a/src/main/java/appeng/menu/me/common/MEStorageMenu.java +++ b/src/main/java/appeng/menu/me/common/MEStorageMenu.java @@ -37,6 +37,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import appeng.api.behaviors.ContainerItemStrategies; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; import appeng.api.config.SecurityPermissions; @@ -79,7 +80,6 @@ import appeng.menu.guisync.GuiSync; import appeng.menu.implementations.MenuTypeBuilder; import appeng.menu.me.crafting.CraftAmountMenu; -import appeng.menu.me.interaction.StackInteractions; import appeng.menu.slot.AppEngSlot; import appeng.menu.slot.RestrictedInputSlot; import appeng.util.ConfigManager; @@ -457,12 +457,12 @@ protected void handleNetworkInteraction(ServerPlayer player, @Nullable AEKey cli return; } - if (action == InventoryAction.PICKUP_OR_SET_DOWN && StackInteractions.isKeySupported(clickedKey)) { + if (action == InventoryAction.PICKUP_OR_SET_DOWN && ContainerItemStrategies.isKeySupported(clickedKey)) { action = InventoryAction.FILL_ITEM; } if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) { - if (StackInteractions.getContainedStack(getCarried()) != null) { + if (ContainerItemStrategies.getContainedStack(getCarried()) != null) { action = InventoryAction.EMPTY_ITEM; } } diff --git a/src/main/java/appeng/parts/CableBusContainer.java b/src/main/java/appeng/parts/CableBusContainer.java index f65c6c57738..4be3aea6301 100644 --- a/src/main/java/appeng/parts/CableBusContainer.java +++ b/src/main/java/appeng/parts/CableBusContainer.java @@ -28,7 +28,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; @@ -91,22 +90,6 @@ public class CableBusContainer implements AEMultiBlockEntity, ICableBusContainer .map(d -> d == null ? "cable" : d.getSerializedName()) .toArray(String[]::new); - /** - * Old NBT property names used to store the item-ids for parts on the given side. Index is 0-5 for normal directions - * and 6 for the null-direction. TODO Remove in 1.20 - */ - private static final String[] NBT_KEY_OLD_PART_ID = Arrays.stream(Platform.DIRECTIONS_WITH_NULL) - .map(d -> d == null ? "item:center" : "item:" + d.name()) - .toArray(String[]::new); - - /** - * Old NBT property names used to store the item-ids for parts on the given side. Index is 0-5 for normal directions - * and 6 for the null-direction. TODO Remove in 1.20 - */ - private static final String[] NBT_KEY_OLD_PART_DATA = Arrays.stream(Platform.DIRECTIONS_WITH_NULL) - .map(d -> d == null ? "extra:center" : "extra:" + d.name()) - .toArray(String[]::new); - private static final ThreadLocal IS_LOADING = new ThreadLocal<>(); private final CableBusStorage storage = new CableBusStorage(); private YesNo hasRedstone = YesNo.UNDECIDED; @@ -849,15 +832,6 @@ public void readFromNBT(CompoundTag data) { continue; } - // Try to migrate old part data (TODO: Remove in 1.20) - if (data.contains(NBT_KEY_OLD_PART_ID[sideIndex], Tag.TAG_STRING)) { - var partData = data.getCompound(NBT_KEY_OLD_PART_DATA[sideIndex]).copy(); - partData.putString("id", data.getString(NBT_KEY_OLD_PART_ID[sideIndex])); - if (loadPart(side, partData)) { - continue; - } - } - // If nothing was loaded, the side is empty and has to be cleared this.removePartFromSide(side); } diff --git a/src/main/java/appeng/parts/reporting/AbstractMonitorPart.java b/src/main/java/appeng/parts/reporting/AbstractMonitorPart.java index b0f92fe1c67..8a9f044a8a2 100644 --- a/src/main/java/appeng/parts/reporting/AbstractMonitorPart.java +++ b/src/main/java/appeng/parts/reporting/AbstractMonitorPart.java @@ -32,6 +32,7 @@ import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.phys.Vec3; +import appeng.api.behaviors.ContainerItemStrategies; import appeng.api.implementations.parts.IStorageMonitorPart; import appeng.api.networking.IStackWatcher; import appeng.api.networking.storage.IStorageService; @@ -44,7 +45,6 @@ import appeng.api.stacks.AmountFormat; import appeng.client.render.BlockEntityRenderHelper; import appeng.core.localization.PlayerMessages; -import appeng.menu.me.interaction.StackInteractions; import appeng.util.Platform; /** @@ -156,7 +156,7 @@ public boolean onPartActivate(Player player, InteractionHand hand, Vec3 pos) { var eq = player.getItemInHand(hand); if (AEItemKey.matches(this.configuredItem, eq)) { // Already matches: try to swap to key contained in the item. - var containedStack = StackInteractions.getContainedStack(eq); + var containedStack = ContainerItemStrategies.getContainedStack(eq); if (containedStack != null) { this.configuredItem = containedStack.what(); }