Skip to content

Commit

Permalink
Updated changelog and merged with fix
Browse files Browse the repository at this point in the history
  • Loading branch information
B1n-ry committed Aug 22, 2024
2 parents 24cb790 + ee928f7 commit 5cef8fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Fixes
* Added translation for enabling soulbound enchantment in the configs
* Improved accessories compat implementation (thanks @Dragon-Seeker!)

---

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ org.gradle.parallel=true
# origins_version=v1.12.10
# levelz_version=1.4.13+1.20.1
# beans_backpacks_version=bsSV8DuI
accessories_version=1.0.0-beta.26+1.21
accessories_version=1.0.0-beta.30+1.21

# Dev dependencies
# cca_version=5.3.0
Expand Down
24 changes: 9 additions & 15 deletions src/main/java/com/b1n_ry/yigd/compat/AccessoriesCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.wispforest.accessories.api.AccessoriesAPI;
import io.wispforest.accessories.api.AccessoriesCapability;
import io.wispforest.accessories.api.AccessoriesContainer;
import io.wispforest.accessories.api.Accessory;
import io.wispforest.accessories.api.slot.SlotReference;
import io.wispforest.accessories.impl.ExpandedSimpleContainer;
import net.minecraft.item.ItemStack;
Expand All @@ -33,10 +32,7 @@ public String getModName() {

@Override
public void clear(ServerPlayerEntity player) {
AccessoriesCapability.getOptionally(player).ifPresent(inv -> inv.getContainers().forEach((s, accessoriesContainer) -> {
accessoriesContainer.getAccessories().clear();
accessoriesContainer.getCosmeticAccessories().clear();
}));
AccessoriesCapability.getOptionally(player).ifPresent(inv -> inv.reset(false));
}

@Override
Expand All @@ -52,12 +48,12 @@ public CompatComponent<Map<String, AccessoriesInventorySlot>> readNbt(NbtCompoun
// We need to check in case the drop rule is a trinket drop rule (only has one difference and that is trinkets have DEFAULT)
String dropRuleString = itemNbt.getString("dropRule");
if (dropRuleString.equals("DEFAULT")) {
dropRule = YigdConfig.getConfig().compatConfig.defaultTrinketsDropRule;
dropRule = YigdConfig.getConfig().compatConfig.defaultAccessoriesDropRule;
} else {
dropRule = DropRule.valueOf(dropRuleString);
}
} else {
dropRule = YigdConfig.getConfig().compatConfig.defaultTrinketsDropRule;
dropRule = YigdConfig.getConfig().compatConfig.defaultAccessoriesDropRule;
}

return new Pair<>(stack, dropRule);
Expand All @@ -69,12 +65,12 @@ public CompatComponent<Map<String, AccessoriesInventorySlot>> readNbt(NbtCompoun
// We need to check in case the drop rule is a trinket drop rule (only has one difference and that is trinkets have DEFAULT)
String dropRuleString = itemNbt.getString("dropRule");
if (dropRuleString.equals("DEFAULT")) {
dropRule = YigdConfig.getConfig().compatConfig.defaultTrinketsDropRule;
dropRule = YigdConfig.getConfig().compatConfig.defaultAccessoriesDropRule;
} else {
dropRule = DropRule.valueOf(dropRuleString);
}
} else {
dropRule = YigdConfig.getConfig().compatConfig.defaultTrinketsDropRule;
dropRule = YigdConfig.getConfig().compatConfig.defaultAccessoriesDropRule;
}

return new Pair<>(stack, dropRule);
Expand Down Expand Up @@ -161,7 +157,7 @@ public DefaultedList<ItemStack> merge(CompatComponent<?> mergingComponent, Serve

Pair<ItemStack, DropRule> currentPair = thisSlot.normal.get(i);
ItemStack thisStack = currentPair.getLeft();
if (YigdConfig.getConfig().graveConfig.treatBindingCurse && !AccessoriesAPI.getOrDefaultAccessory(mergingStack).canUnequip(mergingStack, SlotReference.of(merger, key, i))) {
if (YigdConfig.getConfig().graveConfig.treatBindingCurse && !AccessoriesAPI.canUnequip(mergingStack, SlotReference.of(merger, key, i))) {
extraItems.add(currentPair.getLeft()); // Add the current item to extraItems (as it's being replaced)
thisSlot.normal.set(i, new Pair<>(mergingStack, mergingPair.getRight())); // Can't be unequipped, so it's prioritized
continue; // Already set the item, so we can skip the rest
Expand All @@ -186,7 +182,7 @@ public DefaultedList<ItemStack> merge(CompatComponent<?> mergingComponent, Serve

Pair<ItemStack, DropRule> currentPair = thisSlot.cosmetic.get(i);
ItemStack thisStack = currentPair.getLeft();
if (YigdConfig.getConfig().graveConfig.treatBindingCurse && !AccessoriesAPI.getOrDefaultAccessory(mergingStack).canUnequip(mergingStack, SlotReference.of(merger, key, i))) {
if (YigdConfig.getConfig().graveConfig.treatBindingCurse && !AccessoriesAPI.canUnequip(mergingStack, SlotReference.of(merger, key, i))) {
extraItems.add(currentPair.getLeft()); // Add the current item to extraItems (as it's being replaced)
thisSlot.cosmetic.set(i, new Pair<>(mergingStack, mergingPair.getRight())); // Can't be unequipped, so it's prioritized
continue; // Already set the item, so we can skip the rest
Expand All @@ -213,8 +209,7 @@ public DefaultedList<ItemStack> pullBindingCurseItems(ServerPlayerEntity playerR
for (int i = 0; i < inventorySlot.normal.size(); i++) {
Pair<ItemStack, DropRule> pair = inventorySlot.normal.get(i);
ItemStack stack = pair.getLeft();
Accessory accessory = AccessoriesAPI.getOrDefaultAccessory(stack);
boolean isBound = accessory.canUnequip(stack, SlotReference.of(playerRef, entry.getKey(), i));
boolean isBound = !AccessoriesAPI.canUnequip(stack, SlotReference.of(playerRef, entry.getKey(), i));
if (isBound) {
noUnequipItems.add(stack);
pair.setLeft(ItemStack.EMPTY);
Expand All @@ -223,8 +218,7 @@ public DefaultedList<ItemStack> pullBindingCurseItems(ServerPlayerEntity playerR
for (int i = 0; i < inventorySlot.cosmetic.size(); i++) {
Pair<ItemStack, DropRule> pair = inventorySlot.cosmetic.get(i);
ItemStack stack = pair.getLeft();
Accessory accessory = AccessoriesAPI.getOrDefaultAccessory(stack);
boolean isBound = !accessory.canUnequip(stack, SlotReference.of(playerRef, entry.getKey(), i));
boolean isBound = !AccessoriesAPI.canUnequip(stack, SlotReference.of(playerRef, entry.getKey(), i));
if (isBound) {
noUnequipItems.add(stack);
pair.setLeft(ItemStack.EMPTY);
Expand Down

0 comments on commit 5cef8fb

Please sign in to comment.