From 18f8b557e6614ee3f76a28d90f8d22185256331c Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Wed, 3 Oct 2018 14:21:19 +0200 Subject: refined automatic bee exchange --- src/main/java/gregtech/common/GT_Proxy.java | 134 ++++++++++++++++------------ 1 file changed, 76 insertions(+), 58 deletions(-) (limited to 'src/main/java/gregtech/common') diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 1e9db7931e..100b5016ab 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1320,81 +1320,99 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { if (tStack.getTagCompound()!= null && (tStack.getTagCompound().getTag("Mate")!= null || tStack.getTagCompound().getTag("Genome")!= null )) { - String identifier = ""; + String orgMate = ""; if(tStack.getTagCompound().getTag("Mate")!= null) - identifier = (tStack.getTagCompound().getCompoundTag("Mate")).getTagList("Chromosomes",10).getCompoundTagAt(0).getString("UID1"); + orgMate = (tStack.getTagCompound().getCompoundTag("Mate")).getTagList("Chromosomes",10).getCompoundTagAt(0).getString("UID1"); - String identifier2 = identifier; + String orgGen = orgMate; if(tStack.getTagCompound().getTag("Genome")!= null) - identifier2 = (tStack.getTagCompound().getCompoundTag("Genome")).getTagList("Chromosomes",10).getCompoundTagAt(0).getString("UID1"); + orgGen = (tStack.getTagCompound().getCompoundTag("Genome")).getTagList("Chromosomes",10).getCompoundTagAt(0).getString("UID1"); - if (identifier.contains("gendustry") || identifier2.contains("gendustry")) { + final boolean[] yn = {orgMate.contains("gendustry"),orgGen.contains("gendustry")}; + + if (yn[0] || yn[1]) { final NBTTagCompound NBTTAGCOMPOUND = (NBTTagCompound) tStack.getTagCompound().copy(); //MATE - final NBTTagCompound MATE = NBTTAGCOMPOUND.getCompoundTag("Mate"); - final NBTTagList chromosomesMate = MATE.getTagList("Chromosomes",10); - final NBTTagCompound species = chromosomesMate.getCompoundTagAt(0); + if (yn[0]) { + final NBTTagCompound MATE = NBTTAGCOMPOUND.getCompoundTag("Mate"); + final NBTTagList chromosomesMate = MATE.getTagList("Chromosomes", 10); + final NBTTagCompound species = chromosomesMate.getCompoundTagAt(0); - String ident1 = species.getString("UID1"); - final String[] split = ident1.split("[.]"); - ident1="gregtech.bee.species"+WordUtils.capitalize(split[2].toLowerCase(Locale.ENGLISH)); + String ident1 = species.getString("UID1"); + final String[] split = ident1.split("[.]"); + ident1 = "gregtech.bee.species" + WordUtils.capitalize(split[2].toLowerCase(Locale.ENGLISH)); - if (AlleleManager.alleleRegistry.getAllele(ident1) == null) - return; + if (AlleleManager.alleleRegistry.getAllele(ident1) == null) + return; - String ident2 = species.getString("UID0"); - final String[] split2 = ident2.split("[.]"); - ident2 = "gregtech.bee.species"+WordUtils.capitalize(split2[2].toLowerCase(Locale.ENGLISH)); - - final NBTTagCompound nuspeciesmate = new NBTTagCompound(); - nuspeciesmate.setString("UID1", ident1); - nuspeciesmate.setString("UID0", ident2); - nuspeciesmate.setByte("Slot", (byte) 0); - - //Genome - final NBTTagCompound genome = NBTTAGCOMPOUND.getCompoundTag("Genome"); - final NBTTagList chromosomesGenome = genome.getTagList("Chromosomes", 10); - final NBTTagCompound speciesGenome = chromosomesGenome.getCompoundTagAt(0); - - String ident1Genome = speciesGenome.getString("UID1"); - final String[] splitGenome = ident1Genome.split("[.]"); - ident1Genome="gregtech.bee.species"+WordUtils.capitalize(splitGenome[2].toLowerCase(Locale.ENGLISH)); - String ident2Genome = speciesGenome.getString("UID0"); - final String[] splitGenome2 = ident2Genome.split("[.]"); - ident2Genome = "gregtech.bee.species"+WordUtils.capitalize(splitGenome2[2].toLowerCase(Locale.ENGLISH)); - - final NBTTagCompound nuspeciesgenome = new NBTTagCompound(); - nuspeciesgenome.setString("UID1", ident1Genome); - nuspeciesgenome.setString("UID0", ident2Genome); - nuspeciesgenome.setByte("Slot", (byte) 0); - - - final NBTTagCompound nuMate2 = new NBTTagCompound(); - final NBTTagList nuMate = new NBTTagList(); - nuMate.appendTag(nuspeciesmate); - for (int j = 1; j < chromosomesMate.tagCount(); j++) { - nuMate.appendTag(chromosomesMate.getCompoundTagAt(j)); - } - nuMate2.setTag("Chromosomes", nuMate); - NBTTAGCOMPOUND.removeTag("Mate"); - NBTTAGCOMPOUND.setTag("Mate", nuMate2); - - final NBTTagCompound nugenome2 = new NBTTagCompound(); - final NBTTagList nuGenome = new NBTTagList(); - nuGenome.appendTag(nuspeciesgenome); - for (int j = 1; j < chromosomesGenome.tagCount(); j++) { - nuGenome.appendTag(chromosomesGenome.getCompoundTagAt(j)); + String ident2 = species.getString("UID0"); + final String[] split2 = ident2.split("[.]"); + ident2 = "gregtech.bee.species"+WordUtils.capitalize(split2[2].toLowerCase(Locale.ENGLISH)); + + if (AlleleManager.alleleRegistry.getAllele(ident2) == null) + return; + + final NBTTagCompound nuspeciesmate = new NBTTagCompound(); + nuspeciesmate.setString("UID1", ident1); + nuspeciesmate.setString("UID0", ident2); + nuspeciesmate.setByte("Slot", (byte) 0); + + final NBTTagCompound nuMate2 = new NBTTagCompound(); + final NBTTagList nuMate = new NBTTagList(); + nuMate.appendTag(nuspeciesmate); + + for (int j = 1; j < chromosomesMate.tagCount(); j++) { + nuMate.appendTag(chromosomesMate.getCompoundTagAt(j)); + } + + nuMate2.setTag("Chromosomes", nuMate); + NBTTAGCOMPOUND.removeTag("Mate"); + NBTTAGCOMPOUND.setTag("Mate", nuMate2); } - nugenome2.setTag("Chromosomes", nuGenome); - NBTTAGCOMPOUND.removeTag("Genome"); - NBTTAGCOMPOUND.setTag("Genome", nugenome2); + if (yn[1]) { + //Genome + final NBTTagCompound genome = NBTTAGCOMPOUND.getCompoundTag("Genome"); + final NBTTagList chromosomesGenome = genome.getTagList("Chromosomes", 10); + final NBTTagCompound speciesGenome = chromosomesGenome.getCompoundTagAt(0); + String ident1Genome = speciesGenome.getString("UID1"); + final String[] splitGenome = ident1Genome.split("[.]"); + ident1Genome = "gregtech.bee.species" + WordUtils.capitalize(splitGenome[2].toLowerCase(Locale.ENGLISH)); + + if (AlleleManager.alleleRegistry.getAllele(ident1Genome) == null) + return; + + String ident2Genome = speciesGenome.getString("UID0"); + final String[] splitGenome2 = ident2Genome.split("[.]"); + ident2Genome = "gregtech.bee.species" + WordUtils.capitalize(splitGenome2[2].toLowerCase(Locale.ENGLISH)); + + if (AlleleManager.alleleRegistry.getAllele(ident2Genome) == null) + return; + + final NBTTagCompound nuspeciesgenome = new NBTTagCompound(); + nuspeciesgenome.setString("UID1", ident1Genome); + nuspeciesgenome.setString("UID0", ident2Genome); + nuspeciesgenome.setByte("Slot", (byte) 0); + + final NBTTagCompound nugenome2 = new NBTTagCompound(); + final NBTTagList nuGenome = new NBTTagList(); + nuGenome.appendTag(nuspeciesgenome); + + for (int j = 1; j < chromosomesGenome.tagCount(); j++) { + nuGenome.appendTag(chromosomesGenome.getCompoundTagAt(j)); + } + + nugenome2.setTag("Chromosomes", nuGenome); + NBTTAGCOMPOUND.removeTag("Genome"); + NBTTAGCOMPOUND.setTag("Genome", nugenome2); + } tStack.setTagCompound(new NBTTagCompound()); tStack.setTagCompound(NBTTAGCOMPOUND); } + else return; } GT_OreDictUnificator.setStack(true, tStack); -- cgit