diff options
author | Alexdoru <57050655+Alexdoru@users.noreply.github.com> | 2024-09-28 13:25:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-28 11:25:01 +0000 |
commit | 86f1765b171f4cc6f163b8027d1330f4e5094e2d (patch) | |
tree | b6e293bd3c976558fc4e4b7190e4d342c2ddc555 /src/main/java/bartworks | |
parent | 6b1f145f5028f1bc92cf478e5963224e7d94b5cd (diff) | |
download | GT5-Unofficial-86f1765b171f4cc6f163b8027d1330f4e5094e2d.tar.gz GT5-Unofficial-86f1765b171f4cc6f163b8027d1330f4e5094e2d.tar.bz2 GT5-Unofficial-86f1765b171f4cc6f163b8027d1330f4e5094e2d.zip |
Remove more reflection + reorganize mixin accessors packages (#3260)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: boubou19 <miisterunknown@gmail.com>
Diffstat (limited to 'src/main/java/bartworks')
4 files changed, 3 insertions, 115 deletions
diff --git a/src/main/java/bartworks/common/commands/ClearCraftingCache.java b/src/main/java/bartworks/common/commands/ClearCraftingCache.java index 68172190f6..24f82d90d8 100644 --- a/src/main/java/bartworks/common/commands/ClearCraftingCache.java +++ b/src/main/java/bartworks/common/commands/ClearCraftingCache.java @@ -17,7 +17,7 @@ import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; -import bartworks.hooks.BWCoreStaticReplacementMethodes; +import gregtech.mixin.hooks.BWCoreStaticReplacementMethodes; public class ClearCraftingCache extends CommandBase { diff --git a/src/main/java/bartworks/hooks/BWCoreStaticReplacementMethodes.java b/src/main/java/bartworks/hooks/BWCoreStaticReplacementMethodes.java deleted file mode 100644 index 6110d9c32d..0000000000 --- a/src/main/java/bartworks/hooks/BWCoreStaticReplacementMethodes.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2018-2020 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 bartworks.hooks; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; - -import bartworks.util.NonNullWrappedHashSet; -import bartworks.util.accessprioritylist.AccessPriorityList; -import bartworks.util.accessprioritylist.AccessPriorityListNode; - -public class BWCoreStaticReplacementMethodes { - - private static ThreadLocal<AccessPriorityList<IRecipe>> RECENTLYUSEDRECIPES = ThreadLocal - .withInitial(AccessPriorityList::new); - - public static void clearRecentlyUsedRecipes() { - // the easiest way to ensure the cache is flushed without causing synchronization overhead - // is to just replace the whole ThreadLocal instance. - RECENTLYUSEDRECIPES = ThreadLocal.withInitial(AccessPriorityList::new); - } - - public static ItemStack findCachedMatchingRecipe(InventoryCrafting inventoryCrafting, World world) { - int i = 0; - ItemStack itemstack = null; - ItemStack itemstack1 = null; - int j; - - for (j = 0; j < inventoryCrafting.getSizeInventory(); ++j) { - ItemStack itemstack2 = inventoryCrafting.getStackInSlot(j); - - if (itemstack2 != null) { - if (i == 0) itemstack = itemstack2; - - if (i == 1) itemstack1 = itemstack2; - - ++i; - } - } - - if (i == 2 && itemstack.getItem() == itemstack1.getItem() - && itemstack.stackSize == 1 - && itemstack1.stackSize == 1 - && itemstack.getItem() - .isRepairable()) { - Item item = itemstack.getItem(); - int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); - int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); - int l = j1 + k + item.getMaxDamage() * 5 / 100; - int i1 = item.getMaxDamage() - l; - - if (i1 < 0) i1 = 0; - - return new ItemStack(itemstack.getItem(), 1, i1); - - } - IRecipe iPossibleRecipe = null; - AccessPriorityList<IRecipe> cache = RECENTLYUSEDRECIPES.get(); - Iterator<AccessPriorityListNode<IRecipe>> it = cache.nodeIterator(); - - while (it.hasNext()) { - AccessPriorityListNode<IRecipe> recipeNode = it.next(); - iPossibleRecipe = recipeNode.getELEMENT(); - - if (!iPossibleRecipe.matches(inventoryCrafting, world)) continue; - - cache.addPrioToNode(recipeNode); - return iPossibleRecipe.getCraftingResult(inventoryCrafting); - } - - HashSet<IRecipe> recipeSet = new NonNullWrappedHashSet<>(); - List<IRecipe> recipeList = CraftingManager.getInstance() - .getRecipeList(); - - for (IRecipe r : recipeList) { - if (r.matches(inventoryCrafting, world)) recipeSet.add(r); - } - - Object[] arr = recipeSet.toArray(); - - if (arr.length == 0) return null; - - IRecipe recipe = (IRecipe) arr[0]; - ItemStack stack = recipe.getCraftingResult(inventoryCrafting); - - if (arr.length != 1) return stack; - - if (stack != null) cache.addLast(recipe); - - return stack; - } - -} diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java index c3a8442397..c75d561e29 100644 --- a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java +++ b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -34,7 +34,6 @@ import com.google.common.collect.HashBiMap; import bartworks.API.recipe.BWNBTDependantCraftingRecipe; import bartworks.API.recipe.BartWorksRecipeMaps; -import bartworks.hooks.BWCoreStaticReplacementMethodes; import bartworks.system.material.WerkstoffLoader; import bartworks.util.BWUtil; import bartworks.util.Pair; @@ -48,6 +47,7 @@ import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; +import gregtech.mixin.hooks.BWCoreStaticReplacementMethodes; public class CircuitImprintLoader { diff --git a/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java b/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java index a21a9b5ae9..e3504a4e9c 100644 --- a/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java +++ b/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java @@ -110,7 +110,6 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TierEU; -import gregtech.api.interfaces.IRecipeMutableAccess; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.items.GTGenericBlock; import gregtech.api.items.GTGenericItem; @@ -123,6 +122,7 @@ import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.common.blocks.BlockOresAbstract; +import gregtech.mixin.interfaces.accessors.IRecipeMutableAccess; import gtPlusPlus.core.block.base.BlockBaseModular; import gtPlusPlus.core.item.base.BaseItemComponent; |