From e5193543b16561e0f6b13ba0a347d94092d8a9b4 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 12 May 2019 11:09:03 +1000 Subject: + Thermal Boiler now pulls lava filters from an input bus. + Added some minor GUI functions to GregtechMeta_MultiBlockBase. + Added some new Reflection functions. --- .../core/util/reflect/ReflectionUtils.java | 202 ++++++++++++++++++--- 1 file changed, 176 insertions(+), 26 deletions(-) (limited to 'src/Java/gtPlusPlus/core/util/reflect') diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 722a4f3ff7..c86d6ccb83 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -3,10 +3,17 @@ package gtPlusPlus.core.util.reflect; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.Field; +import java.lang.reflect.GenericDeclaration; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import org.apache.commons.lang3.ArrayUtils; @@ -133,8 +140,8 @@ public class ReflectionUtils { public static Method getMethod(Object aObject, String aMethodName, Class[] aTypes) { return getMethod(aObject.getClass(), aMethodName, aTypes); } - - + + /** * Returns a cached {@link Method} object. * @param aClass - Class containing the Method. @@ -193,7 +200,7 @@ public class ReflectionUtils { return y.get(); } } - + /** * Returns a cached {@link Field} object. * @param aInstance - {@link Object} to get the field instance from. @@ -219,6 +226,20 @@ public class ReflectionUtils { return isClassPresent(classname); } + + /** + * Returns the class of the objects type parameter + * @param o - Object to examine paramters on + * @return - a Class or null + */ + public static Class getTypeOfGenericObject(Object o) { + Class aTypeParam = findSuperClassParameterType(o, o.getClass(), 0); + if (aTypeParam == null) { + aTypeParam = findSubClassParameterType(o, o.getClass(), 0); + } + return aTypeParam; + } + public static void makeFieldAccessible(final Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) @@ -271,7 +292,7 @@ public class ReflectionUtils { return loaded > 0; } - + public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { Class clazz = object.getClass(); @@ -414,13 +435,27 @@ public class ReflectionUtils { - - - - - - - + + + + + + + + + + + + + + + + + + /* + * Internal Magic that probably should not get exposed. + */ + @@ -429,11 +464,126 @@ public class ReflectionUtils { + /* + * + * Below Code block is used for determining generic types associated with type + * + */ + + + //https://xebia.com/blog/acessing-generic-types-at-runtime-in-java/ + //https://www.javacodegeeks.com/2013/12/advanced-java-generics-retreiving-generic-type-arguments.html + public static Class findSuperClassParameterType(Object instance, Class classOfInterest, int parameterIndex) { + Class subClass = instance.getClass(); + while (classOfInterest != subClass.getSuperclass()) { + // instance.getClass() is no subclass of classOfInterest or instance is a direct instance of classOfInterest + subClass = subClass.getSuperclass(); + if (subClass == null) { + return null; + } + } + ParameterizedType parameterizedType = (ParameterizedType) subClass.getGenericSuperclass(); + Class aReturn; + aReturn = (Class) parameterizedType.getActualTypeArguments()[parameterIndex]; + return aReturn; + } + + public static Class findSubClassParameterType(Object instance, Class classOfInterest, int parameterIndex) { + Map typeMap = new HashMap(); + Class instanceClass = instance.getClass(); + while (classOfInterest != instanceClass.getSuperclass()) { + extractTypeArguments(typeMap, instanceClass); + instanceClass = instanceClass.getSuperclass(); + if (instanceClass == null) { + return null; + } + } + + ParameterizedType parameterizedType = (ParameterizedType) instanceClass.getGenericSuperclass(); + Type actualType = parameterizedType.getActualTypeArguments()[parameterIndex]; + if (typeMap.containsKey(actualType)) { + actualType = typeMap.get(actualType); + } + if (actualType instanceof Class) { + return (Class) actualType; + } else if (actualType instanceof TypeVariable) { + return browseNestedTypes(instance, (TypeVariable) actualType); + } else { + return null; + } + } + + private static void extractTypeArguments(Map typeMap, Class clazz) { + Type genericSuperclass = clazz.getGenericSuperclass(); + if (!(genericSuperclass instanceof ParameterizedType)) { + return; + } + + ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass; + Type[] typeParameter = ((Class) parameterizedType.getRawType()).getTypeParameters(); + Type[] actualTypeArgument = parameterizedType.getActualTypeArguments(); + for (int i = 0; i < typeParameter.length; i++) { + if(typeMap.containsKey(actualTypeArgument[i])) { + actualTypeArgument[i] = typeMap.get(actualTypeArgument[i]); + } + typeMap.put(typeParameter[i], actualTypeArgument[i]); + } + } + + private static Class browseNestedTypes(Object instance, TypeVariable actualType) { + Class instanceClass = instance.getClass(); + List> nestedOuterTypes = new LinkedList>(); + for (Class enclosingClass = instanceClass + .getEnclosingClass(); enclosingClass != null; enclosingClass = enclosingClass.getEnclosingClass()) { + try { + Field this$0 = instanceClass.getDeclaredField("this$0"); + Object outerInstance = this$0.get(instance); + Class outerClass = outerInstance.getClass(); + nestedOuterTypes.add(outerClass); + Map outerTypeMap = new HashMap(); + extractTypeArguments(outerTypeMap, outerClass); + for (Map.Entry entry : outerTypeMap.entrySet()) { + if (!(entry.getKey() instanceof TypeVariable)) { + continue; + } + TypeVariable foundType = (TypeVariable) entry.getKey(); + if (foundType.getName().equals(actualType.getName()) + && isInnerClass(foundType.getGenericDeclaration(), actualType.getGenericDeclaration())) { + if (entry.getValue() instanceof Class) { + return (Class) entry.getValue(); + } + actualType = (TypeVariable) entry.getValue(); + } + } + } catch (NoSuchFieldException | IllegalAccessException e) { + + } + + } + return null; + } + + private static boolean isInnerClass(GenericDeclaration outerDeclaration, GenericDeclaration innerDeclaration) { + if (!(outerDeclaration instanceof Class) || !(innerDeclaration instanceof Class)) { + return false; + } + Class outerClass = (Class) outerDeclaration; + Class innerClass = (Class) innerDeclaration; + while ((innerClass = innerClass.getEnclosingClass()) != null) { + if (innerClass == outerClass) { + return true; + } + } + return false; + } /* - * Internal Magic that probably should not get exposed. - */ + * + * End of Generics Block + * + */ + private static Field getField_Internal(final Class clazz, final String fieldName) throws NoSuchFieldException { @@ -525,26 +675,26 @@ public class ReflectionUtils { return getMethod_Internal(superClass, aMethodName); } } - + private static void dumpClassInfo(Class aClass) { Logger.INFO("We ran into an error processing reflection in "+aClass.getName()+", dumping all data for debugging."); // Get the methods - Method[] methods = aClass.getDeclaredMethods(); - Field[] fields = aClass.getDeclaredFields(); - Constructor[] consts = aClass.getDeclaredConstructors(); + Method[] methods = aClass.getDeclaredMethods(); + Field[] fields = aClass.getDeclaredFields(); + Constructor[] consts = aClass.getDeclaredConstructors(); Logger.INFO("Dumping all Methods."); - for (Method method : methods) { - System.out.println(method.getName()+" | "+StringUtils.getDataStringFromArray(method.getParameterTypes())); - } + for (Method method : methods) { + System.out.println(method.getName()+" | "+StringUtils.getDataStringFromArray(method.getParameterTypes())); + } Logger.INFO("Dumping all Fields."); - for (Field f : fields) { - System.out.println(f.getName()); - } + for (Field f : fields) { + System.out.println(f.getName()); + } Logger.INFO("Dumping all Constructors."); - for (Constructor c : consts) { - System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+StringUtils.getDataStringFromArray(c.getParameterTypes())); - } + for (Constructor c : consts) { + System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+StringUtils.getDataStringFromArray(c.getParameterTypes())); + } } private static Class getNonPublicClass(final String className) { -- cgit From d30f18947a5c5e275ef7f17323ac837939cb0135 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 12 May 2019 16:04:15 +1000 Subject: % More work on Advanced Mufflers. --- src/Java/gtPlusPlus/core/slots/SlotAirFilter.java | 30 ++++++ src/Java/gtPlusPlus/core/util/math/MathUtils.java | 9 +- .../core/util/reflect/ReflectionUtils.java | 9 +- .../api/gui/CONTAINER_Hatch_Muffler_Advanced.java | 25 +---- .../api/gui/GUI_Hatch_Muffler_Advanced.java | 22 ++-- .../GT_MetaTileEntity_Hatch_Muffler_Adv.java | 118 ++++++++++++++++----- 6 files changed, 154 insertions(+), 59 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/slots/SlotAirFilter.java (limited to 'src/Java/gtPlusPlus/core/util/reflect') diff --git a/src/Java/gtPlusPlus/core/slots/SlotAirFilter.java b/src/Java/gtPlusPlus/core/slots/SlotAirFilter.java new file mode 100644 index 0000000000..92e9bebe21 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotAirFilter.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.slots; + +import gtPlusPlus.core.item.general.ItemAirFilter; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotAirFilter extends Slot { + + public SlotAirFilter(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if (itemstack == null) { + return false; + } + if (itemstack.getItem() instanceof ItemAirFilter){ + return true; + } + return false; + } + + @Override + public int getSlotStackLimit() { + return 1; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 3cef3c511f..bda722b47e 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -7,6 +7,7 @@ import gregtech.api.enums.GT_Values; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -227,7 +228,7 @@ public class MathUtils { * @param x Value A. * @return boolean Whether or not it divides evenly. */ - public static boolean isNumberEven(final int x){ + public static boolean isNumberEven(final long x){ if ((x % 2) == 0) { return true; @@ -696,5 +697,11 @@ public class MathUtils { int aAmount = Math.max(Math.min(i, aMax), aMin); return aAmount; } + + public static Pair splitLongIntoIntegers(long aLong){ + int aIntMaxInLong = (int) Math.min(Integer.MAX_VALUE, Math.floor(aLong/Integer.MAX_VALUE)); + int aRemainder = (int) (aLong - (aIntMaxInLong * Integer.MAX_VALUE)); + return new Pair(aIntMaxInLong, aRemainder); + } } diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index c86d6ccb83..224d842ba7 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -318,9 +318,14 @@ public class ReflectionUtils { /** * Allows to change the state of an immutable instance. Huh?!? */ - public static void setFinalFieldValue(Class clazz, String fieldName, Object newValue) throws Exception { + public static void setFinalFieldValue(Class clazz, String fieldName, Object newValue) { Field nameField = getField(clazz, fieldName); - setFieldValue_Internal(clazz, nameField, newValue); + try { + setFieldValue_Internal(clazz, nameField, newValue); + } + catch (Throwable t) { + t.printStackTrace(); + } } @Deprecated diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java index 30d0c3dcd6..721fe053ae 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java @@ -1,13 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import java.util.List; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler_Adv; +import gtPlusPlus.core.slots.SlotAirFilter; +import net.minecraft.entity.player.InventoryPlayer; public class CONTAINER_Hatch_Muffler_Advanced extends GT_ContainerMetaTile_Machine { @@ -25,7 +21,7 @@ public class CONTAINER_Hatch_Muffler_Advanced extends GT_ContainerMetaTile_Machi @Override public void addSlots(final InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot(this.mTileEntity, 1, 80, 17)); + this.addSlotToContainer(new SlotAirFilter(this.mTileEntity, 1, 80, 35)); } @Override @@ -41,26 +37,15 @@ public class CONTAINER_Hatch_Muffler_Advanced extends GT_ContainerMetaTile_Machi @Override public void updateProgressBar(final int id, final int value) { super.updateProgressBar(id, value); - switch (id) { - case 100: - this.maxEU = value; - return; - case 101: - this.storedEU = value; - break; + switch (id) { default: break; } } - @SuppressWarnings("unchecked") @Override public void detectAndSendChanges() { - super.detectAndSendChanges(); - for(final ICrafting crafting : (List)this.crafters) { - crafting.sendProgressBarUpdate(this, 100, (int) ((GT_MetaTileEntity_Hatch_Muffler_Adv) this.mTileEntity.getMetaTileEntity()).maxEUStore()); - crafting.sendProgressBarUpdate(this, 101, (int) ((GT_MetaTileEntity_Hatch_Muffler_Adv) this.mTileEntity.getMetaTileEntity()).getEUVar()); - } + super.detectAndSendChanges(); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java index 7aed0e60e1..4b998f6487 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java @@ -1,12 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.gui; -import net.minecraft.entity.player.InventoryPlayer; - import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.lib.CORE; +import net.minecraft.entity.player.InventoryPlayer; public class GUI_Hatch_Muffler_Advanced extends GT_GUIContainerMetaTile_Machine { @@ -21,18 +19,26 @@ public class GUI_Hatch_Muffler_Advanced extends GT_GUIContainerMetaTile_Machine @Override protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.fontRendererObj.drawString(this.mName, 64, 6, 16448255); + this.fontRendererObj.drawString(this.mName, 8, 8, 16448255); + /* + * ReflectionUtils.setField(this.fontRendererObj, "underlineStyle", true); + * ReflectionUtils.setField(this.fontRendererObj, "italicStyle", true); + * ReflectionUtils.setField(this.fontRendererObj, "boldStyle", true); boolean + * isBold = ReflectionUtils.getField(this.fontRendererObj, "boldStyle"); + * this.fontRendererObj.drawString("Insert Air Filters - Bold: "+isBold, 8, 18, + * 16448255); + */ if (this.mContainer != null) { - this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; - this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + //this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + //this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; } } @Override protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; - this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; + //this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; + //this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; final int x = (this.width - this.xSize) / 2; final int y = (this.height - this.ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java index 0479914115..4052a5c266 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -10,6 +11,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.general.ItemAirFilter; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_Hatch_Muffler_Advanced; import gtPlusPlus.xmod.gregtech.api.gui.GUI_Hatch_Muffler_Advanced; import gtPlusPlus.xmod.gregtech.common.StaticFields59; @@ -44,26 +46,30 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch public GT_MetaTileEntity_Hatch_Muffler_Adv(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public GT_MetaTileEntity_Hatch_Muffler_Adv(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription[0], aTextures); + ReflectionUtils.setField(this, "mInventory", new ItemStack[1]); } public String[] getDescription() { if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { String[] mDescArray = StaticFields59.getDescriptionArray(this); - String[] desc = new String[mDescArray.length + 5]; + String[] desc = new String[mDescArray.length + 6]; System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length); desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; desc[mDescArray.length + 1] = "Requires 3 Air on the exhaust face"; desc[mDescArray.length + 2] = "Requires Air Filters"; - desc[mDescArray.length + 3] = "Reduces Pollution to " + this.calculatePollutionReduction(100) + "%"; - desc[mDescArray.length + 4] = "Recovers " + (105 - this.calculatePollutionReduction(100)) + desc[mDescArray.length + 3] = "Mufflers require T2 Filters from IV-"+GT_Values.VN[9]; + desc[mDescArray.length + 4] = "Reduces Pollution to " + this.calculatePollutionReductionForTooltip(100) + "%"; + desc[mDescArray.length + 5] = "Recovers " + (105 - this.calculatePollutionReductionForTooltip(100)) + "% of CO2/CO/SO2"; return desc; } @@ -81,7 +87,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public boolean isValidSlot(int aIndex) { - return false; + return aIndex == SLOT_FILTER; } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -104,7 +110,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "machine_Charger.png"); + return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, "Advanced Muffler", "machine_Charger.png"); } private boolean airCheck() { @@ -119,7 +125,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public boolean polluteEnvironment() { - if (airCheck()) { + if (airCheck() && damageAirFilter()) { int aEmission = this.calculatePollutionReduction(10000); PollutionUtils.addPollution(this.getBaseMetaTileEntity(), aEmission); //Logger.INFO("Outputting "+aEmission+"gbl"); @@ -130,6 +136,11 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } } + + public int calculatePollutionReductionForTooltip(int aPollution) { + return (int) (aPollution * Math.pow(0.64D, (double) (this.mTier - 1))); + } + public int calculatePollutionReduction(int aPollution) { double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1)); int aVal2 = (int) aVal1; @@ -148,21 +159,69 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch return false; } + private ItemStack getInventoryStack() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length-1 >= this.SLOT_FILTER) { + return this.mInventory[this.SLOT_FILTER]; + } + } + return null; + } + + private void breakAirFilter() { + if (this.mInventory != null && this.mInventory.length > 0) { + if (this.mInventory.length-1 >= this.SLOT_FILTER) { + Logger.INFO("Breaking Filter"); + this.mInventory[this.SLOT_FILTER] = null; + } + } + } + public boolean hasValidFilter() { - return isAirFilter(this.mInventory[this.SLOT_FILTER]); + return isAirFilter(getInventoryStack()); } - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + + //Logger.INFO("A1"); + super.onPostTick(aBaseMetaTileEntity, aTick); - String aParticleName; - if (hasValidFilter()) { - aParticleName = "cloud"; - } else { - aParticleName = "smoke"; + + //Logger.INFO("A2"); + + String aParticleName; + if ((aTick % 2) == 0){ + aParticleName = "cloud"; } - if (aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) { - this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); + else { + aParticleName = "smoke"; + } + + //Logger.INFO("A3"); + + if (aBaseMetaTileEntity.isClientSide()) { + //Logger.INFO("B1"); + if (this.getBaseMetaTileEntity().isActive()) { + //Logger.INFO("C1"); + this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); + } + //return; + } + else { + //Logger.INFO("B2"); + if (this.getInventoryStack() == null) { + //Logger.INFO("D1"); + //Logger.INFO("Empty - "+this.mInventory.length); + } + else { + //Logger.INFO("D2"); + Logger.INFO("Has Item"); + } } + //Logger.INFO("A4"); + + + } public boolean isAirFilter(ItemStack filter){ @@ -170,39 +229,42 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch return false; } if (filter.getItem() instanceof ItemAirFilter){ - return true; + + if (this.mTier < 5) { + return true; + } + else { + if (filter.getItemDamage() == 1) { + return true; + } + } } return false; } - public boolean damageAirFilter(){ - ItemStack filter = this.mInventory[this.SLOT_FILTER]; + public boolean damageAirFilter(){ + ItemStack filter = getInventoryStack(); if (filter == null) { return false; } if (isAirFilter(filter)){ long currentUse = ItemAirFilter.getFilterDamage(filter); + Logger.INFO("Filter Damage: "+currentUse); //Remove broken Filter - if (filter.getItemDamage() == 0 && currentUse >= 50-1){ - this.mInventory[this.SLOT_FILTER] = null; + if ((filter.getItemDamage() == 0 && currentUse >= 50-1) || (filter.getItemDamage() == 1 && currentUse >= 2500-1)){ + breakAirFilter(); return false; - } - else if (filter.getItemDamage() == 1 && currentUse >= 2500-1){ - this.mInventory[this.SLOT_FILTER] = null; - return false; - } + } else { //Do Damage ItemAirFilter.setFilterDamage(filter, currentUse+1); - Logger.WARNING("Filter Damage: "+currentUse); + Logger.INFO("Filter Damage now: "+currentUse); return true; } } return false; } - - public void pollutionParticles(World aWorld, String name) { float ran1 = CORE.RANDOM.nextFloat(); -- cgit From 6200f857ad6477eca6456d74a6d7044208bfb1e1 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 14 May 2019 15:58:32 +1000 Subject: + Added new Fireproof Bauble. $ Fixed #479. --- .../core/common/compat/COMPAT_Baubles.java | 2 + src/Java/gtPlusPlus/core/item/ModItems.java | 1 + .../core/item/bauble/FireProtectionBauble.java | 146 +++++++++++++++++++++ .../core/util/reflect/ReflectionUtils.java | 23 ++++ .../behaviours/Behaviour_Electric_Lighter.java | 11 +- 5 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java (limited to 'src/Java/gtPlusPlus/core/util/reflect') diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java index dd7f0866ab..c9704603af 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java @@ -3,6 +3,7 @@ package gtPlusPlus.core.common.compat; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; +import gtPlusPlus.core.item.bauble.FireProtectionBauble; import gtPlusPlus.core.item.bauble.MonsterKillerBaseBauble; import gtPlusPlus.core.item.general.ItemCloakingDevice; import gtPlusPlus.core.item.general.ItemHealingDevice; @@ -34,6 +35,7 @@ public class COMPAT_Baubles { ModItems.itemPersonalCloakingDevice = new ItemCloakingDevice(0); //itemPersonalCloakingDeviceCharged = new ItemCloakingDevice(0).set; ModItems.itemPersonalHealingDevice = new ItemHealingDevice(); + ModItems.itemPersonalFireProofDevice = new FireProtectionBauble(); try { ModItems.itemChargePack_Low_1 = new BatteryPackBaseBauble(1); diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index db218cf251..de22821127 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -184,6 +184,7 @@ public final class ModItems { public static Item itemPersonalCloakingDevice; public static Item itemPersonalCloakingDeviceCharged; public static Item itemPersonalHealingDevice; + public static Item itemPersonalFireProofDevice; public static Item itemSlowBuildingRing; public static MultiPickaxeBase MP_GTMATERIAL; diff --git a/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java b/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java new file mode 100644 index 0000000000..c2ef0dfd2f --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java @@ -0,0 +1,146 @@ +package gtPlusPlus.core.item.bauble; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + +import baubles.api.BaubleType; +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class FireProtectionBauble extends BaseBauble { + + public static HashMap mDataMap = new HashMap(); + + public static HashSet mPlayerMap = new HashSet(); + + private static Field isImmuneToFire; + + static { + isImmuneToFire = ReflectionUtils.getField(Entity.class, "isImmuneToFire"); + } + + public static boolean fireImmune(Entity aEntity) { + return aEntity.isImmuneToFire(); + } + + public static boolean setEntityImmuneToFire(Entity aEntity, boolean aImmune) { + return ReflectionUtils.setField(aEntity, isImmuneToFire, aImmune); + } + + + public FireProtectionBauble() { + super(BaubleType.RING, "GTPP.bauble.fireprotection.0" + ".name", 0); + String aUnlocalName = "GTPP.bauble.fireprotection.0" + ".name"; + this.setUnlocalizedName(aUnlocalName); + this.setTextureName(CORE.MODID + ":" + getTextureNameForBauble()); + this.setMaxDamage(100); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setCreativeTab(AddToCreativeTab.tabMachines); + if (GameRegistry.findItem(CORE.MODID, aUnlocalName) == null) { + GameRegistry.registerItem(this, aUnlocalName); + } + } + + @Override + public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (EnumChatFormatting.DARK_RED + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); + } + + @Override + public boolean showDurabilityBar(final ItemStack stack) { + return false; + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + String aString1 = StatCollector.translateToLocal("GTPP.battpack.tooltip.1"); + String aString2 = StatCollector.translateToLocal("GTPP.battpack.tooltip.2"); + String aString3 = StatCollector.translateToLocal("GTPP.battpack.tooltip.3"); + String aString4 = StatCollector.translateToLocal("GTPP.battpack.tooltip.4"); + + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU+"/t"; + + list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString4 + EnumChatFormatting.GRAY); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public void onEquipped(final ItemStack arg0, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (aPlayer instanceof EntityPlayer) { + EntityPlayer bPlayer = (EntityPlayer) aPlayer; + mPlayerMap.add(bPlayer.getUniqueID()); + } + } + } + + @Override + public void onUnequipped(final ItemStack arg0, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (aPlayer instanceof EntityPlayer) { + EntityPlayer bPlayer = (EntityPlayer) aPlayer; + if (bPlayer.isPotionActive(Potion.fireResistance)) { + bPlayer.removePotionEffect(Potion.fireResistance.id); + } + mPlayerMap.remove(bPlayer.getUniqueID()); + setEntityImmuneToFire(bPlayer, false); + } + } + } + + @Override + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (aPlayer instanceof EntityPlayer) { + EntityPlayer bPlayer = (EntityPlayer) aPlayer; + if (!fireImmune(bPlayer)) { + setEntityImmuneToFire(bPlayer, true); + } + if (!bPlayer.isPotionActive(Potion.fireResistance)) { + bPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 4)); + } + } + } + } + + public String getTextureNameForBauble() { + return "chargepack/"+1; + } + +} diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 224d842ba7..2371753fe6 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -293,6 +293,7 @@ public class ReflectionUtils { return loaded > 0; } + public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { Class clazz = object.getClass(); @@ -312,6 +313,28 @@ public class ReflectionUtils { } } return false; + + + } + + public static boolean setField(final Object object, final Field field, final Object fieldValue) { + Class clazz = object.getClass(); + while (clazz != null) { + try { + final Field field2 = getField(clazz, field.getName()); + if (field2 != null) { + setFieldValue_Internal(object, field, fieldValue); + return true; + } + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField("+object.toString()+", "+field.getName()+") failed."); + clazz = clazz.getSuperclass(); + } catch (final Exception e) { + Logger.REFLECTION("setField("+object.toString()+", "+field.getName()+") failed."); + throw new IllegalStateException(e); + } + } + return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java index 64676fa907..d772c294b9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/behaviours/Behaviour_Electric_Lighter.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.items.behaviours; +import java.util.ArrayList; import java.util.List; import codechicken.lib.math.MathHelper; @@ -191,7 +192,12 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { aList.add(this.mTooltip); int aUses = 0; + if (aStack == null) { + return new ArrayList(); + } + if (aStack != null) { + if (aStack.getItem() instanceof MetaGeneratedGregtechTools) { if (ChargingHelper.isItemValid(aStack)) { if (aStack.getItem() instanceof IElectricItemManager) { @@ -202,14 +208,14 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { } } } + } - NBTTagCompound tNBT = aStack.getTagCompound(); aList.add(this.mTooltipUses + " " + aUses); aList.add(this.mTooltipUnstackable); - boolean aCurrentMode; + boolean aCurrentMode; if (NBTUtils.hasKey(aStack, "aFireballMode")) { aCurrentMode = NBTUtils.getBoolean(aStack, "aFireballMod"); } @@ -217,6 +223,7 @@ public class Behaviour_Electric_Lighter extends Behaviour_None { aStack.getTagCompound().setBoolean("aFireballMod", false); aCurrentMode = false; } + aList.add("Current Mode: "+EnumChatFormatting.RED+(aCurrentMode ? "Projectile" : "Fire Starter")); return aList; } -- cgit From 8b26a2af88e0a187faad9add2838b4916dfd2c1e Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 17 May 2019 11:46:50 +1000 Subject: $ Recipes Fixes. $ Fixed ICO not using Pyro Recipes. Closes #471. --- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 26 +++++------ .../core/recipe/RECIPES_SeleniumProcessing.java | 4 +- .../core/util/reflect/AddGregtechRecipe.java | 54 +++++++++++++++++++++- src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java | 15 +++++- 4 files changed, 82 insertions(+), 17 deletions(-) (limited to 'src/Java/gtPlusPlus/core/util/reflect') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 1b2588f469..52a6c4889e 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -2074,9 +2074,9 @@ public class RECIPES_Machines { }; for (int i = 0;i<10;i++) { GT_Values.RA.addCutterRecipe( - CI.getNumberedCircuit(18), - CI.getTieredMachineCasing(i), - mMachineCasingCovers[i].get(9), + CI.getTieredMachineCasing(i), + mMachineCasingCovers[i].get(5), + null, 20 * 5 * i, (int) GT_Values.V[i]); } @@ -2111,11 +2111,11 @@ public class RECIPES_Machines { ItemStack[] mInputHatch = new ItemStack[] { ItemList.Hatch_Input_Bus_EV.get(1), - ItemList.Hatch_Input_Bus_EV.get(1), - ItemList.Hatch_Input_Bus_EV.get(1), - ItemList.Hatch_Input_Bus_EV.get(1), - ItemList.Hatch_Input_Bus_EV.get(1), - ItemList.Hatch_Input_Bus_EV.get(1), + ItemList.Hatch_Input_Bus_IV.get(1), + ItemList.Hatch_Input_Bus_LuV.get(1), + ItemList.Hatch_Input_Bus_ZPM.get(1), + ItemList.Hatch_Input_Bus_UV.get(1), + ItemList.Hatch_Input_Bus_MAX.get(1), GregtechItemList.Hatch_SuperBus_Input_ULV.get(1), GregtechItemList.Hatch_SuperBus_Input_LV.get(1), GregtechItemList.Hatch_SuperBus_Input_MV.get(1), @@ -2124,11 +2124,11 @@ public class RECIPES_Machines { ItemStack[] mOutputHatch = new ItemStack[] { ItemList.Hatch_Output_Bus_EV.get(1), - ItemList.Hatch_Output_Bus_EV.get(1), - ItemList.Hatch_Output_Bus_EV.get(1), - ItemList.Hatch_Output_Bus_EV.get(1), - ItemList.Hatch_Output_Bus_EV.get(1), - ItemList.Hatch_Output_Bus_EV.get(1), + ItemList.Hatch_Output_Bus_IV.get(1), + ItemList.Hatch_Output_Bus_LuV.get(1), + ItemList.Hatch_Output_Bus_ZPM.get(1), + ItemList.Hatch_Output_Bus_UV.get(1), + ItemList.Hatch_Output_Bus_MAX.get(1), GregtechItemList.Hatch_SuperBus_Output_ULV.get(1), GregtechItemList.Hatch_SuperBus_Output_LV.get(1), GregtechItemList.Hatch_SuperBus_Output_MV.get(1), diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java index eaa939a2fd..471a3cc33e 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_SeleniumProcessing.java @@ -23,10 +23,10 @@ public class RECIPES_SeleniumProcessing { processCopperRecipes(); //Liquify the Dried Dioxide - AddGregtechRecipe.addCokeAndPyrolyseRecipes(MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), 13, FluidUtils.getSteam(500), null, MISC_MATERIALS.SELENIUM_DIOXIDE.getFluid(1000), 120, 1024); + AddGregtechRecipe.addCokeAndPyrolyseRecipes(MISC_MATERIALS.SELENIUM_DIOXIDE.getDust(1), 13, FluidUtils.getSteam(500), null, MISC_MATERIALS.SELENIUM_DIOXIDE.getFluid(1000), 20, 1024); // Produce Selenious Acid - AddGregtechRecipe.addCokeAndPyrolyseRecipes(MISC_MATERIALS.SELENIUM_DIOXIDE.getCell(1), 14, FluidUtils.getHotWater(4000), CI.emptyCells(1), MISC_MATERIALS.SELENIOUS_ACID.getFluid(1000), 120, 2048); + AddGregtechRecipe.addCokeAndPyrolyseRecipes(MISC_MATERIALS.SELENIUM_DIOXIDE.getCell(1), 14, FluidUtils.getHotWater(4000), CI.emptyCells(1), MISC_MATERIALS.SELENIOUS_ACID.getFluid(1000), 20, 2048); // Make Selenium CORE.RA.addBlastSmelterRecipe( diff --git a/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java b/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java index fcb8c42197..c56b9a09ef 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java +++ b/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java @@ -7,13 +7,65 @@ import net.minecraft.item.ItemStack; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.internal.IGT_RecipeAdder; - +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraftforge.fluids.FluidStack; public final class AddGregtechRecipe { + + + public static boolean importPyroRecipe(GT_Recipe aRecipe) { + + int aModifiedTime = (int) (aRecipe.mDuration * 0.8); + + if (aRecipe.mInputs.length > 2 || aRecipe.mFluidInputs.length > 1 || aRecipe.mFluidOutputs.length > 1 || aRecipe.mOutputs.length > 1) { + return false; + } + + int aCircuitNumber = -1; + int aItemSlot = -1; + + int aSlot = 0; + for (ItemStack a : aRecipe.mInputs) { + if (a != null && a.getItem() != CI.getNumberedCircuit(1).getItem()) { + aItemSlot = aSlot; + } + else { + aSlot++; + } + } + + for (int i=0;i<25;i++) { + ItemStack aTest = CI.getNumberedCircuit(i); + for (ItemStack a : aRecipe.mInputs) { + if (a != null && GT_Utility.areStacksEqual(a, aTest)) { + aCircuitNumber = i; + break; + } + } + } + + if (aCircuitNumber < 0) { + return false; + } + + + return CORE.RA.addCokeOvenRecipe( + aRecipe.mInputs[aItemSlot], + ItemUtils.getGregtechCircuit(aCircuitNumber), + aRecipe.mFluidInputs[0], + aRecipe.mFluidOutputs[0], + aRecipe.mOutputs[0], + aModifiedTime, + aRecipe.mEUt); + + + } + public static boolean addCokeAndPyrolyseRecipes( ItemStack input1, int circuitNumber, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 47f4ad372b..ba1ead8c76 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -35,6 +35,7 @@ import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.core.util.reflect.AddGregtechRecipe; import gtPlusPlus.everglades.gen.gt.WorldGen_GT; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; @@ -135,9 +136,21 @@ public class HANDLER_GT { removeOldHighTierCasingRecipes(); } RecipesToRemove.go(); + convertPyroToCokeOven(); } - private static GT_Recipe replaceItemInRecipeWithAnother(GT_Recipe aRecipe, ItemStack aExisting, ItemStack aNewItem) { + private static void convertPyroToCokeOven() { + int aCount = 0; + for (GT_Recipe g : GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.mRecipeList) { + if (AddGregtechRecipe.importPyroRecipe(g)) { + aCount++; + } + } + Logger.INFO("Converted "+aCount+" Pyrolyse recipes into Industrial Coke Oven recipes."); + + } + + private static GT_Recipe replaceItemInRecipeWithAnother(GT_Recipe aRecipe, ItemStack aExisting, ItemStack aNewItem) { ItemStack[] aInputItemsCopy = aRecipe.mInputs; String aOutputName = ItemUtils.getItemName(aRecipe.mOutputs[0]); boolean aDidChange = false; -- cgit From 7db09b10c98752d1092e9ace9460055d0b80ac6c Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 17 May 2019 12:07:22 +1000 Subject: $ One more small fix for Pyro recipe conversion. % Made Advanced Mufflers work as efficiently as their standard tier counterparts while there is no air filter. (Currently bugged) --- src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java | 7 +++++++ .../implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Java/gtPlusPlus/core/util/reflect') diff --git a/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java b/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java index c56b9a09ef..0b22ea3acc 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java +++ b/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java @@ -22,9 +22,16 @@ public final class AddGregtechRecipe { int aModifiedTime = (int) (aRecipe.mDuration * 0.8); + if (aRecipe.mInputs == null || aRecipe.mFluidInputs == null || aRecipe.mFluidOutputs == null || aRecipe.mOutputs == null) { + return false; + } + if (aRecipe.mInputs.length > 2 || aRecipe.mFluidInputs.length > 1 || aRecipe.mFluidOutputs.length > 1 || aRecipe.mOutputs.length > 1) { return false; } + else if (aRecipe.mInputs.length <= 0 || aRecipe.mFluidInputs.length <= 0 || aRecipe.mFluidOutputs.length <= 0 || aRecipe.mOutputs.length <= 0) { + return false; + } int aCircuitNumber = -1; int aItemSlot = -1; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java index 4052a5c266..5fa1fc8aba 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java @@ -145,7 +145,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1)); int aVal2 = (int) aVal1; if (!hasValidFilter()) { - aVal2 = 0; + aVal2 = (int) ((double) aPollution * Math.pow(0.7D, (double) (this.mTier - 1)));; } return aVal2; } -- cgit