use of gregapi.oredict.OreDictPrefix in project gregtech6 by GregTech6.
the class GT_API_Proxy method onServerTick.
@SubscribeEvent
@SuppressWarnings({ "unchecked", "rawtypes" })
public void onServerTick(ServerTickEvent aEvent) {
if (aEvent.side.isServer()) {
// Try acquiring the Lock within 10 Milliseconds. Otherwise fuck anyone who locks it up for too long, or any other faulty reason MC doesn't work.
try {
TICK_LOCK.tryLock(10, TimeUnit.MILLISECONDS);
} catch (Throwable e) {
e.printStackTrace(ERR);
} finally {
if (TICK_LOCK.isHeldByCurrentThread())
TICK_LOCK.unlock();
}
// Making sure it is being free'd up in order to prevent exploits or Garbage Collection mishaps.
LAST_BROKEN_TILEENTITY.set(null);
if (aEvent.phase == Phase.START) {
SYNC_SECOND = (SERVER_TIME % 20 == 0);
if (SERVER_TIME++ == 0) {
// Unification Stuff
HashSetNoNulls<ItemStack> tStacks = new HashSetNoNulls<>(10000);
if (MD.IC2.mLoaded)
try {
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.cannerBottle.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.centrifuge.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.compressor.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.extractor.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.macerator.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.metalformerCutting.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.metalformerExtruding.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.metalformerRolling.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.matterAmplifier.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
for (ic2.api.recipe.RecipeOutput tRecipe : ic2.api.recipe.Recipes.oreWashing.getRecipes().values()) for (ItemStack tStack : tRecipe.items) tStacks.add(tStack);
} catch (Throwable e) {
e.printStackTrace(ERR);
}
if (MD.RC.mLoaded) {
try {
for (Object tRecipe : mods.railcraft.api.crafting.RailcraftCraftingManager.blastFurnace.getRecipes()) tStacks.add((ItemStack) UT.Reflection.getFieldContent(tRecipe, "output"));
} catch (Throwable e) {
e.printStackTrace(ERR);
}
try {
for (Object tRecipe : mods.railcraft.api.crafting.RailcraftCraftingManager.cokeOven.getRecipes()) tStacks.add((ItemStack) UT.Reflection.getFieldContent(tRecipe, "output"));
} catch (Throwable e) {
e.printStackTrace(ERR);
}
try {
for (Object tRecipe : mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.getRecipes()) for (Map.Entry<ItemStack, Float> tEntry : (List<Map.Entry<ItemStack, Float>>) UT.Reflection.getFieldContent(tRecipe, "outputs")) tStacks.add(tEntry.getKey());
} catch (Throwable e) {
e.printStackTrace(ERR);
}
try {
for (IRecipe tRecipe : mods.railcraft.api.crafting.RailcraftCraftingManager.rollingMachine.getRecipeList()) if (tRecipe != null)
tStacks.add(tRecipe.getRecipeOutput());
} catch (Throwable e) {
e.printStackTrace(ERR);
}
}
if (MD.TE.mLoaded && ALWAYS_FALSE) {
List<Map> tMaps = new ArrayListNoNulls<>();
List<Set> tSets = new ArrayListNoNulls<>();
for (String tClassName : new String[] { "cofh.thermalexpansion.util.crafting.InsolatorManager", "cofh.thermalexpansion.util.crafting.ChargerManager", "cofh.thermalexpansion.util.crafting.ExtruderManager", "cofh.thermalexpansion.util.crafting.PrecipitatorManager", "cofh.thermalexpansion.util.crafting.TransposerManager", "cofh.thermalexpansion.util.crafting.CrucibleManager", "cofh.thermalexpansion.util.crafting.SmelterManager", "cofh.thermalexpansion.util.crafting.SawmillManager", "cofh.thermalexpansion.util.crafting.PulverizerManager", "cofh.thermalexpansion.util.crafting.FurnaceManager" }) {
try {
Class tClass = Class.forName(tClassName);
Object tObject = UT.Reflection.getFieldContent(tClass, "recipeMap", T, F);
if (tObject instanceof Map)
tMaps.add((Map) tObject);
tObject = UT.Reflection.getFieldContent(tClass, "recipeMapFill", T, F);
if (tObject instanceof Map)
tMaps.add((Map) tObject);
tObject = UT.Reflection.getFieldContent(tClass, "recipeMapExtraction", T, F);
if (tObject instanceof Map)
tMaps.add((Map) tObject);
tObject = UT.Reflection.getFieldContent(tClass, "validationSet", T, F);
if (tObject instanceof Set)
tSets.add((Set) tObject);
tObject = UT.Reflection.getFieldContent(tClass, "lockSet", T, F);
if (tObject instanceof Set)
tSets.add((Set) tObject);
} catch (Throwable e) {
e.printStackTrace(ERR);
}
}
for (Map tMap : tMaps) {
try {
for (Object tCompStack : tMap.keySet()) if (tCompStack instanceof ComparableItem) {
ItemStack tStack = OM.get(ST.make(((ComparableItem) tCompStack).item, 1, ((ComparableItem) tCompStack).metadata));
if (ST.valid(tStack)) {
((ComparableItem) tCompStack).item = ST.item_(tStack);
((ComparableItem) tCompStack).metadata = ST.meta_(tStack);
}
}
} catch (Throwable e) {
e.printStackTrace(ERR);
}
UT.Code.reMap(tMap);
}
for (Set tSet : tSets) {
try {
for (Object tCompStack : tSet) if (tCompStack instanceof ComparableItem) {
ItemStack tStack = OM.get(ST.make(((ComparableItem) tCompStack).item, 1, ((ComparableItem) tCompStack).metadata));
if (ST.valid(tStack)) {
((ComparableItem) tCompStack).item = ST.item_(tStack);
((ComparableItem) tCompStack).metadata = ST.meta_(tStack);
}
}
} catch (Throwable e) {
e.printStackTrace(ERR);
}
UT.Code.reMap(tSet);
}
}
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.BONUS_CHEST).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CROSSING).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_LIBRARY).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CORRIDOR).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_DISPENSER).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_DESERT_CHEST).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
for (WeightedRandomChestContent tContent : ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).getItems(RNGSUS)) tStacks.add(tContent.theItemId);
if (MD.IE.mLoaded)
try {
for (WeightedRandomChestContent tContent : ((ChestGenHooks) UT.Reflection.getFieldContent("blusunrize.immersiveengineering.common.world.VillageEngineersHouse", "crateContents")).getItems(RNGSUS)) {
if (OM.is("ingotAluminium", tContent.theItemId)) {
ST.set(tContent.theItemId, OP.ingot.mat(MT.Constantan, 1));
} else {
tStacks.add(tContent.theItemId);
}
}
} catch (Throwable e) {
e.printStackTrace(ERR);
}
for (Object tStack : FurnaceRecipes.smelting().getSmeltingList().values()) tStacks.add((ItemStack) tStack);
if (MD.EtFu.mLoaded)
try {
for (Object tStack : SmokerRecipes.smelting().getSmeltingList().values()) tStacks.add((ItemStack) tStack);
for (Object tStack : BlastFurnaceRecipes.smelting().getSmeltingList().values()) tStacks.add((ItemStack) tStack);
} catch (Throwable e) {
e.printStackTrace(ERR);
}
for (IRecipe tRecipe : CR.list()) if (tRecipe != null)
tStacks.add(tRecipe.getRecipeOutput());
for (ItemStack tOutput : tStacks) {
if (OreDictManager.INSTANCE.isOreDictItem(tOutput)) {
ERR.println("GT-ERR-01: @ " + tOutput.getUnlocalizedName() + " " + tOutput.getDisplayName());
FMLLog.severe("GT-ERR-01: @ " + tOutput.getUnlocalizedName() + " " + tOutput.getDisplayName());
if (CS.CODE_CLIENT) {
FMLLog.severe("A Recipe used an OreDict Item as Output directly, without copying it before!!! This is a typical CallByReference/CallByValue Error");
FMLLog.severe("Said Item will be renamed to make the invalid Recipe visible, so that you can report it properly.");
FMLLog.severe("Please check all Recipes outputting this Item, and report the Recipes to their Owner.");
FMLLog.severe("The Owner of the ==>RECIPE<==, NOT the Owner of the Item, which has been mentioned above!!!");
FMLLog.severe("And ONLY Recipes which are ==>OUTPUTTING<== the Item, sorry but I don't want failed Bug Reports.");
FMLLog.severe("GregTech just reports this Error to you, so you can report it to the Mod causing the Problem.");
FMLLog.severe("Even though I make that Bug visible, I can not and will not fix that for you, that's for the causing Mod to fix.");
FMLLog.severe("And speaking of failed Reports:");
FMLLog.severe("Both IC2 and GregTech CANNOT be the CAUSE of this Problem, so don't report it to either of them.");
FMLLog.severe("I REPEAT, BOTH, IC2 and GregTech CANNOT be the source of THIS BUG. NO MATTER WHAT.");
FMLLog.severe("Asking in the IC2 Forums, which Mod is causing that, won't help anyone, since it is not possible to determine, which Mod it is.");
FMLLog.severe("If it would be possible, then I would have had added the Mod which is causing it to the Message already. But it is not possible.");
FMLLog.severe("Sorry, but this Error is serious enough to justify this Wall-O-Text and the partially allcapsed Language.");
FMLLog.severe("Also it is a Ban Reason on the IC2-Forums to seriously post this Text. We all know about its existence.");
tOutput.setStackDisplayName("ERROR!");
UT.NBT.setBoolean(UT.NBT.getNBT(tOutput), "gt.err.oredict.output", T);
}
} else {
OM.set(tOutput);
}
}
// Cleaning up Recipes with Empty OreDict Lists, since they are never craftable.
List<IRecipe> tList = CR.list();
for (int i = 0; i < tList.size(); i++) {
Object tRecipe = tList.get(i);
if (tRecipe instanceof ShapedOreRecipe) {
Object[] tInput = ((ShapedOreRecipe) tRecipe).getInput();
for (int j = 0; j < tInput.length; j++) {
if (tInput[j] instanceof List && ((List<?>) tInput[j]).isEmpty()) {
// DEB.println("Removed Recipe for " + ((ShapedOreRecipe)tRecipe).getRecipeOutput().getDisplayName() + " because Ingredient Nr. " + j + " is missing");
tList.remove(i--);
break;
}
}
} else if (tRecipe instanceof ShapelessOreRecipe) {
ArrayList<Object> tInput = ((ShapelessOreRecipe) tRecipe).getInput();
for (int j = 0; j < tInput.size(); j++) {
if (tInput.get(j) instanceof List && ((List<?>) tInput.get(j)).isEmpty()) {
// DEB.println("Removed Recipe for " + ((ShapelessOreRecipe)tRecipe).getRecipeOutput().getDisplayName() + " because Ingredient Nr. " + j + " is missing");
tList.remove(i--);
break;
}
}
}
}
OreDictManager.INSTANCE.fixStacksizes();
}
for (int i = 0; i < SERVER_TICK_PRE.size(); i++) {
ITileEntityServerTickPre tTileEntity = SERVER_TICK_PRE.get(i);
if (tTileEntity.isDead()) {
SERVER_TICK_PRE.remove(i--);
tTileEntity.onUnregisterPre();
} else {
try {
tTileEntity.onServerTickPre(T);
} catch (Throwable e) {
SERVER_TICK_PRE.remove(i--);
tTileEntity.setError("Server Tick Pre 1 - " + e);
e.printStackTrace(ERR);
}
}
}
for (int i = 0; i < SERVER_TICK_PR2.size(); i++) {
ITileEntityServerTickPre tTileEntity = SERVER_TICK_PR2.get(i);
if (tTileEntity.isDead()) {
SERVER_TICK_PR2.remove(i--);
tTileEntity.onUnregisterPre();
} else {
try {
tTileEntity.onServerTickPre(F);
} catch (Throwable e) {
SERVER_TICK_PR2.remove(i--);
tTileEntity.setError("Server Tick Pre 2 - " + e);
e.printStackTrace(ERR);
}
}
}
DELAYED_BLOCK_UPDATES_2.clear();
List tList = DELAYED_BLOCK_UPDATES_2;
DELAYED_BLOCK_UPDATES_2 = DELAYED_BLOCK_UPDATES;
DELAYED_BLOCK_UPDATES = tList;
for (IHasWorldAndCoords tTileEntity : DELAYED_BLOCK_UPDATES_2) {
try {
tTileEntity.getWorld().notifyBlocksOfNeighborChange(tTileEntity.getX(), tTileEntity.getY(), tTileEntity.getZ(), tTileEntity.getBlock(tTileEntity.getCoords()));
} catch (Throwable e) {
if (tTileEntity instanceof ITileEntityErrorable)
((ITileEntityErrorable) tTileEntity).setError("Delayed Block Update - " + e);
e.printStackTrace(ERR);
}
}
if (SERVER_TIME > 10) {
for (ITileEntityScheduledUpdate tTileEntity : SCHEDULED_TILEENTITY_UPDATES_2) if (!tTileEntity.isDead()) {
try {
tTileEntity.onScheduledUpdate();
} catch (Throwable e) {
if (tTileEntity instanceof ITileEntityErrorable)
((ITileEntityErrorable) tTileEntity).setError("Scheduled TileEntity Update - " + e);
e.printStackTrace(ERR);
}
}
SCHEDULED_TILEENTITY_UPDATES_2.clear();
tList = SCHEDULED_TILEENTITY_UPDATES_2;
SCHEDULED_TILEENTITY_UPDATES_2 = SCHEDULED_TILEENTITY_UPDATES;
SCHEDULED_TILEENTITY_UPDATES = tList;
while (!mNewPlayers.isEmpty()) {
EntityPlayerMP tPlayer = mNewPlayers.remove(0);
NW_API.sendToPlayer(new PacketConfig(), tPlayer);
for (OreDictPrefix tPrefix : OreDictPrefix.VALUES) if (!tPrefix.contains(TD.Prefix.PREFIX_UNUSED))
NW_API.sendToPlayer(new PacketPrefix(tPrefix), tPlayer);
}
}
}
if (aEvent.phase == Phase.END) {
for (int i = 0; i < SERVER_TICK_POST.size(); i++) {
ITileEntityServerTickPost tTileEntity = SERVER_TICK_POST.get(i);
if (tTileEntity.isDead()) {
SERVER_TICK_POST.remove(i--);
tTileEntity.onUnregisterPost();
} else {
try {
tTileEntity.onServerTickPost(T);
} catch (Throwable e) {
SERVER_TICK_POST.remove(i--);
tTileEntity.setError("Server Tick Post 1 - " + e);
e.printStackTrace(ERR);
}
}
}
for (int i = 0; i < SERVER_TICK_PO2T.size(); i++) {
ITileEntityServerTickPost tTileEntity = SERVER_TICK_PO2T.get(i);
if (tTileEntity.isDead()) {
SERVER_TICK_PO2T.remove(i--);
tTileEntity.onUnregisterPost();
} else {
try {
tTileEntity.onServerTickPost(F);
} catch (Throwable e) {
SERVER_TICK_PO2T.remove(i--);
tTileEntity.setError("Server Tick Post 2 - " + e);
e.printStackTrace(ERR);
}
}
}
EntityFoodTracker.tick();
if (TICK_LOCK.isHeldByCurrentThread())
TICK_LOCK.unlock();
}
}
}
use of gregapi.oredict.OreDictPrefix in project gregtech6 by GregTech6.
the class GT_API_Proxy_Client method onProxyAfterInit.
@Override
public void onProxyAfterInit(Abstract_Mod aMod, FMLInitializationEvent aEvent) {
for (OreDictPrefix tPrefix : OreDictPrefix.VALUES) {
LH.add("oredict.prefix." + tPrefix.mNameInternal, tPrefix.mNameLocal);
tPrefix.mNameLocal = LH.get("oredict.prefix." + tPrefix.mNameInternal, tPrefix.mNameLocal);
}
}
use of gregapi.oredict.OreDictPrefix in project gregtech6 by GregTech6.
the class NEI_RecipeMap method loadCraftingRecipes.
@Override
public void loadCraftingRecipes(ItemStack aResult) {
if (!CODE_CLIENT)
return;
if (ST.invalid(aResult))
return;
try {
OreDictItemData tPrefixMaterial = OM.association_(aResult);
ArrayList<ItemStack> tResults = new ArrayListNoNulls<>();
tResults.add(aResult);
tResults.add(OM.get_(aResult));
ArrayList<ItemStack> tRedirects = ItemsGT.sNEIRedirects.get(new ItemStackContainer(aResult));
if (tRedirects != null)
tResults.addAll(tRedirects);
tRedirects = ItemsGT.sNEIRedirects.get(new ItemStackContainer(aResult, W));
if (tRedirects != null)
tResults.addAll(tRedirects);
if (tPrefixMaterial != null && !tPrefixMaterial.mBlackListed) {
if (tPrefixMaterial.mMaterial.mMaterial.mID > 0 && BlocksGT.ore != null && BlocksGT.oreBroken != null && tPrefixMaterial.mPrefix.containsAny(TD.Prefix.ORE, TD.Prefix.ORE_PROCESSING_BASED)) {
tResults.add(ST.make((Block) BlocksGT.ore, 1, tPrefixMaterial.mMaterial.mMaterial.mID));
tResults.add(ST.make((Block) BlocksGT.oreBroken, 1, tPrefixMaterial.mMaterial.mMaterial.mID));
}
for (OreDictPrefix tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) {
tResults.add(tPrefix.mat(tPrefixMaterial.mMaterial.mMaterial, 1));
}
}
if (!ItemsGT.NEI_DONT_SHOW_FLUIDS.contains(aResult, T)) {
FluidStack tFluid = FL.getFluid(aResult, T);
if (tFluid != null) {
tResults.add(FL.display(tFluid, F, F));
for (FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (tData.fluid.isFluidEqual(tFluid))
tResults.add(ST.copy(tData.filledContainer));
}
}
}
ArrayList<Recipe> tRecipes = new ArrayListNoNulls<>();
for (Recipe tRecipe : mRecipeMap.getNEIRecipes(tResults.toArray(ZL_IS))) if (!tRecipes.contains(tRecipe))
tRecipes.add(tRecipe);
for (Recipe tRecipe : tRecipes) arecipes.add(new CachedDefaultRecipe(tRecipe));
sortRecipes();
} catch (Throwable e) {
e.printStackTrace(ERR);
}
}
use of gregapi.oredict.OreDictPrefix in project gregtech6 by GregTech6.
the class NEI_RecipeMap method loadUsageRecipes.
@Override
public void loadUsageRecipes(ItemStack aInput) {
if (!CODE_CLIENT)
return;
if (ST.invalid(aInput))
return;
try {
OreDictItemData tPrefixMaterial = OM.association_(aInput);
ArrayList<ItemStack> tInputs = new ArrayListNoNulls<>();
tInputs.add(aInput);
tInputs.add(OreDictManager.INSTANCE.getStack_(F, aInput));
ArrayList<ItemStack> tRedirects = ItemsGT.sNEIRedirects.get(new ItemStackContainer(aInput));
if (tRedirects != null)
tInputs.addAll(tRedirects);
tRedirects = ItemsGT.sNEIRedirects.get(new ItemStackContainer(aInput, W));
if (tRedirects != null)
tInputs.addAll(tRedirects);
if (tPrefixMaterial != null) {
for (OreDictPrefix tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) {
tInputs.add(tPrefix.mat(tPrefixMaterial.mMaterial.mMaterial, 1));
}
}
if (!ItemsGT.NEI_DONT_SHOW_FLUIDS.contains(aInput, T)) {
FluidStack tFluid = FL.getFluid(aInput, T);
if (tFluid != null) {
tInputs.add(FL.display(tFluid, F, F));
for (FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (tData.fluid.isFluidEqual(tFluid))
tInputs.add(ST.copy(tData.filledContainer));
}
}
}
ArrayList<Recipe> tRecipes = new ArrayListNoNulls<>();
for (Recipe tRecipe : mRecipeMap.getNEIUsages(tInputs.toArray(ZL_IS))) if (!tRecipes.contains(tRecipe))
tRecipes.add(tRecipe);
for (Recipe tRecipe : tRecipes) arecipes.add(new CachedDefaultRecipe(tRecipe));
sortRecipes();
} catch (Throwable e) {
e.printStackTrace(ERR);
}
}
use of gregapi.oredict.OreDictPrefix in project gregtech6 by GregTech6.
the class OM method data.
public static OreDictItemData data(String aOre) {
OreDictPrefix tPrefix = OreDictPrefix.get(aOre);
if (tPrefix == null)
return null;
OreDictMaterial tMaterial = OreDictMaterial.MATERIAL_MAP.get(aOre.replaceFirst(tPrefix.mNameInternal, ""));
if (tMaterial == null)
return null;
return new OreDictItemData(tPrefix, tMaterial);
}
Aggregations