Skip to content

Commit

Permalink
Fixed black hole units losing the nbt of items when stored in control…
Browse files Browse the repository at this point in the history
…lers, closes #1435
  • Loading branch information
Buuz135 committed Jun 24, 2024
1 parent f696b55 commit d077580
Show file tree
Hide file tree
Showing 35 changed files with 597 additions and 54 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 3.5.18

* Added Machine Settings Copier

# Version 3.5.17

* Fix bug where Black Hole Units could transmute items (by notcake)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ dependencies {
compileOnly fg.deobf("mezz.jei:jei-1.20.1-forge-api:15.2.0.23")
// at runtime, use the full JEI jar for Forge
runtimeOnly fg.deobf("mezz.jei:jei-1.20.1-forge:15.2.0.23")
implementation fg.deobf(project.dependencies.create('com.hrznstudio:titanium:1.20.1-3.8.25'))
implementation fg.deobf(project.dependencies.create('com.hrznstudio:titanium:1.20.1-3.8.32'))

implementation fg.deobf("curse.maven:curios-309927:5086821")
implementation fg.deobf("curse.maven:patchouli-306770:4636277")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2023-07-29T16:46:10.132647 Titanium Serializable (industrialforegoing)
// 1.20.1 2024-06-24T21:25:49.052893 Titanium Serializable (industrialforegoing)
447935433d16d79caf2fe9ab416dc72313d264c9 data/industrialforegoing/recipes/crusher/cobble_gravel.json
4581eba498ede5633c603189ae2e7d3825519364 data/industrialforegoing/recipes/crusher/gravel_sand.json
f9381c4e926f16b49a2e00fe0d52e4db4de7e8bf data/industrialforegoing/recipes/crusher/sand_silicon.json
Expand Down Expand Up @@ -70,7 +70,7 @@ e918fe6905db398570f947cc4fb00329087e5378 data/industrialforegoing/recipes/laser_
c04b6ad48ff9e3a3e568f3b2fcc3eb6954ee04a6 data/industrialforegoing/recipes/laser_drill_ore/ores/arcane.json
7ebd9c0c04dd8203b262756b3d7de0fe031aab0b data/industrialforegoing/recipes/laser_drill_ore/ores/bitumen.json
9433e8dc94616f5ee60ed268b07761e73a4125eb data/industrialforegoing/recipes/laser_drill_ore/ores/cinnabar.json
225e946b9329975efb01892c489114810286dd7f data/industrialforegoing/recipes/laser_drill_ore/ores/draconium.json
48979b5ea08762752ce9e456cac3094091f4f00d data/industrialforegoing/recipes/laser_drill_ore/ores/draconium.json
455f8955cc7340a58c3cd3ca87ad4d0224b046f4 data/industrialforegoing/recipes/laser_drill_ore/ores/fluorite.json
509a42763d5dc2c3b191f1cbf6b767bfa1818b02 data/industrialforegoing/recipes/laser_drill_ore/ores/niter.json
4dc21472f8183148bf65d5a6b6d798a150690be6 data/industrialforegoing/recipes/laser_drill_ore/ores/peridot.json
Expand All @@ -95,11 +95,11 @@ da8f8ad50ae07882efc3cc351b2b73a4c0b1d084 data/industrialforegoing/recipes/laser_
4ab3581ad0aa8df18ed90343edbdc561f8476958 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/osmium.json
ed404e550f07f6935ebd8454a5f9db903f775cb7 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/platinum.json
0df626d3246810813093185a349abae680185cd7 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/pyrite.json
bcdf66a104cbcd3230ac20df3f6faac2078bff04 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/sheldonite.json
41d33ad8b448d82bbe160256793278b0d6afee11 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/sheldonite.json
3e3b445e83bfb7211240f8ab69a57861bb1cf4aa data/industrialforegoing/recipes/laser_drill_ore/raw_materials/silver.json
1b9d2ad49c1968f6f4569bbe9700aefccd41bf41 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/tetrahedrite.json
c83076227a472bf77cb14c2047f1537c9e10d9d1 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/tin.json
28edb5ffb344915a51c1edebd57910a22ac4e32f data/industrialforegoing/recipes/laser_drill_ore/raw_materials/tungsten.json
f04ac0255b11df77aefb63669ebef608d6c45561 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/tungsten.json
da8d278159b12d8b81ec34639118637095d8bb9c data/industrialforegoing/recipes/laser_drill_ore/raw_materials/uranium.json
8106837eb4bd3e92befdffe0738344d3a25fe105 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/yellorite.json
3541011ea411945c16294a925a3ce6071a8b3779 data/industrialforegoing/recipes/laser_drill_ore/raw_materials/yellorium.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2023-07-29T16:46:10.13545 Recipes
// 1.20.1 2024-06-24T21:25:49.0568937 Recipes
c8f846bcd9160f716825ea42b439dea11e0ca891 data/industrialforegoing/advancements/recipes/misc/dryrubber.json
a6b4e1ab72ec8541dabe29faaa7da3e48f7a4049 data/industrialforegoing/advancements/recipes/misc/laser_lens_black_recolor.json
ec8c71020b9cc7203af2fe111e7aaa4641844cc9 data/industrialforegoing/advancements/recipes/misc/laser_lens_blue_recolor.json
Expand Down Expand Up @@ -74,8 +74,9 @@ f0983f5553778f6515aae7e480b0445e849cdce0 data/industrialforegoing/recipes/laser_
1911650b20a7e168c0f3a9bd57357c62a0d0f67e data/industrialforegoing/recipes/laser_lens_red_recolor.json
8df2405341d74e993701da5085f11efe3ae3d1a2 data/industrialforegoing/recipes/laser_lens_white_recolor.json
394567cca53b8f25ccae6350cba00aa1cb7f7e00 data/industrialforegoing/recipes/laser_lens_yellow_recolor.json
6732576016603d2d039c31d1f38d4423f254e580 data/industrialforegoing/recipes/latex_processing_unit.json
1b271bc61262eb71c394869c48dc610febd3bbc9 data/industrialforegoing/recipes/latex_processing_unit.json
9c783901b9c73d40e8a69557efd916565ab09409 data/industrialforegoing/recipes/machine_frame_pity.json
33f51917bd4c30ea099ae6a87d7b424892801215 data/industrialforegoing/recipes/machine_settings_copier.json
4f2634c9360208c6948a44b0fc9d8737f3fc0524 data/industrialforegoing/recipes/marine_fisher.json
1cd82fc5b83dacfeee89dbbc80e8726a20632a25 data/industrialforegoing/recipes/material_stonework_factory.json
e685cce4190d4872918e949cf7fa3a9ecefb0e13 data/industrialforegoing/recipes/meat_feeder.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 1.20.1 2023-07-29T16:46:10.1359 Tags for minecraft:block mod id industrialforegoing
// 1.20.1 2024-06-24T21:25:49.0593931 Tags for minecraft:block mod id industrialforegoing
d19fb5f318758fdaef5883eac670afb1d488f5ac data/industrialforegoing/tags/blocks/machine_frame/advanced.json
078014cbf879ad3b7979dfd739a4f4a9f9436050 data/industrialforegoing/tags/blocks/machine_frame/pity.json
3fc18d8c3f4e2763c5bacb8d3a7d34208cb0aac0 data/industrialforegoing/tags/blocks/machine_frame/simple.json
62c1d369f5daa4c5411fce7042ba70e62cc604cc data/industrialforegoing/tags/blocks/machine_frame/supreme.json
978c5cd1bafc1fdb56371e35cc3ce4b6759ab456 data/minecraft/tags/blocks/dirt.json
8c73051e1ec462f521ee0e5ce8dffca2b809994a data/minecraft/tags/blocks/mineable/pickaxe.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"item": "industrialforegoing:laser_lens10"
},
"output": {
"tag": "forge:ores/ores/draconium"

This comment has been minimized.

Copy link
@Christofmeg

Christofmeg Sep 10, 2024

Contributor

This fixes #1441

"tag": "forge:ores/draconium"
},
"pointer": 0,
"rarity": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"item": "industrialforegoing:laser_lens0"
},
"output": {
"tag": "forge:ores/raw_materials/sheldonite"
"tag": "forge:raw_materials/sheldonite"
},
"pointer": 0,
"rarity": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"item": "industrialforegoing:laser_lens15"
},
"output": {
"tag": "forge:ores/raw_materials/tungsten"
"tag": "forge:raw_materials/tungsten"
},
"pointer": 0,
"rarity": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"type": "forge:conditional",
"recipes": [
{
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "forge:item_exists",
"item": "industrialforegoing:machine_settings_copier"
}
]
}
],
"recipe": {
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"L": {
"tag": "forge:plastic"
},
"P": {
"item": "minecraft:paper"
},
"R": {
"item": "minecraft:redstone"
}
},
"pattern": [
"PLP",
"LRL",
"PRP"
],
"result": {
"item": "industrialforegoing:machine_settings_copier"
},
"show_notification": true
}
}
]
}
35 changes: 35 additions & 0 deletions src/main/java/com/buuz135/industrial/api/IMachineSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.buuz135.industrial.api;

