mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-11-28 07:35:46 +00:00
Add dynamic bauble slots and safe inventory synchronization
This commit is contained in:
1 parent
b461473f30
commit
93b1d42f8b
20 files changed
+1090
-352
No files matched your search
@@ -45,7 +45,7 @@ public class SlotBauble extends Slot {
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
if (stack == null || BaubleExpandedSlots.unknownType.equals(slotType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public class SlotBauble extends Slot {
|
||||
types = new String[] {BaubleExpandedSlots.getTypeFromBaubleType(legacyType)};
|
||||
}
|
||||
|
||||
if (types == null) return false;
|
||||
for(String type : types) {
|
||||
if (BaublesConfig.canTypeFitSlot(type, slotType)) {
|
||||
return true;
|
||||
@@ -75,15 +76,9 @@ public class SlotBauble extends Slot {
|
||||
public void onSlotChanged() {
|
||||
super.onSlotChanged();
|
||||
|
||||
ItemStack stack = getStack();
|
||||
if (stack == null || !(stack.getItem() instanceof IBaubleExpanded bauble)
|
||||
|| !(inventory instanceof InventoryBaubles baubleInventory)) {
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = baubleInventory.player.get();
|
||||
if (player != null) {
|
||||
bauble.onSlotContentsChanged(stack, player);
|
||||
}
|
||||
if (inventory instanceof InventoryBaubles baubleInventory) {
|
||||
baubleInventory.onSlotContentsChanged(getSlotIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user