Skip to content

Commit

Permalink
Fix #228: compare SpecialChestInventory.
Browse files Browse the repository at this point in the history
This doesn't address the issue with shulker box sounds which seem
slightly different for reasons I haven't yet established.
  • Loading branch information
noobanidus committed Jan 25, 2024
1 parent 1cca1b7 commit 99465b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import noobanidus.mods.lootr.api.blockentity.ILootBlockEntity;
import noobanidus.mods.lootr.block.LootrBarrelBlock;
import noobanidus.mods.lootr.config.ConfigManager;
import noobanidus.mods.lootr.data.ChestData;
import noobanidus.mods.lootr.data.SpecialChestInventory;
import noobanidus.mods.lootr.init.ModBlockEntities;
import noobanidus.mods.lootr.util.Getter;

Expand Down Expand Up @@ -84,11 +86,11 @@ protected void openerCountChanged(Level level, BlockPos pos, BlockState state, i
@Override
protected boolean isOwnContainer(Player player) {
if (player.containerMenu instanceof ChestMenu) {
Container container = ((ChestMenu) player.containerMenu).getContainer();
return container == LootrBarrelBlockEntity.this;
} else {
return false;
if (((ChestMenu) player.containerMenu).getContainer() instanceof SpecialChestInventory data) {
return data.getTileId().equals(LootrBarrelBlockEntity.this.getTileId());
}
}
return false;
}
};

Expand Down Expand Up @@ -157,7 +159,7 @@ public void unpackLootTable(Player player, Container inventory, @Nullable Resour
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer) player, overrideTable != null ? overrideTable : this.lootTable);
}

LootParams.Builder builder = (new LootParams.Builder((ServerLevel)this.level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition));
LootParams.Builder builder = (new LootParams.Builder((ServerLevel) this.level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition));
if (player != null) {
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,13 @@ protected void openerCountChanged(Level level, BlockPos pos, BlockState state, i

@Override
protected boolean isOwnContainer(Player player) {
if (!(player.containerMenu instanceof ChestMenu)) {
return false;
} else {
Container container = ((ChestMenu) player.containerMenu).getContainer();
if (container instanceof SpecialChestInventory chest) {
if ((player.containerMenu instanceof ChestMenu menu)) {
if (menu.getContainer() instanceof SpecialChestInventory chest) {
return LootrChestBlockEntity.this.getTileId().equals(chest.getTileId());
}
return false;
}

return false;
}
};
private final ChestLidController chestLidController = new ChestLidController();
Expand Down

0 comments on commit 99465b6

Please sign in to comment.