import com.hrznstudio.titanium.component.inventory.InventoryComponent;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

import java.util.ArrayList;
import java.util.List;

public interface IMachineSettings {

public static CompoundTag writeInventory(InventoryComponent component) {
CompoundTag tag = new CompoundTag();
for (int i = 0; i < component.getSlots(); i++) {
var stack = component.getStackInSlot(i);
if (!stack.isEmpty()) {
tag.put(i + "", stack.save(new CompoundTag()));
}
}
return tag;
}

public static List<ItemStack> readInventory(CompoundTag tag) {
List<ItemStack> stacks = new ArrayList<>();
for (String allKey : tag.getAllKeys()) {
stacks.add(ItemStack.of(tag.getCompound(allKey)));
}
return stacks;
}

void loadSettings(Player player, CompoundTag tag);

void saveSettings(Player player, CompoundTag tag);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
import com.hrznstudio.titanium.component.button.ButtonComponent;
import com.hrznstudio.titanium.component.energy.EnergyStorageComponent;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -118,4 +120,15 @@ public AnimalBabySeparatorTile getSelf() {
return this;
}

@Override
public void saveSettings(Player player, CompoundTag tag) {
tag.putBoolean("ABS_movingAdults", movingAdults);
super.saveSettings(player, tag);
}

@Override
public void loadSettings(Player player, CompoundTag tag) {
if (tag.contains("ABS_movingAdults")) this.movingAdults = tag.getBoolean("ABS_movingAdults");
super.loadSettings(player, tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.hrznstudio.titanium.util.LangUtil;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.DamageSource;
Expand All @@ -53,13 +54,13 @@
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.boss.wither.WitherBoss;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
Expand Down Expand Up @@ -222,4 +223,18 @@ protected EnergyStorageComponent<MobCrusherTile> createEnergyStorage() {
public int getMaxProgress() {
return MobCrusherConfig.maxProgress;
}

@Override
public void saveSettings(Player player, CompoundTag tag) {
tag.putBoolean("MC_drops", dropXP);
super.saveSettings(player, tag);
}

@Override
public void loadSettings(Player player, CompoundTag tag) {
if (tag.contains("MC_drops")) {
this.dropXP = tag.getBoolean("MC_drops");
}
super.loadSettings(player, tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
import com.hrznstudio.titanium.component.inventory.SidedInventoryComponent;
import com.hrznstudio.titanium.item.AugmentWrapper;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ServerLevelAccessor;
Expand Down Expand Up @@ -161,4 +163,18 @@ public void sync() {
public int getMaxProgress() {
return MobDuplicatorConfig.maxProgress;
}

@Override
public void saveSettings(Player player, CompoundTag tag) {
tag.putBoolean("MC_exactCopy", exactCopy);
super.saveSettings(player, tag);
}

@Override
public void loadSettings(Player player, CompoundTag tag) {
if (tag.contains("MC_exactCopy")) {
exactCopy = tag.getBoolean("MC_exactCopy");
}
super.loadSettings(player, tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import com.hrznstudio.titanium.item.AugmentWrapper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -143,4 +145,28 @@ public int getMaxProgress() {
public PlantSowerTile getSelf() {
return this;
}

@Override
public void loadSettings(Player player, CompoundTag tag) {
if (tag.contains("PS_locked")) {
input.setLocked(tag.getBoolean("PS_locked"));
}
if (tag.contains("PS_filter")) {
for (String psFilter : tag.getCompound("PS_filter").getAllKeys()) {
input.getFilter()[Integer.parseInt(psFilter)] = ItemStack.of(tag.getCompound("PS_filter").getCompound(psFilter));
}
}
super.loadSettings(player, tag);
}

@Override
public void saveSettings(Player player, CompoundTag tag) {
tag.putBoolean("PS_locked", input.isLocked());
CompoundTag filterTag = new CompoundTag();
for (int i = 0; i < input.getFilter().length; i++) {
filterTag.put(i + "", input.getFilter()[i].serializeNBT());
}
tag.put("PS_filter", filterTag);
super.saveSettings(player, tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import com.hrznstudio.titanium.component.inventory.SidedInventoryComponent;
import com.hrznstudio.titanium.util.RecipeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
Expand Down Expand Up @@ -178,4 +180,28 @@ public static Pair<Integer, Integer> getSlotPos(int slot) {
public DissolutionChamberTile getSelf() {
return this;
}

@Override
public void loadSettings(Player player, CompoundTag tag) {
if (tag.contains("DC_locked")) {
input.setLocked(tag.getBoolean("DC_locked"));
}
if (tag.contains("DC_filter")) {
for (String psFilter : tag.getCompound("DC_filter").getAllKeys()) {
input.getFilter()[Integer.parseInt(psFilter)] = ItemStack.of(tag.getCompound("DC_filter").getCompound(psFilter));
}
}
super.loadSettings(player, tag);
}

@Override
public void saveSettings(Player player, CompoundTag tag) {
tag.putBoolean("DC_locked", input.isLocked());
CompoundTag filterTag = new CompoundTag();
for (int i = 0; i < input.getFilter().length; i++) {
filterTag.put(i + "", input.getFilter()[i].serializeNBT());
}
tag.put("DC_filter", filterTag);
super.saveSettings(player, tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
import com.hrznstudio.titanium.component.progress.ProgressBarComponent;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -176,4 +178,28 @@ public int getMaxProgress() {
public BioReactorTile getSelf() {
return this;
}

@Override
public void loadSettings(Player player, CompoundTag tag) {
if (tag.contains("BR_locked")) {
input.setLocked(tag.getBoolean("BR_locked"));
}
if (tag.contains("BR_filter")) {
for (String psFilter : tag.getCompound("BR_filter").getAllKeys()) {
input.getFilter()[Integer.parseInt(psFilter)] = ItemStack.of(tag.getCompound("BR_filter").getCompound(psFilter));
}
}
super.loadSettings(player, tag);
}

@Override
public void saveSettings(Player player, CompoundTag tag) {
tag.putBoolean("BR_locked", input.isLocked());
CompoundTag filterTag = new CompoundTag();
for (int i = 0; i < input.getFilter().length; i++) {
filterTag.put(i + "", input.getFilter()[i].serializeNBT());
}
tag.put("BR_filter", filterTag);
super.saveSettings(player, tag);
}
}
Loading

0 comments on commit d077580

Please sign in to comment.