diff options
Diffstat (limited to 'src')
31 files changed, 275 insertions, 728 deletions
diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java index 8e04f770f8..ed08d3ef29 100644 --- a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java +++ b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -282,14 +282,7 @@ public class CircuitImprintLoader { BWCoreStaticReplacementMethodes.clearRecentlyUsedRecipes(); RecipeMaps.slicerRecipes.getBackend() .removeRecipes(gtrecipeWorldCache); - recipeWorldCache.forEach(r -> { - try { - BWUtil.getGTBufferedRecipeList() - .remove(r); - } catch (Exception e) { - e.printStackTrace(); - } - }); + GTModHandler.sBufferRecipeList.removeAll(recipeWorldCache); recipeWorldCache.clear(); gtrecipeWorldCache.clear(); } diff --git a/src/main/java/bartworks/util/BWUtil.java b/src/main/java/bartworks/util/BWUtil.java index a9a4811bb5..ad75eb275e 100644 --- a/src/main/java/bartworks/util/BWUtil.java +++ b/src/main/java/bartworks/util/BWUtil.java @@ -19,7 +19,6 @@ import static gregtech.api.enums.GTValues.M; import static gregtech.api.enums.GTValues.VN; import static gregtech.api.enums.GTValues.W; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -39,8 +38,6 @@ import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; -import org.apache.commons.lang3.reflect.FieldUtils; - import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; import com.gtnewhorizon.structurelib.structure.IStructureElement; @@ -362,20 +359,6 @@ public class BWUtil { }; } - private static Field sBufferedRecipeList; - - @SuppressWarnings("unchecked") - public static List<IRecipe> getGTBufferedRecipeList() - throws SecurityException, IllegalArgumentException, IllegalAccessException { - if (sBufferedRecipeList == null) { - sBufferedRecipeList = FieldUtils.getDeclaredField(GTModHandler.class, "sBufferRecipeList", true); - } - if (sBufferedRecipeList == null) { - sBufferedRecipeList = FieldUtils.getField(GTModHandler.class, "sBufferRecipeList", true); - } - return (List<IRecipe>) sBufferedRecipeList.get(null); - } - public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) { return createGTCraftingRecipe( aResult, diff --git a/src/main/java/gregtech/api/enums/TAE.java b/src/main/java/gregtech/api/enums/TAE.java index 48a39da036..edc0e5123c 100644 --- a/src/main/java/gregtech/api/enums/TAE.java +++ b/src/main/java/gregtech/api/enums/TAE.java @@ -1,6 +1,5 @@ package gregtech.api.enums; -import java.lang.reflect.Field; import java.util.HashMap; import java.util.HashSet; @@ -8,7 +7,6 @@ import gregtech.api.interfaces.ITexture; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.GTPPCore; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; public class TAE { @@ -77,38 +75,6 @@ public class TAE { Logger.INFO("Finalised TAE."); } - private static boolean registerTextures(GTPPCopiedBlockTexture GTPPCopiedBlockTexture) { - try { - // Handle page 2. - Logger.INFO("[TAE} Registering Texture, Last used casing ID is " + gtPPLastUsedIndex + "."); - if (gtPPLastUsedIndex >= 128) { - Field x = ReflectionUtils.getField(Textures.BlockIcons.class, "casingTexturePages"); - if (x != null) { - ITexture[][] h = (ITexture[][]) x.get(null); - if (h != null) { - h[64][secondaryIndex++] = GTPPCopiedBlockTexture; - x.set(null, h); - Logger - .INFO("[TAE} Registered Texture with ID " + (secondaryIndex - 1) + " in secondary index."); - return true; - } - } - } - - // set to page 1. - else { - Textures.BlockIcons.setCasingTextureForId(gtPPLastUsedIndex, GTPPCopiedBlockTexture); - Logger.INFO("[TAE} Registered Texture with ID " + (gtPPLastUsedIndex) + " in main index."); - gtPPLastUsedIndex++; - return true; - } - } catch (Throwable t) { - t.printStackTrace(); - } - Logger.INFO("[TAE} Failed to register texture, Last used casing ID is " + gtPPLastUsedIndex + "."); - return false; - } - public static ITexture getTexture(int index) { if (gtPPLastUsedIndex >= 128) { return Textures.BlockIcons.getCasingTextureForId(((64 * 128) + index)); diff --git a/src/main/java/gregtech/api/items/ItemEnergyArmor.java b/src/main/java/gregtech/api/items/ItemEnergyArmor.java index 77c8d0991a..257059e963 100644 --- a/src/main/java/gregtech/api/items/ItemEnergyArmor.java +++ b/src/main/java/gregtech/api/items/ItemEnergyArmor.java @@ -28,7 +28,6 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTechAPI; import gregtech.api.util.GTLanguageManager; import gregtech.api.util.GTModHandler; -import gregtech.api.util.GTUtility; public class ItemEnergyArmor extends ItemArmor implements ISpecialArmor { @@ -126,11 +125,11 @@ public class ItemEnergyArmor extends ItemArmor implements ISpecialArmor { if ((mSpecials & 8) != 0) { if (GTModHandler.canUseElectricItem(aStack, 10000) && aPlayer.isPotionActive(Potion.poison)) { - GTUtility.removePotion(aPlayer, Potion.poison.id); + aPlayer.removePotionEffect(Potion.poison.id); GTModHandler.useElectricItem(aStack, 10000, aPlayer); } if (GTModHandler.canUseElectricItem(aStack, 100000) && aPlayer.isPotionActive(Potion.wither)) { - GTUtility.removePotion(aPlayer, Potion.wither.id); + aPlayer.removePotionEffect(Potion.wither.id); GTModHandler.useElectricItem(aStack, 100000, aPlayer); } } diff --git a/src/main/java/gregtech/api/util/FishPondFakeRecipe.java b/src/main/java/gregtech/api/util/FishPondFakeRecipe.java index 2deb38dccf..385af4ffef 100644 --- a/src/main/java/gregtech/api/util/FishPondFakeRecipe.java +++ b/src/main/java/gregtech/api/util/FishPondFakeRecipe.java @@ -1,8 +1,8 @@ package gregtech.api.util; import static gregtech.api.util.GTRecipeBuilder.SECONDS; -import static gtPlusPlus.api.recipe.GTPPRecipeMaps.fishPondRecipes; +import java.lang.reflect.Field; import java.util.ArrayList; import net.minecraft.item.ItemStack; @@ -11,61 +11,55 @@ import net.minecraftforge.common.FishingHooks; import gregtech.api.enums.GTValues; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.api.recipe.GTPPRecipeMaps; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.MTEIndustrialFishingPond; public class FishPondFakeRecipe { - public static ArrayList<WeightedRandomFishable> fish = new ArrayList<>(); - public static ArrayList<WeightedRandomFishable> junk = new ArrayList<>(); - public static ArrayList<WeightedRandomFishable> treasure = new ArrayList<>(); + public static final ArrayList<ItemStack> fish = new ArrayList<>(); + public static final ArrayList<ItemStack> junk = new ArrayList<>(); + public static final ArrayList<ItemStack> treasure = new ArrayList<>(); @SuppressWarnings("unchecked") - public static boolean generateFishPondRecipes() { - + public static void generateFishPondRecipes() { try { - fish = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "fish") + ArrayList<WeightedRandomFishable> fishList = (ArrayList<WeightedRandomFishable>) GTUtility + .getField(FishingHooks.class, "fish") .get(null); - junk = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "junk") + ArrayList<WeightedRandomFishable> junkList = (ArrayList<WeightedRandomFishable>) GTUtility + .getField(FishingHooks.class, "junk") .get(null); - treasure = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "treasure") + ArrayList<WeightedRandomFishable> treasureList = (ArrayList<WeightedRandomFishable>) GTUtility + .getField(FishingHooks.class, "treasure") .get(null); - } catch (IllegalArgumentException | IllegalAccessException e) { - Logger.INFO("Error generating Fish Pond Recipes. [1]"); + final Field stackField = GTUtility.getField(WeightedRandomFishable.class, "field_150711_b"); + generateRecipesFor(MTEIndustrialFishingPond.FISH_MODE, fish, fishList, stackField); + generateRecipesFor(MTEIndustrialFishingPond.JUNK_MODE, junk, junkList, stackField); + generateRecipesFor(MTEIndustrialFishingPond.TREASURE_MODE, treasure, treasureList, stackField); + } catch (Exception e) { + Logger.INFO("Error reading the vanilla fishing loot table."); e.printStackTrace(); } + } - ArrayList<ArrayList<WeightedRandomFishable>> mega = new ArrayList<>(); - mega.add(fish); - mega.add(junk); - mega.add(treasure); - - int mType = 14; - for (ArrayList<WeightedRandomFishable> f : mega) { - for (WeightedRandomFishable weightedRandomFishable : f) { - if (weightedRandomFishable != null) { - WeightedRandomFishable u = weightedRandomFishable; - try { - ItemStack t = (ItemStack) ReflectionUtils - .getField(WeightedRandomFishable.class, "field_150711_b") - .get(u); - GTValues.RA.stdBuilder() - .itemInputs(GTUtility.getIntegratedCircuit(mType)) - .itemOutputs(t) - .duration(5 * SECONDS) - .eut(0) - .ignoreCollision() - .addTo(fishPondRecipes); - Logger.INFO("Fishing [" + mType + "]: " + ItemUtils.getArrayStackNames(new ItemStack[] { t })); - } catch (IllegalArgumentException | IllegalAccessException e1) { - Logger.INFO("Error generating Fish Pond Recipes. [2]"); - e1.printStackTrace(); - } - } + private static void generateRecipesFor(int circuitType, ArrayList<ItemStack> listToFill, + ArrayList<WeightedRandomFishable> lootTable, Field stackField) { + for (WeightedRandomFishable fishable : lootTable) { + try { + ItemStack stack = (ItemStack) stackField.get(fishable); + listToFill.add(stack.copy()); + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(circuitType)) + .itemOutputs(stack) + .duration(5 * SECONDS) + .eut(0) + .ignoreCollision() + .addTo(GTPPRecipeMaps.fishPondRecipes); + } catch (IllegalArgumentException | IllegalAccessException e1) { + Logger.INFO("Error generating Fish Pond Recipes"); + e1.printStackTrace(); } - mType++; } - - return true; + listToFill.trimToSize(); } } diff --git a/src/main/java/gregtech/api/util/GTOreDictUnificator.java b/src/main/java/gregtech/api/util/GTOreDictUnificator.java index 2a7ee08537..af7f249cec 100644 --- a/src/main/java/gregtech/api/util/GTOreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GTOreDictUnificator.java @@ -583,4 +583,8 @@ public class GTOreDictUnificator { return GTUtility.isStringValid(aName) ? Collections.unmodifiableList(OreDictionary.getOres(aName)) : Collections.emptyList(); } + + public static Map<String, ItemStack> getName2StackMap() { + return sName2StackMap; + } } diff --git a/src/main/java/gregtech/api/util/GTUtility.java b/src/main/java/gregtech/api/util/GTUtility.java index 442ba2a562..3294b0523d 100644 --- a/src/main/java/gregtech/api/util/GTUtility.java +++ b/src/main/java/gregtech/api/util/GTUtility.java @@ -62,7 +62,6 @@ import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.item.EntityItem; @@ -364,21 +363,6 @@ public class GTUtility { return null; } - public static Object callConstructor(String aClass, int aConstructorIndex, Object aReplacementObject, - boolean aLogErrors, Object... aParameters) { - try { - return callConstructor( - Class.forName(aClass), - aConstructorIndex, - aReplacementObject, - aLogErrors, - aParameters); - } catch (Throwable e) { - if (aLogErrors) e.printStackTrace(GTLog.err); - } - return aReplacementObject; - } - public static Object callConstructor(Class<?> aClass, int aConstructorIndex, Object aReplacementObject, boolean aLogErrors, Object... aParameters) { if (aConstructorIndex < 0) { @@ -401,31 +385,12 @@ public class GTUtility { return aReplacementObject; } - public static String capitalizeString(String aString) { - if (aString != null && aString.length() > 0) return aString.substring(0, 1) - .toUpperCase() + aString.substring(1); - return E; - } - - public static boolean getPotion(EntityLivingBase aPlayer, int aPotionIndex) { - try { - Field tPotionHashmap = null; - - Field[] fields = EntityLiving.class.getDeclaredFields(); - - for (Field field : fields) { - if (field.getType() == HashMap.class) { - tPotionHashmap = field; - tPotionHashmap.setAccessible(true); - break; - } - } - - if (tPotionHashmap != null) return ((HashMap<?, ?>) tPotionHashmap.get(aPlayer)).get(aPotionIndex) != null; - } catch (Throwable e) { - if (D1) e.printStackTrace(GTLog.err); + public static String capitalizeString(String s) { + if (s != null && !s.isEmpty()) { + return s.substring(0, 1) + .toUpperCase() + s.substring(1); } - return false; + return ""; } public static String getClassName(Object aObject) { @@ -438,26 +403,6 @@ public class GTUtility { .lastIndexOf(".") + 1); } - public static void removePotion(EntityLivingBase aPlayer, int aPotionIndex) { - try { - Field tPotionHashmap = null; - - Field[] fields = EntityLiving.class.getDeclaredFields(); - - for (Field field : fields) { - if (field.getType() == HashMap.class) { - tPotionHashmap = field; - tPotionHashmap.setAccessible(true); - break; - } - } - - if (tPotionHashmap != null) ((HashMap<?, ?>) tPotionHashmap.get(aPlayer)).remove(aPotionIndex); - } catch (Throwable e) { - if (D1) e.printStackTrace(GTLog.err); - } - } - public static boolean getFullInvisibility(EntityPlayer aPlayer) { try { if (aPlayer.isInvisible()) { diff --git a/src/main/java/gregtech/api/util/ReflectionUtil.java b/src/main/java/gregtech/api/util/ReflectionUtil.java new file mode 100644 index 0000000000..60abae8199 --- /dev/null +++ b/src/main/java/gregtech/api/util/ReflectionUtil.java @@ -0,0 +1,13 @@ +package gregtech.api.util; + +public class ReflectionUtil { + + public static Class<?> getClass(String classname) { + try { + return Class.forName(classname); + } catch (ClassNotFoundException e) { + return null; + } + } + +} diff --git a/src/main/java/gregtech/common/GTProxy.java b/src/main/java/gregtech/common/GTProxy.java index 221fcd6f1f..b5854ea2eb 100644 --- a/src/main/java/gregtech/common/GTProxy.java +++ b/src/main/java/gregtech/common/GTProxy.java @@ -136,7 +136,6 @@ import gregtech.api.interfaces.IBlockOnWalkOver; import gregtech.api.interfaces.IProjectileItem; import gregtech.api.interfaces.IToolStats; import gregtech.api.interfaces.internal.IGTMod; -import gregtech.api.interfaces.internal.IThaumcraftCompat; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.MetaGeneratedItem; import gregtech.api.items.MetaGeneratedTool; @@ -796,8 +795,9 @@ public abstract class GTProxy implements IGTMod, IFuelHandler { FMLCommonHandler.instance() .bus() .register(this); - GregTechAPI.sThaumcraftCompat = (IThaumcraftCompat) GTUtility - .callConstructor("gregtech.common.GTThaumcraftCompat", 0, null, GTValues.D1, new Object[0]); + if (Thaumcraft.isModLoaded()) { + GregTechAPI.sThaumcraftCompat = new GTThaumcraftCompat(); + } for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry .getRegisteredFluidContainerData()) { onFluidContainerRegistration(new FluidContainerRegistry.FluidContainerRegisterEvent(tData)); diff --git a/src/main/java/gregtech/common/GTThaumcraftCompat.java b/src/main/java/gregtech/common/GTThaumcraftCompat.java index 7f8c6dd8c7..aa52d9a292 100644 --- a/src/main/java/gregtech/common/GTThaumcraftCompat.java +++ b/src/main/java/gregtech/common/GTThaumcraftCompat.java @@ -193,7 +193,7 @@ public class GTThaumcraftCompat implements IThaumcraftCompat { if (aParentResearches != null) { ArrayList<String> tParentResearches = new ArrayList<>(); Collections.addAll(tParentResearches, aParentResearches); - if (tParentResearches.size() > 0) { + if (!tParentResearches.isEmpty()) { rResearch.setParents(tParentResearches.toArray(new String[0])); rResearch.setConcealed(); } diff --git a/src/main/java/gregtech/common/items/ItemAdvancedSensorCard.java b/src/main/java/gregtech/common/items/ItemAdvancedSensorCard.java index 8c68951bb7..8e588b4960 100644 --- a/src/main/java/gregtech/common/items/ItemAdvancedSensorCard.java +++ b/src/main/java/gregtech/common/items/ItemAdvancedSensorCard.java @@ -33,6 +33,7 @@ import com.google.common.collect.ImmutableList; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Mods; import gregtech.common.misc.GlobalMetricsCoverDatabase; import gregtech.common.misc.GlobalMetricsCoverDatabase.State; import shedar.mods.ic2.nuclearcontrol.api.CardState; @@ -41,7 +42,9 @@ import shedar.mods.ic2.nuclearcontrol.api.IPanelDataSource; import shedar.mods.ic2.nuclearcontrol.api.PanelSetting; import shedar.mods.ic2.nuclearcontrol.api.PanelString; -@SuppressWarnings("unused") +@cpw.mods.fml.common.Optional.Interface( + iface = "shedar.mods.ic2.nuclearcontrol.api.IPanelDataSource", + modid = Mods.Names.I_C2_NUCLEAR_CONTROL) public class ItemAdvancedSensorCard extends Item implements IPanelDataSource { public static final UUID CARD_TYPE_ID = UUID.fromString("ff952e84-7608-4c4a-85af-dd6e1aa27fc7"); diff --git a/src/main/java/gregtech/common/items/ItemSensorCard.java b/src/main/java/gregtech/common/items/ItemSensorCard.java index 39e3d48081..c3f0ef7061 100644 --- a/src/main/java/gregtech/common/items/ItemSensorCard.java +++ b/src/main/java/gregtech/common/items/ItemSensorCard.java @@ -14,8 +14,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; +import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Mods; import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; import gregtech.api.items.GTGenericItem; import gregtech.api.util.GTLanguageManager; @@ -26,6 +28,14 @@ import shedar.mods.ic2.nuclearcontrol.api.IRemoteSensor; import shedar.mods.ic2.nuclearcontrol.api.PanelSetting; import shedar.mods.ic2.nuclearcontrol.api.PanelString; +@Optional.InterfaceList( + value = { + @Optional.Interface( + iface = "shedar.mods.ic2.nuclearcontrol.api.IRemoteSensor", + modid = Mods.Names.I_C2_NUCLEAR_CONTROL), + @Optional.Interface( + iface = "shedar.mods.ic2.nuclearcontrol.api.IPanelDataSource", + modid = Mods.Names.I_C2_NUCLEAR_CONTROL) }) public class ItemSensorCard extends GTGenericItem implements IRemoteSensor, IPanelDataSource { private static final UUID CARD_TYPE = new UUID(0L, 41L); diff --git a/src/main/java/gregtech/common/render/GTCapeRenderer.java b/src/main/java/gregtech/common/render/GTCapeRenderer.java index ea8e0a37cd..43fda419e4 100644 --- a/src/main/java/gregtech/common/render/GTCapeRenderer.java +++ b/src/main/java/gregtech/common/render/GTCapeRenderer.java @@ -6,7 +6,6 @@ import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.potion.Potion; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderPlayerEvent; @@ -19,14 +18,19 @@ import gregtech.api.util.GTUtility; public class GTCapeRenderer extends RenderPlayer { - private final ResourceLocation[] mCapes = { new ResourceLocation("gregtech:textures/BrainTechCape.png"), + // spotless:off + private final ResourceLocation[] mCapes = { + new ResourceLocation("gregtech:textures/BrainTechCape.png"), new ResourceLocation("gregtech:textures/GregTechCape.png"), new ResourceLocation("gregtech:textures/MrBrainCape.png"), new ResourceLocation("gregtech:textures/GregoriusCape.png"), - new ResourceLocation("gregtech:textures/DonorCape.png"), new ResourceLocation("gregtech:textures/DevCape.png"), - new ResourceLocation("gregtech:textures/Steam.png"), new ResourceLocation("gregtech:textures/Titanium.png"), + new ResourceLocation("gregtech:textures/DonorCape.png"), + new ResourceLocation("gregtech:textures/DevCape.png"), + new ResourceLocation("gregtech:textures/Steam.png"), + new ResourceLocation("gregtech:textures/Titanium.png"), new ResourceLocation("gregtech:textures/Neutronium.png"), new ResourceLocation("gregtech:textures/Stargate.png") }; + // spotless:on private final Collection<String> mCapeList; public GTCapeRenderer(Collection<String> aCapeList) { @@ -40,13 +44,9 @@ public class GTCapeRenderer extends RenderPlayer { aEvent.setCanceled(true); return; } - float aPartialTicks = aEvent.partialRenderTick; if (aPlayer.isInvisible()) { return; } - if (GTUtility.getPotion(aPlayer, Potion.invisibility.id)) { - return; - } try { ResourceLocation tResource = aPlayer.getLocationCape(); if (aPlayer.getDisplayName() @@ -101,6 +101,7 @@ public class GTCapeRenderer extends RenderPlayer { bindTexture(tResource); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.0F, 0.125F); + float aPartialTicks = aEvent.partialRenderTick; double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks); double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks diff --git a/src/main/java/gregtech/common/tools/ToolPlunger.java b/src/main/java/gregtech/common/tools/ToolPlunger.java index 3ba428e707..5cb9bcff48 100644 --- a/src/main/java/gregtech/common/tools/ToolPlunger.java +++ b/src/main/java/gregtech/common/tools/ToolPlunger.java @@ -7,14 +7,13 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; +import gregtech.api.enums.Mods; import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.IItemBehaviour; -import gregtech.api.items.MetaBaseItem; import gregtech.api.items.MetaGeneratedTool; import gregtech.api.util.GTToolHarvestHelper; -import gregtech.api.util.GTUtility; +import gregtech.common.items.behaviors.BehaviourPlungerEssentia; import gregtech.common.items.behaviors.BehaviourPlungerFluid; import gregtech.common.items.behaviors.BehaviourPlungerItem; @@ -62,21 +61,12 @@ public class ToolPlunger extends GTTool { } @Override - @SuppressWarnings("unchecked") // the IItemBehaviour cast cannot be expressed strictly via generics public void onStatsAddedToTool(MetaGeneratedTool aItem, int aID) { aItem.addItemBehavior(aID, new BehaviourPlungerItem(getToolDamagePerDropConversion())); aItem.addItemBehavior(aID, new BehaviourPlungerFluid(getToolDamagePerDropConversion())); - try { - Object tObject = GTUtility.callConstructor( - "gregtech.common.items.behaviors.BehaviourPlungerEssentia", - 0, - null, - false, - getToolDamagePerDropConversion()); - if ((tObject instanceof IItemBehaviour)) { - aItem.addItemBehavior(aID, (IItemBehaviour<MetaBaseItem>) tObject); - } - } catch (Throwable ignored) {} + if (Mods.Thaumcraft.isModLoaded()) { + aItem.addItemBehavior(aID, new BehaviourPlungerEssentia(getToolDamagePerDropConversion())); + } } @Override diff --git a/src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java b/src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java index 08eb98c7d4..ee207bbaeb 100644 --- a/src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java +++ b/src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java @@ -22,7 +22,6 @@ import java.util.Locale; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -80,10 +79,12 @@ import gregtech.common.blocks.BlockStones; import gregtech.common.blocks.BlockTintedIndustrialGlass; import gregtech.common.blocks.BlockWormholeRender; import gregtech.common.blocks.TileEntityOres; +import gregtech.common.items.ItemAdvancedSensorCard; import gregtech.common.items.ItemDepletedCell; import gregtech.common.items.ItemFluidDisplay; import gregtech.common.items.ItemIntegratedCircuit; import gregtech.common.items.ItemNeutronReflector; +import gregtech.common.items.ItemSensorCard; import gregtech.common.items.ItemTierDrone; import gregtech.common.items.ItemVolumetricFlask; import gregtech.common.items.ItemWirelessHeadphones; @@ -179,25 +180,18 @@ public class LoaderGTBlockFluid implements Runnable { ItemList.VOLUMETRIC_FLASK.set(new ItemVolumetricFlask("Volumetric_Flask", "Volumetric flask", 1000)); - Item tItem = (Item) GTUtility.callConstructor( - "gregtech.common.items.ItemSensorCard", - 0, - null, - false, - new Object[] { "sensorcard", "GregTech Sensor Card" }); - ItemList.NC_SensorCard.set( - tItem == null ? new GTGenericItem("sensorcard", "GregTech Sensor Card", "Nuclear Control not installed") - : tItem); - - Item advSensorCard = (Item) GTUtility - .callConstructor("gregtech.common.items.ItemAdvancedSensorCard", 0, null, false); - ItemList.NC_AdvancedSensorCard.set( - advSensorCard == null - ? new GTGenericItem( + if (Mods.IC2NuclearControl.isModLoaded()) { + ItemList.NC_SensorCard.set(new ItemSensorCard("sensorcard", "GregTech Sensor Card")); + ItemList.NC_AdvancedSensorCard.set(new ItemAdvancedSensorCard()); + } else { + ItemList.NC_SensorCard + .set(new GTGenericItem("sensorcard", "GregTech Sensor Card", "Nuclear Control not installed")); + ItemList.NC_AdvancedSensorCard.set( + new GTGenericItem( "advancedsensorcard", "GregTech Advanced Sensor Card", - "Nuclear Control not installed") - : advSensorCard); + "Nuclear Control not installed")); + } ItemList.Neutron_Reflector.set(new ItemNeutronReflector("neutronreflector", "Iridium Neutron Reflector", 0)); ItemList.Reactor_Coolant_He_1 @@ -241,12 +235,12 @@ public class LoaderGTBlockFluid implements Runnable { ItemList.Depleted_Thorium_1.set(new ItemDepletedCell("ThoriumcellDep", "Fuel Rod (Depleted Thorium)", 1)); ItemList.Depleted_Thorium_2 .set(new ItemDepletedCell("Double_ThoriumcellDep", "Dual Fuel Rod (Depleted Thorium)", 1)); // TODO - // CHECK - // num + // CHECK + // num ItemList.Depleted_Thorium_4 .set(new ItemDepletedCell("Quad_ThoriumcellDep", "Quad Fuel Rod (Depleted Thorium)", 1)); // TODO - // CHECK - // num + // CHECK + // num ItemList.ThoriumCell_1.set( new ItemRadioactiveCellIC( "Thoriumcell", diff --git a/src/main/java/gtPlusPlus/GTplusplus.java b/src/main/java/gtPlusPlus/GTplusplus.java index 16d0b013b4..893446ea72 100644 --- a/src/main/java/gtPlusPlus/GTplusplus.java +++ b/src/main/java/gtPlusPlus/GTplusplus.java @@ -146,7 +146,7 @@ public class GTplusplus implements ActionListener { INIT_PHASE.SUPER.setPhaseActive(true); } - @Mod.EventHandler + @EventHandler public void preInit(final FMLPreInitializationEvent event) { INIT_PHASE.PRE_INIT.setPhaseActive(true); // Load all class objects within the plugin package. @@ -165,7 +165,7 @@ public class GTplusplus implements ActionListener { CoreManager.preInit(); } - @Mod.EventHandler + @EventHandler public void init(final FMLInitializationEvent event) { INIT_PHASE.INIT.setPhaseActive(true); proxy.init(event); @@ -178,7 +178,7 @@ public class GTplusplus implements ActionListener { } } - @Mod.EventHandler + @EventHandler public void postInit(final FMLPostInitializationEvent event) { INIT_PHASE.POST_INIT.setPhaseActive(true); proxy.postInit(event); @@ -222,7 +222,7 @@ public class GTplusplus implements ActionListener { INIT_PHASE.STARTED.setPhaseActive(true); } - @Mod.EventHandler + @EventHandler public synchronized void serverStopping(final FMLServerStoppingEvent event) { CoreManager.serverStop(); } @@ -238,7 +238,7 @@ public class GTplusplus implements ActionListener { * @param event - The {@link EventHandler} object passed through from FML to {@link #GTplusplus()}'s * {@link #instance}. */ - @Mod.EventHandler + @EventHandler public void onLoadComplete(FMLLoadCompleteEvent event) { proxy.onLoadComplete(event); generateGregtechRecipeMaps(); @@ -246,27 +246,25 @@ public class GTplusplus implements ActionListener { protected void generateGregtechRecipeMaps() { - int[] mInvalidCount = new int[] { 0, 0, 0, 0, 0, 0, 0 }; - RecipeGenBlastSmelterGTNH.generateGTNHBlastSmelterRecipesFromEBFList(); FishPondFakeRecipe.generateFishPondRecipes(); SemiFluidFuelHandler.generateFuels(); - mInvalidCount[0] = RecipeGenMultisUsingFluidInsteadOfCells + RecipeGenMultisUsingFluidInsteadOfCells .generateRecipesNotUsingCells(RecipeMaps.centrifugeRecipes, GTPPRecipeMaps.centrifugeNonCellRecipes); - mInvalidCount[1] = RecipeGenMultisUsingFluidInsteadOfCells + RecipeGenMultisUsingFluidInsteadOfCells .generateRecipesNotUsingCells(RecipeMaps.electrolyzerRecipes, GTPPRecipeMaps.electrolyzerNonCellRecipes); - mInvalidCount[2] = RecipeGenMultisUsingFluidInsteadOfCells + RecipeGenMultisUsingFluidInsteadOfCells .generateRecipesNotUsingCells(RecipeMaps.vacuumFreezerRecipes, GTPPRecipeMaps.advancedFreezerRecipes); - mInvalidCount[3] = RecipeGenMultisUsingFluidInsteadOfCells + RecipeGenMultisUsingFluidInsteadOfCells .generateRecipesNotUsingCells(RecipeMaps.mixerRecipes, GTPPRecipeMaps.mixerNonCellRecipes); - mInvalidCount[4] = RecipeGenMultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( + RecipeGenMultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( GTPPRecipeMaps.chemicalDehydratorRecipes, GTPPRecipeMaps.chemicalDehydratorNonCellRecipes); - mInvalidCount[5] = RecipeGenMultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( + RecipeGenMultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( GTPPRecipeMaps.coldTrapRecipes, GTPPRecipeMaps.nuclearSaltProcessingPlantRecipes); - mInvalidCount[6] = RecipeGenMultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( + RecipeGenMultisUsingFluidInsteadOfCells.generateRecipesNotUsingCells( GTPPRecipeMaps.reactorProcessingUnitRecipes, GTPPRecipeMaps.nuclearSaltProcessingPlantRecipes); } @@ -352,7 +350,7 @@ public class GTplusplus implements ActionListener { sMissingItemMappings.put("miscutils:oreFluorite", GameRegistry.findItem(GTPlusPlus.ID, "oreFluoriteF")); } - @Mod.EventHandler + @EventHandler public void missingMapping(FMLMissingMappingsEvent event) { processMissingMappings(); for (MissingMapping mapping : event.getAll()) { diff --git a/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java b/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java index 13dc18c4b1..51780fd030 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java @@ -13,36 +13,23 @@ import com.kuba6000.mobsinfo.api.MobRecipe; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.util.ReflectionUtil; import gtPlusPlus.core.material.MaterialsElements; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; @Optional.Interface(iface = "com.kuba6000.mobsinfo.api.IMobExtraInfoProvider", modid = "mobsinfo") public class EnderDragonDeathHandler implements IMobExtraInfoProvider { - private static final String mDragonClassName = "chylex.hee.entity.boss.EntityBossDragon"; - private static final boolean mHEE; - private static final Class mHardcoreDragonClass; - - private static final String mChaosDragonClassName = "com.brandon3055.draconicevolution.common.entity.EntityCustomDragon"; - private static final boolean mDE; - private static final Class mChaoseDragonClass; - - static { - mHEE = ReflectionUtils.doesClassExist(mDragonClassName); - mHardcoreDragonClass = (mHEE ? ReflectionUtils.getClass(mDragonClassName) : null); - mDE = ReflectionUtils.doesClassExist(mChaosDragonClassName); - mChaoseDragonClass = (mDE ? ReflectionUtils.getClass(mChaosDragonClassName) : null); - } + private static final Class<?> mHardcoreDragonClass = ReflectionUtil + .getClass("chylex.hee.entity.boss.EntityBossDragon"); + private static final Class<?> mChaoseDragonClass = ReflectionUtil + .getClass("com.brandon3055.draconicevolution.common.entity.EntityCustomDragon"); @SubscribeEvent public void onEntityDrop(LivingDropsEvent event) { - // - int aCountTotal = 0; - - if (mHEE && mHardcoreDragonClass != null && mHardcoreDragonClass.isInstance(event.entityLiving)) { + if (mHardcoreDragonClass != null && mHardcoreDragonClass.isInstance(event.entityLiving)) { for (int y = 0; y < MathUtils.randInt(100, 250); y++) { int aAmount = MathUtils.randInt(5, 25); event.entityLiving.entityDropItem( @@ -50,7 +37,7 @@ public class EnderDragonDeathHandler implements IMobExtraInfoProvider { MathUtils.randFloat(0, 1)); aCountTotal = +aAmount; } - } else if (mDE && mChaoseDragonClass != null && mChaoseDragonClass.isInstance(event.entityLiving)) { + } else if (mChaoseDragonClass != null && mChaoseDragonClass.isInstance(event.entityLiving)) { for (int y = 0; y < MathUtils.randInt(100, 200); y++) { int aAmount = MathUtils.randInt(1, 5); event.entityLiving.entityDropItem( @@ -69,7 +56,7 @@ public class EnderDragonDeathHandler implements IMobExtraInfoProvider { } if (aCountTotal > 0) { PlayerUtils - .messageAllPlayers(aCountTotal + " Shards of Dragons Blood have crystalized into a metallic form."); + .messageAllPlayers(aCountTotal + " Shards of Dragons Blood have crystallized into a metallic form."); } } @@ -77,7 +64,7 @@ public class EnderDragonDeathHandler implements IMobExtraInfoProvider { @Override public void provideExtraDropsInformation(@NotNull String entityString, @NotNull ArrayList<MobDrop> drops, @NotNull MobRecipe recipe) { - if (mHEE && mHardcoreDragonClass != null && mHardcoreDragonClass.isInstance(recipe.entity)) { + if (mHardcoreDragonClass != null && mHardcoreDragonClass.isInstance(recipe.entity)) { MobDrop drop = new MobDrop( MaterialsElements.STANDALONE.DRAGON_METAL.getNugget(1), MobDrop.DropType.Normal, @@ -90,7 +77,7 @@ public class EnderDragonDeathHandler implements IMobExtraInfoProvider { drop.clampChance(); drops.add(drop); - } else if (mDE && mChaoseDragonClass != null && mChaoseDragonClass.isInstance(recipe.entity)) { + } else if (mChaoseDragonClass != null && mChaoseDragonClass.isInstance(recipe.entity)) { MobDrop drop = new MobDrop( MaterialsElements.STANDALONE.DRAGON_METAL.getIngot(1), MobDrop.DropType.Normal, diff --git a/src/main/java/gtPlusPlus/core/item/ModItems.java b/src/main/java/gtPlusPlus/core/item/ModItems.java index 67ff8034dc..014b399044 100644 --- a/src/main/java/gtPlusPlus/core/item/ModItems.java +++ b/src/main/java/gtPlusPlus/core/item/ModItems.java @@ -1,5 +1,6 @@ package gtPlusPlus.core.item; +import static gregtech.api.enums.Mods.Baubles; import static gregtech.api.enums.Mods.Forestry; import static gregtech.api.enums.Mods.GTPlusPlus; import static gregtech.api.enums.Mods.GregTech; @@ -80,7 +81,6 @@ import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.everglades.GTPPEverglades; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; @@ -784,19 +784,9 @@ public final class ModItems { // Milled Ore Processing new MilledOreProcessing(); - // IC2 Exp - Logger.INFO("IndustrialCraft2 Found - Loading Resources."); - - // Baubles Mod Test - try { - final Class<?> baublesTest = ReflectionUtils.getClass("baubles.api.IBauble"); - if (baublesTest != null) { - CompatBaubles.run(); - } else { - Logger.INFO("Baubles Not Found - Skipping Resources."); - } - } catch (final Throwable T) { - Logger.INFO("Baubles Not Found - Skipping Resources."); + // Baubles + if (Baubles.isModLoaded()) { + CompatBaubles.run(); } // Buffer Cores! diff --git a/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java index 35adc35e96..89ddb241ed 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java @@ -22,7 +22,7 @@ import gtPlusPlus.preloader.PreloaderCore; public class FireProtectionBauble extends BaseBauble { - private static Field isImmuneToFire; + private static final Field isImmuneToFire; static { isImmuneToFire = ReflectionUtils diff --git a/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ItemArmourTinFoilHat.java b/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ItemArmourTinFoilHat.java index 7df52a176a..94b33a270e 100644 --- a/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ItemArmourTinFoilHat.java +++ b/src/main/java/gtPlusPlus/core/item/wearable/armour/tinfoil/ItemArmourTinFoilHat.java @@ -28,7 +28,6 @@ import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.util.GTUtility; import gtPlusPlus.core.item.wearable.armour.ArmourLoader; import gtPlusPlus.core.item.wearable.armour.base.BaseArmourHelm; @@ -120,55 +119,41 @@ public class ItemArmourTinFoilHat extends BaseArmourHelm { public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if (itemStack != null && player != null && world != null && !world.isRemote) { if (player instanceof EntityPlayer) { - // Apply Slow - if (!GTUtility.getPotion(player, Potion.moveSlowdown.id)) { + if (!player.isPotionActive(Potion.moveSlowdown.id)) { player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 1, true)); } - // Move Xp orbs away - try { - AxisAlignedBB box = player.boundingBox; - box.maxX = player.posX + 5; - box.maxY = player.posY + 5; - box.maxZ = player.posZ + 5; - box.minX = player.posX - 5; - box.minY = player.posY - 5; - box.minZ = player.posZ - 5; - @SuppressWarnings("unchecked") - List<Entity> g = world.getEntitiesWithinAABBExcludingEntity(player, box); - if (g.size() > 0) { - for (Entity e : g) { - if (e != null) { - if (!EntityXPOrb.class.isInstance(e) && !EntityBoat.class.isInstance(e) - && !EntitySnowball.class.isInstance(e) - && !EntityFireball.class.isInstance(e) - && !EntityEgg.class.isInstance(e) - && !EntityExpBottle.class.isInstance(e) - && !EntityEnderEye.class.isInstance(e) - && !EntityEnderPearl.class.isInstance(e)) { - continue; - } else { - // Logger.INFO("Found "+e.getClass().getName()); - double distX = player.posX - e.posX; - double distZ = player.posZ - e.posZ; - double distY = e.posY + 1.5D - player.posY; - double dir = Math.atan2(distZ, distX); - double speed = 1F / e.getDistanceToEntity(player) * 0.5; - speed = -speed; - if (distY < 0) { - e.motionY += speed; - } - e.motionX = Math.cos(dir) * speed; - e.motionZ = Math.sin(dir) * speed; - } - } + final AxisAlignedBB box = player.getBoundingBox(); + if (box != null) { + List<Entity> list = world.getEntitiesWithinAABBExcludingEntity( + player, + box.expand(5, 5, 5), + e -> e instanceof EntityXPOrb || e instanceof EntityBoat + || e instanceof EntitySnowball + || e instanceof EntityFireball + || e instanceof EntityEgg + || e instanceof EntityExpBottle + || e instanceof EntityEnderEye + || e instanceof EntityEnderPearl); + for (Entity e : list) { + final float dist = e.getDistanceToEntity(player); + if (dist == 0) continue; + double distX = player.posX - e.posX; + double distZ = player.posZ - e.posZ; + double distY = e.posY + 1.5D - player.posY; + double dir = Math.atan2(distZ, distX); + double speed = 1F / dist * 0.5; + speed = -speed; + if (distY < 0) { + e.motionY += speed; } + e.motionX = Math.cos(dir) * speed; + e.motionZ = Math.sin(dir) * speed; } - } catch (Throwable t) {} + } } } - super.onArmorTick(world, player, itemStack); } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 3565b1c14d..c64686a151 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -72,16 +72,16 @@ public class ItemUtils { return simpleMetaStack(Item.getItemFromBlock(x), meta, i); } - public static ItemStack getSimpleStack(final Item x, final int i) { - return new ItemStack(x, i); + public static ItemStack getSimpleStack(final Item item, final int stackSize) { + return new ItemStack(item, stackSize); } - public static ItemStack getSimpleStack(final ItemStack x, final int i) { - if (x == null) { + public static ItemStack getSimpleStack(final ItemStack stack, final int stackSize) { + if (stack == null) { return null; } - final ItemStack r = x.copy(); - r.stackSize = i; + final ItemStack r = stack.copy(); + r.stackSize = stackSize; return r; } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java index 7ea6af4a23..6f50da5eb2 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/PlayerUtils.java @@ -19,21 +19,14 @@ import net.minecraftforge.common.util.FakePlayer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.util.GTUtility; +import gregtech.api.util.ReflectionUtil; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class PlayerUtils { public static final Map<String, EntityPlayer> mCachedFakePlayers = new WeakHashMap<>(); - private static final Class mThaumcraftFakePlayer; - - static { - if (ReflectionUtils.doesClassExist("thaumcraft.common.lib.FakeThaumcraftPlayer")) { - mThaumcraftFakePlayer = ReflectionUtils.getClass("thaumcraft.common.lib.FakeThaumcraftPlayer"); - } else { - mThaumcraftFakePlayer = null; - } - } + private static final Class<?> mThaumcraftFakePlayer = ReflectionUtil + .getClass("thaumcraft.common.lib.FakeThaumcraftPlayer"); public static List<EntityPlayerMP> getOnlinePlayers() { final List<EntityPlayerMP> onlinePlayers = MinecraftServer.getServer() diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 576c236de6..40b32fed86 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -20,7 +20,6 @@ import gtPlusPlus.core.util.data.StringUtils; @SuppressWarnings({ "unchecked", "rawtypes" }) public class ReflectionUtils { - public static Map<String, Class<?>> mCachedClasses = new LinkedHashMap<>(); public static Map<String, CachedMethod> mCachedMethods = new LinkedHashMap<>(); public static Map<String, CachedField> mCachedFields = new LinkedHashMap<>(); public static Map<String, CachedConstructor> mCachedConstructors = new LinkedHashMap<>(); @@ -74,18 +73,6 @@ public class ReflectionUtils { .getUntypedField(Fields.LookupType.DECLARED_IN_HIERARCHY, field.getName())); } - private static boolean cacheClass(Class<?> aClass) { - if (aClass == null) { - return false; - } - Class<?> y = mCachedClasses.get(aClass.getCanonicalName()); - if (y == null) { - mCachedClasses.put(aClass.getCanonicalName(), aClass); - return true; - } - return false; - } - private static boolean cacheMethod(Class<?> aClass, Method aMethod) { if (aMethod == null) { return false; @@ -154,27 +141,6 @@ public class ReflectionUtils { } /** - * Returns a cached {@link Class} object. - * - * @param aClassCanonicalName - The canonical name of the underlying class. - * @return - Valid, {@link Class} object, or {@link null}. - */ - public static Class<?> getClass(String aClassCanonicalName) { - if (aClassCanonicalName == null || aClassCanonicalName.length() <= 0) { - return null; - } - Class<?> y = mCachedClasses.get(aClassCanonicalName); - if (y == null) { - y = getClass_Internal(aClassCanonicalName); - if (y != null) { - Logger.REFLECTION("Caching Class: " + aClassCanonicalName); - cacheClass(y); - } - } - return y; - } - - /** * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. * * @param aObject - Object containing the Method. @@ -263,10 +229,6 @@ public class ReflectionUtils { * Utility Functions */ - public static boolean doesClassExist(final String classname) { - return isClassPresent(classname); - } - public static void makeFieldAccessible(final Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic( field.getDeclaringClass() @@ -445,20 +407,6 @@ public class ReflectionUtils { } } - /** - * if (isPresent("com.optionaldependency.DependencyClass")) || This block will never execute when the dependency is - * not present. There is therefore no more risk of code throwing NoClassDefFoundException. - */ - private static boolean isClassPresent(final String className) { - try { - Class.forName(className); - return true; - } catch (final Throwable ex) { - // Class or one of its dependencies is not present... - return false; - } - } - private static Method getMethod_Internal(Class<?> aClass, String aMethodName, Class<?>... aTypes) { Method m = null; try { @@ -561,106 +509,6 @@ public class ReflectionUtils { } } - private static Class<?> getNonPublicClass(final String className) { - Class<?> c = null; - try { - c = Class.forName(className); - } catch (final ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - // full package name --------^^^^^^^^^^ - // or simpler without Class.forName: - // Class<package1.A> c = package1.A.class; - - if (null != c) { - // In our case we need to use - Constructor<?> constructor = null; - try { - constructor = c.getDeclaredConstructor(); - } catch (NoSuchMethodException | SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - // note: getConstructor() can return only public constructors - // so we needed to search for any Declared constructor - - // now we need to make this constructor accessible - if (null != constructor) { - constructor.setAccessible(true); // ABRACADABRA! - - try { - final Object o = constructor.newInstance(); - return (Class<?>) o; - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - return null; - } - - private static Class<?> getClass_Internal(String string) { - Class<?> aClass = null; - if (ReflectionUtils.doesClassExist(string)) { - try { - aClass = Class.forName(string); - } catch (ClassNotFoundException e) { - aClass = getNonPublicClass(string); - } - } - - if (aClass == null) { - String aClassName = ""; - Logger.REFLECTION("Splitting " + string + " to try look for hidden classes."); - String[] aData = string.split("\\."); - Logger.REFLECTION("Obtained " + aData.length + " pieces."); - for (int i = 0; i < (aData.length - 1); i++) { - aClassName += (i > 0) ? "." + aData[i] : "" + aData[i]; - Logger.REFLECTION("Building: " + aClassName); - } - if (aClassName != null && aClassName.length() > 0) { - Logger.REFLECTION("Trying to search '" + aClassName + "' for inner classes."); - Class<?> clazz = ReflectionUtils.getClass(aClassName); - if (clazz != null) { - Class[] y = clazz.getDeclaredClasses(); - if (y == null || y.length <= 0) { - Logger.REFLECTION("No hidden inner classes found."); - return null; - } else { - boolean found = false; - for (Class<?> h : y) { - Logger.REFLECTION("Found hidden inner class: " + h.getCanonicalName()); - if (h.getSimpleName() - .toLowerCase() - .equals(aData[aData.length - 1].toLowerCase())) { - Logger.REFLECTION( - "Found correct class. [" + aData[aData.length - 1] - + "] Caching at correct location: " - + string); - Logger.REFLECTION("Found at location: " + h.getCanonicalName()); - ReflectionUtils.mCachedClasses.put(string, h); - aClass = h; - found = true; - break; - } - } - if (!found) { - return null; - } - } - } else { - return null; - } - } else { - return null; - } - } - return aClass; - } - /** * * Set the value of a field reflectively. @@ -693,9 +541,7 @@ public class ReflectionUtils { T aInstance; try { aInstance = (T) aConstructor.newInstance(aArgs); - if (aInstance != null) { - return aInstance; - } + return aInstance; } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); diff --git a/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard.java b/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard.java index 4d3c78e6bd..a10f842d95 100644 --- a/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard.java +++ b/src/main/java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_LWJGL_Keyboard.java @@ -23,7 +23,7 @@ import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; -import gtPlusPlus.core.util.Utils; +import gregtech.api.util.ReflectionUtil; import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ClassTransformer_LWJGL_Keyboard { @@ -66,23 +66,21 @@ public class ClassTransformer_LWJGL_Keyboard { } public static void trySetClientKey(int aKey) { - if (Utils.isClient() && ReflectionUtils.doesClassExist("net.minecraft.client.Minecraft")) { - FMLRelaunchLog.log( - "[GT++ ASM] LWJGL Keybinding index out of bounds fix", - Level.INFO, - "Trying to set key value to be empty."); - GameSettings options = Minecraft.getMinecraft().gameSettings; - KeyBinding[] akeybinding = Minecraft.getMinecraft().gameSettings.keyBindings; - int i = akeybinding.length; - for (KeyBinding keybinding : akeybinding) { - if (keybinding != null && keybinding.getKeyCode() == aKey) { - options.setOptionKeyBinding(keybinding, 0); - FMLRelaunchLog.log( - "[GT++ ASM] LWJGL Keybinding index out of bounds fix", - Level.INFO, - "Set keybind " + aKey + " to 0."); - break; - } + FMLRelaunchLog.log( + "[GT++ ASM] LWJGL Keybinding index out of bounds fix", + Level.INFO, + "Trying to set key value to be empty."); + GameSettings options = Minecraft.getMinecraft().gameSettings; + KeyBinding[] akeybinding = Minecraft.getMinecraft().gameSettings.keyBindings; + int i = akeybinding.length; + for (KeyBinding keybinding : akeybinding) { + if (keybinding != null && keybinding.getKeyCode() == aKey) { + options.setOptionKeyBinding(keybinding, 0); + FMLRelaunchLog.log( + "[GT++ ASM] LWJGL Keybinding index out of bounds fix", + Level.INFO, + "Set keybind " + aKey + " to 0."); + break; } } } @@ -97,7 +95,7 @@ public class ClassTransformer_LWJGL_Keyboard { if (mKeyName != null) { return true; } - Class aKeyboard = ReflectionUtils.getClass("org.lwjgl.input.Keyboard"); + Class aKeyboard = ReflectionUtil.getClass("org.lwjgl.input.Keyboard"); if (aKeyboard != null) { mKeyboard = aKeyboard; Field aKeyName = ReflectionUtils.getField(mKeyboard, "keyName"); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java index ef3cb3ba48..7db3262531 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java @@ -9,14 +9,12 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; -import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; import java.util.function.BiPredicate; import java.util.function.Function; -import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -82,7 +80,6 @@ import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.config.ASMConfiguration; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.PreloaderCore; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.METHatchAirIntake; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchInputBattery; @@ -1591,12 +1588,7 @@ public abstract class GTPPMultiBlockBase<T extends MTEExtendedPowerMultiBlockBas public long count(GTPPMultiBlockBase<?> t) { return t.mTecTechEnergyHatches.size(); } - },; - - @SuppressWarnings("unchecked") - private static <T> Class<T> retype(Class<?> clazz) { - return (Class<T>) clazz; - } + }; private final List<? extends Class<? extends IMetaTileEntity>> mMteClasses; private final IGTHatchAdder<? super GTPPMultiBlockBase<?>> mAdder; @@ -1608,15 +1600,6 @@ public abstract class GTPPMultiBlockBase<T extends MTEExtendedPowerMultiBlockBas this.mAdder = aAdder; } - GTPPHatchElement(IGTHatchAdder<? super GTPPMultiBlockBase<?>> aAdder, String... aClassNames) { - this.mMteClasses = Arrays.stream(aClassNames) - .map(ReflectionUtils::getClass) - .filter(Objects::nonNull) - .<Class<? extends IMetaTileEntity>>map(GTPPHatchElement::retype) - .collect(Collectors.toList()); - this.mAdder = aAdder; - } - @Override public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { return mMteClasses; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialFishingPond.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialFishingPond.java index 4b9b5c0ae4..7f048b6847 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialFishingPond.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/MTEIndustrialFishingPond.java @@ -13,14 +13,11 @@ import static gregtech.api.util.GTStructureUtility.buildHatchAdder; import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandomFishable; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.NotNull; @@ -46,6 +43,7 @@ import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; import gregtech.api.util.ParallelHelper; +import gregtech.api.util.ReflectionUtil; import gtPlusPlus.api.recipe.GTPPRecipeMaps; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.config.Configuration; @@ -53,7 +51,6 @@ import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; import ic2.core.init.BlocksItems; import ic2.core.init.InternalName; @@ -61,15 +58,22 @@ import ic2.core.init.InternalName; public class MTEIndustrialFishingPond extends GTPPMultiBlockBase<MTEIndustrialFishingPond> implements ISurvivalConstructable { - private boolean isUsingControllerCircuit = false; - private static final Item circuit = GTUtility.getIntegratedCircuit(0) + public static final int FISH_MODE = 14; + public static final int JUNK_MODE = 15; + public static final int TREASURE_MODE = 16; + private static final Item CONTROL_CIRCUIT = GTUtility.getIntegratedCircuit(0) .getItem(); + private static IStructureDefinition<MTEIndustrialFishingPond> STRUCTURE_DEFINITION; + + private boolean isUsingControllerCircuit = false; private int mCasing; - private static IStructureDefinition<MTEIndustrialFishingPond> STRUCTURE_DEFINITION = null; + private int mMode = FISH_MODE; + private int mMax = 8; + private static final Class<?> cofhWater; static { - cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); + cofhWater = ReflectionUtil.getClass("cofh.asmhooks.block.BlockWater"); } public MTEIndustrialFishingPond(final int aID, final String aName, final String aNameRegional) { @@ -97,9 +101,9 @@ public class MTEIndustrialFishingPond extends GTPPMultiBlockBase<MTEIndustrialFi .addInfo("Controller Block for the Fishing Pond") .addInfo("Can process (Tier + 1) * 2 recipes") .addInfo("Put a numbered circuit into the input bus.") - .addInfo("Circuit 14 for Fish") - .addInfo("Circuit 15 for Junk") - .addInfo("Circuit 16 for Treasure") + .addInfo("Circuit " + FISH_MODE + " for Fish") + .addInfo("Circuit " + JUNK_MODE + " for Junk") + .addInfo("Circuit " + TREASURE_MODE + " for Treasure") .addInfo("Need to be filled with water.") .addInfo("Will automatically fill water from input hatch.") .addPollutionAmount(getPollutionPerSecond(null)) @@ -194,7 +198,7 @@ public class MTEIndustrialFishingPond extends GTPPMultiBlockBase<MTEIndustrialFi public @NotNull CheckRecipeResult checkProcessing() { ItemStack controllerStack = getControllerSlot(); if (controllerStack != null) { - if (controllerStack.getItem() == circuit) { + if (controllerStack.getItem() == CONTROL_CIRCUIT) { this.isUsingControllerCircuit = true; this.mMode = controllerStack.getItemDamage(); } else { @@ -203,9 +207,6 @@ public class MTEIndustrialFishingPond extends GTPPMultiBlockBase<MTEIndustrialFi } else { this.isUsingControllerCircuit = false; } - if (!hasGenerateRecipes) { - generateRecipes(); - } if (!checkForWater()) { return SimpleCheckRecipeResult.ofFailure("no_water"); } @@ -218,9 +219,9 @@ public class MTEIndustrialFishingPond extends GTPPMultiBlockBase<MTEIndustrialFi long tEnergy = getMaxInputEnergy(); - getCircuit(tItemInputs); + setModeFromInputStacks(tItemInputs); - ItemStack[] mFishOutput = generateLoot(this.mMode); + ItemStack[] mFishOutput = generateLoot(); mFishOutput = removeNulls(mFishOutput); GTRecipe g = new GTRecipe( true, @@ -281,45 +282,28 @@ public class MTEIndustrialFishingPond extends GTPPMultiBlockBase<MTEIndustrialFi return Configuration.pollution.pollutionPerSecondMultiIndustrialFishingPond; } - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public Block getCasingBlock() { + private Block getCasingBlock() { return ModBlocks.blockCasings3Misc; } - public byte getCasingMeta() { + private byte getCasingMeta() { return 0; } - public int getCasingTextureIndex() { + private int getCasingTextureIndex() { return TAE.GTPP_INDEX(32); } - public boolean checkForWater() { + private boolean checkForWater() { // Get Facing direction IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - int mDirectionX = aBaseMetaTileEntity.getBackFacing().offsetX; - int mCurrentDirectionX; - int mCurrentDirectionZ; - int mOffsetX_Lower = 0; - int mOffsetX_Upper = 0; - int mOffsetZ_Lower = 0; - int mOffsetZ_Upper = 0; - - mCurrentDirectionX = 4; - mCurrentDirectionZ = 4; - - mOffsetX_Lower = -4; - mOffsetX_Upper = 4; - mOffsetZ_Lower = -4; - mOffsetZ_Upper = 4; - - // if (aBaseMetaTileEntity.fac) - + final int mCurrentDirectionX = 4; + final int mCurrentDirectionZ = 4; + final int mOffsetX_Lower = -4; + final int mOffsetX_Upper = 4; + final int mOffsetZ_Lower = -4; + final int mOffsetZ_Upper = 4; final int xDir = aBaseMetaTileEntity.getBackFacing().offsetX * mCurrentDirectionX; final int zDir = aBaseMetaTileEntity.getBackFacing().offsetZ * mCurrentDirectionZ; @@ -336,13 +320,12 @@ public class MTEIndustrialFishingPond extends GTPPMultiBlockBase<MTEIndustrialFi if (stored.amount >= 1000) { // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus."); stored.amount -= 1000; - Block fluidUsed = Blocks.water; aBaseMetaTileEntity.getWorld() .setBlock( aBaseMetaTileEntity.getXCoord() + xDir + i, aBaseMetaTileEntity.getYCoord() + h, aBaseMetaTileEntity.getZCoord() + zDir + j, - fluidUsed); + Blocks.water); } } } @@ -365,119 +348,57 @@ public class MTEIndustrialFishingPond extends GTPPMultiBlockBase<MTEIndustrialFi || (cofhWater != null && cofhWater.isAssignableFrom(block.getClass()) && meta != 0); } - private static ArrayList<ArrayList<WeightedRandomFishable>> categories = new ArrayList<>(); - private static ArrayList<WeightedRandomFishable> categoryFish = new ArrayList<>(); - private static ArrayList<WeightedRandomFishable> categoryJunk = new ArrayList<>(); - private static ArrayList<WeightedRandomFishable> categoryLoot = new ArrayList<>(); - private static boolean hasGenerateRecipes = false; - private int mMode = 14; - private int mMax = 8; - - private void generateRecipes() { - if (hasGenerateRecipes) return; - - categories.add(categoryFish); - categories.add(categoryJunk); - categories.add(categoryLoot); - categoryFish.addAll(FishPondFakeRecipe.fish); - categoryJunk.addAll(FishPondFakeRecipe.junk); - categoryLoot.addAll(FishPondFakeRecipe.treasure); - hasGenerateRecipes = true; - } - - private int getCircuit(ItemStack[] t) { - if (!this.isUsingControllerCircuit) { - for (ItemStack j : t) { - if (j.getItem() == GTUtility.getIntegratedCircuit(0) - .getItem()) { - // Fish - if (j.getItemDamage() == 14) { - mMax = 8 + (this.getMaxParallelRecipes() - 2); - this.mMode = 14; - break; - } - // Junk - else if (j.getItemDamage() == 15) { - this.mMode = 15; - mMax = 4; - break; - } - // Loot - else if (j.getItemDamage() == 16) { - this.mMode = 16; - mMax = 4; - break; - } else { - this.mMode = 0; - mMax = 0; - break; - } + private void setModeFromInputStacks(ItemStack[] stacks) { + if (this.isUsingControllerCircuit) return; + for (ItemStack stack : stacks) { + if (stack.getItem() == CONTROL_CIRCUIT) { + if (stack.getItemDamage() == FISH_MODE) { + mMode = FISH_MODE; + mMax = 8 + (this.getMaxParallelRecipes() - 2); + return; + } else if (stack.getItemDamage() == JUNK_MODE) { + mMode = JUNK_MODE; + mMax = 4; + return; + } else if (stack.getItemDamage() == TREASURE_MODE) { + mMode = TREASURE_MODE; + mMax = 4; + return; } else { - this.mMode = 0; + mMode = 0; mMax = 0; - break; + return; } + } else { + mMode = 0; + mMax = 0; + break; } } - return this.mMode; } - // reflection map - private static Map<WeightedRandomFishable, ItemStack> reflectiveFishMap = new HashMap<>(); - - private ItemStack reflectiveFish(WeightedRandomFishable y) { - if (reflectiveFishMap.containsKey(y)) { - return reflectiveFishMap.get(y); + private ItemStack[] generateLoot() { + if (this.mMode == FISH_MODE) { + return getLootFromList(FishPondFakeRecipe.fish, (65 - getMaxParallelRecipes())); + } else if (this.mMode == JUNK_MODE) { + return getLootFromList(FishPondFakeRecipe.junk, 200); + } else if (this.mMode == TREASURE_MODE) { + return getLootFromList(FishPondFakeRecipe.treasure, 100); + } else { + return null; } - ItemStack t; - try { - t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b") - .get(y); - ItemStack k = ItemUtils.getSimpleStack(t, 1); - reflectiveFishMap.put(y, k); - return t; - } catch (IllegalArgumentException | IllegalAccessException e) {} - return null; } - private ItemStack[] generateLoot(int mode) { - ItemStack[] mFishOutput = new ItemStack[this.mMax]; - if (this.mMode == 14) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryFish) { - if (MathUtils.randInt(0, (65 - getMaxParallelRecipes())) <= 2) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } - } - } - } else if (this.mMode == 15) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryJunk) { - if (MathUtils.randInt(0, 100) <= 1) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } - } - } - } else if (this.mMode == 16) { - for (int k = 0; k < this.mMax; k++) { - if (mFishOutput[k] == null) for (WeightedRandomFishable g : categoryLoot) { - if (MathUtils.randInt(0, 1000) <= 2) { - ItemStack t = reflectiveFish(g); - if (t != null) { - mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); - } - } + private ItemStack[] getLootFromList(ArrayList<ItemStack> list, int max) { + ItemStack[] out = new ItemStack[this.mMax]; + for (int i = 0; i < this.mMax; i++) { + for (ItemStack stack : list) { + if (MathUtils.randInt(0, max) <= 2) { + out[i] = ItemUtils.getSimpleStack(stack, 1); + break; } } - } else { - mFishOutput = null; } - return mFishOutput; + return out; } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java index f2f0bcb104..c9af07ecf3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/MTEAlgaePondBase.java @@ -43,6 +43,7 @@ import gregtech.api.util.GTRecipe; import gregtech.api.util.GTStreamUtil; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.ReflectionUtil; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.config.Configuration; @@ -50,7 +51,6 @@ import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GTPPMultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoaderAlgaeFarm; @@ -67,7 +67,7 @@ public class MTEAlgaePondBase extends GTPPMultiBlockBase<MTEAlgaePondBase> imple private static final Class<?> cofhWater; static { - cofhWater = ReflectionUtils.getClass("cofh.asmhooks.block.BlockWater"); + cofhWater = ReflectionUtil.getClass("cofh.asmhooks.block.BlockWater"); } public MTEAlgaePondBase(final int aID, final String aName, final String aNameRegional) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java index 89fdf23ec6..5f5160b6a4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java @@ -7,15 +7,12 @@ import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; import static gregtech.api.util.GTRecipeBuilder.SECONDS; import java.util.ArrayList; -import java.util.Map; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; -import org.apache.commons.lang3.reflect.FieldUtils; - import gregtech.api.enums.GTValues; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -33,7 +30,7 @@ public class RecipeGenRecycling implements Runnable { public static ArrayList<Runnable> mQueuedRecyclingGenerators = new ArrayList<>(); public static void executeGenerators() { - if (mQueuedRecyclingGenerators.size() > 0) { + if (!mQueuedRecyclingGenerators.isEmpty()) { for (Runnable R : mQueuedRecyclingGenerators) { R.run(); } @@ -41,21 +38,15 @@ public class RecipeGenRecycling implements Runnable { } final Material toGenerate; - public static Map<String, ItemStack> mNameMap; public RecipeGenRecycling(final Material M) { this.toGenerate = M; - if (mNameMap == null) { - mNameMap = this.getNameMap(); - } mQueuedRecyclingGenerators.add(this); } @Override public void run() { - if (mNameMap != null) { - generateRecipes(this.toGenerate); - } + generateRecipes(this.toGenerate); } public static void generateRecipes(final Material material) { @@ -253,12 +244,14 @@ public class RecipeGenRecycling implements Runnable { Logger.modLogger.warn("Returning Null. Method: ", new Exception()); return null; } - if (!mNameMap.containsKey(aName.toString()) && aMentionPossibleTypos) { + if (!GTOreDictUnificator.getName2StackMap() + .containsKey(aName.toString()) && aMentionPossibleTypos) { Logger.WARNING("Unknown Key for Unification, Typo? " + aName); } return GTUtility.copyAmount( aAmount, - new Object[] { mNameMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement }); + new Object[] { GTOreDictUnificator.getName2StackMap() + .get(aName.toString()), getFirstOre(aName, aAmount), aReplacement }); } public static ItemStack getFirstOre(final Object aName, final long aAmount) { @@ -266,7 +259,8 @@ public class RecipeGenRecycling implements Runnable { Logger.modLogger.warn("Returning Null. Method: ", new Exception()); return null; } - final ItemStack tStack = mNameMap.get(aName.toString()); + final ItemStack tStack = GTOreDictUnificator.getName2StackMap() + .get(aName.toString()); if (GTUtility.isStackValid(tStack)) { Logger.WARNING("Found valid stack."); return GTUtility.copyAmount(aAmount, new Object[] { tStack }); @@ -289,23 +283,6 @@ public class RecipeGenRecycling implements Runnable { return rList; } - @SuppressWarnings("unchecked") - public Map<String, ItemStack> getNameMap() { - Map<String, ItemStack> tempMap; - try { - tempMap = (Map<String, ItemStack>) FieldUtils - .readStaticField(GTOreDictUnificator.class, "sName2StackMap", true); - if (tempMap != null) { - Logger.WARNING("Found 'sName2StackMap' in GTOreDictUnificator.class."); - return tempMap; - } - } catch (final IllegalAccessException e) { - e.printStackTrace(); - } - Logger.WARNING("Invalid map stored in GTOreDictUnificator.class, unable to find sName2StackMap field."); - return null; - } - public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, final int amount) { try { diff --git a/src/main/java/gtPlusPlus/xmod/thermalfoundation/item/TFItems.java b/src/main/java/gtPlusPlus/xmod/thermalfoundation/item/TFItems.java index 556b11483f..9c8e7137c3 100644 --- a/src/main/java/gtPlusPlus/xmod/thermalfoundation/item/TFItems.java +++ b/src/main/java/gtPlusPlus/xmod/thermalfoundation/item/TFItems.java @@ -7,9 +7,9 @@ import cofh.core.item.ItemBase; import cofh.core.item.ItemBucket; import cofh.core.util.energy.FurnaceFuelHandler; import cofh.core.util.fluid.BucketHandler; +import gregtech.api.enums.Mods; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.thermalfoundation.block.TFBlocks; import gtPlusPlus.xmod.thermalfoundation.fluid.TFFluids; @@ -45,9 +45,8 @@ public class TFItems { dustPyrotheum = itemMaterial.addOreDictItem(3, "dustPyrotheum"); dustCryotheum = itemMaterial.addOreDictItem(4, "dustCryotheum"); - if (ReflectionUtils.doesClassExist("cofh.core.util.energy.FurnaceFuelHandler")) { - FurnaceFuelHandler.registerFuel(dustPyrotheum, 2400); // cofh.core.util.energy.FurnaceFuelHandler.registerFuel(ItemStack, - // int) + if (Mods.COFHCore.isModLoaded()) { + FurnaceFuelHandler.registerFuel(dustPyrotheum, 2400); } ItemUtils.addItemToOreDictionary(rodBlizz, "stickBlizz"); diff --git a/src/main/java/gtnhlanth/loader/ZPMRubberChanges.java b/src/main/java/gtnhlanth/loader/ZPMRubberChanges.java index a5cba15f63..a00b28ae9b 100644 --- a/src/main/java/gtnhlanth/loader/ZPMRubberChanges.java +++ b/src/main/java/gtnhlanth/loader/ZPMRubberChanges.java @@ -43,16 +43,6 @@ public class ZPMRubberChanges implements Runnable { @SuppressWarnings("unchecked") public void run() { - List<IRecipe> bufferedRecipeList = null; - - try { - bufferedRecipeList = (List<IRecipe>) FieldUtils - .getDeclaredField(GTModHandler.class, "sBufferRecipeList", true) - .get(null); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - HashSet<ItemStack> ZPMPlusComponents = new HashSet<>(); OrePrefixes[] RubberGenerated = { plate }; @@ -77,7 +67,7 @@ public class ZPMRubberChanges implements Runnable { GTLog.out.print(component.getDisplayName() + " "); } - replaceAllRecipes(ZPMPlusComponents, RubberGenerated, bufferedRecipeList); + replaceAllRecipes(ZPMPlusComponents, RubberGenerated, GTModHandler.sBufferRecipeList); } private static void replaceAllRecipes(Collection<ItemStack> ZPMPlusComponents, OrePrefixes[] RubberGenerated, diff --git a/src/main/resources/META-INF/gregtech_at.cfg b/src/main/resources/META-INF/gregtech_at.cfg index 065f0c4a26..9e6576dc3d 100644 --- a/src/main/resources/META-INF/gregtech_at.cfg +++ b/src/main/resources/META-INF/gregtech_at.cfg @@ -8,18 +8,3 @@ public net.minecraft.nbt.NBTTagCompound field_74784_a # tagMap # TecTech public net.minecraft.block.Block field_149781_w #blockResistance public net.minecraft.block.Block field_149782_v #blockHardness -protected net.minecraft.client.gui.FontRenderer field_111274_c #unicodePageLocations -protected net.minecraft.client.gui.FontRenderer field_78285_g #colorCode -protected net.minecraft.client.gui.FontRenderer field_78298_i #renderEngine -protected net.minecraft.client.gui.FontRenderer field_78293_l #unicodeFlag -protected net.minecraft.client.gui.FontRenderer field_78294_m #bidiFlag -protected net.minecraft.client.gui.FontRenderer field_78291_n #red -protected net.minecraft.client.gui.FontRenderer field_78292_o #blue -protected net.minecraft.client.gui.FontRenderer field_78306_p #green -protected net.minecraft.client.gui.FontRenderer field_78305_q #alpha -protected net.minecraft.client.gui.FontRenderer field_78304_r #textColor -protected net.minecraft.client.gui.FontRenderer field_78303_s #randomStyle -protected net.minecraft.client.gui.FontRenderer field_78302_t #boldStyle -protected net.minecraft.client.gui.FontRenderer field_78301_u #italicStyle -protected net.minecraft.client.gui.FontRenderer field_78300_v #underlineStyle -protected net.minecraft.client.gui.FontRenderer field_78299_w #strikethroughStyle |