diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2023-06-15 17:53:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-15 17:53:16 +0200 |
commit | cb383c824c3f799e678fb98f29661d79b5a13836 (patch) | |
tree | c27ec3672eb0cb1726565bf28ae2655404496231 /src/main/java/kubatech/tileentity | |
parent | b2c2a6dfe91696d4ecada95e5e43806ddb144ece (diff) | |
download | GT5-Unofficial-cb383c824c3f799e678fb98f29661d79b5a13836.tar.gz GT5-Unofficial-cb383c824c3f799e678fb98f29661d79b5a13836.tar.bz2 GT5-Unofficial-cb383c824c3f799e678fb98f29661d79b5a13836.zip |
Use mixins accessors + some misc fixes (#77)
* Change reflections to mixins
* Wrap witchery checking
* Remove more repeating code
* hmm
* test generation
* test
* client sided
* Update CommandCustomDrops.java
* Update MobRecipeLoader.java
* Save to static variable
* Imports
* Log message
* Convert InfernalHelper to mixin accessors
* Update build.gradle
* One more
* Return class nodes to optimize
* Translations mixin
* Automatically add commands
* Fixes
* Fix https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/12021
* Update kubatech.java
* Update CommonProxy.java
* Unnecessary qualified reference
* Simplify ItemUtils
* Check if single player diffrently
* Remove accessor for infernal-mobs
Diffstat (limited to 'src/main/java/kubatech/tileentity')
2 files changed, 21 insertions, 23 deletions
diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java index 4b86cda1e7..0c8dab2722 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java @@ -31,6 +31,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static kubatech.api.Variables.Author; import static kubatech.api.Variables.StructureHologram; +import static kubatech.api.utils.ItemUtils.readItemStackFromNBT; +import static kubatech.api.utils.ItemUtils.writeItemStackToNBT; import java.io.IOException; import java.lang.ref.WeakReference; @@ -1097,27 +1099,22 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse public NBTTagCompound toNBTTagCompound() { NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setTag("input", input.writeToNBT(new NBTTagCompound())); + aNBT.setTag("input", writeItemStackToNBT(input)); aNBT.setBoolean("isValid", isValid); aNBT.setBoolean("isIC2Crop", isIC2Crop); if (!isIC2Crop) { aNBT.setInteger("crop", Block.getIdFromBlock(crop)); if (customDrops != null && customDrops.size() > 0) { aNBT.setInteger("customDropsCount", customDrops.size()); - for (int i = 0; i < customDrops.size(); i++) aNBT.setTag( - "customDrop." + i, - customDrops.get(i) - .writeToNBT(new NBTTagCompound())); + for (int i = 0; i < customDrops.size(); i++) + aNBT.setTag("customDrop." + i, writeItemStackToNBT(customDrops.get(i))); } aNBT.setInteger("dropscount", drops.size()); - for (int i = 0; i < drops.size(); i++) aNBT.setTag( - "drop." + i, - drops.get(i) - .writeToNBT(new NBTTagCompound())); + for (int i = 0; i < drops.size(); i++) aNBT.setTag("drop." + i, writeItemStackToNBT(drops.get(i))); aNBT.setInteger("optimalgrowth", optimalgrowth); aNBT.setBoolean("needsreplanting", needsreplanting); } else { - if (undercrop != null) aNBT.setTag("undercrop", undercrop.writeToNBT(new NBTTagCompound())); + if (undercrop != null) aNBT.setTag("undercrop", writeItemStackToNBT(undercrop)); aNBT.setInteger("generationscount", generations.size()); for (int i = 0; i < generations.size(); i++) { aNBT.setInteger( @@ -1128,9 +1125,9 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .size(); j++) aNBT.setTag( "generation." + i + "." + j, - generations.get(i) - .get(j) - .writeToNBT(new NBTTagCompound())); + writeItemStackToNBT( + generations.get(i) + .get(j))); } aNBT.setInteger("growthticks", growthticks); aNBT.setBoolean("noHumidity", noHumidity); @@ -1142,29 +1139,28 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse super(null, 3, 3); isIC2Crop = aNBT.getBoolean("isIC2Crop"); isValid = aNBT.getBoolean("isValid"); - input = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("input")); + input = readItemStackFromNBT(aNBT.getCompoundTag("input")); if (!isIC2Crop) { crop = Block.getBlockById(aNBT.getInteger("crop")); if (aNBT.hasKey("customDropsCount")) { int imax = aNBT.getInteger("customDropsCount"); customDrops = new ArrayList<>(imax); for (int i = 0; i < imax; i++) - customDrops.add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("customDrop." + i))); + customDrops.add(readItemStackFromNBT(aNBT.getCompoundTag("customDrop." + i))); } drops = new ArrayList<>(); for (int i = 0; i < aNBT.getInteger("dropscount"); i++) - drops.add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("drop." + i))); + drops.add(readItemStackFromNBT(aNBT.getCompoundTag("drop." + i))); optimalgrowth = aNBT.getInteger("optimalgrowth"); if (optimalgrowth == 0) optimalgrowth = 7; if (aNBT.hasKey("needsreplanting")) needsreplanting = aNBT.getBoolean("needsreplanting"); } else { - if (aNBT.hasKey("undercrop")) - undercrop = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("undercrop")); + if (aNBT.hasKey("undercrop")) undercrop = readItemStackFromNBT(aNBT.getCompoundTag("undercrop")); generations = new ArrayList<>(); for (int i = 0; i < aNBT.getInteger("generationscount"); i++) { generations.add(new ArrayList<>()); for (int j = 0; j < aNBT.getInteger("generation." + i + ".count"); j++) generations.get(i) - .add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("generation." + i + "." + j))); + .add(readItemStackFromNBT(aNBT.getCompoundTag("generation." + i + "." + j))); } growthticks = aNBT.getInteger("growthticks"); noHumidity = aNBT.getBoolean("noHumidity"); diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_MegaIndustrialApiary.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_MegaIndustrialApiary.java index baabda3211..43fea0f182 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_MegaIndustrialApiary.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_MegaIndustrialApiary.java @@ -38,6 +38,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_ import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static kubatech.api.Variables.StructureHologram; import static kubatech.api.Variables.buildAuthorList; +import static kubatech.api.utils.ItemUtils.readItemStackFromNBT; +import static kubatech.api.utils.ItemUtils.writeItemStackToNBT; import java.io.IOException; import java.lang.ref.WeakReference; @@ -1126,7 +1128,7 @@ public class GT_MetaTileEntity_MegaIndustrialApiary } public BeeSimulator(NBTTagCompound tag) { - queenStack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("queenStack")); + queenStack = readItemStackFromNBT(tag.getCompoundTag("queenStack")); isValid = tag.getBoolean("isValid"); drops = new ArrayList<>(); specialDrops = new ArrayList<>(); @@ -1151,7 +1153,7 @@ public class GT_MetaTileEntity_MegaIndustrialApiary public NBTTagCompound toNBTTagCompound() { NBTTagCompound tag = new NBTTagCompound(); - tag.setTag("queenStack", queenStack.writeToNBT(new NBTTagCompound())); + tag.setTag("queenStack", writeItemStackToNBT(queenStack)); tag.setBoolean("isValid", isValid); tag.setInteger("dropssize", drops.size()); for (int i = 0; i < drops.size(); i++) tag.setTag( @@ -1244,7 +1246,7 @@ public class GT_MetaTileEntity_MegaIndustrialApiary } public BeeDrop(NBTTagCompound tag) { - stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("stack")); + stack = readItemStackFromNBT(tag.getCompoundTag("stack")); chance = tag.getFloat("chance"); beeSpeed = tag.getFloat("beeSpeed"); t = tag.getFloat("t"); @@ -1254,7 +1256,7 @@ public class GT_MetaTileEntity_MegaIndustrialApiary public NBTTagCompound toNBTTagCompound() { NBTTagCompound tag = new NBTTagCompound(); - tag.setTag("stack", stack.writeToNBT(new NBTTagCompound())); + tag.setTag("stack", writeItemStackToNBT(stack)); tag.setFloat("chance", chance); tag.setFloat("beeSpeed", beeSpeed); tag.setFloat("t", t); |