From ce53eca3e47fafce7526a928637ed7e5a63237d1 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Tue, 31 Dec 2024 20:59:49 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Updated=20upgrade=20code=20?= =?UTF-8?q?to=20keep=20it=20compatible=20with=20the=20latest=20version=20o?= =?UTF-8?q?f=20core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 4 ++-- .../backpack/BackpackBlockEntity.java | 2 +- .../backpack/wrapper/BackpackWrapper.java | 2 +- .../common/gui/BackpackContainer.java | 6 ++++++ .../sophisticatedbackpacks/network/SBPPacketHandler.java | 2 +- .../upgrades/refill/RefillUpgradeWrapper.java | 6 +++--- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index d8d1711b..a03db307 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedbackpacks mod_group_id=sophisticatedbackpacks -mod_version=3.21.1 +mod_version=3.21.2 sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks @@ -31,5 +31,5 @@ crafting_tweaks_cf_file_id=4596466 chipped_cf_file_id=5077656 resourcefullib_cf_file_id=5070629 athena_cf_file_id=4764357 -sc_version=[1.20.1-1.0.4,1.20.4) +sc_version=[1.20.1-1.0.5,1.20.4) parchment_version=2023.09.03-1.20.1 \ No newline at end of file diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackBlockEntity.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackBlockEntity.java index 30ad767a..b89fbdf9 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackBlockEntity.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackBlockEntity.java @@ -58,7 +58,7 @@ public BackpackBlockEntity(BlockPos pos, BlockState state) { public void setBackpack(ItemStack backpack) { backpackWrapper = backpack.getCapability(CapabilityBackpackWrapper.getCapabilityInstance()).orElse(IBackpackWrapper.Noop.INSTANCE); - backpackWrapper.setSaveHandler(() -> { + backpackWrapper.setContentsChangeHandler(() -> { setChanged(); updateBlockRender = false; WorldHelper.notifyBlockUpdate(this); diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java index aa8acfc7..10c7ee6e 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java @@ -95,7 +95,7 @@ public BackpackWrapper(ItemStack backpack) { } @Override - public void setSaveHandler(Runnable saveHandler) { + public void setContentsChangeHandler(Runnable saveHandler) { backpackSaveHandler = saveHandler; refreshInventoryForUpgradeProcessing(); } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/gui/BackpackContainer.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/gui/BackpackContainer.java index 406fdfdb..1d772062 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/gui/BackpackContainer.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/common/gui/BackpackContainer.java @@ -6,6 +6,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.SimpleMenuProvider; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.Slot; @@ -57,6 +58,11 @@ public Optional getBlockPosition() { return Optional.empty(); } + @Override + public Optional getEntity() { + return Optional.of(player); + } + @Override protected void sendStorageSettingsToClient() { if (player.level().isClientSide) { diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/network/SBPPacketHandler.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/network/SBPPacketHandler.java index 2c3d27ac..bfb32323 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/network/SBPPacketHandler.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/network/SBPPacketHandler.java @@ -6,7 +6,7 @@ public class SBPPacketHandler extends PacketHandler { public static final SBPPacketHandler INSTANCE = new SBPPacketHandler(SophisticatedBackpacks.MOD_ID); - public SBPPacketHandler(String modId) { + private SBPPacketHandler(String modId) { super(modId); } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeWrapper.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeWrapper.java index 28faa58a..153da34e 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeWrapper.java @@ -7,7 +7,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.util.StringRepresentable; import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -86,7 +86,7 @@ public FilterLogic getFilterLogic() { } @Override - public void tick(@Nullable LivingEntity entity, Level world, BlockPos pos) { + public void tick(@Nullable Entity entity, Level world, BlockPos pos) { if (entity == null /*not supported in block form*/ || isInCooldown(world)) { return; } @@ -99,7 +99,7 @@ public void tick(@Nullable LivingEntity entity, Level world, BlockPos pos) { setCooldown(world, COOLDOWN); } - private void tryRefillFilter(@Nonnull LivingEntity entity, IItemHandler playerInvHandler, ItemStack filter, TargetSlot targetSlot) { + private void tryRefillFilter(@Nonnull Entity entity, IItemHandler playerInvHandler, ItemStack filter, TargetSlot targetSlot) { if (!(entity instanceof Player player)) { return; }