From 3133cb8b65258848f0dc44725867c8e26443eda2 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 7 Jul 2024 00:50:40 +0200 Subject: [PATCH 1/3] fix: configuration card for wireless transmitter not transferring upgrades --- CHANGELOG.md | 1 + .../AbstractDiskInterfaceBlockEntity.java | 21 +++------------ ...deableNetworkNodeContainerBlockEntity.java | 26 +++++-------------- .../common/upgrade/UpgradeContainer.java | 18 +++++++++++++ .../WirelessTransmitterBlockEntity.java | 19 +++++++++----- 5 files changed, 41 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75604f94f..e00d32c90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Fixed Relay model not being able to load correctly. - Fixed not being able to ghost drag resources from recipe viewers into filter slots on NeoForge. - Fixed extra dark backgrounds due to drawing background on GUIs twice. +- Fixed Configuration Card not being able to transfer upgrades for the Wireless Transmitter. ## [2.0.0-milestone.4.2] - 2024-07-06 diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java index 35c061945..1590e1f3a 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java @@ -16,7 +16,6 @@ import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeDestinations; -import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.function.UnaryOperator; @@ -34,7 +33,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; -// TODO: upgradeable + level interacting class hierarchy? Disk Interface is copying stuff now... :( public abstract class AbstractDiskInterfaceBlockEntity extends AbstractDiskContainerBlockEntity implements StorageTransferListener { @@ -71,15 +69,11 @@ protected AbstractDiskInterfaceBlockEntity(final BlockPos pos, final BlockState } private void upgradeContainerChanged() { - configureAccordingToUpgrades(); - setChanged(); - } - - private void configureAccordingToUpgrades() { final int amountOfSpeedUpgrades = upgradeContainer.getAmount(Items.INSTANCE.getSpeedUpgrade()); this.workTickRate = 9 - (amountOfSpeedUpgrades * 2); final long baseEnergyUsage = Platform.INSTANCE.getConfig().getDiskInterface().getEnergyUsage(); mainNode.setEnergyUsage(baseEnergyUsage + upgradeContainer.getEnergyUsage()); + setChanged(); } @Override @@ -104,7 +98,6 @@ public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider pr if (tag.contains(TAG_UPGRADES)) { upgradeContainer.fromTag(tag.getList(TAG_UPGRADES, Tag.TAG_COMPOUND), provider); } - configureAccordingToUpgrades(); super.loadAdditional(tag, provider); } @@ -134,20 +127,12 @@ public void writeConfiguration(final CompoundTag tag, final HolderLookup.Provide @Override public List getUpgradeItems() { - final List upgradeItems = new ArrayList<>(); - for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { - final ItemStack itemStack = upgradeContainer.getItem(i); - if (itemStack.isEmpty()) { - continue; - } - upgradeItems.add(itemStack.getItem()); - } - return upgradeItems; + return upgradeContainer.getUpgradeItems(); } @Override public boolean addUpgradeItem(final Item upgradeItem) { - return upgradeContainer.addItem(new ItemStack(upgradeItem)).isEmpty(); + return upgradeContainer.addUpgradeItem(upgradeItem); } @Override diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java index c59505b40..b93af0b80 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java @@ -7,7 +7,6 @@ import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeDestinations; -import java.util.ArrayList; import java.util.List; import net.minecraft.core.BlockPos; @@ -63,7 +62,10 @@ protected void postDoWork() { } private void upgradeContainerChanged() { - configureAccordingToUpgrades(); + LOGGER.debug("Reconfiguring {} for upgrades", getBlockPos()); + final int amountOfSpeedUpgrades = upgradeContainer.getAmount(Items.INSTANCE.getSpeedUpgrade()); + this.workTickRate = 9 - (amountOfSpeedUpgrades * 2); + this.setEnergyUsage(upgradeContainer.getEnergyUsage()); setChanged(); if (level instanceof ServerLevel serverLevel) { initialize(serverLevel); @@ -72,20 +74,12 @@ private void upgradeContainerChanged() { @Override public List getUpgradeItems() { - final List upgradeItems = new ArrayList<>(); - for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { - final ItemStack itemStack = upgradeContainer.getItem(i); - if (itemStack.isEmpty()) { - continue; - } - upgradeItems.add(itemStack.getItem()); - } - return upgradeItems; + return upgradeContainer.getUpgradeItems(); } @Override public boolean addUpgradeItem(final Item upgradeItem) { - return upgradeContainer.addItem(new ItemStack(upgradeItem)).isEmpty(); + return upgradeContainer.addUpgradeItem(upgradeItem); } @Override @@ -99,17 +93,9 @@ public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider pr if (tag.contains(TAG_UPGRADES)) { upgradeContainer.fromTag(tag.getList(TAG_UPGRADES, Tag.TAG_COMPOUND), provider); } - configureAccordingToUpgrades(); super.loadAdditional(tag, provider); } - private void configureAccordingToUpgrades() { - LOGGER.debug("Reconfiguring {} for upgrades", getBlockPos()); - final int amountOfSpeedUpgrades = upgradeContainer.getAmount(Items.INSTANCE.getSpeedUpgrade()); - this.workTickRate = 9 - (amountOfSpeedUpgrades * 2); - this.setEnergyUsage(upgradeContainer.getEnergyUsage()); - } - protected abstract void setEnergyUsage(long upgradeEnergyUsage); @Override diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/UpgradeContainer.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/UpgradeContainer.java index 945ca75f5..1b312ded0 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/UpgradeContainer.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/upgrade/UpgradeContainer.java @@ -7,6 +7,8 @@ import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeRegistry; import com.refinedmods.refinedstorage.platform.api.upgrade.UpgradeState; +import java.util.ArrayList; +import java.util.List; import java.util.OptionalLong; import java.util.Set; import java.util.stream.IntStream; @@ -123,4 +125,20 @@ public long getEnergyUsage() { } return usage; } + + public List getUpgradeItems() { + final List upgradeItems = new ArrayList<>(); + for (int i = 0; i < getContainerSize(); ++i) { + final ItemStack itemStack = getItem(i); + if (itemStack.isEmpty()) { + continue; + } + upgradeItems.add(itemStack.getItem()); + } + return upgradeItems; + } + + public boolean addUpgradeItem(final Item upgradeItem) { + return addItem(new ItemStack(upgradeItem)).isEmpty(); + } } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java index 72ab2a1d1..2995b4baf 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java @@ -13,6 +13,7 @@ import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeDestinations; +import java.util.List; import javax.annotation.Nullable; import net.minecraft.core.BlockPos; @@ -26,6 +27,7 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.Item; import net.minecraft.world.level.block.state.BlockState; public class WirelessTransmitterBlockEntity @@ -61,10 +63,19 @@ public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider pr if (tag.contains(TAG_UPGRADES)) { upgradeContainer.fromTag(tag.getList(TAG_UPGRADES, Tag.TAG_COMPOUND), provider); } - configureAccordingToUpgrades(); super.loadAdditional(tag, provider); } + @Override + public List getUpgradeItems() { + return upgradeContainer.getUpgradeItems(); + } + + @Override + public boolean addUpgradeItem(final Item upgradeItem) { + return upgradeContainer.addUpgradeItem(upgradeItem); + } + @Override public void addOutgoingConnections(final ConnectionSink sink) { final Direction myDirection = getDirection(); @@ -109,13 +120,9 @@ int getRange() { } private void upgradeContainerChanged() { - setChanged(); - configureAccordingToUpgrades(); - } - - private void configureAccordingToUpgrades() { final long baseUsage = Platform.INSTANCE.getConfig().getWirelessTransmitter().getEnergyUsage(); mainNode.setEnergyUsage(baseUsage + upgradeContainer.getEnergyUsage()); + setChanged(); } @Override From 2b6b6f08de9ebe43db124ffc2a01017651134aab Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 7 Jul 2024 00:58:26 +0200 Subject: [PATCH 2/3] fix: upgrade inventories not retaining order --- CHANGELOG.md | 1 + .../common/networking/NetworkTransmitterBlockEntity.java | 9 +++------ .../diskinterface/AbstractDiskInterfaceBlockEntity.java | 8 ++++---- ...stractUpgradeableNetworkNodeContainerBlockEntity.java | 8 ++++---- .../platform/common/upgrade/UpgradeContainer.java | 8 -------- .../WirelessTransmitterBlockEntity.java | 8 ++++---- 6 files changed, 16 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e00d32c90..5fa814fcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Fixed not being able to ghost drag resources from recipe viewers into filter slots on NeoForge. - Fixed extra dark backgrounds due to drawing background on GUIs twice. - Fixed Configuration Card not being able to transfer upgrades for the Wireless Transmitter. +- Fixed upgrade inventories not maintaining order after reloading. Upgrade inventories from the milestone 4.2 are incompatible and will be empty. ## [2.0.0-milestone.4.2] - 2024-07-06 diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/networking/NetworkTransmitterBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/networking/NetworkTransmitterBlockEntity.java index f3fd8a91e..f60dea301 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/networking/NetworkTransmitterBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/networking/NetworkTransmitterBlockEntity.java @@ -10,6 +10,7 @@ import com.refinedmods.refinedstorage.platform.common.support.BlockEntityWithDrops; import com.refinedmods.refinedstorage.platform.common.support.containermenu.NetworkNodeExtendedMenuProvider; import com.refinedmods.refinedstorage.platform.common.support.network.AbstractRedstoneModeNetworkNodeContainerBlockEntity; +import com.refinedmods.refinedstorage.platform.common.util.ContainerUtil; import javax.annotation.Nullable; @@ -19,7 +20,6 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; @@ -155,17 +155,14 @@ Container getNetworkCardInventory() { @Override public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.saveAdditional(tag, provider); - tag.put(TAG_NETWORK_CARD_INVENTORY, networkCardInventory.createTag(provider)); + tag.put(TAG_NETWORK_CARD_INVENTORY, ContainerUtil.write(networkCardInventory, provider)); } @Override public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.loadAdditional(tag, provider); if (tag.contains(TAG_NETWORK_CARD_INVENTORY)) { - networkCardInventory.fromTag( - tag.getList(TAG_NETWORK_CARD_INVENTORY, Tag.TAG_COMPOUND), - provider - ); + ContainerUtil.read(tag.getCompound(TAG_NETWORK_CARD_INVENTORY), networkCardInventory, provider); } updateReceiverLocation(); } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java index 1590e1f3a..86002c063 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/storage/diskinterface/AbstractDiskInterfaceBlockEntity.java @@ -15,6 +15,7 @@ import com.refinedmods.refinedstorage.platform.common.support.FilterModeSettings; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeDestinations; +import com.refinedmods.refinedstorage.platform.common.util.ContainerUtil; import java.util.List; import java.util.Set; @@ -24,7 +25,6 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -38,7 +38,7 @@ public abstract class AbstractDiskInterfaceBlockEntity implements StorageTransferListener { public static final int AMOUNT_OF_DISKS = 6; - private static final String TAG_UPGRADES = "u"; + private static final String TAG_UPGRADES = "upgr"; private static final String TAG_FILTER_MODE = "fim"; private static final String TAG_TRANSFER_MODE = "tm"; @@ -96,7 +96,7 @@ protected void setNormalizer(final UnaryOperator normalizer) { @Override public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { if (tag.contains(TAG_UPGRADES)) { - upgradeContainer.fromTag(tag.getList(TAG_UPGRADES, Tag.TAG_COMPOUND), provider); + ContainerUtil.read(tag.getCompound(TAG_UPGRADES), upgradeContainer, provider); } super.loadAdditional(tag, provider); } @@ -104,7 +104,7 @@ public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider pr @Override public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.saveAdditional(tag, provider); - tag.put(TAG_UPGRADES, upgradeContainer.createTag(provider)); + tag.put(TAG_UPGRADES, ContainerUtil.write(upgradeContainer, provider)); tag.putInt(TAG_FILTER_MODE, FilterModeSettings.getFilterMode(mainNode.getFilterMode())); } diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java index b93af0b80..918873204 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java @@ -6,6 +6,7 @@ import com.refinedmods.refinedstorage.platform.common.support.BlockEntityWithDrops; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeDestinations; +import com.refinedmods.refinedstorage.platform.common.util.ContainerUtil; import java.util.List; @@ -13,7 +14,6 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -29,7 +29,7 @@ public abstract class AbstractUpgradeableNetworkNodeContainerBlockEntity implements NetworkNodeExtendedMenuProvider { - private static final String TAG_UPGRADES = "u"; + private static final String TAG_UPGRADES = "upgr"; private final UpgradeContainer upgradeContainer = new UpgradeContainer( UpgradeDestinations.WIRELESS_TRANSMITTER, @@ -55,13 +55,13 @@ protected InWorldNetworkNodeContainer createMainContainer(final SimpleNetworkNod @Override public void saveAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { super.saveAdditional(tag, provider); - tag.put(TAG_UPGRADES, upgradeContainer.createTag(provider)); + tag.put(TAG_UPGRADES, ContainerUtil.write(upgradeContainer, provider)); } @Override public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider provider) { if (tag.contains(TAG_UPGRADES)) { - upgradeContainer.fromTag(tag.getList(TAG_UPGRADES, Tag.TAG_COMPOUND), provider); + ContainerUtil.read(tag.getCompound(TAG_UPGRADES), upgradeContainer, provider); } super.loadAdditional(tag, provider); } From 592fd03dcc95f43c33bdf5aba4bda6a3f8529b1a Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 7 Jul 2024 01:00:57 +0200 Subject: [PATCH 3/3] fix: wireless transmitter not dropping upgrades --- CHANGELOG.md | 1 + ...UpgradeableNetworkNodeContainerBlockEntity.java | 2 +- .../WirelessTransmitterBlockEntity.java | 14 +++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fa814fcb..1bf1931ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Fixed extra dark backgrounds due to drawing background on GUIs twice. - Fixed Configuration Card not being able to transfer upgrades for the Wireless Transmitter. - Fixed upgrade inventories not maintaining order after reloading. Upgrade inventories from the milestone 4.2 are incompatible and will be empty. +- Fixed Wireless Transmitter not dropping upgrades when breaking block. ## [2.0.0-milestone.4.2] - 2024-07-06 diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java index 918873204..36b9ac59f 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/support/network/AbstractUpgradeableNetworkNodeContainerBlockEntity.java @@ -99,7 +99,7 @@ public void loadAdditional(final CompoundTag tag, final HolderLookup.Provider pr protected abstract void setEnergyUsage(long upgradeEnergyUsage); @Override - public NonNullList getDrops() { + public final NonNullList getDrops() { final NonNullList drops = NonNullList.create(); for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { drops.add(upgradeContainer.getItem(i)); diff --git a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java index f8ef9f05c..873ff63f1 100644 --- a/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java +++ b/refinedstorage-platform-common/src/main/java/com/refinedmods/refinedstorage/platform/common/wirelesstransmitter/WirelessTransmitterBlockEntity.java @@ -8,6 +8,7 @@ import com.refinedmods.refinedstorage.platform.common.content.BlockEntities; import com.refinedmods.refinedstorage.platform.common.content.ContentNames; import com.refinedmods.refinedstorage.platform.common.support.AbstractDirectionalBlock; +import com.refinedmods.refinedstorage.platform.common.support.BlockEntityWithDrops; import com.refinedmods.refinedstorage.platform.common.support.containermenu.NetworkNodeExtendedMenuProvider; import com.refinedmods.refinedstorage.platform.common.support.network.AbstractRedstoneModeNetworkNodeContainerBlockEntity; import com.refinedmods.refinedstorage.platform.common.upgrade.UpgradeContainer; @@ -20,6 +21,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.HolderLookup; +import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -28,11 +30,12 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; public class WirelessTransmitterBlockEntity extends AbstractRedstoneModeNetworkNodeContainerBlockEntity - implements NetworkNodeExtendedMenuProvider { + implements NetworkNodeExtendedMenuProvider, BlockEntityWithDrops { private static final String TAG_UPGRADES = "upgr"; private final UpgradeContainer upgradeContainer = new UpgradeContainer( @@ -125,6 +128,15 @@ private void upgradeContainerChanged() { setChanged(); } + @Override + public NonNullList getDrops() { + final NonNullList drops = NonNullList.create(); + for (int i = 0; i < upgradeContainer.getContainerSize(); ++i) { + drops.add(upgradeContainer.getItem(i)); + } + return drops; + } + @Override protected boolean doesBlockStateChangeWarrantNetworkNodeUpdate(final BlockState oldBlockState, final BlockState newBlockState) {