From 80dea06f2f245d1f3e443eebd4766deef15f1521 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Mon, 23 Dec 2024 10:05:11 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20A=20bit=20of?= =?UTF-8?q?=20change=20to=20what=20kind=20of=20entities=20can=20run=20upgr?= =?UTF-8?q?ades=20+=20a=20bit=20more=20refactoring=20in=20prep=20for=20new?= =?UTF-8?q?=20features?= 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 | 4 ++-- .../network/SyncClientInfoPayload.java | 2 +- .../upgrades/refill/RefillUpgradeWrapper.java | 6 +++--- .../textures/item/smithing_upgrade.png | Bin 0 -> 261 bytes 6 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/assets/sophisticatedbackpacks/textures/item/smithing_upgrade.png diff --git a/gradle.properties b/gradle.properties index 201b7be1..fd47c2f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedbackpacks mod_name=Sophisticated Backpacks mod_license=GNU General Public License v3.0 -mod_version=3.20.27 +mod_version=3.20.28 mod_group_id=sophisticatedbackpacks mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional backpacks. @@ -34,7 +34,7 @@ chipped_cf_file_id=5506938 resourcefullib_cf_file_id=5483169 athena_cf_file_id=5431579 curios_cf_file_id=5546342 -sc_version=[1.21-1.0.2,1.22) +sc_version=[1.21-1.0.4,1.22) #publish curseforge_id=422301 diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackBlockEntity.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackBlockEntity.java index fe2241d7..a1a9e6f4 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackBlockEntity.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/BackpackBlockEntity.java @@ -56,7 +56,7 @@ public BackpackBlockEntity(BlockPos pos, BlockState state) { public void setBackpack(ItemStack backpack) { backpackWrapper = BackpackWrapper.fromStack(backpack); - 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 a02eb6a1..e49a0439 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java @@ -106,8 +106,8 @@ public static Optional fromExistingData(ItemStack stack) { } @Override - public void setSaveHandler(Runnable saveHandler) { - backpackSaveHandler = saveHandler; + public void setContentsChangeHandler(Runnable contentsChangeHandler) { + backpackSaveHandler = contentsChangeHandler; refreshInventoryForUpgradeProcessing(); } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/network/SyncClientInfoPayload.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/network/SyncClientInfoPayload.java index 74c54912..2f05236a 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/network/SyncClientInfoPayload.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/network/SyncClientInfoPayload.java @@ -40,7 +40,7 @@ public static void handlePayload(SyncClientInfoPayload payload, IPayloadContext } ItemStack backpack = player.getInventory().items.get(payload.slotIndex); IBackpackWrapper backpackWrapper = BackpackWrapper.fromStack(backpack); - backpackWrapper.getRenderInfo().deserializeFrom(player.level().registryAccess(), payload.renderInfoNbt); + backpackWrapper.getRenderInfo().deserializeFrom(payload.renderInfoNbt); backpackWrapper.setColumnsTaken(payload.columnsTaken, false); } } 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 a20eaa57..1618f628 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeWrapper.java @@ -10,7 +10,7 @@ import net.minecraft.network.codec.StreamCodec; 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; @@ -94,7 +94,7 @@ public FilterLogic getFilterLogic() { } @Override - public void tick(@Nullable LivingEntity entity, Level level, BlockPos pos) { + public void tick(@Nullable Entity entity, Level level, BlockPos pos) { if (entity == null /*not supported in block form*/ || isInCooldown(level)) { return; } @@ -107,7 +107,7 @@ public void tick(@Nullable LivingEntity entity, Level level, BlockPos pos) { setCooldown(level, 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; } diff --git a/src/main/resources/assets/sophisticatedbackpacks/textures/item/smithing_upgrade.png b/src/main/resources/assets/sophisticatedbackpacks/textures/item/smithing_upgrade.png new file mode 100644 index 0000000000000000000000000000000000000000..da1ca64000beb669f6b54a3aa54c5b5b159318cd GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`XFOdTLo7}wCoEv&2o(P_h>1%#QInVsLQ zxymwk@4ut+B6dFfe))1=ylK<+fIFr6I9rc{a8R@Vy$?EX7>imwRU|t4>PP@X7c>?o+ECvQoS3j3^P65~ literal 0 HcmV?d00001