Skip to content

Commit

Permalink
refactor: ♻️ A bit of change to what kind of entities can run upgrade…
Browse files Browse the repository at this point in the history
…s + a bit more refactoring in prep for new features
  • Loading branch information
P3pp3rF1y committed Dec 23, 2024
1 parent 086df87 commit 80dea06
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public static Optional<IBackpackWrapper> fromExistingData(ItemStack stack) {
}

@Override
public void setSaveHandler(Runnable saveHandler) {
backpackSaveHandler = saveHandler;
public void setContentsChangeHandler(Runnable contentsChangeHandler) {
backpackSaveHandler = contentsChangeHandler;
refreshInventoryForUpgradeProcessing();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 80dea06

Please sign in to comment.