diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-08-17 13:31:45 +0200 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-08-17 13:31:45 +0200 |
commit | 4c6858c45f178ff2aa0cb5a74947e90fa5540ca9 (patch) | |
tree | ebc58d060a0e9a4506e5cc32adeb3bd9a793ea58 /src/main | |
parent | 11cb4d041b3364bca9ff5e69e265047b9f928fc1 (diff) | |
download | GT5-Unofficial-4c6858c45f178ff2aa0cb5a74947e90fa5540ca9.tar.gz GT5-Unofficial-4c6858c45f178ff2aa0cb5a74947e90fa5540ca9.tar.bz2 GT5-Unofficial-4c6858c45f178ff2aa0cb5a74947e90fa5540ca9.zip |
fixed CircuitAssemblyLine
+added Gas
+started on fluid generation
+started on forced re-unification
+worked on TileEntity_GTDataServer
Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>
Former-commit-id: c9328571559451e83d31e56d17cdb07fd9e5e008
Diffstat (limited to 'src/main')
10 files changed, 335 insertions, 95 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 068a28b906..d1b2935cf3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -45,10 +45,7 @@ import com.github.bartimaeusnek.bartworks.util.BW_Util; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartedEvent; +import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import gregtech.api.GregTech_API; @@ -133,8 +130,11 @@ public final class MainMod { public void init(FMLInitializationEvent init) { if (FMLCommonHandler.instance().getSide().isClient() && ConfigHandler.tooltips) MinecraftForge.EVENT_BUS.register(new TooltipEventHandler()); - if (FMLCommonHandler.instance().getSide().isServer()) - MinecraftForge.EVENT_BUS.register(new ServerEventHandler()); + if (FMLCommonHandler.instance().getSide().isServer()) { + ServerEventHandler serverEventHandler = new ServerEventHandler(); + MinecraftForge.EVENT_BUS.register(serverEventHandler); +// FMLCommonHandler.instance().bus().register(serverEventHandler); + } new LoaderRegistry().run(); if (ConfigHandler.BioLab) new BioLabLoader().run(); @@ -185,7 +185,7 @@ public final class MainMod { continue; HashSet<ItemStack> inputs = new HashSet<>(); for (ItemStack is : recipe.mInputs) - if (!checkForExplosives(is)) + if (!MainMod.checkForExplosives(is)) inputs.add(is); eicMap.addRecipe(true, inputs.toArray(new ItemStack[0]), recipe.mOutputs, null, null, null, recipe.mDuration, BW_Util.getMachineVoltageFromTier(10), 0); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java index 805ab0a55f..1db2ae5c15 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java @@ -105,6 +105,8 @@ public class GT_TileEntity_CircuitAssemblyLine extends GT_MetaTileEntity_MultiBl } + private final Collection<GT_Recipe> GT_RECIPE_COLLECTION = new HashSet<>(); + @Override public boolean checkRecipe(ItemStack itemStack) { if (this.type.equals(new NBTTagCompound())) @@ -113,11 +115,12 @@ public class GT_TileEntity_CircuitAssemblyLine extends GT_MetaTileEntity_MultiBl if (this.bufferedRecipe != null && this.bufferedRecipe.isRecipeInputEqual(true,false,BW_Util.getFluidsFromInputHatches(this),BW_Util.getItemsFromInputBusses(this))) { BW_Util.calculateOverclockedNessMulti(this.bufferedRecipe.mEUt,this.bufferedRecipe.mDuration,1,this.getMaxInputVoltage(),this); - if (this.mEUt < 0) + if (this.mEUt > 0) this.mEUt = -this.mEUt; this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mOutputItems = this.bufferedRecipe.mOutputs; this.mOutputFluids = this.bufferedRecipe.mFluidOutputs; + this.updateSlots(); return true; } @@ -126,30 +129,27 @@ public class GT_TileEntity_CircuitAssemblyLine extends GT_MetaTileEntity_MultiBl if (stack == null) return false; - Collection<GT_Recipe> recipes = new HashSet<>(); - - for (GT_Recipe recipe : BWRecipes.instance.getMappingsFor((byte)3).mRecipeList){ - if (GT_Utility.areStacksEqual(recipe.mOutputs[0],stack,true)){ - recipes.add(recipe); - break; + if (this.GT_RECIPE_COLLECTION.isEmpty()) { + for (GT_Recipe recipe : BWRecipes.instance.getMappingsFor((byte) 3).mRecipeList) { + if (GT_Utility.areStacksEqual(recipe.mOutputs[0], stack, true)) { + this.GT_RECIPE_COLLECTION.add(recipe); + } } } - if (recipes.isEmpty()) - return false; - - for (GT_Recipe recipe : recipes){ + for (GT_Recipe recipe : this.GT_RECIPE_COLLECTION) { if (recipe.isRecipeInputEqual(true,false, BW_Util.getFluidsFromInputHatches(this),BW_Util.getItemsFromInputBusses(this))) this.bufferedRecipe = recipe; else continue; BW_Util.calculateOverclockedNessMulti(this.bufferedRecipe.mEUt,this.bufferedRecipe.mDuration,1,this.getMaxInputVoltage(),this); - if (this.mEUt < 0) + if (this.mEUt > 0) this.mEUt = -this.mEUt; this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mOutputItems = this.bufferedRecipe.mOutputs; this.mOutputFluids = this.bufferedRecipe.mFluidOutputs; + this.updateSlots(); return true; } return false; @@ -313,6 +313,7 @@ public class GT_TileEntity_CircuitAssemblyLine extends GT_MetaTileEntity_MultiBl @Override public String[] getInfoData() { String[] ret = new String[super.getInfoData().length+1]; + System.arraycopy(super.getInfoData(),0,ret,0,super.getInfoData().length); ret[super.getInfoData().length] = "Imprinted with: "+ GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(CircuitImprintLoader.getStackFromTag(this.type))); return ret; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java index 5c357302e7..493a06bd11 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java @@ -25,12 +25,19 @@ package com.github.bartimaeusnek.bartworks.server.EventHandler; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.net.OreDictCachePacket; import com.github.bartimaeusnek.bartworks.common.net.ServerJoinedPackage; +import com.github.bartimaeusnek.bartworks.system.material.BWUnificationEnforcer; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; public class ServerEventHandler { @@ -41,4 +48,24 @@ public class ServerEventHandler { MainMod.BW_Network_instance.sendToPlayer(new OreDictCachePacket(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity); MainMod.BW_Network_instance.sendToPlayer(new ServerJoinedPackage(null),(EntityPlayerMP) event.entity); } + +// @SubscribeEvent(priority = EventPriority.HIGHEST) +// public void onPlayerTickEventServer(TickEvent.PlayerTickEvent event) { +// if (!BWUnificationEnforcer.isEnabled() || event == null || !(event.player instanceof EntityPlayerMP) || !FMLCommonHandler.instance().getSide().isServer()) +// return; +// +// for (int i = 0; i < event.player.inventory.mainInventory.length; i++) { +// ItemStack stack = event.player.inventory.mainInventory[i]; +// for (int id : OreDictionary.getOreIDs(stack)) +// if (BWUnificationEnforcer.getUnificationTargets().contains(OreDictionary.getOreName(id))){ +// ArrayList<ItemStack> stacks = OreDictionary.getOres(OreDictionary.getOreName(id)); +// for (int j = 0; j < stacks.size(); j++) { +// GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(stacks.get(j).getItem()); +// if (UI.modId.equals(MainMod.MOD_ID)){ +// event.player.inventory.mainInventory[i] = stacks.get(j).copy().splitStack(stack.stackSize); +// } +// } +// } +// } +// } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BWUnificationEnforcer.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BWUnificationEnforcer.java new file mode 100644 index 0000000000..784459f25e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BWUnificationEnforcer.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.material; + +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashSet; + +public class BWUnificationEnforcer { + private static boolean enabled; + private static final HashSet<String> UNIFICATION_TARGETS = new HashSet<>(); + public static boolean isEnabled() { + return BWUnificationEnforcer.enabled; + } + + public static HashSet<String> getUnificationTargets() { + return BWUnificationEnforcer.UNIFICATION_TARGETS; + } + + public static void addUnificationTarget(String aOreDictName){ + if (aOreDictName == null || aOreDictName.isEmpty() || !OreDictionary.doesOreNameExist(aOreDictName)) + return; + BWUnificationEnforcer.UNIFICATION_TARGETS.add(aOreDictName); + BWUnificationEnforcer.enabled = true; + } + + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java index 7baa3c7090..b3e8417ceb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java @@ -100,7 +100,7 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { - aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dust, aMaterial, aItemEntity.getEntityItem().stackSize)); + aItemEntity.setEntityItemStack(WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dust, aMaterial, aItemEntity.getEntityItem().stackSize)); aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); return true; } @@ -108,7 +108,7 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { - aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.crushedPurified, aMaterial, aItemEntity.getEntityItem().stackSize)); + aItemEntity.setEntityItemStack(WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedPurified, aMaterial, aItemEntity.getEntityItem().stackSize)); aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); return true; } @@ -143,7 +143,7 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa @Override public final IIconContainer getIconContainer(int aMetaData) { - return werkstoffHashMap.get((short) aMetaData) == null ? null : werkstoffHashMap.get((short) aMetaData).getTexSet().mTextures[this.orePrefixes.mTextureIndex]; + return werkstoffHashMap.get((short) aMetaData) == null ? null : this.orePrefixes.mTextureIndex == -1 ? null : werkstoffHashMap.get((short) aMetaData).getTexSet().mTextures[this.orePrefixes.mTextureIndex]; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java index 24af0547a7..dbb42d004d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -154,11 +154,14 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { this.texSet = texSet; - if (this.getStats().meltingPoint > 0) { + if (this.getStats().meltingPoint > 0 && !this.getStats().isGas()) { this.fluid = new GT_Fluid("molten" + this.getDefaultName().replaceAll(" ", ""), "molten.autogenerated", this.getRGBA()); this.getGenerationFeatures().toGenerate |= 16; } - + if (this.getGenerationFeatures().enforceUnification) { + for (OrePrefixes prefix : OrePrefixes.values()) + BWUnificationEnforcer.addUnificationTarget(prefix+this.getDefaultName()); + } Werkstoff.werkstoffHashSet.add(this); Werkstoff.werkstoffHashMap.put(this.mID, this); } @@ -241,7 +244,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { if (o == null||o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) return this.get(prefixes); if (o instanceof Werkstoff) - return WerkstoffLoader.getCorresopndingItemStack(prefixes, (Werkstoff) o); + return WerkstoffLoader.getCorrespondingItemStack(prefixes, (Werkstoff) o); if (o instanceof Materials) return GT_OreDictUnificator.get(prefixes, o, 1L); return null; @@ -304,11 +307,11 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { } public ItemStack get(OrePrefixes prefixes) { - return WerkstoffLoader.getCorresopndingItemStack(prefixes, this); + return WerkstoffLoader.getCorrespondingItemStack(prefixes, this); } public ItemStack get(OrePrefixes prefixes, int amount) { - return WerkstoffLoader.getCorresopndingItemStack(prefixes, this, amount); + return WerkstoffLoader.getCorrespondingItemStack(prefixes, this, amount); } public enum Types { @@ -339,6 +342,8 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { public byte toGenerate = 0b0001001; public byte blacklist; + public boolean enforceUnification; + /* * Auto add Chemical Recipes 1 * Auto add mixer Recipes 10 @@ -364,6 +369,11 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { return (this.toGenerate & 0b1000) != 0; } + public Werkstoff.GenerationFeatures enforceUnification(){ + this.enforceUnification = true; + return this; + } + public Werkstoff.GenerationFeatures removeGems(){ if (this.hasGems()) this.toGenerate = (byte) (this.toGenerate ^ 0b100); @@ -420,6 +430,10 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { this.toGenerate = (byte) (0); return this; } + public Werkstoff.GenerationFeatures addCells() { + this.toGenerate = (byte) (this.toGenerate | 0b10000); + return this; + } public Werkstoff.GenerationFeatures addGems() { this.toGenerate = (byte) (this.toGenerate | 0x4); @@ -459,7 +473,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { long mass; private Pair<Object,Integer>[] mTC_Aspects; //logic gate shit - byte quality = ~0b111111; + byte quality = ~0b1111111; public Werkstoff.Stats setmTC_AspectsArray(Pair<Object, Integer>[] mTC_Aspects) { this.mTC_Aspects = mTC_Aspects; @@ -514,7 +528,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { if (sublimation) this.quality = (byte) (this.quality | 0b000001); else - this.quality = (byte) (this.quality & 0b111110); + this.quality = (byte) (this.quality & 0b1111110); return this; } @@ -526,7 +540,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { if (toxic) this.quality = (byte) (this.quality | 0b000010); else - this.quality = (byte) (this.quality & 0b111101); + this.quality = (byte) (this.quality & 0b1111101); return this; } @@ -538,7 +552,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { if (radioactive) this.quality = (byte) (this.quality | 0b000100); else - this.quality = (byte) (this.quality & 0b111011); + this.quality = (byte) (this.quality & 0b1111011); return this; } @@ -550,7 +564,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { if (blastFurnace) this.quality = (byte) (this.quality | 0b001000); else - this.quality = (byte) (this.quality & 0b110111); + this.quality = (byte) (this.quality & 0b1110111); return this; } @@ -560,9 +574,9 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { public Werkstoff.Stats setElektrolysis(boolean elektrolysis) { if (elektrolysis) - this.quality = (byte) (this.quality | 0b010000); + this.quality = (byte) (this.quality | 0x10); else - this.quality = (byte) (this.quality & 0b101111); + this.quality = (byte) (this.quality & 0b1101111); return this; } @@ -572,9 +586,21 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { public Werkstoff.Stats setCentrifuge(boolean centrifuge) { if (centrifuge) - this.quality = (byte) (this.quality | 0b100000); + this.quality = (byte) (this.quality | 0x20); + else + this.quality = (byte) (this.quality & 0b1011111); + return this; + } + + public boolean isGas() { + return (this.quality >> 6 & 0b1) == 0b1; + } + + public Werkstoff.Stats setGas(boolean gas) { + if (gas) + this.quality = (byte) (this.quality | 0x40); else - this.quality = (byte) (this.quality & 0b011111); + this.quality = (byte) (this.quality & 0b0111111); return this; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java index d3175f967c..4fcf361c9d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -24,7 +24,6 @@ package com.github.bartimaeusnek.bartworks.system.material; import com.github.bartimaeusnek.bartworks.API.WerkstoffAdderRegistry; import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.client.renderer.BW_GT_ItemRenderer; import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.system.log.DebugLog; @@ -44,6 +43,7 @@ import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.*; import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.objects.GT_Fluid; import gregtech.api.objects.GT_MultiTexture; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_LanguageManager; @@ -57,6 +57,7 @@ import ic2.api.recipe.Recipes; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; @@ -544,16 +545,29 @@ public class WerkstoffLoader implements Runnable { new Pair<>(WerkstoffLoader.CubicZirconia,1), new Pair<>(Materials.SteelMagnetic,1) ); +// public static final Werkstoff Xenon = new Werkstoff( +// new short[]{0x14,0x39,0x7F,0}, +// "Xenon", +// "Xe", +// new Werkstoff.Stats().setProtons(54).setGas(true), +// Werkstoff.Types.ELEMENT, +// new Werkstoff.GenerationFeatures().disable().addCells(), +// 37, +// TextureSet.SET_FLUID +// //No Byproducts +// //No Ingridients +// ); public static HashMap<OrePrefixes, BW_MetaGenerated_Items> items = new HashMap<>(); + public static HashMap<Werkstoff, GT_Fluid> fluids = new HashMap<>(); public static Block BWOres; public boolean registered; - public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { - return WerkstoffLoader.getCorresopndingItemStack(orePrefixes, werkstoff, 1); + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { + return WerkstoffLoader.getCorrespondingItemStack(orePrefixes, werkstoff, 1); } - public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { ItemStack ret = OreDictHandler.getItemStack(werkstoff.getDefaultName(),orePrefixes,amount); if (ret != null) return ret; @@ -646,8 +660,12 @@ public class WerkstoffLoader implements Runnable { public static int toGenerateGlobal; private void addItemsForGeneration() { for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + if ((werkstoff.getGenerationFeatures().toGenerate & 0b10000) != 0 && FluidRegistry.isFluidRegistered(werkstoff.getDefaultName())){ + DebugLog.log("Adding new Fluid: "+werkstoff.getDefaultName()); + WerkstoffLoader.fluids.put(werkstoff, (GT_Fluid) new GT_Fluid(werkstoff.getDefaultName(),"molten.autogenerated",werkstoff.getRGBA()).setGaseous(werkstoff.getStats().isGas())); + } for (OrePrefixes p : values()) - if ((werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 && OreDictHandler.getItemStack(werkstoff.getDefaultName(),p,1) != null) { + if (!werkstoff.getGenerationFeatures().enforceUnification && (werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 && OreDictHandler.getItemStack(werkstoff.getDefaultName(),p,1) != null) { MainMod.LOGGER.info("Found: "+(p+werkstoff.getDefaultName().replaceAll(" ",""))+" in oreDict, disable and reroute my Items to that, also add a Tooltip."); werkstoff.getGenerationFeatures().setBlacklist(p); } @@ -683,8 +701,11 @@ public class WerkstoffLoader implements Runnable { } if ((WerkstoffLoader.toGenerateGlobal & 0b10000) != 0) { WerkstoffLoader.items.put(cell, new BW_MetaGenerated_Items(cell)); - WerkstoffLoader.items.put(bottle, new BW_MetaGenerated_Items(bottle)); - WerkstoffLoader.items.put(capsule, new BW_MetaGenerated_Items(capsule)); + // WerkstoffLoader.items.put(bottle, new BW_MetaGenerated_Items(bottle)); + // WerkstoffLoader.items.put(capsule, new BW_MetaGenerated_Items(capsule)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b100000) != 0) { + WerkstoffLoader.items.put(cellPlasma, new BW_MetaGenerated_Items(cellPlasma)); } } @@ -746,14 +767,14 @@ public class WerkstoffLoader implements Runnable { if (werkstoff.getGenerationFeatures().hasSifterRecipes() || ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0 && (werkstoff.getGenerationFeatures().toGenerate & 0b1) != 0)) { GT_Values.RA.addSifterRecipe( - WerkstoffLoader.getCorresopndingItemStack(crushedPurified, werkstoff), + WerkstoffLoader.getCorrespondingItemStack(crushedPurified, werkstoff), new ItemStack[]{ - WerkstoffLoader.getCorresopndingItemStack(gemExquisite, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(gemFlawless, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(gem, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(gemFlawed, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(gemChipped, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + WerkstoffLoader.getCorrespondingItemStack(gemExquisite, werkstoff), + WerkstoffLoader.getCorrespondingItemStack(gemFlawless, werkstoff), + WerkstoffLoader.getCorrespondingItemStack(gem, werkstoff), + WerkstoffLoader.getCorrespondingItemStack(gemFlawed, werkstoff), + WerkstoffLoader.getCorrespondingItemStack(gemChipped, werkstoff), + WerkstoffLoader.getCorrespondingItemStack(dust, werkstoff) }, new int[]{ 200, 1000, 2500, 2000, 4000, 5000 @@ -855,7 +876,7 @@ public class WerkstoffLoader implements Runnable { } } } - ItemStack input = WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff); + ItemStack input = WerkstoffLoader.getCorrespondingItemStack(dust, werkstoff); input.stackSize = werkstoff.getContents().getKey(); if (werkstoff.getStats().isElektrolysis()) GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.addRecipe(true, new ItemStack[]{input, cells > 0 ? Materials.Empty.getCells(cells) : null}, stOutputs.toArray(new ItemStack[0]), null, null, new FluidStack[]{null}, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, (int) Math.max(1L, Math.abs(werkstoff.getStats().protons * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 30, 0); @@ -873,24 +894,24 @@ public class WerkstoffLoader implements Runnable { } } - GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), new Object[]{ + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorrespondingItemStack(dust, werkstoff), new Object[]{ "TTT","TTT","TTT",'T', - WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff) + WerkstoffLoader.getCorrespondingItemStack(dustTiny, werkstoff) }); - GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), new Object[]{ + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorrespondingItemStack(dust, werkstoff), new Object[]{ "TT ","TT ",'T', - WerkstoffLoader.getCorresopndingItemStack(dustSmall, werkstoff) + WerkstoffLoader.getCorrespondingItemStack(dustSmall, werkstoff) }); - GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustSmall, werkstoff, 4), new Object[]{ - " T ", 'T', WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorrespondingItemStack(dustSmall, werkstoff, 4), new Object[]{ + " T ", 'T', WerkstoffLoader.getCorrespondingItemStack(dust, werkstoff) }); - GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff, 9), new Object[]{ - "T ", 'T', WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorrespondingItemStack(dustTiny, werkstoff, 9), new Object[]{ + "T ", 'T', WerkstoffLoader.getCorrespondingItemStack(dust, werkstoff) }); if ((werkstoff.getGenerationFeatures().toGenerate & 0b10) != 0 && !werkstoff.getStats().isBlastFurnace()) { - GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), WerkstoffLoader.getCorresopndingItemStack(ingot, werkstoff)); - GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff), WerkstoffLoader.getCorresopndingItemStack(nugget, werkstoff)); + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorrespondingItemStack(dust, werkstoff), WerkstoffLoader.getCorrespondingItemStack(ingot, werkstoff)); + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorrespondingItemStack(dustTiny, werkstoff), WerkstoffLoader.getCorrespondingItemStack(nugget, werkstoff)); } if ((werkstoff.getGenerationFeatures().toGenerate & 0b10) != 0){ GT_ModHandler.addPulverisationRecipe(werkstoff.get(ingot),werkstoff.get(dust)); @@ -901,7 +922,7 @@ public class WerkstoffLoader implements Runnable { private void addOreRecipes(Werkstoff werkstoff) { if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0 && (werkstoff.getGenerationFeatures().toGenerate & 0b10) != 0 &&!werkstoff.getStats().isBlastFurnace()) - GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(ore, werkstoff), WerkstoffLoader.getCorresopndingItemStack(ingot, werkstoff)); + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorrespondingItemStack(ore, werkstoff), WerkstoffLoader.getCorrespondingItemStack(ingot, werkstoff)); if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0) { GT_Values.RA.addForgeHammerRecipe(werkstoff.get(ore), werkstoff.getGenerationFeatures().hasGems() ? werkstoff.get(gem) : werkstoff.get(crushed), 16, 10); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java index 5a8af015ef..d37f3f0661 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java @@ -55,18 +55,18 @@ public class NEIbartworksConfig implements IConfigureNEI { API.hideItem(new ItemStack(FluidLoader.bioFluidBlock)); API.hideItem(new ItemStack(ItemRegistry.bw_fake_glasses)); ItemStack[] prefixesToHide = { - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dustTiny, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dustSmall, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.crushed, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.crushedPurified, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.crushedCentrifuged, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.nugget, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.gemChipped, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.gemFlawed, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.gemFlawless, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.gemExquisite, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dustImpure, WerkstoffLoader.Bismutite).copy(), - WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dustPure, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustTiny, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustSmall, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushed, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedPurified, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedCentrifuged, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.nugget, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemChipped, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemFlawed, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemFlawless, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemExquisite, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustImpure, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustPure, WerkstoffLoader.Bismutite).copy(), }; for (ItemStack stack : prefixesToHide) { stack.setItemDamage(Short.MAX_VALUE); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java index b32385e29d..7db0ab7bb5 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java @@ -22,13 +22,14 @@ package com.github.bartimaeusnek.crossmod.openComputers; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; import net.minecraft.nbt.NBTTagCompound; -import java.util.HashMap; - public class GT_NBT_DataBase { - private static final HashMap<NBTTagCompound, Long> tagToIdMap = new HashMap<>(); + private static final BiMap<NBTTagCompound, Long> tagIdBiMap = HashBiMap.create(); + private static final BiMap<GT_NBT_DataBase, Long> GTNBTBIMAP = HashBiMap.create(); private static long maxID = Long.MIN_VALUE+1; @@ -43,12 +44,25 @@ public class GT_NBT_DataBase { this.mDataTitle = mDataTitle; this.tagCompound = tagCompound; this.id = GT_NBT_DataBase.maxID; - GT_NBT_DataBase.tagToIdMap.put(tagCompound, this.id); + GT_NBT_DataBase.tagIdBiMap.put(tagCompound, this.id); + GT_NBT_DataBase.GTNBTBIMAP.put(this,this.id); ++GT_NBT_DataBase.maxID; } + static GT_NBT_DataBase getGTTagFromId(Long id){ + return GT_NBT_DataBase.GTNBTBIMAP.inverse().get(id); + } + + static Long getIdFromGTTag(GT_NBT_DataBase tagCompound){ + return GT_NBT_DataBase.GTNBTBIMAP.get(tagCompound); + } + + static NBTTagCompound getTagFromId(Long id){ + return GT_NBT_DataBase.tagIdBiMap.inverse().get(id); + } + static Long getIdFromTag(NBTTagCompound tagCompound){ - return GT_NBT_DataBase.tagToIdMap.get(tagCompound); + return GT_NBT_DataBase.tagIdBiMap.get(tagCompound); } public NBTTagCompound getTagCompound() { diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java index 9f7c593084..78251dac89 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java @@ -25,41 +25,61 @@ package com.github.bartimaeusnek.crossmod.openComputers; import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Optional; import gregtech.api.enums.ItemList; import gregtech.api.util.GT_Utility; import gregtech.common.items.behaviors.Behaviour_DataOrb; +import li.cil.oc.api.machine.Arguments; +import li.cil.oc.api.machine.Callback; +import li.cil.oc.api.machine.Context; +import li.cil.oc.api.network.SimpleComponent; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; -//@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers") -public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, ITileAddsInformation, ITileHasDifferentTextureSides/*, SimpleComponent*/ { +@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers") +public class TileEntity_GTDataServer extends TileEntity implements ISidedInventory, ITileWithGUI, ITileAddsInformation, ITileHasDifferentTextureSides, SimpleComponent { - private static final HashMap<Long,GT_NBT_DataBase> OrbDataBase = new HashMap<>(); + private final BiMap<Long,GT_NBT_DataBase> OrbDataBase = HashBiMap.create(); - private final ItemStack[] mItems = new ItemStack[2]; - - + private ItemStack[] mItems = new ItemStack[2]; private byte TickTimer; + @Optional.Method(modid = "OpenComputers") public String getComponentName() { return "GT-Data Server"; } -// @Callback -// @Optional.Method(modid = "OpenComputers") -// public Object[] listData(Context context, Arguments args) { -// return new String[] -// } + @Optional.Method(modid = "OpenComputers") + @Callback + public Object[] listData(Context context, Arguments args) { + Set<String> ret = new HashSet<>(); + for (Map.Entry<Long,GT_NBT_DataBase> entry : OrbDataBase.entrySet()){ + ret.add((entry.getValue().getId()+Long.MAX_VALUE)+". "+entry.getValue().getmDataTitle()); + } + return ret.toArray(new String[0]); + } + + @Optional.Method(modid = "OpenComputers") + @Callback + public Object[] imprintOrb(Context context, Arguments args) { + return new Object[]{false}; + } + private boolean isServerSide(){ return !this.worldObj.isRemote || FMLCommonHandler.instance().getSide().isServer(); } - - + @Override public void updateEntity() { if (this.TickTimer++ % 20 != 0) @@ -69,7 +89,7 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, if (GT_Utility.areStacksEqual(this.mItems[0],ItemList.Tool_DataOrb.get(1))) { if (this.mItems[0].hasTagCompound()) { if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { - TileEntity_GTDataServer.OrbDataBase.put( + this.OrbDataBase.put( GT_NBT_DataBase.getMaxID(), new GT_NBT_DataBase( Behaviour_DataOrb.getDataName(this.mItems[0]), @@ -77,6 +97,9 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, this.mItems[0].getTagCompound() ) ); + } else { + long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); + this.OrbDataBase.put(id,GT_NBT_DataBase.getGTTagFromId(id)); } } } @@ -91,7 +114,7 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, String title = data == 1 ? bookTitle : data == 2 ? punchcardData : data == 3 ? ""+mapID : "Custom Data"; String name = data == 1 ? "eBook" : data == 2 ? "Punch Card Data" : data == 3 ? "Map Data" : "Custom Data"; if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { - TileEntity_GTDataServer.OrbDataBase.put( + this.OrbDataBase.put( GT_NBT_DataBase.getMaxID(), new GT_NBT_DataBase( name, @@ -99,6 +122,9 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, this.mItems[0].getTagCompound() ) ); + } else { + long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); + this.OrbDataBase.put(id,GT_NBT_DataBase.getGTTagFromId(id)); } } } @@ -119,4 +145,81 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, public int getGUIID() { return 0; } + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[0]; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return this.mItems.length; + } + + @Override + public ItemStack getStackInSlot(int p_70301_1_) { + return p_70301_1_ == 0 ? this.mItems[0] : this.mItems[1]; + } + + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + if (p_70299_1_ > 1 || p_70299_1_ < 0) + return; + this.mItems[p_70299_1_]=p_70299_2_; + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void openInventory() { + + } + + @Override + public void closeInventory() { + + } + + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + return p_94041_1_ == 0; + } } |