diff options
author | Tec <daniel112092@gmail.com> | 2019-07-13 20:30:57 +0200 |
---|---|---|
committer | Tec <daniel112092@gmail.com> | 2019-07-13 20:30:57 +0200 |
commit | e7d27642960690b73044dd5ecf9227d43a88fcbb (patch) | |
tree | 75472e642db25ff11e4e50502f291c4f8380111b | |
parent | 8f159adc12a15e8e7e2ebfc44acc69058128d064 (diff) | |
parent | 99708323b391b108d035ba483da82f4aa2211b1c (diff) | |
download | GT5-Unofficial-e7d27642960690b73044dd5ecf9227d43a88fcbb.tar.gz GT5-Unofficial-e7d27642960690b73044dd5ecf9227d43a88fcbb.tar.bz2 GT5-Unofficial-e7d27642960690b73044dd5ecf9227d43a88fcbb.zip |
Merge branch 'betterParametrizers' into BassAddons
# Conflicts:
# src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java
# src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java
31 files changed, 420 insertions, 124 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 6f1c4fc7a0..337f493801 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -4,6 +4,7 @@ import com.github.technus.tectech.loader.MainLoader; import com.github.technus.tectech.loader.TecTechConfig; import com.github.technus.tectech.mechanics.ConvertFloat; import com.github.technus.tectech.mechanics.ConvertInteger; +import com.github.technus.tectech.mechanics.chunkData.ChunkDataHandler; import com.github.technus.tectech.mechanics.elementalMatter.core.commands.GiveEM; import com.github.technus.tectech.mechanics.elementalMatter.core.commands.ListEM; import com.github.technus.tectech.proxy.CommonProxy; @@ -34,6 +35,8 @@ public class TecTech { private static IngameErrorLog moduleAdminErrorLogs; public static TecTechConfig configTecTech; + public static ChunkDataHandler chunkDataHandler=new ChunkDataHandler(); + /** * For Loader.isModLoaded checks during the runtime */ @@ -93,4 +96,9 @@ public class TecTech { pEvent.registerServerCommand(new GiveEM()); } } + + @Mod.EventHandler + public void onServerStarting(FMLServerStartingEvent aEvent) { + chunkDataHandler.onServerStarting(); + } } diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index c550203874..e333e70137 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -41,7 +41,7 @@ public final class Util { @SuppressWarnings("ComparatorMethodParameterNotUsed") public static <K, V extends Comparable<? super V>> SortedSet<Map.Entry<K, V>> entriesSortedByValues(Map<K, V> map) { - SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<Map.Entry<K, V>>( + SortedSet<Map.Entry<K, V>> sortedEntries = new TreeSet<>( (e1, e2) -> { int res = e1.getValue().compareTo(e2.getValue()); return res != 0 ? res : 1; // Special fix to preserve items with equal values @@ -1159,7 +1159,7 @@ public final class Util { c++;//depth } output.add("}"); - return output.toArray(new String[output.size()]); + return output.toArray(new String[0]); } private static final Pattern matchE_ = Pattern.compile("(E,(E,)+)"); diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java index 91523326db..da930a1d79 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/elementalMatter/definitions/AspectDefinitionCompatEnabled.java @@ -30,7 +30,7 @@ public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat aspectToDef.put("perditio",magic_entropy); ArrayList<Aspect> list=Aspect.getCompoundAspects(); - Aspect[] array= list.toArray(new Aspect[list.size()]); + Aspect[] array= list.toArray(new Aspect[0]); while (!list.isEmpty()) { for (Aspect aspect : array) { if (list.contains(aspect)) { diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java index 884436a144..425849668d 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -239,14 +239,11 @@ public final class MainLoader { } public static void addAfterGregTechPostLoadRunner() { - GregTech_API.sAfterGTPostload.add(new Runnable() { - @Override - public void run() { - if(TecTech.configTecTech.NERF_FUSION) { - FixBrokenFusionRecipes(); - } - GT_MetaTileEntity_EM_collider.setValues(getFuelValue(Materials.Helium.getPlasma(125))); + GregTech_API.sAfterGTPostload.add(() -> { + if(TecTech.configTecTech.NERF_FUSION) { + FixBrokenFusionRecipes(); } + GT_MetaTileEntity_EM_collider.setValues(getFuelValue(Materials.Helium.getPlasma(125))); }); } diff --git a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java index dcd7f526d7..f96794c795 100644 --- a/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/thing/MachineLoader.java @@ -17,7 +17,6 @@ import net.minecraft.item.ItemStack; import static com.github.technus.tectech.CommonValues.V;
import static com.github.technus.tectech.thing.CustomItemList.*;
-import static com.github.technus.tectech.thing.CustomItemList.eM_dynamotunnel9001;
/**
* Created by danie_000 on 16.11.2016.
diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java new file mode 100644 index 0000000000..f0669431a9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java @@ -0,0 +1,32 @@ +package com.github.technus.tectech.mechanics.anomaly; + +import com.github.technus.tectech.mechanics.chunkData.ChunkDataHandler; +import com.github.technus.tectech.mechanics.chunkData.ChunkMetaDataHandler; +import cpw.mods.fml.common.gameevent.TickEvent; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.HashMap; + +public class AnomalyHandler implements ChunkMetaDataHandler { + + @Override + public String getTagName() { + return "Anomaly"; + } + + @Override + public void mergeData(NBTTagCompound target, NBTTagCompound loadedData) { + target.setInteger("intensity", + target.getInteger("intensity")+loadedData.getInteger("intensity")); + } + + @Override + public NBTTagCompound createData() { + return new NBTTagCompound(); + } + + @Override + public void TickData(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.ServerTickEvent event) { + + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkDataHandler.java b/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkDataHandler.java new file mode 100644 index 0000000000..50a92d6178 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkDataHandler.java @@ -0,0 +1,229 @@ +package com.github.technus.tectech.mechanics.chunkData; + +import cpw.mods.fml.common.gameevent.TickEvent; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.event.world.ChunkDataEvent; + +import java.util.*; + +public class ChunkDataHandler { + private final String BASE_TAG_NAME ="TecTechData"; + private final HashMap<Integer,HashMap<ChunkCoordIntPair, NBTChunk>> dimensionWiseChunkData=new HashMap<>(); + private final HashMap<String,HashMap<Integer,ChunkHashMap >> dimensionWiseMetaChunkData=new HashMap<>(); + private final HashMap<String,ChunkMetaDataHandler> metaDataHandlerHashMap =new HashMap<>(); + + public void handleChunkSaveEvent(ChunkDataEvent.Save event) { + HashMap<ChunkCoordIntPair, NBTChunk> dimensionData=dimensionWiseChunkData.get(event.world.provider.dimensionId); + NBTChunk chunkData =dimensionData!=null?dimensionData.get(event.getChunk().getChunkCoordIntPair()):null; + if(chunkData==null) { + event.getData().removeTag(BASE_TAG_NAME); + } else { + chunkData.isLoaded=true; + event.getData().setTag(BASE_TAG_NAME,chunkData.data); + } + } + + public void handleChunkLoadEvent(ChunkDataEvent.Load event) { + NBTTagCompound loadedTag=event.getData().getCompoundTag(BASE_TAG_NAME); + if(loadedTag.hasNoTags()){ + return; + } + + int dimId=event.world.provider.dimensionId; + HashMap<ChunkCoordIntPair, NBTChunk> dimensionMemory= + dimensionWiseChunkData.computeIfAbsent(dimId, this::createDimensionData); + + ChunkCoordIntPair chunkCoordIntPair=event.getChunk().getChunkCoordIntPair(); + NBTChunk chunkMemory =dimensionMemory.get(chunkCoordIntPair); + Set<String> loadedKeys=loadedTag.func_150296_c(); + + if(chunkMemory==null) { + chunkMemory=new NBTChunk(loadedTag,true); + dimensionMemory.put(chunkCoordIntPair,chunkMemory); + for (String s :loadedKeys) { + dimensionWiseMetaChunkData.get(s).get(dimId).putLoaded(chunkCoordIntPair, loadedTag.getCompoundTag(s)); + } + }else if(!chunkMemory.isLoaded) { + chunkMemory.isLoaded=true; + + Set<String> tagsDuplicated=new HashSet(loadedKeys); + tagsDuplicated.retainAll(chunkMemory.data.func_150296_c()); + + if (tagsDuplicated.isEmpty()) { + for (String s:loadedKeys) { + NBTTagCompound tag=loadedTag.getCompoundTag(s); + chunkMemory.data.setTag(s,tag); + dimensionWiseMetaChunkData.get(s).get(dimId).putLoaded(chunkCoordIntPair,tag); + } + } else { + for (String s : loadedKeys) { + NBTTagCompound memory=chunkMemory.data.getCompoundTag(s); + if(tagsDuplicated.contains(s)){ + metaDataHandlerHashMap.get(s).mergeData(memory,loadedTag.getCompoundTag(s)); + }else { + chunkMemory.data.setTag(s,loadedTag.getCompoundTag(s)); + dimensionWiseMetaChunkData.get(s).get(dimId).putLoaded(chunkCoordIntPair,memory); + } + } + } + } + } + + public void tickData(TickEvent.ServerTickEvent event){ + dimensionWiseMetaChunkData.forEach((k, v) -> metaDataHandlerHashMap.get(k).TickData(v, event)); + } + + public void onServerStarting() { + dimensionWiseChunkData.clear(); + dimensionWiseMetaChunkData.clear(); + } + + public void registerChunkMetaDataHandler(ChunkMetaDataHandler handler){ + metaDataHandlerHashMap.put(handler.getTagName(),handler); + dimensionWiseMetaChunkData.put(handler.getTagName(),new HashMap<>()); + } + + public NBTTagCompound getChunkData(ChunkMetaDataHandler handler, World world, Chunk chunk){ + return getChunkData(handler,world.provider.dimensionId,chunk.getChunkCoordIntPair()); + } + + public NBTTagCompound getChunkData(ChunkMetaDataHandler handler, int world, ChunkCoordIntPair chunk){ + return dimensionWiseMetaChunkData.get(handler.getTagName()).get(world).get(chunk); + } + + public NBTTagCompound computeIfAbsentChunkData(ChunkMetaDataHandler handler, World world, Chunk chunk){ + return computeIfAbsentChunkData(handler,world.provider.dimensionId,chunk.getChunkCoordIntPair()); + } + + public NBTTagCompound computeIfAbsentChunkData(ChunkMetaDataHandler handler, int world, ChunkCoordIntPair chunk){ + return dimensionWiseMetaChunkData.get(handler.getTagName()).get(world) + .computeIfAbsent(chunk,chunkCoordIntPair -> handler.createData()); + } + + public HashMap<Integer,ChunkHashMap> getChunkData(ChunkMetaDataHandler chunkMetaDataHandler){ + return dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()); + } + + public ChunkHashMap getChunkData(ChunkMetaDataHandler chunkMetaDataHandler,World world){ + return dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()).get(world.provider.dimensionId); + } + + public ChunkHashMap getChunkData(ChunkMetaDataHandler chunkMetaDataHandler,int world){ + return dimensionWiseMetaChunkData.get(chunkMetaDataHandler.getTagName()).get(world); + } + + private HashMap<ChunkCoordIntPair, NBTChunk> createDimensionData(Integer dim) { + HashMap<ChunkCoordIntPair, NBTChunk> map = new HashMap<>(); + for (String meta : metaDataHandlerHashMap.keySet()) { + dimensionWiseMetaChunkData.get(meta).put(dim, new ChunkHashMap(meta, map)); + } + return map; + } + + public static class ChunkHashMap implements Map<ChunkCoordIntPair,NBTTagCompound>{ + private final HashMap<ChunkCoordIntPair,NBTChunk> storage; + private final HashMap<ChunkCoordIntPair,NBTTagCompound> storageMeta=new HashMap<>(1024); + private final String meta; + + private ChunkHashMap(String meta, HashMap<ChunkCoordIntPair, NBTChunk> storage) { + this.storage =storage; + this.meta=meta; + } + + private void putLoaded(ChunkCoordIntPair key, NBTTagCompound value) { + storageMeta.put(key, value); + } + + @Override + public NBTTagCompound remove(Object key) { + NBTTagCompound compound=storageMeta.remove(key); + if(compound!=null) { + NBTChunk chunk = storage.get(key); + chunk.data.removeTag(meta); + if(chunk.data.hasNoTags()){ + storage.remove(key); + } + } + return compound; + } + + @Override + public NBTTagCompound put(ChunkCoordIntPair key, NBTTagCompound value) { + NBTChunk chunk = storage.get(key); + if(chunk==null){ + NBTTagCompound base=new NBTTagCompound(); + base.setTag(meta,value); + storage.put(key,new NBTChunk(base,false)); + }else { + chunk.data.setTag(meta,value); + } + return storageMeta.put(key, value); + } + + @Override + public int size() { + return storageMeta.size(); + } + + @Override + public boolean isEmpty() { + return storageMeta.isEmpty(); + } + + @Override + public NBTTagCompound get(Object key) { + return storageMeta.get(key); + } + + @Override + public void clear() { + entrySet().forEach(this::remove); + } + + @Override + public void putAll(Map<? extends ChunkCoordIntPair, ? extends NBTTagCompound> m) { + m.forEach(this::put); + } + + @Override + public boolean containsKey(Object key) { + return storageMeta.containsKey(key); + } + + @Override + public boolean containsValue(Object value) { + return storageMeta.containsValue(value); + } + + @Override + public Set<ChunkCoordIntPair> keySet() { + return storageMeta.keySet(); + } + + @Override + public Collection<NBTTagCompound> values() { + return storageMeta.values(); + } + + @Override + public Set<Entry<ChunkCoordIntPair, NBTTagCompound>> entrySet() { + return storageMeta.entrySet(); + } + } + + private static class NBTChunk { + private final NBTTagCompound data; + private boolean isLoaded; + + private NBTChunk(NBTTagCompound data, boolean isLoaded) { + if(data==null){ + data=new NBTTagCompound(); + } + this.data = data; + this.isLoaded = isLoaded; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkMetaDataHandler.java b/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkMetaDataHandler.java new file mode 100644 index 0000000000..420f24f46d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/chunkData/ChunkMetaDataHandler.java @@ -0,0 +1,14 @@ +package com.github.technus.tectech.mechanics.chunkData; + +import cpw.mods.fml.common.gameevent.TickEvent; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.HashMap; + +public interface ChunkMetaDataHandler { + String getTagName(); + void mergeData(NBTTagCompound target, NBTTagCompound loadedData); + NBTTagCompound createData(); + void TickData(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.ServerTickEvent event); +} + diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java index 7f56ee8e5b..7d5e079876 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalDecay.java @@ -8,7 +8,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElem * Created by danie_000 on 22.10.2016. */ public final class cElementalDecay { - public static final cElementalDecay[] noDecay = (cElementalDecay[]) null; + public static final cElementalDecay[] noDecay = null; //DECAY IMPOSSIBLE!!! //Do not use regular NULL java will not make it work with varargs!!! //Or cast null into ARRAY type but this static is more convenient!!! diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java index 19f5789804..fb6acec084 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/cElementalStackMap.java @@ -48,12 +48,12 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { public final cElementalDefinitionStack[] values() { Collection<cElementalDefinitionStack> var = map.values(); - return var.toArray(new cElementalDefinitionStack[var.size()]); + return var.toArray(new cElementalDefinitionStack[0]); } public final iElementalDefinition[] keys() { Set<iElementalDefinition> var = map.keySet(); - return var.toArray(new iElementalDefinition[var.size()]); + return var.toArray(new iElementalDefinition[0]); } public long getCountOfAllAmounts(){ diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java index ad8d1ad8c8..333359949f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/GiveEM.java @@ -45,8 +45,7 @@ public class GiveEM implements ICommand { }else{ TecTech.LOGGER.info("Spawninig EM for "+((EntityPlayerMP) sender).getDisplayName()+" - "+Arrays.toString(args)); - ArrayList<String> list=new ArrayList<>(); - list.addAll(Arrays.asList(args)); + ArrayList<String> list = new ArrayList<>(Arrays.asList(args)); String energy=list.remove(0); cElementalDefinitionStack def= getDefinitionStack(list); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java index 9e034f4655..20110c0b0d 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/commands/ListEM.java @@ -29,7 +29,7 @@ public class ListEM implements ICommand { sender.addChatMessage(new ChatComponentText(" Available Classes: tag - name")); Map<Byte,Method> binds= cElementalDefinition.getBindsComplex(); for (Map.Entry<Byte,Method> e:binds.entrySet()) { - sender.addChatMessage(new ChatComponentText(String.valueOf((char)e.getKey().byteValue())+" - "+e.getValue().getReturnType().getSimpleName())); + sender.addChatMessage(new ChatComponentText((char) e.getKey().byteValue() +" - "+e.getValue().getReturnType().getSimpleName())); } }else if(args.length==1){ sender.addChatMessage(new ChatComponentText(" Available Primitives: symbol - name")); diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java index c2fd9a81d4..e191cc0e0a 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipe.java @@ -38,13 +38,7 @@ public class rElementalRecipe implements Comparable<rElementalRecipe> { if(compare!=0) { return compare; } - if(ID>o.ID) { - return 1; - } - if(ID<o.ID) { - return -1; - } - return 0; + return Short.compare(ID, o.ID); } @Override diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java index c289fc94ae..ed5e46f43f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/rElementalRecipeMap.java @@ -15,11 +15,7 @@ public class rElementalRecipeMap {//TODO FIX } public rElementalRecipe put(rElementalRecipe in) { - HashMap<Short, rElementalRecipe> r = recipes.get(in.inEM); - if (r == null) { - r = new HashMap<>(); - recipes.put(in.inEM, r); - } + HashMap<Short, rElementalRecipe> r = recipes.computeIfAbsent(in.inEM, k -> new HashMap<>()); return r.put(in.ID, in);//IF THIS RETURN SHIT, it means that inputs are using the exact same types of matter as input - (non amount wise collision) //It is either bad, or unimportant if you use different id's } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java index bcd46c579a..749d5c687b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/templates/cElementalPrimitive.java @@ -251,13 +251,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { public final int compareTo(iElementalDefinition o) { if (getClassType() == o.getClassType()) { int oID = ((cElementalPrimitive) o).ID; - if (ID > oID) { - return 1; - } - if (ID < oID) { - return -1; - } - return 0; + return Integer.compare(ID, oID); } return compareClassID(o); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java index 99e80b7be2..86d31bfb1b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/dAtomDefinition.java @@ -396,35 +396,35 @@ public final class dAtomDefinition extends cElementalDefinition { switch (decayMode) { case -2: if(TecTech.RANDOM.nextBoolean() && ElectronCapture(decaysList)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } else if(PbetaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; case -1: if(Emmision(decaysList, dHadronDefinition.hadron_p1)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; case 0: if(alphaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; case 1: if(Emmision(decaysList, dHadronDefinition.hadron_n1)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; case 2: if(MbetaDecay(decaysList)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } break; default: if(decayMode>8){ if(iaeaDecay(decaysList,0)) { - return decaysList.toArray(new cElementalDecay[decaysList.size()]); + return decaysList.toArray(new cElementalDecay[0]); } return getDecayArray(decaysList,decayMode- BYTE_OFFSET,false); } @@ -1167,7 +1167,7 @@ public final class dAtomDefinition extends cElementalDefinition { if (iaeaDefinitionExistsAndHasEnergyLevels) { ArrayList<cElementalDecay> decays=new ArrayList<>(4); if(iaeaDecay(decays,energyLevel)){ - return decays.toArray(new cElementalDecay[decays.size()]); + return decays.toArray(new cElementalDecay[0]); } } if(energyLevel< Math.abs(charge)/3+neutralCount) { @@ -1257,7 +1257,7 @@ public final class dAtomDefinition extends cElementalDefinition { decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); } } - return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[decaysInto.size()])), deadEnd}; + return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), deadEnd}; } //@Override @@ -1357,10 +1357,7 @@ public final class dAtomDefinition extends cElementalDefinition { float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); iaeaNuclide nuclide = iaeaNuclide.get(element, isotope); if (rawLifeTime >= STABLE_RAW_LIFE_TIME || nuclide != null && nuclide.halfTime >= STABLE_RAW_LIFE_TIME) { - TreeSet<Integer> isotopes = stableIsotopes.get(element); - if (isotopes == null) { - stableIsotopes.put(element, isotopes = new TreeSet<>()); - } + TreeSet<Integer> isotopes = stableIsotopes.computeIfAbsent(element, k -> new TreeSet<>()); isotopes.add(isotope); } } @@ -1375,10 +1372,7 @@ public final class dAtomDefinition extends cElementalDefinition { int izoDiff = isotope - Isotope; int izoDiffAbs = Math.abs(izoDiff); float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - TreeMap<Float, Integer> isotopes = mostStableUnstableIsotopes.get(element); - if (isotopes == null) { - mostStableUnstableIsotopes.put(element, isotopes = new TreeMap<>()); - } + TreeMap<Float, Integer> isotopes = mostStableUnstableIsotopes.computeIfAbsent(element, k -> new TreeMap<>()); isotopes.put(rawLifeTime, isotope); } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java index 10c537ed55..ac44f9242e 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/atom/iaeaNuclide.java @@ -134,7 +134,7 @@ public final class iaeaNuclide { if(energeticStates==null || energeticStates.isEmpty()) { energeticStatesArray = empty; } else { - energeticStatesArray = energeticStates.values().toArray(new energeticState[energeticStates.size()]); + energeticStatesArray = energeticStates.values().toArray(new energeticState[0]); } } @@ -273,7 +273,7 @@ public final class iaeaNuclide { //if(DEBUG_MODE){ // System.out.println("INVALID SUM?\t"+normalization+"\t"+decay1+"\t"+chance1+"\t"+decay2+"\t"+chance2+"\t"+decay3+"\t"+chance3); //} - return decays.values().toArray(new iaeaDecay[decays.size()]); + return decays.values().toArray(new iaeaDecay[0]); } public static final class iaeaDecay{ diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java index 6b98cd2a99..1d617fcdb9 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/definitions/complex/hadron/dHadronDefinition.java @@ -198,7 +198,7 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } } return new cElementalDecay[]{ - new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[decaysInto.size()])), + new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[0])), eBosonDefinition.deadEnd }; } diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java index a797a65d09..1c75dceec7 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java @@ -365,7 +365,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { } } } - items = tDisplayStacks.toArray(new ItemStack[tDisplayStacks.size()]); + items = tDisplayStacks.toArray(new ItemStack[0]); if (items.length == 0) { items = new ItemStack[]{new ItemStack(Blocks.fire)}; } diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java index 8154816cfc..e9624f1b33 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java @@ -365,7 +365,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { } } } - items = tDisplayStacks.toArray(new ItemStack[tDisplayStacks.size()]); + items = tDisplayStacks.toArray(new ItemStack[0]); if (items.length == 0) { items = new ItemStack[]{new ItemStack(Blocks.fire)}; } diff --git a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java index 598a8b148f..31b1b1824c 100644 --- a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java @@ -1,5 +1,8 @@ package com.github.technus.tectech.proxy; +import com.github.technus.tectech.TecTech; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.network.IGuiHandler; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; @@ -9,6 +12,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraft.world.WorldServer; +import net.minecraftforge.event.world.ChunkDataEvent; public class CommonProxy implements IGuiHandler { public void registerRenderInfo() {} @@ -81,4 +85,19 @@ public class CommonProxy implements IGuiHandler { } return false; } + + @SubscribeEvent + public void handleChunkSaveEvent(ChunkDataEvent.Save event) { + TecTech.chunkDataHandler.handleChunkSaveEvent(event); + } + + @SubscribeEvent + public void handleChunkLoadEvent(ChunkDataEvent.Load event) { + TecTech.chunkDataHandler.handleChunkLoadEvent(event); + } + + @SubscribeEvent + public void onServerTickEvent(TickEvent.ServerTickEvent aEvent) { + TecTech.chunkDataHandler.tickData(aEvent); + } } diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java index 57d479a705..b5b5dd82b9 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java @@ -165,8 +165,8 @@ public class TT_recipe extends GT_Recipe { } public static class GT_Recipe_MapTT extends GT_Recipe.GT_Recipe_Map { - public static GT_Recipe_MapTT sResearchableFakeRecipes =new GT_Recipe_MapTT(new HashSet<GT_Recipe>(32), "gt.recipe.researchStation", "Research station", (String)null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1,1,0,1,"", 1, "", true, false);//nei to false - using custom handler - public static GT_Recipe_MapTT sScannableFakeRecipes = new GT_Recipe_MapTT(new HashSet<GT_Recipe>(32),"gt.recipe.em_scanner","EM Scanner Research",(String)null,"gregtech:textures/gui/multimachines/ResearchFake",1,1,1,0,1,"",1,"",true,false); + public static GT_Recipe_MapTT sResearchableFakeRecipes =new GT_Recipe_MapTT(new HashSet<>(32), "gt.recipe.researchStation", "Research station", null, "gregtech:textures/gui/multimachines/ResearchFake", 1, 1,1,0,1,"", 1, "", true, false);//nei to false - using custom handler + public static GT_Recipe_MapTT sScannableFakeRecipes = new GT_Recipe_MapTT(new HashSet<>(32),"gt.recipe.em_scanner","EM Scanner Research", null,"gregtech:textures/gui/multimachines/ResearchFake",1,1,1,0,1,"",1,"",true,false); public GT_Recipe_MapTT(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java index 4e352a7610..61efea1a0e 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java @@ -115,7 +115,7 @@ public class TT_recipeAdder extends GT_RecipeAdder { computationRequiredPerSec = Short.MAX_VALUE; } TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result")}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); - GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false,tInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result", new Object[0])},aFluidInputs,null,assDuration,assEUt,0,tAlts,true); + GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false,tInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result")},aFluidInputs,null,assDuration,assEUt,0,tAlts,true); GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe.GT_Recipe_AssemblyLine( CustomItemList.UnusedStuff.get(1), totalComputationRequired/computationRequiredPerSec, tInputs, aFluidInputs, aOutput, assDuration, assEUt, tAlts)); return true; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java index 867f814b63..63321a03a4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java @@ -40,7 +40,7 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity private static Textures.BlockIcons.CustomIcon EM_T_ACTIVE; private static Textures.BlockIcons.CustomIcon MufflerEM; private static Textures.BlockIcons.CustomIcon MufflerEMidle; - private float overflowMatter = 0f; + private float overflowMatter; public final float overflowMax; private final float overflowDisperse; @@ -195,7 +195,7 @@ public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity "Contained mass:", EnumChatFormatting.RED + Double.toString(overflowMatter) + EnumChatFormatting.RESET + " eV/c\u00b2 /", EnumChatFormatting.GREEN + Double.toString(overflowMax) + EnumChatFormatting.RESET + " eV/c\u00b2", - "Mass Disposal speed: " + EnumChatFormatting.BLUE + Double.toString(overflowDisperse) + EnumChatFormatting.RESET + " (eV/c\u00b2)/s" + "Mass Disposal speed: " + EnumChatFormatting.BLUE + overflowDisperse + EnumChatFormatting.RESET + " (eV/c\u00b2)/s" }; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java index 06f1866826..b9b589c409 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java @@ -173,35 +173,29 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } }); - PRIMITIVE_FUSE_HANDLERS.put(eQuarkDefinition.class.getName() + '\0' + eQuarkDefinition.class.getName(), new PrimitiveColliderHandler() { - @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { - try { - cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); - defs.putUnify(in1.definition.getStackForm(1)); - defs.putUnify(in2.definition.getStackForm(1)); - dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); - out.putUnify(new cElementalInstanceStack(hadron,Math.min(in1.amount,in2.amount))); - }catch (Exception e){ - out.putUnifyAll(in1,in2); - return; - } - if(in1.amount>in2.amount){ - out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); - }else if (in2.amount>in1.amount){ - out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); - } + PRIMITIVE_FUSE_HANDLERS.put(eQuarkDefinition.class.getName() + '\0' + eQuarkDefinition.class.getName(), (in1, in2, out) -> { + try { + cElementalMutableDefinitionStackMap defs=new cElementalMutableDefinitionStackMap(); + defs.putUnify(in1.definition.getStackForm(1)); + defs.putUnify(in2.definition.getStackForm(1)); + dHadronDefinition hadron = new dHadronDefinition(defs.toImmutable_optimized_unsafeLeavesExposedElementalTree()); + out.putUnify(new cElementalInstanceStack(hadron,Math.min(in1.amount,in2.amount))); + }catch (Exception e){ + out.putUnifyAll(in1,in2); + return; + } + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); } }); - PRIMITIVE_FUSE_HANDLERS.put(ePrimalAspectDefinition.class.getName() + '\0' + ePrimalAspectDefinition.class.getName(), new PrimitiveColliderHandler() { - @Override - public void collide(cElementalInstanceStack in1, cElementalInstanceStack in2, cElementalInstanceStackMap out) { - if (fuseAspects(in1, in2, out)) return; - if(in1.amount>in2.amount){ - out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); - }else if (in2.amount>in1.amount){ - out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); - } + PRIMITIVE_FUSE_HANDLERS.put(ePrimalAspectDefinition.class.getName() + '\0' + ePrimalAspectDefinition.class.getName(), (in1, in2, out) -> { + if (fuseAspects(in1, in2, out)) return; + if(in1.amount>in2.amount){ + out.putUnify(new cElementalInstanceStack(in1.definition,in1.amount-in2.amount)); + }else if (in2.amount>in1.amount){ + out.putUnify(new cElementalInstanceStack(in2.definition,in2.amount-in1.amount)); } }); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index 381df4b893..d34acd1534 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -117,7 +117,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock public boolean checkRecipe_EM(ItemStack itemStack) {//TODO implement instance quantization if (GregTech_API.sPostloadFinished) { ArrayList<ItemStack> storedInputs = getStoredInputs(); - ItemStack[] inI = storedInputs.toArray(new ItemStack[storedInputs.size()]); + ItemStack[] inI = storedInputs.toArray(new ItemStack[0]); if (inI.length > 0) { for (ItemStack is : inI) { //ITEM STACK quantization @@ -156,7 +156,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock } } ArrayList<FluidStack> storedFluids = getStoredFluids(); - FluidStack[] inF = storedFluids.toArray(new FluidStack[storedFluids.size()]); + FluidStack[] inF = storedFluids.toArray(new FluidStack[0]); if (inF.length > 0) { for (FluidStack fs : inF) { aFluidQuantizationInfo aFQI = bTransformationInfo.fluidQuantization.get(fs.getFluid().getID()); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java index 88b24d11ae..e74cef7a34 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java @@ -515,20 +515,20 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB return new String[]{ "Energy Hatches:", EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET + " EU", + EnumChatFormatting.YELLOW + maxEnergy + EnumChatFormatting.RESET + " EU", (mEUt <= 0 ? "Probably uses: " : "Probably makes: ") + - EnumChatFormatting.RED + Integer.toString(Math.abs(mEUt)) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.RED + Math.abs(mEUt) + EnumChatFormatting.RESET + " EU/t at " + EnumChatFormatting.RED + eAmpereFlow + EnumChatFormatting.RESET + " A", "Tier Rating: " + EnumChatFormatting.YELLOW + VN[getMaxEnergyInputTier_EM()] + EnumChatFormatting.RESET + " / " + EnumChatFormatting.GREEN + VN[getMinEnergyInputTier_EM()] + EnumChatFormatting.RESET + " Amp Rating: " + EnumChatFormatting.GREEN + eMaxAmpereFlow + EnumChatFormatting.RESET + " A", "Problems: " + EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + - " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", + " Efficiency: " + EnumChatFormatting.YELLOW + mEfficiency / 100.0F + EnumChatFormatting.RESET + " %", "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, "Computation Available: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET, "Computation Remaining:", EnumChatFormatting.GREEN + Long.toString(computationRemaining / 20L) + EnumChatFormatting.RESET + " / " + - EnumChatFormatting.YELLOW + Long.toString(computationRequired / 20L) + EnumChatFormatting.YELLOW + computationRequired / 20L }; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index 05d496e844..97a56a94cf 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -4,8 +4,6 @@ import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.*; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.NameFunction; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.StatusFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedTexture; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java index dea5030fde..5f5ddf6e4a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java @@ -1,12 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; -import gregtech.api.GregTech_API; +import com.github.technus.tectech.TecTech; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.client.gui.FontRenderer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemDye; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @@ -205,6 +204,30 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach private void LEDdrawP(int x, int y, int i, int j, LedStatus status) { int v = 192, su = 8, sv = 6, u = 11; switch (status) { + case STATUS_WTF: { + int c=counter; + if(c>4){ + c= TecTech.RANDOM.nextInt(5); + } + switch (c) { + case 0: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv);//BLUE + break; + case 1: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (2 + j), su, sv);//cyan + break; + case 2: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (4 + j), su, sv);//green + break; + case 3: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (6 + j), su, sv);//orangeyello + break; + case 4: + drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv);//redd + break; + } + break; + } case STATUS_WRONG: //fallthrough if (counter < 2) { drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv);//blue @@ -254,16 +277,16 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach break; case STATUS_UNUSED: default: - if (GregTech_API.sColoredGUI && this.mContainer.mTileEntity != null) { - int tColor = this.mContainer.mTileEntity.getColorization() & 15; - if (tColor < ItemDye.field_150922_c.length) { - tColor = ItemDye.field_150922_c[tColor]; - GL11.glColor4f((float)(tColor >> 16 & 255) / 255.0F, (float)(tColor >> 8 & 255) / 255.0F, (float)(tColor & 255) / 255.0F, 1F); - } - } - drawTexturedModalRect(x + su * i, y + sv * j, 212, 96, su+2, sv+2); - GL11.glColor4f(1f, 1f, 1f, 1f); - break; + //if (GregTech_API.sColoredGUI && this.mContainer.mTileEntity != null) { + // int tColor = this.mContainer.mTileEntity.getColorization() & 15; + // if (tColor < ItemDye.field_150922_c.length) { + // tColor = ItemDye.field_150922_c[tColor]; + // GL11.glColor4f((float)(tColor >> 16 & 255) / 255.0F, (float)(tColor >> 8 & 255) / 255.0F, (float)(tColor & 255) / 255.0F, 1F); + // } + //} + //drawTexturedModalRect(x + su * i, y + sv * j, 212, 96, su+2, sv+2); + //GL11.glColor4f(1f, 1f, 1f, 1f); + //break; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index 3b7d4233f2..c2d3ffcf06 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -441,7 +441,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt EnumChatFormatting.YELLOW+ ":" + EnumChatFormatting.AQUA+paramID + EnumChatFormatting.YELLOW+ ":"+ - EnumChatFormatting.AQUA+"I "+parametrization.getStatusIn(hatchNo, paramID).name); + EnumChatFormatting.AQUA+"I "+parametrization.getStatusIn(hatchNo, paramID).name.get()); list.add(EnumChatFormatting.WHITE+"Value: "+ EnumChatFormatting.AQUA+ Util.doubleToString(parametrization.getIn(hatchNo,paramID))); try{ @@ -465,7 +465,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt EnumChatFormatting.YELLOW+ ":" + EnumChatFormatting.AQUA+paramID + EnumChatFormatting.YELLOW+ ":"+ - EnumChatFormatting.AQUA+"O "+parametrization.getStatusOut(hatchNo, paramID).name); + EnumChatFormatting.AQUA+"O "+parametrization.getStatusOut(hatchNo, paramID).name.get()); list.add(EnumChatFormatting.WHITE+"Value: "+ EnumChatFormatting.AQUA+Util.doubleToString(parametrization.getOut(hatchNo,paramID))); try{ diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java index f2eebe3f4b..5fce024cfc 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/LedStatus.java @@ -1,22 +1,28 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; +import com.github.technus.tectech.TecTech; import net.minecraft.util.EnumChatFormatting; +import java.util.function.Supplier; + public enum LedStatus { - STATUS_UNUSED(EnumChatFormatting.DARK_GRAY +"Unused",true),// - STATUS_TOO_LOW(EnumChatFormatting.BLUE+"Too Low",false),// - STATUS_LOW(EnumChatFormatting.AQUA+"Low",true),// - STATUS_WRONG(EnumChatFormatting.DARK_PURPLE+"Wrong",false),// - STATUS_OK(EnumChatFormatting.GREEN+"Valid",true),// - STATUS_TOO_HIGH(EnumChatFormatting.RED+"Too High",false),// - STATUS_HIGH(EnumChatFormatting.GOLD+"High",true),// - STATUS_UNDEFINED(EnumChatFormatting.GRAY+"Unknown",false), - STATUS_NEUTRAL(EnumChatFormatting.WHITE+"Neutral",true);// - - public final String name; + STATUS_UNUSED(()->EnumChatFormatting.DARK_GRAY +"Unused",true),// + STATUS_TOO_LOW(()->EnumChatFormatting.BLUE+"Too Low",false),// + STATUS_LOW(()->EnumChatFormatting.AQUA+"Low",true),// + STATUS_WRONG(()->EnumChatFormatting.DARK_PURPLE+"Wrong",false),// + STATUS_OK(()->EnumChatFormatting.GREEN+"Valid",true),// + STATUS_TOO_HIGH(()->EnumChatFormatting.RED+"Too High",false),// + STATUS_HIGH(()->EnumChatFormatting.GOLD+"High",true),// + STATUS_UNDEFINED(()->EnumChatFormatting.GRAY+"Unknown",false), + STATUS_NEUTRAL(()->EnumChatFormatting.WHITE+"Neutral",true),// + STATUS_WTF(()->{ + return LedStatus.values()[TecTech.RANDOM.nextInt(9)].name.get(); + },false);// + + public final Supplier<String> name; public final boolean isOk; - LedStatus(String name,boolean ok){ + LedStatus(Supplier<String> name, boolean ok){ this.name=name; this.isOk=ok; } |