Skip to content

Commit

Permalink
Fix Capacitor NBT Removal + Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Feb 17, 2024
1 parent 52b2ebf commit 1fc7487
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
35 changes: 19 additions & 16 deletions src/main/java/com/nomiceu/nomilabs/remap/datafixer/LabsFixes.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ public static void init() {
*/
itemFixes = new ObjectArrayList<>();

// Must be first Dark Red Coal Remap and Custom Capacitor NBT Removal, then Deprecated Item Remap, then CT General Remap,
// because only one fix is applied.

itemFixes.add(
new DataFix.ItemFix("Dark Red Coal Remap",
"Correctly remaps Content Tweaker Dark Red Coal to XU2 Red Coal.",
Expand All @@ -155,6 +158,20 @@ public static void init() {
.setMeta((short) 4)) // Red Coal
);

if (Loader.isModLoaded(LabsValues.ENDER_IO_MODID))
itemFixes.add(
new DataFix.ItemFix("Custom Capacitor NBT Removal",
"Removes NBT from Custom Capacitors.",
false,
(version) -> version <= PRE_CAPACITOR_REMAPPING,
(modList) -> true,
(stack) -> (stack.rl.getNamespace().equals(LABS_MODID) ||
stack.rl.getNamespace().equals(CONTENTTWEAKER_MODID)) &&
capacitorSpecificationRemap.containsKey(stack.rl.getPath()) &&
capacitorSpecificationRemap.get(stack.rl.getPath()).needChange(stack.tag),
(stack) -> stack.setTag(capacitorSpecificationRemap.get(stack.rl.getPath()).remove(stack.tag)))
);

itemFixes.add(
new DataFix.ItemFix("Deprecated Item Remap",
"Remaps Deprecated Items to their Modern Counterparts.",
Expand Down Expand Up @@ -197,7 +214,7 @@ public static void init() {
(stack) -> {
var tag = Objects.requireNonNull(stack.tag);
tag.removeTag("Freq");
stack.setTag(tag.isEmpty() ? null : tag);
stack.setTag(tag);
})
);

Expand Down Expand Up @@ -247,20 +264,6 @@ public static void init() {
.setRl(LabsNames.makeLabsName(stack.rl.getPath())))
);

if (Loader.isModLoaded(LabsValues.ENDER_IO_MODID))
itemFixes.add(
new DataFix.ItemFix("Custom Capacitor NBT Removal",
"Removes NBT from Custom Capacitors.",
false,
(version) -> version <= PRE_CAPACITOR_REMAPPING,
(modList) -> true,
(stack) -> (stack.rl.getNamespace().equals(LABS_MODID) ||
stack.rl.getNamespace().equals(CONTENTTWEAKER_MODID)) &&
capacitorSpecificationRemap.containsKey(stack.rl.getPath()) &&
capacitorSpecificationRemap.get(stack.rl.getPath()).needChange(stack.tag),
(stack) -> stack.setTag(capacitorSpecificationRemap.get(stack.rl.getPath()).remove(stack.tag)))
);

/*
* Block Fixes.
* Note that this is not applied on any new blocks, placed or generated.
Expand Down Expand Up @@ -496,7 +499,7 @@ public NBTTagCompound remove(@Nullable NBTTagCompound compound) {
if (compound == null || compound.isEmpty()) return null;
removeEIO(compound);
removeDisplay(compound);
return compound.isEmpty() ? null : compound;
return compound;
}

private void removeEIO(NBTTagCompound compound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ItemStackLike setMeta(short newMeta) {
}

public ItemStackLike setTag(@Nullable NBTTagCompound newTag) {
tag = newTag;
tag = newTag == null || newTag.isEmpty() ? null : newTag;
return this;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/assets/nomilabs/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fluid.moltendarksoularium=Molten Dark Soularium
nomilabs.fixer.intro.1=This world must be remapped.
nomilabs.fixer.intro.2=§lA Backup will be made.§r
nomilabs.fixer.intro.3=Pressing 'No' will cancel world loading.
nomilabs.fixer.intro.4=§cNote that after the world is loaded with this, you CANNOT undo this!.§r
nomilabs.fixer.intro.4=§cNote that after the world is loaded with this, you §nCANNOT§r§c undo this!.§r
nomilabs.fixer.intro.5=You §nWILL§r have to load from the backup in order to load in a previous version!
nomilabs.fixer.intro.6=§7The changes that must be made via Data Fixers have been printed to your log.§r

Expand Down

0 comments on commit 1fc7487

Please sign in to comment.