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. --- .../base/GregtechMeta_MultiBlockBase.java | 52 +++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index e352712138..e0f768830d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1,10 +1,10 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; -import static gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -48,6 +48,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -1136,6 +1137,47 @@ GT_MetaTileEntity_MultiBlockBase { ItemStack guiSlot = this.mInventory[1]; return guiSlot; } + + protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { + boolean result = false; + if (this.mInventory[1] == null) { + this.mInventory[1] = aNewGuiSlotContents != null ? aNewGuiSlotContents.copy() : null; + aNewGuiSlotContents = null; + this.updateSlots(); + result = true; + } + return result; + } + + protected boolean clearGUIItemSlot() { + return setGUIItemStack(null); + } + + + public ItemStack findItemInInventory(Item aSearchStack) { + return findItemInInventory(aSearchStack, 0); + } + + public ItemStack findItemInInventory(Item aSearchStack, int aMeta) { + return findItemInInventory(ItemUtils.simpleMetaStack(aSearchStack, aMeta, 1)); + } + + public ItemStack findItemInInventory(ItemStack aSearchStack) { + if (aSearchStack != null && this.mInputBusses.size() > 0) { + for (GT_MetaTileEntity_Hatch_InputBus bus : this.mInputBusses) { + if (bus != null) { + for (ItemStack uStack : bus.mInventory) { + if (uStack != null) { + if (aSearchStack.getClass().isInstance(uStack.getItem())) { + return uStack; + } + } + } + } + } + } + return null; + } @Override public void updateSlots() { @@ -1208,6 +1250,14 @@ GT_MetaTileEntity_MultiBlockBase { if (aTileEntity == null) { return false; } + + //Check type + Class aHatchType = ReflectionUtils.getTypeOfGenericObject(aList); + if (!aHatchType.isInstance(aTileEntity)) { + return false; + } + + if (aList.isEmpty()) { if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { -- cgit From 3615baf8ffb7a2efc44d4770da97ce1337f7801e Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sun, 12 May 2019 13:58:15 +1000 Subject: + Properly implemented Air Filter requirements & a new GUI for Advanced Mufflers. --- .../api/gui/CONTAINER_Hatch_Muffler_Advanced.java | 66 +++++++++++++ .../gregtech/api/gui/CONTAINER_SuperChest.java | 11 +-- .../api/gui/GUI_Hatch_Muffler_Advanced.java | 40 ++++++++ .../GT_MetaTileEntity_Hatch_Muffler_Adv.java | 108 ++++++++++++++++----- .../GT_MetaTileEntity_Hatch_Plasma.java | 1 - .../GregtechMetaAtmosphericReconditioner.java | 7 -- 6 files changed, 194 insertions(+), 39 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity') 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 new file mode 100644 index 0000000000..30d0c3dcd6 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_Hatch_Muffler_Advanced.java @@ -0,0 +1,66 @@ +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; + + +public class CONTAINER_Hatch_Muffler_Advanced extends GT_ContainerMetaTile_Machine { + + public long maxEU = 0; + public long storedEU = 0; + + public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public CONTAINER_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final boolean bindInventory) { + super(aInventoryPlayer, aTileEntity, bindInventory); + } + + @Override + public void addSlots(final InventoryPlayer aInventoryPlayer) { + this.addSlotToContainer(new Slot(this.mTileEntity, 1, 80, 17)); + } + + @Override + public int getSlotCount() { + return 1; + } + + @Override + public int getShiftClickSlotCount() { + return 1; + } + + @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; + 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()); + } + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java index 503b36e157..dcab57c380 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_SuperChest.java @@ -4,21 +4,16 @@ import java.util.Iterator; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Output; import gregtech.api.gui.GT_Slot_Render; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.slots.SlotLockedInput; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredChest; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving.GT4Entity_Shelf_Large; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; public class CONTAINER_SuperChest extends GT_ContainerMetaTile_Machine { 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 new file mode 100644 index 0000000000..7aed0e60e1 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_Hatch_Muffler_Advanced.java @@ -0,0 +1,40 @@ +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; + +public class GUI_Hatch_Muffler_Advanced extends GT_GUIContainerMetaTile_Machine { + + String mName = ""; + long maxPower = 0; + long storedPower = 0; + + public GUI_Hatch_Muffler_Advanced(final InventoryPlayer aInventoryPlayer, final IGregTechTileEntity aTileEntity, final String aName, final String aTextureFile) { + super(new CONTAINER_Hatch_Muffler_Advanced(aInventoryPlayer, aTileEntity), CORE.RES_PATH_GUI + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile)); + this.mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString(this.mName, 64, 6, 16448255); + if (this.mContainer != null) { + 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; + 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 2832941bdd..0479914115 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,11 +1,17 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; +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.xmod.gregtech.api.gui.CONTAINER_Hatch_Muffler_Advanced; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_Hatch_Muffler_Advanced; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; @@ -13,11 +19,11 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch_Muffler { + protected int SLOT_FILTER = 0; + @Override public void onConfigLoad(GT_Config aConfig) { super.onConfigLoad(aConfig); @@ -49,16 +55,15 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public String[] getDescription() { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - - String[] mDescArray = StaticFields59.getDescriptionArray(this); - - String[] desc = new String[mDescArray.length + 4]; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + String[] mDescArray = StaticFields59.getDescriptionArray(this); + String[] desc = new String[mDescArray.length + 5]; System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length); desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; - desc[mDescArray.length + 1] = "Requires extra Air on the exhaust face"; - desc[mDescArray.length + 2] = "Reduces Pollution to " + this.calculatePollutionReduction(100) + "%"; - desc[mDescArray.length + 3] = "Recovers " + (105 - this.calculatePollutionReduction(100)) + 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)) + "% of CO2/CO/SO2"; return desc; } @@ -88,24 +93,33 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; - //aBaseMetaTileEntity.openGUI(aPlayer); + aBaseMetaTileEntity.openGUI(aPlayer); return true; } - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, - IGregTechTileEntity aBaseMetaTileEntity) { - return null; + + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity); } - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, - IGregTechTileEntity aBaseMetaTileEntity) { - return null; + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_Hatch_Muffler_Advanced(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "machine_Charger.png"); + } + + private boolean airCheck() { + if ( + this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) && + this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1) && + this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 2) + ) { + return true; + } + return false; } public boolean polluteEnvironment() { - if (this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing()) && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getFrontFacing(), 1)) { + if (airCheck()) { int aEmission = this.calculatePollutionReduction(10000); PollutionUtils.addPollution(this.getBaseMetaTileEntity(), aEmission); //Logger.INFO("Outputting "+aEmission+"gbl"); @@ -117,15 +131,25 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public int calculatePollutionReduction(int aPollution) { - return (int) ((double) aPollution * Math.pow(0.64D, (double) (this.mTier - 1))); + double aVal1 = aPollution * Math.pow(0.64D, (double) (this.mTier - 1)); + int aVal2 = (int) aVal1; + if (!hasValidFilter()) { + aVal2 = 0; + } + return aVal2; } public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; + if (aIndex == this.SLOT_FILTER) { + if (isAirFilter(aStack)) { + return true; + } + } + return false; } public boolean hasValidFilter() { - return false; + return isAirFilter(this.mInventory[this.SLOT_FILTER]); } public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @@ -139,8 +163,46 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch if (aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) { this.pollutionParticles(this.getBaseMetaTileEntity().getWorld(), aParticleName); } + } + + public boolean isAirFilter(ItemStack filter){ + if (filter == null) { + return false; + } + if (filter.getItem() instanceof ItemAirFilter){ + return true; + } + return false; + } + + public boolean damageAirFilter(){ + ItemStack filter = this.mInventory[this.SLOT_FILTER]; + if (filter == null) { + return false; + } + if (isAirFilter(filter)){ + long currentUse = ItemAirFilter.getFilterDamage(filter); + //Remove broken Filter + if (filter.getItemDamage() == 0 && currentUse >= 50-1){ + this.mInventory[this.SLOT_FILTER] = null; + 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); + return true; + } + } + return false; } + + public void pollutionParticles(World aWorld, String name) { float ran1 = CORE.RANDOM.nextFloat(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java index bed80d8d13..b395bbbabe 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -8,7 +8,6 @@ import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index c364fe5e9e..e277b671c6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -126,13 +126,6 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi return V[mTier]; } - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - if (getBaseMetaTileEntity().isServerSide()) { - - } - } - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); -- 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/xmod/gregtech/api/metatileentity') 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 f7390af19986b4e4370379bb46dee71f12b717e8 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 13 May 2019 15:45:29 +1000 Subject: + Added High Quality Industrial Diamond. + Added various material components. + Added a debug machine used for calling the Garbage Collector. + Added recipe to obtain Hot Water. + Added way to obtain Dragonsblood. + Added lots of quick access fluids directly to FluidUtils. % Updated English Locale. $ Fixed issue preventing all Multiblocks from forming. $ Fixed some minor texture issues. --- src/Java/gtPlusPlus/core/common/CommonProxy.java | 2 + .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 11 + .../handler/events/EnderDragonDeathHandler.java | 57 ++++ src/Java/gtPlusPlus/core/item/ModItems.java | 60 ++++ .../core/item/base/BaseItemComponent.java | 10 +- src/Java/gtPlusPlus/core/item/base/CoreItem.java | 5 + .../core/item/base/plates/BaseItemPlateHeavy.java | 47 +++ .../core/item/bauble/ElectricBaseBauble.java | 4 +- .../core/item/bauble/MonsterKillerBaseBauble.java | 2 +- src/Java/gtPlusPlus/core/lib/CORE.java | 8 + src/Java/gtPlusPlus/core/material/ALLOY.java | 4 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 6 + src/Java/gtPlusPlus/core/recipe/common/CI.java | 2 +- .../gtPlusPlus/core/util/minecraft/FluidUtils.java | 52 +++- .../core/util/minecraft/MaterialUtils.java | 45 +++ .../core/util/minecraft/PlayerUtils.java | 4 + .../xmod/gregtech/api/enums/GregtechItemList.java | 1 + .../base/GregtechMeta_MultiBlockBase.java | 8 +- .../basic/GregtechMetaGarbageCollector.java | 318 +++++++++++++++++++++ src/resources/assets/miscutils/lang/en_US.lang | 70 ++++- .../textures/items/IndustrialDiamondExquisite.png | Bin 0 -> 608 bytes .../miscutils/textures/items/itemFineWire.png | Bin 0 -> 514 bytes .../miscutils/textures/items/itemHeavyPlate.png | Bin 597 -> 397 bytes .../textures/items/itemHeavyPlate_Overlay.png | Bin 0 -> 471 bytes .../miscutils/textures/items/itemSmallSpring.png | Bin 0 -> 317 bytes .../assets/miscutils/textures/items/itemSpring.png | Bin 0 -> 276 bytes 26 files changed, 694 insertions(+), 22 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java create mode 100644 src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlateHeavy.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java create mode 100644 src/resources/assets/miscutils/textures/items/IndustrialDiamondExquisite.png create mode 100644 src/resources/assets/miscutils/textures/items/itemFineWire.png create mode 100644 src/resources/assets/miscutils/textures/items/itemHeavyPlate_Overlay.png create mode 100644 src/resources/assets/miscutils/textures/items/itemSmallSpring.png create mode 100644 src/resources/assets/miscutils/textures/items/itemSpring.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity') diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index cacc471249..23bdb2c5f1 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -27,6 +27,7 @@ import gtPlusPlus.core.handler.COMPAT_IntermodStaging; import gtPlusPlus.core.handler.GuiHandler; import gtPlusPlus.core.handler.StopAnnoyingFuckingAchievements; import gtPlusPlus.core.handler.events.BlockEventHandler; +import gtPlusPlus.core.handler.events.EnderDragonDeathHandler; import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; import gtPlusPlus.core.handler.events.ZombieBackupSpawnEventHandler; @@ -145,6 +146,7 @@ public class CommonProxy { // Register Chunkloader ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, ChunkManager.getInstance()); Utils.registerEvent(ChunkManager.getInstance()); + Utils.registerEvent(new EnderDragonDeathHandler()); if (ConfigSwitches.disableZombieReinforcement) { // Make Zombie reinforcements fuck off. diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 1e3cb0ffbb..a00d1ea152 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -22,6 +22,9 @@ import gtPlusPlus.core.recipe.*; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaGarbageCollector; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaPollutionCreator; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; import gtPlusPlus.xmod.gregtech.registration.gregtech.*; import net.minecraft.item.ItemStack; @@ -49,6 +52,14 @@ public class COMPAT_HANDLER { public static void registerGregtechMachines() { if (Gregtech) { + //Debug + GregtechItemList.Garbage_Collector_Debug_Machine.set( + new GregtechMetaGarbageCollector( + "garbagecollector.01.tier.single", + "JVM Garbage Collector", + "Useful for debugging or smoother performance on local servers").getStackForm(1L)); + + //Free IDs /* --- diff --git a/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java b/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java new file mode 100644 index 0000000000..c1c2341dd6 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java @@ -0,0 +1,57 @@ +package gtPlusPlus.core.handler.events; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraftforge.event.entity.living.LivingDropsEvent; + +public class EnderDragonDeathHandler { + + private static final String mDragonClassName = "chylex.hee.entity.boss.EntityBossDragon"; + private static final boolean mHEE; + private static final Class mHardcoreDragonClass; + + static { + mHEE = ReflectionUtils.doesClassExist(mDragonClassName); + mHardcoreDragonClass = (mHEE ? ReflectionUtils.getClass(mDragonClassName) : null); + } + + @SubscribeEvent + public void onEntityDrop(LivingDropsEvent event) { + + boolean aDidDrop = false; + + //HEE Dragon + if (mHEE) { + if (mHardcoreDragonClass != null) { + if (mHardcoreDragonClass.isInstance(event.entityLiving)) { + for (int y = 0; y < MathUtils.randInt(100, 250); y++) { + int aAmount = MathUtils.randInt(5, 25); + event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); + aDidDrop = true; + } + } + } + } + //Vanilla Dragon or any other dragon that extends it + else { + if (event.entityLiving instanceof EntityDragon) { + for (int y = 0; y < MathUtils.randInt(25, 50); y++) { + int aAmount = MathUtils.randInt(1, 10); + event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); + aDidDrop = true; + } + } + } + + if (aDidDrop) { + PlayerUtils.messageAllPlayers("Small quantities of Dragonsblood has crystalized after the death of the Ender Dragon!"); + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 9b32c55d2d..db218cf251 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -94,6 +94,7 @@ import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.debug.DEBUG_INIT; 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.GTplusplus_Everglades; import gtPlusPlus.xmod.eio.material.MaterialEIO; @@ -361,6 +362,8 @@ public final class ModItems { public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Nether; public static MonsterKillerBaseBauble itemAmuletMonsterKiller_Infernal; + public static CoreItem itemExquisiteIndustrialDiamond; + static { Logger.INFO("Items!"); //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. @@ -851,6 +854,63 @@ public final class ModItems { itemHotTitaniumIngot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotHotTitanium", 1); } + //Industrial Diamonds + itemExquisiteIndustrialDiamond = new CoreItem("IndustrialDiamondExquisite", "High Quality Industrial Diamond", tabMisc); + ItemStack tempStack = itemExquisiteIndustrialDiamond.getStack(); + ItemUtils.addItemToOreDictionary(tempStack, "gemDiamond"); + ItemUtils.addItemToOreDictionary(tempStack, "craftingIndustrialDiamond"); + ItemUtils.addItemToOreDictionary(tempStack, "gemExquisiteDiamond"); + ItemUtils.addItemToOreDictionary(tempStack, "craftingExquisiteIndustrialDiamond"); + + //Custom GT++ Crafting Components + + //Springs + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.NITINOL_60); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.AQUATIC_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SPRING, ALLOY.EGLIN_STEEL); + + //Small Springs + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.MARAGING250); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.NICHROME); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.STABALLOY); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.STEEL_BLACK); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.SMALLSPRING, ALLOY.BLACK_TITANIUM); + + //Fine Wire + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.getInstance().PALLADIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ELEMENT.getInstance().ZIRCONIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.LEAGRISIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.BABBIT_ALLOY); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.KOBOLDITE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.HG1223); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.FINEWIRE, ALLOY.QUANTUM); + + //Dense Plates + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.POTIN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.AQUATIC_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.BRONZE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.OSMIRIDIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.QUANTUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.STEEL_BLACK); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.STAINLESS_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.EGLIN_STEEL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.MARAGING300); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ALLOY.TALONITE); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.HYPOGEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.RHUGNOR); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.ADVANCED_NITINOL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.ASTRAL_TITANIUM); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.WHITE_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.BLACK_METAL); + MaterialUtils.generateComponentAndAssignToAMaterial(ComponentTypes.PLATEHEAVY, ELEMENT.STANDALONE.GRANITE); + + + + //Special Sillyness if (true) { diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 33198e8d41..90e831cbb4 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -248,12 +248,17 @@ public class BaseItemComponent extends Item{ public int getColorFromItemStack(final ItemStack stack, final int renderPass) { + if (this.componentType == ComponentTypes.CELL || this.componentType == ComponentTypes.PLASMACELL) { if (renderPass == 0 && !CORE.ConfigSwitches.useGregtechTextures){ return Utils.rgbtoHexValue(255, 255, 255); } if (renderPass == 1 && CORE.ConfigSwitches.useGregtechTextures){ return Utils.rgbtoHexValue(255, 255, 255); } + } + if (this.componentType == ComponentTypes.PLATEHEAVY) { + + } @@ -495,7 +500,10 @@ public class BaseItemComponent extends Item{ PLASMACELL("CellPlasma", " Plasma Cell", "cellPlasma", OrePrefixes.cellPlasma), CELL("Cell", " Cell", "cell", OrePrefixes.cell), NUGGET("Nugget", " Nugget", "nugget", OrePrefixes.nugget), - PLATEHEAVY("HeavyPlate", " Heavy Plate", "plateHeavy", OrePrefixes.plateDense); + PLATEHEAVY("HeavyPlate", "Heavy@Plate", "plateHeavy", OrePrefixes.plateDense), + SPRING("Spring", " Spring", "spring", OrePrefixes.spring), + SMALLSPRING("SmallSpring", "Small@Spring", "springSmall", OrePrefixes.springSmall), + FINEWIRE("FineWire", "Fine@Wire", "wireFine", OrePrefixes.wireFine),; private String COMPONENT_NAME; private String DISPLAY_NAME; diff --git a/src/Java/gtPlusPlus/core/item/base/CoreItem.java b/src/Java/gtPlusPlus/core/item/base/CoreItem.java index 376be7bac8..7ce96b2a88 100644 --- a/src/Java/gtPlusPlus/core/item/base/CoreItem.java +++ b/src/Java/gtPlusPlus/core/item/base/CoreItem.java @@ -17,6 +17,7 @@ import net.minecraft.world.World; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; public class CoreItem extends Item { @@ -221,6 +222,10 @@ public class CoreItem extends Item public boolean isRepairable() { return false; } + + public ItemStack getStack() { + return ItemUtils.getSimpleStack(this); + } /* @Override public String getItemStackDisplayName(final ItemStack tItem) { diff --git a/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlateHeavy.java b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlateHeavy.java new file mode 100644 index 0000000000..c9072b0d82 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/plates/BaseItemPlateHeavy.java @@ -0,0 +1,47 @@ +package gtPlusPlus.core.item.base.plates; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +public class BaseItemPlateHeavy extends BaseItemComponent{ + + final static ComponentTypes HEAVY = ComponentTypes.PLATEHEAVY; + + public BaseItemPlateHeavy(final Material material) { + super(material, HEAVY); + } + + @Override + public String getCorrectTextures(){ + return CORE.MODID + ":" + "itemHeavyPlate"; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses(){ + return true; + } + + @Override + public void registerIcons(final IIconRegister i) { + this.base = i.registerIcon(CORE.MODID + ":" + "itemHeavyPlate"); + this.overlay = i.registerIcon(CORE.MODID + ":" + "itemHeavyPlate_Overlay"); + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + + if (pass == 0) { + return this.base; + } + else { + return this.overlay; + } + + } +} diff --git a/src/Java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java b/src/Java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java index 8472549e8d..cfa5cb363d 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/ElectricBaseBauble.java @@ -9,11 +9,9 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.GT_Values; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; @@ -21,7 +19,6 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; @@ -54,6 +51,7 @@ public abstract class ElectricBaseBauble extends BaseBauble implements IElectric public abstract String getTextureNameForBauble(); + @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) @Override public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { diff --git a/src/Java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java b/src/Java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java index aa89ff1627..aab302688b 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/MonsterKillerBaseBauble.java @@ -169,7 +169,7 @@ public class MonsterKillerBaseBauble extends ElectricBaseBauble { @Override public String getTextureNameForBauble() { - return CORE.MODID + ":" + "baubles/itemAmulet"; + return "baubles/itemAmulet"; } } diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 632378987a..6b6d83d0bd 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -282,4 +282,12 @@ public class CORE { public static final String VERSION = "0.1"; } + public static final void crash() { + System.exit(0); + } + + public static final void gc() { + System.gc(); + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/material/ALLOY.java b/src/Java/gtPlusPlus/core/material/ALLOY.java index 1df843da0b..95e3631aaf 100644 --- a/src/Java/gtPlusPlus/core/material/ALLOY.java +++ b/src/Java/gtPlusPlus/core/material/ALLOY.java @@ -15,7 +15,7 @@ public final class ALLOY { public static final Material KANTHAL = MaterialUtils.generateMaterialFromGtENUM(Materials.Kanthal); public static final Material NICHROME = MaterialUtils.generateMaterialFromGtENUM(Materials.Nichrome); public static final Material TUNGSTENSTEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.TungstenSteel); - public static final Material STAINLESSSTEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.StainlessSteel); + public static final Material STAINLESS_STEEL = MaterialUtils.generateMaterialFromGtENUM(Materials.StainlessSteel); public static final Material OSMIRIDIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmiridium); public static final Material ENERGYCRYSTAL = new Material( @@ -804,7 +804,7 @@ public final class ALLOY { true, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ - new MaterialStack(ALLOY.STAINLESSSTEEL, 10), + new MaterialStack(ALLOY.STAINLESS_STEEL, 10), new MaterialStack(ALLOY.TUNGSTEN_CARBIDE, 10), new MaterialStack(ALLOY.NICHROME, 10), new MaterialStack(ALLOY.BRONZE, 10), diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index e264a680fc..bd19eca5e9 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -91,10 +91,16 @@ public class RECIPES_GREGTECH { assemblyLineRecipes(); latheRecipes(); vacuumFreezerRecipes(); + fluidheaterRecipes(); addFuels(); } + private static void fluidheaterRecipes() { + GT_Values.RA.addFluidHeaterRecipe(CI.getNumberedCircuit(20), FluidUtils.getWater(1000), FluidUtils.getHotWater(1000), 30, 30); + + } + private static void vacuumFreezerRecipes() { GT_Values.RA.addVacuumFreezerRecipe(GregtechItemList.Bomb_Cast_Molten.get(1), GregtechItemList.Bomb_Cast_Set.get(1), 20 * 30); } diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index dffb438e4a..80abc18158 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -574,7 +574,7 @@ public class CI { private static final Material[] aMaterial_Tertiary = new Material[] { ALLOY.STEEL, ELEMENT.getInstance().ALUMINIUM, - ALLOY.STAINLESSSTEEL, + ALLOY.STAINLESS_STEEL, ELEMENT.getInstance().TUNGSTEN, ALLOY.HASTELLOY_N, ALLOY.ENERGYCRYSTAL, diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java index 0ae751a20b..09263bb639 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java @@ -25,14 +25,64 @@ public class FluidUtils { return FluidUtils.getFluidStack("water", amount); } - public static FluidStack getlava(final int amount){ + public static FluidStack getDistilledWater(final int amount){ + return FluidUtils.getFluidStack("ic2distilledwater", amount); + } + + public static FluidStack getHotWater(final int amount) { + return FluidUtils.getFluidStack("ic2hotwater", amount); + } + + public static FluidStack getLava(final int amount){ return FluidUtils.getFluidStack("lava", amount); } + public static FluidStack getPahoehoeLava(final int amount){ + return FluidUtils.getFluidStack("ic2pahoehoelava", amount); + } + public static FluidStack getMilk(final int amount){ return FluidUtils.getFluidStack("milk", amount); } + public static FluidStack getColdCoolant(final int amount){ + return FluidUtils.getFluidStack("ic2coolant", amount); + } + + public static FluidStack getHotCoolant(final int amount){ + return FluidUtils.getFluidStack("ic2hotcoolant", amount); + } + + public static FluidStack getSteam(final int amount){ + return FluidUtils.getFluidStack("steam", amount); + } + + public static FluidStack getIC2Steam(final int amount){ + return FluidUtils.getFluidStack("ic2steam", amount); + } + + public static FluidStack getSuperHeatedSteam(final int amount){ + return FluidUtils.getFluidStack("ic2superheatedsteam", amount); + } + + @Deprecated + /** + * Do not use - Gives third tier steam - Not implemented + * @param amount + * @return + */ + public static FluidStack getHyperSteam(final int amount){ + return FluidUtils.getFluidStack("water", amount); + } + + public static FluidStack getUUA(final int amount){ + return FluidUtils.getFluidStack("uuamplifier", amount); + } + + public static FluidStack getUUM(final int amount){ + return FluidUtils.getFluidStack("ic2uumatter", amount); + } + public static FluidStack getFluidStack(final String fluidName, final int amount){ Logger.WARNING("Trying to get a fluid stack of "+fluidName); try { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index ce665945c4..364430b07d 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -15,6 +15,9 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.TypeCounter; import gtPlusPlus.core.client.CustomTextureSet.TextureSets; +import gtPlusPlus.core.item.base.BaseItemComponent; +import gtPlusPlus.core.item.base.BaseItemComponent.ComponentTypes; +import gtPlusPlus.core.item.base.plates.BaseItemPlateHeavy; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; @@ -440,6 +443,48 @@ public class MaterialUtils { } return resultList; } + + public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial) { + generateComponentAndAssignToAMaterial(aType, aMaterial, true); + } + + public static void generateComponentAndAssignToAMaterial(ComponentTypes aType, Material aMaterial, boolean generateRecipes) { + Item aGC; + if (aType == ComponentTypes.PLATEHEAVY) { + aGC = new BaseItemPlateHeavy(aMaterial); + } + else { + aGC = new BaseItemComponent(aMaterial, aType); + } + if (aGC != null) { + String aFormattedLangName = aType.getName(); + + if (!aFormattedLangName.startsWith(" ")) { + if (aFormattedLangName.contains("@")) { + String[] aSplit = aFormattedLangName.split("@"); + aFormattedLangName = aSplit[0] + " " + aMaterial.getLocalizedName() + " " + aSplit[1]; + } + } + + if (aFormattedLangName.equals(aType.getName())) { + aFormattedLangName = aMaterial.getLocalizedName() + aFormattedLangName; + + } + + + + Logger.MATERIALS("[Lang] "+aGC.getUnlocalizedName()+".name="+aFormattedLangName); + aMaterial.registerComponentForMaterial(aType, ItemUtils.getSimpleStack(aGC)); + } + } + + + + + + + + public static void generateSpecialDustAndAssignToAMaterial(Material aMaterial) { generateSpecialDustAndAssignToAMaterial(aMaterial, true); } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java index 7dd127203e..2fb7344a28 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java @@ -174,4 +174,8 @@ public class PlayerUtils { return false; } + public static void messageAllPlayers(String string) { + Utils.sendServerMessage(string); + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 68fe121081..6e9a099e72 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -427,6 +427,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Debug machine Pollution_Creator, + Garbage_Collector_Debug_Machine, //Basically is an automatic Cauldron diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index e0f768830d..e9f8546545 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -1252,10 +1252,10 @@ GT_MetaTileEntity_MultiBlockBase { } //Check type - Class aHatchType = ReflectionUtils.getTypeOfGenericObject(aList); - if (!aHatchType.isInstance(aTileEntity)) { - return false; - } + /* + * Class aHatchType = ReflectionUtils.getTypeOfGenericObject(aList); if + * (!aHatchType.isInstance(aTileEntity)) { return false; } + */ if (aList.isEmpty()) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java new file mode 100644 index 0000000000..c09302fb3e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java @@ -0,0 +1,318 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class GregtechMetaGarbageCollector extends GregtechMetaTileEntity { + + long mLastCleanup = 0; + long mLocalTickVar = 0; + int mFrequency = 5; + + public GregtechMetaGarbageCollector(final String aName, final String aNameRegional, final String aDescription) { + super(28750, aName, aNameRegional, 5, 0, aDescription); + } + + public GregtechMetaGarbageCollector(final String aName, final String aDescription, final ITexture[][][] aTextures) { + super(aName, 5, 0, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, "Can request the JVM to perform garbage collection", "Configurable to run once every 5 minute interval (5-180)", "This Machine has no recipe", "Admin Tool, Limit one per world if possible"}; + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3)}; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (mFrequency < 180){ + mFrequency += 5; + } + else { + mFrequency = 5; + } + PlayerUtils.messagePlayer(aPlayer, "Running every "+mFrequency+" minutes."); + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaGarbageCollector(this.mName, this.mDescription, this.mTextures); + } + + @Override public boolean isSimpleMachine() {return true;} + @Override public boolean isElectric() {return false;} + @Override public boolean isValidSlot(final int aIndex) {return false;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return false;} + @Override public boolean isEnetOutput() {return false;} + @Override public boolean isInputFacing(final byte aSide) {return aSide!=this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(final byte aSide) {return aSide==this.getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return 0;} + @Override public long maxEUStore() {return 0;} + + @Override + public int getCapacity() { + return 0; + } + + @Override + public long maxEUInput() { + return 0; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return 0;} + @Override public int dechargerSlotCount() {return 0;} + @Override public int getProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)this.getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(final EntityPlayer aPlayer) {return true;} + + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) + { + return true; + } + this.showPollution(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showPollution(final World worldIn, final EntityPlayer playerIn){ + PlayerUtils.messagePlayer(playerIn, "Running every "+mFrequency+" minutes. Owner: "+this.getBaseMetaTileEntity().getOwnerName()); + long aDiff = mLocalTickVar - this.mLastCleanup; + PlayerUtils.messagePlayer(playerIn, "Last run: "+Utils.getSecondsFromMillis(aDiff)+" seconds ago."); + + + } + + @Override + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) { + return false; + } + + + @Override + public String[] getInfoData() { + return new String[] { + this.getLocalName() + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + return new int[] {}; + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(final int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) { + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + } + + @Override + public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + + } + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + mLocalTickVar = System.currentTimeMillis(); + long aDiff = mLocalTickVar - this.mLastCleanup; + if (Utils.getSecondsFromMillis(aDiff) >= (this.mFrequency * 60)) { + CORE.gc(); + this.mLastCleanup = mLocalTickVar; + } + } + } + +} \ No newline at end of file diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index 1ddcef9c74..78001238f6 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -2794,15 +2794,15 @@ item.itemPlateDoubleRunite.name=Double Runite Plate item.itemCellRunite.name=Runite Cell tile.Block of Runite.name=Block of Runite -item.itemIngotDragonblood.name=Dragonblood Ingot -item.itemDustDragonblood.name=Dragonblood Dust -item.itemDustTinyDragonblood.name=Tiny Pile of Dragonblood Dust -item.itemDustSmallDragonblood.name=Small Pile of Dragonblood Dust -item.itemNuggetDragonblood.name=Dragonblood Nugget -item.itemPlateDragonblood.name=Dragonblood Plate -item.itemPlateDoubleDragonblood.name=Double Dragonblood Plate +item.itemIngotDragonblood.name=Dragon Metal Ingot +item.itemDustDragonblood.name=Dragon Metal Dust +item.itemDustTinyDragonblood.name=Tiny Pile of Dragon Metal Dust +item.itemDustSmallDragonblood.name=Small Pile of Dragon Metal Dust +item.itemNuggetDragonblood.name=Shard of Dragonblood +item.itemPlateDragonblood.name=Dragon Metal Plate +item.itemPlateDoubleDragonblood.name=Double Dragon Metal Plate item.itemCellDragonblood.name=Dragonblood Cell -tile.Block of Dragonblood.name=Block of Dragonblood +tile.Block of Dragonblood.name=Block of Dragon Metal item.itemIngotBlackTitanium.name=Black Titanium Ingot item.itemDustBlackTitanium.name=Black Titanium Dust @@ -2896,4 +2896,56 @@ item.itemNuggetRhugnor.name=Rhugnor Nugget item.itemPlateRhugnor.name=Rhugnor Plate item.itemPlateDoubleRhugnor.name=Double Rhugnor Plate item.itemCellRhugnor.name=Rhugnor Cell -tile.Block of Rhugnor.name=Block of Rhugnor \ No newline at end of file +tile.Block of Rhugnor.name=Block of Rhugnor + + + + +//Added 13/5/19 + +item.GTPP.BattPack.01.name=Charge Pack [LV] +item.GTPP.BattPack.02.name=Charge Pack [MV] +item.GTPP.BattPack.03.name=Charge Pack [HV] +item.GTPP.BattPack.04.name=Charge Pack [EV] +item.GTPP.BattPack.05.name=Charge Pack [IV] +item.IndustrialDiamondExquisite.name=Exquisite Industrial Diamond + +item.itemSpringCelestialTungsten.name=Celestial Tungsten Spring +item.itemSpringWhiteMetal.name=White Metal Spring +item.itemSpringNitinol60.name=Nitinol 60 Spring +item.itemSpringWatertightSteel.name=Watertight Steel Spring +item.itemSpringEglinSteel.name=Eglin Steel Spring + +item.itemSmallSpringMaragingSteel250.name=Small Maraging Steel 250 Spring +item.itemSmallSpringNichrome.name=Small Nichrome Spring +item.itemSmallSpringStaballoy.name=Small Staballoy Spring +item.itemSmallSpringBlackSteel.name=Small Black Steel Spring +item.itemSmallSpringBlackTitanium.name=Small Black Titanium Spring + +item.itemFineWireWhiteMetal.name=Fine White Metal Wire +item.itemFineWirePalladium.name=Fine Palladium Wire +item.itemFineWireZirconium.name=Fine Zirconium Wire +item.itemFineWireGrisium.name=Fine Grisium Wire +item.itemFineWireBabbitAlloy.name=Fine Babbit Alloy Wire +item.itemFineWireKoboldite.name=Fine Koboldite Wire +item.itemFineWireHG1223.name=Fine HG-1223 Wire +item.itemFineWireQuantum.name=Fine Quantum Wire + +item.itemHeavyPlatePotin.name=Heavy Potin Plate +item.itemHeavyPlateWatertightSteel.name=Heavy Watertight Steel Plate +item.itemHeavyPlateBronze.name=Heavy Bronze Plate +item.itemHeavyPlateOsmiridium.name=Heavy Osmiridium Plate +item.itemHeavyPlateQuantum.name=Heavy Quantum Plate +item.itemHeavyPlateBlackSteel.name=Heavy Black Steel Plate +item.itemHeavyPlateStainlessSteel.name=Heavy Stainless Steel Plate +item.itemHeavyPlateEglinSteel.name=Heavy Eglin Steel Plate +item.itemHeavyPlateMaragingSteel300.name=Heavy Maraging Steel 300 Plate +item.itemHeavyPlateTalonite.name=Heavy Talonite Plate +item.itemHeavyPlateHypogen.name=Heavy Hypogen Plate +item.itemHeavyPlateRhugnor.name=Heavy Rhugnor Plate +item.itemHeavyPlateAdvancedNitinol.name=Heavy Advanced Nitinol Plate +item.itemHeavyPlateAstralTitanium.name=Heavy Astral Titanium Plate +item.itemHeavyPlateCelestialTungsten.name=Heavy Celestial Tungsten Plate +item.itemHeavyPlateWhiteMetal.name=Heavy White Metal Plate +item.itemHeavyPlateBlackMetal.name=Heavy Black Metal Plate +item.itemHeavyPlateAncientGranite.name=Heavy Ancient Granite Plate \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/items/IndustrialDiamondExquisite.png b/src/resources/assets/miscutils/textures/items/IndustrialDiamondExquisite.png new file mode 100644 index 0000000000..5427f66858 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/IndustrialDiamondExquisite.png differ diff --git a/src/resources/assets/miscutils/textures/items/itemFineWire.png b/src/resources/assets/miscutils/textures/items/itemFineWire.png new file mode 100644 index 0000000000..1804dc358b Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemFineWire.png differ diff --git a/src/resources/assets/miscutils/textures/items/itemHeavyPlate.png b/src/resources/assets/miscutils/textures/items/itemHeavyPlate.png index 1f005e0156..e09ff6d1df 100644 Binary files a/src/resources/assets/miscutils/textures/items/itemHeavyPlate.png and b/src/resources/assets/miscutils/textures/items/itemHeavyPlate.png differ diff --git a/src/resources/assets/miscutils/textures/items/itemHeavyPlate_Overlay.png b/src/resources/assets/miscutils/textures/items/itemHeavyPlate_Overlay.png new file mode 100644 index 0000000000..c3835b07c1 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemHeavyPlate_Overlay.png differ diff --git a/src/resources/assets/miscutils/textures/items/itemSmallSpring.png b/src/resources/assets/miscutils/textures/items/itemSmallSpring.png new file mode 100644 index 0000000000..54b3afb24e Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemSmallSpring.png differ diff --git a/src/resources/assets/miscutils/textures/items/itemSpring.png b/src/resources/assets/miscutils/textures/items/itemSpring.png new file mode 100644 index 0000000000..df442ed454 Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemSpring.png differ -- cgit From ff47ff098d524402639b3593a0eb58dbbcbeb538 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 13 May 2019 18:20:11 +1000 Subject: + Added EntityDeathHandler.java, along with some custom drops for Zombies, Blazes and SpecialMob's Brutish Zombie. $ Temporarily disabled bonus outputs again on Multiblocks, fixing the ghost item issue along with processing. --- src/Java/gtPlusPlus/core/common/CommonProxy.java | 42 +++++ .../handler/events/EnderDragonDeathHandler.java | 6 +- .../core/handler/events/EntityDeathHandler.java | 95 ++++++++++++ .../core/util/minecraft/EntityUtils.java | 75 +++++---- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 11 ++ .../base/GregtechMeta_MultiBlockBase.java | 169 +++++++++++++++++---- .../GregtechMetaTileEntity_IndustrialSifter.java | 2 +- 7 files changed, 341 insertions(+), 59 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity') diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 23bdb2c5f1..6058d03b80 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -28,6 +28,7 @@ import gtPlusPlus.core.handler.GuiHandler; import gtPlusPlus.core.handler.StopAnnoyingFuckingAchievements; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.handler.events.EnderDragonDeathHandler; +import gtPlusPlus.core.handler.events.EntityDeathHandler; import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; import gtPlusPlus.core.handler.events.ZombieBackupSpawnEventHandler; @@ -36,17 +37,26 @@ import gtPlusPlus.core.item.chemistry.GenericChem; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.tileentities.ModTileEntities; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.debug.DEBUG_INIT; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.player.PlayerCache; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO; import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.thermalfoundation.item.TF_Items; +import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.item.ItemStack; import net.minecraftforge.common.ForgeChunkManager; public class CommonProxy { @@ -147,6 +157,7 @@ public class CommonProxy { ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, ChunkManager.getInstance()); Utils.registerEvent(ChunkManager.getInstance()); Utils.registerEvent(new EnderDragonDeathHandler()); + Utils.registerEvent(new EntityDeathHandler()); if (ConfigSwitches.disableZombieReinforcement) { // Make Zombie reinforcements fuck off. @@ -181,6 +192,7 @@ public class CommonProxy { COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); COMPAT_IntermodStaging.postInit(e); COMPAT_HANDLER.runQueuedRecipes(); + registerCustomMobDrops(); } public void serverStarting(final FMLServerStartingEvent e) { @@ -226,5 +238,35 @@ public class CommonProxy { public void registerCustomItemsForMaterials() { Material.registerComponentForMaterial(GenericChem.CARBYNE, OrePrefixes.plate, GregtechItemList.Carbyne_Sheet_Finished.get(1)); } + + public void registerCustomMobDrops() { + + //Zombie + EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemRope), 3, 100); + EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemFiber), 5, 250); + EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemSandstoneHammer), 1, 10); + EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemBomb), 2, 10); + EntityUtils.registerDropsForMob(EntityZombie.class, ALLOY.TUMBAGA.getTinyDust(1), 1, 10); + EntityUtils.registerDropsForMob(EntityZombie.class, ALLOY.POTIN.getTinyDust(1), 1, 10); + + //Blazes + EntityUtils.registerDropsForMob(EntityBlaze.class, ItemUtils.getSimpleStack(TF_Items.dustPyrotheum, 1), 1, 10); + EntityUtils.registerDropsForMob(EntityBlaze.class, ItemUtils.getSimpleStack(TF_Items.dustPyrotheum, 1), 1, 10); + + //Special mobs Support + if (ReflectionUtils.doesClassExist("toast.specialMobs.entity.zombie.EntityBrutishZombie")) { + Class aBrutishZombie = ReflectionUtils.getClass("toast.specialMobs.entity.zombie.EntityBrutishZombie"); + ItemStack aFortune1 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); + ItemStack aFortune2 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); + ItemStack aFortune3 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); + EntityUtils.registerDropsForMob(aBrutishZombie, aFortune1, 1, 100); + EntityUtils.registerDropsForMob(aBrutishZombie, aFortune2, 1, 50); + EntityUtils.registerDropsForMob(aBrutishZombie, aFortune3, 1, 1); + EntityUtils.registerDropsForMob(aBrutishZombie, ItemUtils.getItemStackOfAmountFromOreDict("ingotRedAlloy", 1), 3, 200); + } + + + + } } diff --git a/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java b/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java index c1c2341dd6..884f14386d 100644 --- a/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.handler.events; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.core.material.ELEMENT; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -24,6 +23,7 @@ public class EnderDragonDeathHandler { public void onEntityDrop(LivingDropsEvent event) { boolean aDidDrop = false; + int aCountTotal = 0; //HEE Dragon if (mHEE) { @@ -33,6 +33,7 @@ public class EnderDragonDeathHandler { int aAmount = MathUtils.randInt(5, 25); event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); aDidDrop = true; + aCountTotal =+ aAmount; } } } @@ -44,12 +45,13 @@ public class EnderDragonDeathHandler { int aAmount = MathUtils.randInt(1, 10); event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); aDidDrop = true; + aCountTotal =+ aAmount; } } } if (aDidDrop) { - PlayerUtils.messageAllPlayers("Small quantities of Dragonsblood has crystalized after the death of the Ender Dragon!"); + PlayerUtils.messageAllPlayers(aCountTotal+" Shards of Dragons Blood have crystalized into a metallic form."); } } diff --git a/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java b/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java new file mode 100644 index 0000000000..c4ab6edaa6 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java @@ -0,0 +1,95 @@ +package gtPlusPlus.core.handler.events; + +import java.util.HashMap; +import java.util.HashSet; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.living.LivingDropsEvent; + +public class EntityDeathHandler { + + + private static final HashMap>> mMobDropMap = new HashMap>>(); + private static final HashSet mInternalClassKeyCache = new HashSet(); + + /** + * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. + * @param aMobClass - The Base Class you want to drop this item. + * @param aStack - The ItemStack, stack size is not respected. + * @param aMaxAmount - The maximum size of the ItemStack which drops. + * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) + */ + public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aMaxAmount, int aChance) { + Triplet aData = new Triplet(aStack, aMaxAmount, aChance); + AutoMap> aDataMap = mMobDropMap.get(aMobClass); + if (aDataMap == null) { + aDataMap = new AutoMap>(); + } + aDataMap.put(aData); + mMobDropMap.put(aMobClass, aDataMap); + + Logger.INFO("[Loot] Registered "+aStack.getDisplayName()+" (1-"+aMaxAmount+") as a valid drop for "+aMobClass.getCanonicalName()); + + if (!mInternalClassKeyCache.contains(aMobClass)) { + mInternalClassKeyCache.add(aMobClass); + } + + } + + private static ItemStack processItemDropTriplet(Triplet aData) { + ItemStack aLoot = aData.getValue_1(); + int aMaxDrop = aData.getValue_2(); + int aChanceOutOf10000 = aData.getValue_3(); + if (MathUtils.randInt(0, 10000) <= aChanceOutOf10000) { + aLoot = ItemUtils.getSimpleStack(aLoot, MathUtils.randInt(1, aMaxDrop)); + if (ItemUtils.checkForInvalidItems(aLoot)) { + return aLoot; + } + } + return null; + } + + private static boolean processDropsForMob(EntityLivingBase entityLiving) { + AutoMap> aMobData = mMobDropMap.get(entityLiving.getClass()); + boolean aDidDrop = false; + if (aMobData != null) { + if (!aMobData.isEmpty()) { + ItemStack aPossibleDrop; + for (Triplet g : aMobData) { + aPossibleDrop = processItemDropTriplet(g); + if (aPossibleDrop != null) { + if (entityLiving.entityDropItem(aPossibleDrop, MathUtils.randFloat(0, 1)) != null) { + aDidDrop = true; + } + } + } + } + } + return aDidDrop; + } + + + + + + @SubscribeEvent + public void onEntityDrop(LivingDropsEvent event) { + boolean aDidDrop = false; + if (event == null || event.entityLiving == null) { + return; + } + for (Class c : mInternalClassKeyCache) { + if (c.isInstance(event.entityLiving)) { + aDidDrop = processDropsForMob(event.entityLiving); + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java index 8c5a9f6581..49aa3a1306 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java @@ -11,6 +11,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.AABB; import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.handler.events.EntityDeathHandler; import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.IC2Potion; import ic2.core.item.armor.ItemArmorHazmat; @@ -20,6 +21,7 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; @@ -87,7 +89,7 @@ public class EntityUtils { } return false; } - + public static boolean applyHeatDamageToEntity(final int heatLevel, final World world, final Entity entityHolding){ if (!world.isRemote){ if ((heatLevel > 0) && (entityHolding instanceof EntityLivingBase)) { @@ -113,11 +115,7 @@ public class EntityUtils { */ public synchronized static boolean doFireDamage(Entity entity, int amount){ if (dealFireDamage == null){ - try { - dealFireDamage = Entity.class.getDeclaredMethod("dealFireDamage", int.class); - dealFireDamage.setAccessible(true); - } - catch (NoSuchMethodException | SecurityException e) {} + dealFireDamage = ReflectionUtils.getMethod(Entity.class, "dealFireDamage", int.class); } else { try { @@ -131,42 +129,41 @@ public class EntityUtils { public static void doDamage(Entity entity, DamageSource dmg, int i) { entity.attackEntityFrom(dmg, i); } - + public static boolean isTileEntityRegistered(Class aTileClass, String aTileName) { Field aRegistry = ReflectionUtils.getField(ReflectionUtils.getClass("net.minecraft.tileentity.TileEntity"), "nameToClassMap"); Field aRegistry2 = ReflectionUtils.getField(ReflectionUtils.getClass("net.minecraft.tileentity.TileEntity"), "classToNameMap"); try { Object o = aRegistry.get(null); if (o != null) { - Map nameToClassMap = (Map) o; - if (!nameToClassMap.containsKey(aTileName)) { - o = aRegistry2.get(null); - if (o != null) { - Map classToNameMap = (Map) o; - if (!classToNameMap.containsKey(aTileClass)) { - return false; - } - else { - return true; - } - } - } - else { - return true; - } + Map nameToClassMap = (Map) o; + if (!nameToClassMap.containsKey(aTileName)) { + o = aRegistry2.get(null); + if (o != null) { + Map classToNameMap = (Map) o; + if (!classToNameMap.containsKey(aTileClass)) { + return false; + } + else { + return true; + } + } + } + else { + return true; + } } } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } return false; } - + public static double getDistance(Entity p1, Entity p2) { - return Math.sqrt( Math.pow(p1.posX - p2.posX, 2) + Math.pow(p1.posY - p2.posY, 2) + Math.pow(p1.posZ - p2.posZ, 2)); + return Math.sqrt( Math.pow(p1.posX - p2.posX, 2) + Math.pow(p1.posY - p2.posY, 2) + Math.pow(p1.posZ - p2.posZ, 2)); } - + public static AutoMap getEntitiesWithinBoundingBoxExcluding(Entity aExclusion, AABB aBoundingBox){ - if (aExclusion == null) { return new AutoMap(); } @@ -175,9 +172,8 @@ public class EntityUtils { return new AutoMap(aEntities); } } - + public static AutoMap getEntitiesWithinBoundingBox(Class aEntityType, AABB aBoundingBox){ - if (aEntityType == null) { return new AutoMap(); } @@ -186,5 +182,26 @@ public class EntityUtils { return new AutoMap(aEntities); } } + + /** + * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. Simplified function with static Max drop size of 1. + * @param aMobClass - The Base Class you want to drop this item. + * @param aStack - The ItemStack, stack size is not respected. + * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) + */ + public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aChance) { + registerDropsForMob(aMobClass, aStack, 1, aChance); + } + + /** + * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. + * @param aMobClass - The Base Class you want to drop this item. + * @param aStack - The ItemStack, stack size is not respected. + * @param aMaxAmount - The maximum size of the ItemStack which drops. + * @param aChance - Chance out of 10000, where 100 is 1%. (1 = 0.01% - this is ok) + */ + public static void registerDropsForMob(Class aMobClass, ItemStack aStack, int aMaxAmount, int aChance) { + EntityDeathHandler.registerDropsForMob(aMobClass, aStack, aMaxAmount, aChance); + } } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 8b2e04d738..433f26aa11 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -35,6 +35,8 @@ import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_DustGeneration; import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentData; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -1205,4 +1207,13 @@ public class ItemUtils { return aOutput; } + public static ItemStack getEnchantedBook(Enchantment aEnch, int aLevel) { + return enchantItem(new ItemStack(Items.enchanted_book), aEnch, aLevel); + } + + public static ItemStack enchantItem(ItemStack aStack, Enchantment aEnch, int aLevel) { + Items.enchanted_book.addEnchantment(aStack, new EnchantmentData(aEnch, aLevel)); + return aStack; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index e9f8546545..0e1ef0e47e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -540,26 +540,149 @@ GT_MetaTileEntity_MultiBlockBase { } + /* + * public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] + * aFluidInputs, int aMaxParallelRecipes, int aEUPercent, int + * aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { // Based on + * the Processing Array. A bit overkill, but very flexible. + * + * + * if (this.doesMachineBoostOutput()) { log("Boosting."); return + * checkRecipeBoostedOutputs(aItemInputs, aFluidInputs, aMaxParallelRecipes, + * aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); } + * + * + * //Control Core to control the Multiblocks behaviour. int aControlCoreTier = + * getControlCoreTier(); + * + * //If no core, return false; if (aControlCoreTier > 0) { + * log("Control core found."); } + * + * + * // Reset outputs and progress stats this.mEUt = 0; this.mMaxProgresstime = 0; + * this.mOutputItems = new ItemStack[]{}; this.mOutputFluids = new + * FluidStack[]{}; + * + * long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, + * GT_Utility.getTier(tVoltage)); log("Running checkRecipeGeneric(0)"); + * + * //Check to see if Voltage Tier > Control Core Tier if (tTier > + * aControlCoreTier) { + * log("Control core found is lower tier than power tier. OK"); tTier = (byte) + * aControlCoreTier; } + * + * tTier = (byte) MathUtils.getValueWithinRange(tTier, 0, 9); + * + * GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( + * getBaseMetaTileEntity(), mLastRecipe, false, + * gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); + * + * log("Running checkRecipeGeneric(1)"); // Remember last recipe - an + * optimization for findRecipe() this.mLastRecipe = tRecipe; + * + * if (tRecipe == null) { log("BAD RETURN - 1"); return false; } + * + * if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) { + * log("BAD RETURN - 2"); return false; } + * + * // EU discount float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; float + * tTotalEUt = 0.0f; + * + * int parallelRecipes = 0; + * + * log("parallelRecipes: "+parallelRecipes); + * log("aMaxParallelRecipes: "+aMaxParallelRecipes); + * log("tTotalEUt: "+tTotalEUt); log("tVoltage: "+tVoltage); + * log("tRecipeEUt: "+tRecipeEUt); Logger.INFO("EU1: "+tRecipeEUt); // Count + * recipes to do in parallel, consuming input items and fluids and considering + * input voltage limits for (; parallelRecipes < aMaxParallelRecipes && + * tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) { if + * (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { + * log("Broke at "+parallelRecipes+"."); break; } + * log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+"."); tTotalEUt + * += tRecipeEUt; Logger.INFO("EU2: "+tTotalEUt); } + * + * if (parallelRecipes == 0) { log("BAD RETURN - 3"); return false; } + * + * Logger.INFO("EU3: "+tTotalEUt); + * + * // -- Try not to fail after this point - inputs have already been consumed! + * -- + * + * + * // Convert speed bonus to duration multiplier // e.g. 100% speed bonus = 200% + * speed = 100%/200% = 50% recipe duration. aSpeedBonusPercent = Math.max(-99, + * aSpeedBonusPercent); float tTimeFactor = 100.0f / (100.0f + + * aSpeedBonusPercent); this.mMaxProgresstime = (int)(tRecipe.mDuration * + * tTimeFactor * 10000); + * + * int aTempEu = (int) Math.floor(tTotalEUt); Logger.INFO("EU4: "+aTempEu); + * this.mEUt = (int) aTempEu; + * + * + * this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + * this.mEfficiencyIncrease = 10000; + * + * // Overclock if (this.mEUt <= 16) { this.mEUt = (this.mEUt * (1 << tTier - 1) + * * (1 << tTier - 1)); this.mMaxProgresstime = (this.mMaxProgresstime / (1 << + * tTier - 1)); } else { while (this.mEUt <= + * gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; + * this.mMaxProgresstime /= 2; } } + * + * if (this.mEUt > 0) { this.mEUt = (-this.mEUt); } + * + * this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + * + * // Collect fluid outputs FluidStack[] tOutputFluids = new + * FluidStack[tRecipe.mFluidOutputs.length]; for (int h = 0; h < + * tRecipe.mFluidOutputs.length; h++) { if (tRecipe.getFluidOutput(h) != null) { + * tOutputFluids[h] = tRecipe.getFluidOutput(h).copy(); tOutputFluids[h].amount + * *= parallelRecipes; } } + * + * // Collect output item types ItemStack[] tOutputItems = new + * ItemStack[tRecipe.mOutputs.length]; for (int h = 0; h < + * tRecipe.mOutputs.length; h++) { if (tRecipe.getOutput(h) != null) { + * tOutputItems[h] = tRecipe.getOutput(h).copy(); tOutputItems[h].stackSize = 0; + * } } + * + * // Set output item stack sizes (taking output chance into account) for (int f + * = 0; f < tOutputItems.length; f++) { if (tRecipe.mOutputs[f] != null && + * tOutputItems[f] != null) { for (int g = 0; g < parallelRecipes; g++) { if + * (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < + * tRecipe.getOutputChance(f)) tOutputItems[f].stackSize += + * tRecipe.mOutputs[f].stackSize; } } } + * + * tOutputItems = removeNulls(tOutputItems); + * + * // Sanitize item stack size, splitting any stacks greater than max stack size + * List splitStacks = new ArrayList(); for (ItemStack + * tItem : tOutputItems) { while (tItem.getMaxStackSize() < tItem.stackSize) { + * ItemStack tmp = tItem.copy(); tmp.stackSize = tmp.getMaxStackSize(); + * tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); + * splitStacks.add(tmp); } } + * + * if (splitStacks.size() > 0) { ItemStack[] tmp = new + * ItemStack[splitStacks.size()]; tmp = splitStacks.toArray(tmp); tOutputItems = + * ArrayUtils.addAll(tOutputItems, tmp); } + * + * // Strip empty stacks List tSList = new ArrayList(); + * for (ItemStack tS : tOutputItems) { if (tS.stackSize > 0) tSList.add(tS); } + * tOutputItems = tSList.toArray(new ItemStack[tSList.size()]); + * + * // Commit outputs this.mOutputItems = tOutputItems; this.mOutputFluids = + * tOutputFluids; updateSlots(); + * + * // Play sounds (GT++ addition - GT multiblocks play no sounds) + * startProcess(); + * + * log("GOOD RETURN - 1"); return true; } + */ + public boolean checkRecipeGeneric( ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - - if (this.doesMachineBoostOutput()) { - log("Boosting."); - return checkRecipeBoostedOutputs(aItemInputs, aFluidInputs, aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll, aRecipe); - } - - - //Control Core to control the Multiblocks behaviour. - int aControlCoreTier = getControlCoreTier(); - - //If no core, return false; - if (aControlCoreTier > 0) { - log("Control core found."); - } + // Based on the Processing Array. A bit overkill, but very flexible. // Reset outputs and progress stats @@ -572,15 +695,8 @@ GT_MetaTileEntity_MultiBlockBase { byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); log("Running checkRecipeGeneric(0)"); - //Check to see if Voltage Tier > Control Core Tier - if (tTier > aControlCoreTier) { - log("Control core found is lower tier than power tier. OK"); - tTier = (byte) aControlCoreTier; - } - tTier = (byte) MathUtils.getValueWithinRange(tTier, 0, 9); - - GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( + GT_Recipe tRecipe = findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); @@ -636,7 +752,7 @@ GT_MetaTileEntity_MultiBlockBase { this.mEUt = (int)Math.ceil(tTotalEUt); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; + this.mEfficiencyIncrease = 10000; // Overclock if (this.mEUt <= 16) { @@ -719,8 +835,7 @@ GT_MetaTileEntity_MultiBlockBase { log("GOOD RETURN - 1"); return true; - } - +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java index 7c57f799d7..38306d914d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java @@ -120,7 +120,7 @@ extends GregtechMeta_MultiBlockBase { @Override protected boolean doesMachineBoostOutput() { - return true; + return false; } @Override -- 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/xmod/gregtech/api/metatileentity') 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