From cb9f0c4abfe54ef509165b13881cbd511ce946bb Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 15 Nov 2017 00:50:31 +1000 Subject: + Added 3 alternative recipes for obtaining Zirconium. (Sifting Tin/Cassiterite & Electromagnetic separation of Bauxite.) --- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 427eb19c9a..7f0bc7a8ca 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -52,6 +52,8 @@ public class RECIPES_GREGTECH { cyclotronRecipes(); blastSmelterRecipes(); advancedMixerRecipes(); + sifterRecipes(); + electroMagneticSeperatorRecipes(); addFuels(); } @@ -956,6 +958,49 @@ public class RECIPES_GREGTECH { 500*20); } + private static void sifterRecipes() { + //Zirconium + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedTin", 1), + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict("dustTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZinc", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1) + }, + new int[]{10000, 5000, 1500, 1000, 500, 500}, + 20*30, + 60); + + //Zirconium + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedCassiterite", 1), + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict("dustCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1) + }, + new int[]{10000, 5000, 1500, 1000, 500, 500}, + 20*30, + 60); + } + + private static void electroMagneticSeperatorRecipes(){ + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedBauxite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustBauxite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallRutile", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetZirconium", 1), + new int[]{10000, 2500, 4000}, + 20*20, + 24); + } + private static void advancedMixerRecipes(){ //HgBa2Ca2Cu3O8 CORE.RA.addMixerRecipe( -- cgit From 5c2b131a29c3ea0871ecbd400635ca0be3ebdfbe Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 15 Nov 2017 03:25:34 +1000 Subject: $ Fixed Power Sub-Station not providing very good scanner info. + Added stats for nerds to the PSS. + Added custom (dis)charge hatches for use with the PSS. --- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 2 +- src/Java/gtPlusPlus/core/slots/SlotElectric.java | 43 ++++ .../xmod/gregtech/api/enums/GregtechItemList.java | 4 + .../gregtech/api/gui/hatches/CONTAINER_2by2.java | 31 +++ .../gregtech/api/gui/hatches/CONTAINER_4by4.java | 43 ++++ .../xmod/gregtech/api/gui/hatches/GUI_2by2.java | 36 +++ .../xmod/gregtech/api/gui/hatches/GUI_4by4.java | 36 +++ .../hatches/charge/CONTAINER_Electric_2by2.java | 22 ++ .../hatches/charge/CONTAINER_Electric_4by4.java | 35 +++ .../api/gui/hatches/charge/GUI_Electric_2by2.java | 19 ++ .../api/gui/hatches/charge/GUI_Electric_4by4.java | 20 ++ .../base/GregtechMetaPipeEntityBase_Cable.java | 219 +++++++++++++------ .../base/GregtechMetaTileEntity.java | 22 +- .../base/GregtechMetaTransformerHiAmp.java | 73 ++++--- .../base/GregtechMeta_MultiBlockBase.java | 243 +++++++++++++++------ ...chMetaTileEntity_PowerSubStationController.java | 77 ++++++- .../gregtech/GregtechPowerSubStation.java | 18 ++ 17 files changed, 763 insertions(+), 180 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/slots/SlotElectric.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 9236aa53e5..788d011733 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -55,7 +55,7 @@ public class COMPAT_HANDLER { to 868 --- - 886 + 890 to 950 */ diff --git a/src/Java/gtPlusPlus/core/slots/SlotElectric.java b/src/Java/gtPlusPlus/core/slots/SlotElectric.java new file mode 100644 index 0000000000..6b11cf5264 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotElectric.java @@ -0,0 +1,43 @@ +package gtPlusPlus.core.slots; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotElectric extends Slot { + + public SlotElectric(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } + + public SlotElectric(IGregTechTileEntity mTileEntity, int i, int j, int k) { + this(mTileEntity.getIInventory(mTileEntity.getXCoord(), mTileEntity.getYCoord(), mTileEntity.getZCoord()), i, j, k); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if ((accepts(itemstack)) || (itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { + return true; + } + return false; + } + + public boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } + return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) + || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); + } + + @Override + public int getSlotStackLimit() { + return 1; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 2032555a7f..e4da291b17 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -253,6 +253,10 @@ public enum GregtechItemList implements GregtechItemContainer { Machine_Advanced_EV_Mixer, Machine_Advanced_IV_Mixer, Machine_Advanced_LuV_Mixer, Machine_Advanced_ZPM_Mixer, Machine_Advanced_UV_Mixer, + //Custom hatches + Hatch_Input_Battery_MV, Hatch_Input_Battery_EV, + Hatch_Output_Battery_MV, Hatch_Output_Battery_EV, + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java new file mode 100644 index 0000000000..60106825a0 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_2by2.java @@ -0,0 +1,31 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +public class CONTAINER_2by2 extends GT_ContainerMetaTile_Machine { + + public CONTAINER_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 71, 26)); + addSlotToContainer(new Slot(mTileEntity, 1, 89, 26)); + addSlotToContainer(new Slot(mTileEntity, 2, 71, 44)); + addSlotToContainer(new Slot(mTileEntity, 3, 89, 44)); + } + + @Override + public int getSlotCount() { + return 4; + } + + @Override + public int getShiftClickSlotCount() { + return 4; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java new file mode 100644 index 0000000000..0c011f164b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/CONTAINER_4by4.java @@ -0,0 +1,43 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import gregtech.api.gui.GT_ContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; + +public class CONTAINER_4by4 extends GT_ContainerMetaTile_Machine { + + public CONTAINER_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mTileEntity, 0, 53, 8)); + addSlotToContainer(new Slot(mTileEntity, 1, 71, 8)); + addSlotToContainer(new Slot(mTileEntity, 2, 89, 8)); + addSlotToContainer(new Slot(mTileEntity, 3, 107, 8)); + addSlotToContainer(new Slot(mTileEntity, 4, 53, 26)); + addSlotToContainer(new Slot(mTileEntity, 5, 71, 26)); + addSlotToContainer(new Slot(mTileEntity, 6, 89, 26)); + addSlotToContainer(new Slot(mTileEntity, 7, 107, 26)); + addSlotToContainer(new Slot(mTileEntity, 8, 53, 44)); + addSlotToContainer(new Slot(mTileEntity, 9, 71, 44)); + addSlotToContainer(new Slot(mTileEntity, 10, 89, 44)); + addSlotToContainer(new Slot(mTileEntity, 11, 107, 44)); + addSlotToContainer(new Slot(mTileEntity, 12, 53, 62)); + addSlotToContainer(new Slot(mTileEntity, 13, 71, 62)); + addSlotToContainer(new Slot(mTileEntity, 14, 89, 62)); + addSlotToContainer(new Slot(mTileEntity, 15, 107, 62)); + } + + @Override + public int getSlotCount() { + return 16; + } + + @Override + public int getShiftClickSlotCount() { + return 16; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java new file mode 100644 index 0000000000..b78d8454c3 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_2by2.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; + +public class GUI_2by2 extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GUI_2by2(CONTAINER_2by2 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(containerType, RES_PATH_GUI + "2by2.png"); + mName = aName; + } + + public GUI_2by2(CONTAINER_2by2 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(containerType, RES_PATH_GUI + aBackground + "2by2.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(mName, 8, 4, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java new file mode 100644 index 0000000000..4cd599110c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/GUI_4by4.java @@ -0,0 +1,36 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; + +public class GUI_4by4 extends GT_GUIContainerMetaTile_Machine { + + private final String mName; + + public GUI_4by4(CONTAINER_4by4 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(containerType, RES_PATH_GUI + "4by4.png"); + mName = aName; + } + + public GUI_4by4(CONTAINER_4by4 containerType, InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(containerType, RES_PATH_GUI + aBackground + "4by4.png"); + mName = aName; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + fontRendererObj.drawString(mName, 8, 4, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java new file mode 100644 index 0000000000..d2ca190658 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_2by2.java @@ -0,0 +1,22 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.slots.SlotElectric; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_2by2; +import net.minecraft.entity.player.InventoryPlayer; + +public class CONTAINER_Electric_2by2 extends CONTAINER_2by2{ + + public CONTAINER_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new SlotElectric(mTileEntity, 0, 71, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 1, 89, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 2, 71, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 3, 89, 44)); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java new file mode 100644 index 0000000000..bb70df0558 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/CONTAINER_Electric_4by4.java @@ -0,0 +1,35 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.core.slots.SlotElectric; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_4by4; +import net.minecraft.entity.player.InventoryPlayer; + +public class CONTAINER_Electric_4by4 extends CONTAINER_4by4{ + + public CONTAINER_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + + @Override + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new SlotElectric(mTileEntity, 0, 53, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 1, 71, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 2, 89, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 3, 107, 8)); + addSlotToContainer(new SlotElectric(mTileEntity, 4, 53, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 5, 71, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 6, 89, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 7, 107, 26)); + addSlotToContainer(new SlotElectric(mTileEntity, 8, 53, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 9, 71, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 10, 89, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 11, 107, 44)); + addSlotToContainer(new SlotElectric(mTileEntity, 12, 53, 62)); + addSlotToContainer(new SlotElectric(mTileEntity, 13, 71, 62)); + addSlotToContainer(new SlotElectric(mTileEntity, 14, 89, 62)); + addSlotToContainer(new SlotElectric(mTileEntity, 15, 107, 62)); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java new file mode 100644 index 0000000000..2e365277ea --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_2by2.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_2by2; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_Electric_2by2 extends GUI_2by2{ + + public GUI_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_Electric_2by2(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, aName); + } + + public GUI_Electric_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(new CONTAINER_Electric_2by2(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, RES_PATH_GUI + aBackground + "2by2.png"); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java new file mode 100644 index 0000000000..a09ab7d7aa --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/hatches/charge/GUI_Electric_4by4.java @@ -0,0 +1,20 @@ +package gtPlusPlus.xmod.gregtech.api.gui.hatches.charge; + +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_4by4; +import net.minecraft.entity.player.InventoryPlayer; + +public class GUI_Electric_4by4 extends GUI_4by4{ + + public GUI_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new CONTAINER_Electric_4by4(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, aName); + } + + public GUI_Electric_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aBackground) { + super(new CONTAINER_Electric_4by4(aInventoryPlayer, aTileEntity), aInventoryPlayer, aTileEntity, RES_PATH_GUI + aBackground + "4by4.png"); + + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java index ee58e0f20f..6de1594b69 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java @@ -43,7 +43,9 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements public short mOverheat; public final int mWireHeatingTicks; - public GregtechMetaPipeEntityBase_Cable(final int aID, final String aName, final String aNameRegional, final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock) { + public GregtechMetaPipeEntityBase_Cable(final int aID, final String aName, final String aNameRegional, + final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, + final long aVoltage, final boolean aInsulated, final boolean aCanShock) { super(aID, aName, aNameRegional, 0); this.mThickNess = aThickNess; this.mMaterial = aMaterial; @@ -55,7 +57,9 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements this.mWireHeatingTicks = this.getGT5Var(); } - public GregtechMetaPipeEntityBase_Cable(final String aName, final float aThickNess, final GT_Materials aMaterial, final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, final boolean aCanShock) { + public GregtechMetaPipeEntityBase_Cable(final String aName, final float aThickNess, final GT_Materials aMaterial, + final long aCableLossPerMeter, final long aAmperage, final long aVoltage, final boolean aInsulated, + final boolean aCanShock) { super(aName, 0); this.mThickNess = aThickNess; this.mMaterial = aMaterial; @@ -67,23 +71,23 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements this.mWireHeatingTicks = this.getGT5Var(); } - private int getGT5Var(){ + private int getGT5Var() { final Class clazz = GT_Mod.gregtechproxy.getClass(); final String lookingForValue = "mWireHeatingTicks"; int temp = 4; Field field; - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { try { field = clazz.getClass().getField(lookingForValue); final Class clazzType = field.getType(); - if (clazzType.toString().equals("int")){ + if (clazzType.toString().equals("int")) { temp = (field.getInt(clazz)); - } - else { + } else { temp = 4; } } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { - //Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + // Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES + // - PLEASE REPORT THIS."); Utils.LOG_WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); Utils.LOG_ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); temp = 4; @@ -99,37 +103,64 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements @Override public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaPipeEntityBase_Cable(this.mName, this.mThickNess, this.mMaterial, this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock); + return new GregtechMetaPipeEntityBase_Cable(this.mName, this.mThickNess, this.mMaterial, + this.mCableLossPerMeter, this.mAmperage, this.mVoltage, this.mInsulated, this.mCanShock); } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) { + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, + final byte aConnections, final byte aColorIndex, final boolean aConnected, final boolean aRedstone) { if (!this.mInsulated) { - return new ITexture[]{new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa)}; + return new ITexture[] { new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa) }; } if (aConnected) { final float tThickNess = this.getThickNess(); if (tThickNess < 0.37F) { - return new ITexture[]{new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; } if (tThickNess < 0.49F) { - return new ITexture[]{new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; } if (tThickNess < 0.74F) { - return new ITexture[]{new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; } if (tThickNess < 0.99F) { - return new ITexture[]{new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; } - return new ITexture[]{new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], this.mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[] { + new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + this.mMaterial.mRGBa), + new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; } - return new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) }; } @Override - public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ, final Entity aEntity) { - if (this.mCanShock && ((((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0) && (aEntity instanceof EntityLivingBase)) { - GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, this.mTransferredVoltageLast20, this.mTransferredAmperageLast20); + public void onEntityCollidedWithBlock(final World aWorld, final int aX, final int aY, final int aZ, + final Entity aEntity) { + if (this.mCanShock && ((((BaseMetaPipeEntity) this.getBaseMetaTileEntity()).mConnections & -128) == 0) + && (aEntity instanceof EntityLivingBase)) { + GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, this.mTransferredVoltageLast20, + this.mTransferredAmperageLast20); } } @@ -138,7 +169,8 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements if (!this.mCanShock) { return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); } - return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, aZ + 0.875D); + return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, + aZ + 0.875D); } @Override @@ -173,19 +205,26 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements @Override public long injectEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { - if (!this.getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, this.getBaseMetaTileEntity().getCoverIDAtSide(aSide), this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), this.getBaseMetaTileEntity())) { + if (!this.getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, + this.getBaseMetaTileEntity().getCoverIDAtSide(aSide), + this.getBaseMetaTileEntity().getCoverDataAtSide(aSide), this.getBaseMetaTileEntity())) { return 0; } - return this.transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<>(Arrays.asList((TileEntity) this.getBaseMetaTileEntity()))); + return this.transferElectricity(aSide, aVoltage, aAmperage, + new ArrayList<>(Arrays.asList((TileEntity) this.getBaseMetaTileEntity()))); } @Override - public long transferElectricity(final byte aSide, long aVoltage, final long aAmperage, final ArrayList aAlreadyPassedTileEntityList) { + public long transferElectricity(final byte aSide, long aVoltage, final long aAmperage, + final ArrayList aAlreadyPassedTileEntityList) { long rUsedAmperes = 0; aVoltage -= this.mCableLossPerMeter; if (aVoltage > 0) { for (byte i = 0; (i < 6) && (aAmperage > rUsedAmperes); i++) { - if ((i != aSide) && ((this.mConnections & (1 << i)) != 0) && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, this.getBaseMetaTileEntity().getCoverIDAtSide(i), this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) { + if ((i != aSide) && ((this.mConnections & (1 << i)) != 0) + && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, + this.getBaseMetaTileEntity().getCoverIDAtSide(i), + this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) { final TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i); if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) { aAlreadyPassedTileEntityList.add(tTileEntity); @@ -196,22 +235,45 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements continue; } } - if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable) && ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)).letsEnergyIn(GT_Utility.getOppositeSide(i), ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity) tTileEntity))) { + if ((tTileEntity instanceof IGregTechTileEntity) + && (((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity() instanceof IMetaTileEntityCable) + && ((IGregTechTileEntity) tTileEntity) + .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)) + .letsEnergyIn(GT_Utility.getOppositeSide(i), + ((IGregTechTileEntity) tTileEntity) + .getCoverIDAtSide(GT_Utility.getOppositeSide(i)), + ((IGregTechTileEntity) tTileEntity) + .getCoverDataAtSide(GT_Utility.getOppositeSide(i)), + ((IGregTechTileEntity) tTileEntity))) { if (((IGregTechTileEntity) tTileEntity).getTimer() > 50) { - rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedTileEntityList); + rUsedAmperes += ((IMetaTileEntityCable) ((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), + aVoltage, aAmperage - rUsedAmperes, aAlreadyPassedTileEntityList); } } else { - rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits(GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes); + rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits( + GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes); } - // } else if (tTileEntity instanceof IEnergySink) { - // ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - // if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) { - // if (((IEnergySink)tTileEntity).demandedEnergyUnits() > 0 && ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, aVoltage) < aVoltage) rUsedAmperes++; - // } + // } else if (tTileEntity instanceof IEnergySink) { + // ForgeDirection tDirection = + // ForgeDirection.getOrientation(i).getOpposite(); + // if + // (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), + // tDirection)) { + // if + // (((IEnergySink)tTileEntity).demandedEnergyUnits() + // > 0 && + // ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, + // aVoltage) < aVoltage) rUsedAmperes++; + // } } else if (tTileEntity instanceof IEnergySink) { final ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(), tDirection)) { - if ((((IEnergySink) tTileEntity).getDemandedEnergy() > 0) && (((IEnergySink) tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage)) { + if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(), + tDirection)) { + if ((((IEnergySink) tTileEntity).getDemandedEnergy() > 0) + && (((IEnergySink) tTileEntity).injectEnergy(tDirection, aVoltage, + aVoltage) < aVoltage)) { rUsedAmperes++; } } @@ -223,15 +285,18 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements rUsedAmperes++; } else if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) > 0) { if (this.mRestRF == 0) { - final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); + final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, + false); rUsedAmperes++; this.mRestRF = rfOut - RFtrans; } else { - final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, (int) this.mRestRF, false); + final int RFtrans = ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, + (int) this.mRestRF, false); this.mRestRF = this.mRestRF - RFtrans; } } - if (GregTech_API.mRFExplosions && (((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < (rfOut * 600))) { + if (GregTech_API.mRFExplosions && (((IEnergyReceiver) tTileEntity) + .getMaxEnergyStored(tDirection) < (rfOut * 600))) { if (rfOut > ((32 * GregTech_API.mEUtoRF) / 100)) { this.doExplosion(rfOut); } @@ -242,24 +307,21 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements } } - this.mTransferredAmperage += rUsedAmperes; this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage); this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage); - - if ((aVoltage > this.mVoltage) || (this.mTransferredAmperage > this.mAmperage)){ - //GT 5.09 + if ((aVoltage > this.mVoltage) || (this.mTransferredAmperage > this.mAmperage)) { + // GT 5.09 if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - if(this.mOverheat>(this.mWireHeatingTicks * 100)){ + if (this.mOverheat > (this.mWireHeatingTicks * 100)) { this.getBaseMetaTileEntity().setToFire(); - } - else{ - this.mOverheat +=100; + } else { + this.mOverheat += 100; } return aAmperage; } - //GT 5.08 + // GT 5.08 else { this.getBaseMetaTileEntity().setToFire(); return aAmperage; @@ -273,7 +335,7 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { if (aBaseMetaTileEntity.isServerSide()) { this.mTransferredAmperage = 0; - if(this.mOverheat>0) { + if (this.mOverheat > 0) { this.mOverheat--; } @@ -283,7 +345,15 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements this.mConnections = 0; for (byte i = 0, j = 0; i < 6; i++) { j = GT_Utility.getOppositeSide(i); - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { + if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, + aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity) + || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, + aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity) + || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, + aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), + aBaseMetaTileEntity)) { final TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); if (tTileEntity instanceof IColoredTileEntity) { if (aBaseMetaTileEntity.getColorization() >= 0) { @@ -293,29 +363,47 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements } } } - if ((tTileEntity instanceof IEnergyConnected) && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) { + if ((tTileEntity instanceof IEnergyConnected) + && (((IEnergyConnected) tTileEntity).inputEnergyFrom(j) + || ((IEnergyConnected) tTileEntity).outputsEnergyTo(j))) { this.mConnections |= (1 << i); continue; } - if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable)) { - if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity))) { + if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity() instanceof IMetaTileEntityCable)) { + if (((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity)) + || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity)) + || ((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, + ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), + ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), + ((IGregTechTileEntity) tTileEntity))) { this.mConnections |= (1 << i); continue; } } - if ((tTileEntity instanceof IEnergySink) && ((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { + if ((tTileEntity instanceof IEnergySink) && ((IEnergySink) tTileEntity).acceptsEnergyFrom( + (TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { this.mConnections |= (1 << i); continue; } - if (GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver) && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) { + if (GregTech_API.mOutputRF && (tTileEntity instanceof IEnergyReceiver) + && ((IEnergyReceiver) tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))) { this.mConnections |= (1 << i); continue; } /* - if (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { - mConnections |= (1< mChargeHatches = new ArrayList(); + public ArrayList mDischargeHatches = new ArrayList(); - public GregtechMeta_MultiBlockBase(final int aID, final String aName, final String aNameRegional) { + public GregtechMeta_MultiBlockBase(final int aID, final String aName, + final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -39,34 +35,47 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult super(aName); } - public static boolean isValidMetaTileEntity(final MetaTileEntity aMetaTileEntity) { - return (aMetaTileEntity.getBaseMetaTileEntity() != null) && (aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity) && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); + public static boolean isValidMetaTileEntity( + final MetaTileEntity aMetaTileEntity) { + return (aMetaTileEntity.getBaseMetaTileEntity() != null) + && (aMetaTileEntity.getBaseMetaTileEntity() + .getMetaTileEntity() == aMetaTileEntity) + && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); } @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + public Object getServerGUI(final int aID, + final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_MultiMachine(aPlayerInventory, + aBaseMetaTileEntity); } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MultiblockDisplay.png"); + public Object getClientGUI(final int aID, + final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, + this.getLocalName(), "MultiblockDisplay.png"); } @Override public String[] getInfoData() { - return new String[]{"Progress:", (this.mProgresstime / 20) + "secs", (this.mMaxProgresstime / 20) + "secs", "Efficiency:", (this.mEfficiency / 100.0F) + "%", "Problems:", "" + (this.getIdealStatus() - this.getRepairStatus())}; + return new String[]{"Progress:", (this.mProgresstime / 20) + "secs", + (this.mMaxProgresstime / 20) + "secs", "Efficiency:", + (this.mEfficiency / 100.0F) + "%", "Problems:", + "" + (this.getIdealStatus() - this.getRepairStatus())}; } @Override public boolean isGivingInformation() { return true; } - + public int getAmountOfOutputs() { return 1; } - + @Override public boolean isCorrectMachinePart(ItemStack paramItemStack) { return true; @@ -76,73 +85,169 @@ public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_Mult public int getDamageToComponent(ItemStack paramItemStack) { return 0; } - - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {} - public void startProcess() {} + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + } - public int getValidOutputSlots(final IGregTechTileEntity machineCalling, final GT_Recipe sRecipes, final ItemStack[] sInputs){ - Utils.LOG_WARNING("Finding valid output slots for "+machineCalling.getInventoryName()); + public void startProcess() { + } + + public int getValidOutputSlots(final IGregTechTileEntity machineCalling, + final GT_Recipe sRecipes, final ItemStack[] sInputs) { + Utils.LOG_WARNING("Finding valid output slots for " + + machineCalling.getInventoryName()); final ArrayList tInputList = this.getStoredInputs(); - final GT_Recipe tRecipe = sRecipes; - final int outputItemCount = tRecipe.mOutputs.length; - int tValidOutputHatches = 0; - - for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { - if (!isValidMetaTileEntity(tHatch)) continue; - - int tEmptySlots = 0; - boolean foundRoom = false; - final IInventory tHatchInv = tHatch.getBaseMetaTileEntity(); - for(int i = 0; i < tHatchInv.getSizeInventory() && !foundRoom; ++i) - { - if(tHatchInv.getStackInSlot(i) != null) continue; - - tEmptySlots++; - if(tEmptySlots < outputItemCount) continue; - - tValidOutputHatches++; - foundRoom = true; - } - } - - return tValidOutputHatches; - } - - public GT_Recipe reduceRecipeTimeByPercentage(GT_Recipe tRecipe, float percentage){ + final GT_Recipe tRecipe = sRecipes; + final int outputItemCount = tRecipe.mOutputs.length; + int tValidOutputHatches = 0; + + for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { + if (!isValidMetaTileEntity(tHatch)) + continue; + + int tEmptySlots = 0; + boolean foundRoom = false; + final IInventory tHatchInv = tHatch.getBaseMetaTileEntity(); + for (int i = 0; i < tHatchInv.getSizeInventory() + && !foundRoom; ++i) { + if (tHatchInv.getStackInSlot(i) != null) + continue; + + tEmptySlots++; + if (tEmptySlots < outputItemCount) + continue; + + tValidOutputHatches++; + foundRoom = true; + } + } + + return tValidOutputHatches; + } + + public GT_Recipe reduceRecipeTimeByPercentage(GT_Recipe tRecipe, + float percentage) { int cloneTime = 0; GT_Recipe baseRecipe; GT_Recipe cloneRecipe = null; - + baseRecipe = tRecipe.copy(); - if (cloneRecipe != baseRecipe || cloneRecipe == null){ + if (cloneRecipe != baseRecipe || cloneRecipe == null) { cloneRecipe = baseRecipe.copy(); Utils.LOG_WARNING("Setting Recipe"); - } - if (cloneTime != baseRecipe.mDuration || cloneTime == 0){ + } + if (cloneTime != baseRecipe.mDuration || cloneTime == 0) { cloneTime = baseRecipe.mDuration; Utils.LOG_WARNING("Setting Time"); } - - if (cloneRecipe.mDuration > 0){ + + if (cloneRecipe.mDuration > 0) { int originalTime = cloneRecipe.mDuration; - int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration, (100-percentage)); + int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration, + (100 - percentage)); cloneRecipe.mDuration = tempTime; - if (cloneRecipe.mDuration < originalTime){ - Utils.LOG_INFO("Generated recipe with a smaller time. | "+originalTime+" | "+cloneRecipe.mDuration+" |"); + if (cloneRecipe.mDuration < originalTime) { + Utils.LOG_INFO("Generated recipe with a smaller time. | " + + originalTime + " | " + cloneRecipe.mDuration + " |"); return cloneRecipe; - } - else { - Utils.LOG_INFO("Did not generate recipe with a smaller time. | "+originalTime+" | "+cloneRecipe.mDuration+" |"); + } else { + Utils.LOG_INFO("Did not generate recipe with a smaller time. | " + + originalTime + " | " + cloneRecipe.mDuration + " |"); return tRecipe; } } Utils.LOG_INFO("Error generating recipe, returning null."); return null; - - - + + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, + long aTick) { + this.mChargeHatches.clear(); + this.mDischargeHatches.clear(); + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public void explodeMultiblock() { + MetaTileEntity tTileEntity; + for (Iterator localIterator = this.mChargeHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) + tTileEntity = (MetaTileEntity) localIterator.next(); + tTileEntity = null; + for (Iterator localIterator = this.mDischargeHatches + .iterator(); localIterator.hasNext(); tTileEntity + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) + tTileEntity = (MetaTileEntity) localIterator.next(); + super.explodeMultiblock(); } + public void updateSlots() { + for (GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) + if (isValidMetaTileEntity(tHatch)) + tHatch.updateSlots(); + for (GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) + if (isValidMetaTileEntity(tHatch)) + tHatch.updateSlots(); + super.updateSlots(); + } + + public boolean addToMachineList(IGregTechTileEntity aTileEntity, + int aBaseCasingIndex) { + if (aTileEntity == null) + return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) + return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity) + .updateTexture(aBaseCasingIndex); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) + return this.mChargeHatches.add( + (GT_MetaTileEntity_Hatch_InputBattery) aMetaTileEntity); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) + return this.mDischargeHatches.add( + (GT_MetaTileEntity_Hatch_OutputBattery) aMetaTileEntity); + return super.addToMachineList(aTileEntity, aBaseCasingIndex); + } + + public boolean addChargeableToMachineList(IGregTechTileEntity aTileEntity, + int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) + return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity) + .updateTexture(aBaseCasingIndex); + return this.mChargeHatches.add( + (GT_MetaTileEntity_Hatch_InputBattery) aMetaTileEntity); + } + return false; + } + + public boolean addDischargeableInputToMachineList( + IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) + return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity) + .updateTexture(aBaseCasingIndex); + return this.mDischargeHatches.add( + (GT_MetaTileEntity_Hatch_OutputBattery) aMetaTileEntity); + } + return false; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java index 5f95a28321..c6a4cc03c1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java @@ -1,5 +1,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; +import java.util.concurrent.TimeUnit; + import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; @@ -8,7 +10,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; import gtPlusPlus.core.block.ModBlocks; @@ -16,16 +17,21 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTileEntity_MultiBlockBase { +public class GregtechMetaTileEntity_PowerSubStationController extends GregtechMeta_MultiBlockBase { private static boolean controller; protected int mAverageEuUsage = 0; + protected long mTotalEnergyAdded = 0; + protected long mTotalEnergyConsumed = 0; + protected long mTotalEnergyLost = 0; + protected long mTotalRunTime = 0; public GregtechMetaTileEntity_PowerSubStationController(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); @@ -52,8 +58,8 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil "Hatches can be placed nearly anywhere", "Minimum 1x Energy Input Hatch", "Minimum 1x Energy Dynamo Hatch", - "1x Input Bus", - "1x Output Bus", + "1x Charge Bus", + "1x Discharge Bus", "1x Maintenance hatch", "--------------------------------------------------------------------------", CORE.GT_Tooltip}; @@ -317,13 +323,19 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil long mActualStoredEU = 0; - + //mTotalEnergyAdded @Override public void saveNBTData(NBTTagCompound aNBT) { aNBT.setLong("mPowerStorageBuffer", this.mPowerStorageBuffer); aNBT.setInteger("mPowerStorageMultiplier", this.mPowerStorageMultiplier); aNBT.setLong("mActualStoredEU", this.mActualStoredEU); aNBT.setInteger("mAverageEuUsage", this.mAverageEuUsage); + + //Usage Stats + aNBT.setLong("mTotalEnergyAdded", this.mTotalEnergyAdded); + aNBT.setLong("mTotalEnergyLost", this.mTotalEnergyLost); + aNBT.setLong("mTotalEnergyConsumed", this.mTotalEnergyConsumed); + aNBT.setLong("mTotalRunTime", this.mTotalRunTime); super.saveNBTData(aNBT); } @@ -333,6 +345,13 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil this.mPowerStorageMultiplier = aNBT.getInteger("mPowerStorageMultiplier"); this.mActualStoredEU = aNBT.getLong("mActualStoredEU"); this.mAverageEuUsage = aNBT.getInteger("mAverageEuUsage"); + + //Usage Stats + this.mTotalEnergyAdded = aNBT.getLong("mTotalEnergyAdded"); + this.mTotalEnergyLost = aNBT.getLong("mTotalEnergyLost"); + this.mTotalEnergyConsumed = aNBT.getLong("mTotalEnergyConsumed"); + this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); + super.loadNBTData(aNBT); } @@ -345,13 +364,19 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { this.mActualStoredEU = this.getEUVar(); + if (aBaseMetaTileEntity.isServerSide()){ + this.mTotalRunTime++; + } //Handle Progress Time if (this.mActualStoredEU >= 0 && this.getBaseMetaTileEntity().isAllowedToWork()){ this.mProgresstime = 20; this.mMaxProgresstime = 40; //Use 10% of average EU determined by adding in/output voltage of all hatches and averaging. - this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(MathUtils.roundToClosestInt(mAverageEuUsage/100), false); + int mDecrease = MathUtils.roundToClosestInt(mAverageEuUsage); + this.mTotalEnergyLost+=mDecrease; + this.setEUVar(this.getEUVar()-mDecrease); + //this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mDecrease, false); } else { this.mProgresstime = 0; @@ -371,6 +396,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil long voltage = energy.maxEUInput(); if (stored > 0){ energy.setEUVar((stored-voltage)); + this.mTotalEnergyAdded+=voltage; this.getBaseMetaTileEntity().increaseStoredEnergyUnits(voltage, false); } } @@ -425,6 +451,7 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil for (GT_MetaTileEntity_Hatch_Dynamo tHatch : this.mDynamoHatches) { if ((isValidMetaTileEntity(tHatch)) && (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(tHatch.getOutputTier()*2, false))) { this.setEUVar(this.getEUVar()-(tHatch.getOutputTier()*2)); + this.mTotalEnergyConsumed+=(tHatch.getOutputTier()*2); //this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(tHatch.getOutputTier()*2, false); //Utils.LOG_INFO("Hatch "+hatchCount+" has "+tHatch.getEUVar()+"eu stored. Avg used is "+(this.mAverageEuUsage)); } @@ -448,4 +475,42 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil return 0; } + //mAverageEuUsage + + @Override + public String[] getInfoData() { + + long seconds = (this.mTotalRunTime/20); + + int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); + int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); + long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); + long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); + + + + return new String[]{ + "Ergon Energy - District Sub-Station", + "EU Required: "+this.mAverageEuUsage+"EU/t", + "Stats for Nerds", + "Total Input: "+this.mTotalEnergyAdded+"EU", + "Total Output: "+this.mTotalEnergyConsumed+"EU", + "Total Wasted: "+this.mTotalEnergyLost+"EU", + + "Total Time Since Build: ", + ""+weeks+" Weeks.", + ""+days+" Days.", + ""+hours+" Hours.", + ""+minutes+" Minutes.", + ""+second+" Seconds.", + "Total Time in ticks: "+this.mTotalRunTime}; + + }; + + @Override + public boolean isGivingInformation() { + return true; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java index 82cbf685ad..5725ebe368 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechPowerSubStation.java @@ -1,8 +1,15 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.OreDictNames; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.util.GT_ModHandler; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_PowerSubStationController; public class GregtechPowerSubStation { @@ -21,6 +28,17 @@ public class GregtechPowerSubStation { // Steam Condensors GregtechItemList.PowerSubStation.set(new GregtechMetaTileEntity_PowerSubStationController(812, "substation.01.input.single", "Power Station Control Node").getStackForm(1L)); + int tID = 886; + GregtechItemList.Hatch_Input_Battery_MV.set(new GT_MetaTileEntity_Hatch_InputBattery(tID++, "hatch.input_battery.tier.00", "Charging Bus (MV)", 0).getStackForm(1L)); + GregtechItemList.Hatch_Input_Battery_EV.set(new GT_MetaTileEntity_Hatch_InputBattery(tID++, "hatch.input_battery.tier.01", "Charging Bus (EV)", 1).getStackForm(1L)); + GregtechItemList.Hatch_Output_Battery_MV.set(new GT_MetaTileEntity_Hatch_OutputBattery(tID++, "hatch.output_battery.tier.00", "Discharging Bus (MV)", 0).getStackForm(1L)); + GregtechItemList.Hatch_Output_Battery_EV.set(new GT_MetaTileEntity_Hatch_OutputBattery(tID++, "hatch.output_battery.tier.01", "Discharging Bus (EV)", 1).getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Input_Battery_MV.get(1L, new Object[0]), CI.bitsd, new Object[]{"C", "M", 'M', ItemList.Hull_MV, 'C', ItemList.Battery_Buffer_2by2_MV}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Input_Battery_EV.get(1L, new Object[0]), CI.bitsd, new Object[]{"C", "M", 'M', ItemList.Hull_EV, 'C', ItemList.Battery_Buffer_4by4_EV}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Output_Battery_MV.get(1L, new Object[0]), CI.bitsd, new Object[]{"M", "C", 'M', ItemList.Hull_MV, 'C', ItemList.Battery_Buffer_2by2_MV}); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Output_Battery_EV.get(1L, new Object[0]), CI.bitsd, new Object[]{"M", "C", 'M', ItemList.Hull_EV, 'C', ItemList.Battery_Buffer_4by4_EV}); + } } -- cgit From f480dbdd4b4750e966900f942a9dbad65202ec8b Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 15 Nov 2017 06:35:52 +1000 Subject: ^ Version bump. --- build.gradle | 2 +- src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- src/resources/mcmod.info | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/build.gradle b/build.gradle index 9b6f629e0a..244c177ce0 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ sourceCompatibility = 1.7 targetCompatibility = 1.7 archivesBaseName = "GT-PlusPlus" -version = "1.6.70-release" +version = "1.6.90-release" minecraft.version = "1.7.10-10.13.4.1448-1.7.10" diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 95c4c7e84a..e9cddfecb8 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -35,7 +35,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.6.70-release"; + public static final String VERSION = "1.6.90-release"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); diff --git a/src/resources/mcmod.info b/src/resources/mcmod.info index 04d58d5491..898bf3b265 100644 --- a/src/resources/mcmod.info +++ b/src/resources/mcmod.info @@ -5,7 +5,7 @@ "description": "Adds a few various Multiblocks, Machines, etc to Gregtech and a plethora of other mods (Nearly 30!)", "credits": "", "logoFile": "", - "version": "1.6.70-release", + "version": "1.6.90-release", "mcversion": "1.7.10", "url": "https://github.com/draknyte1/GTplusplus/wiki", "updateUrl": "https://github.com/draknyte1/GTplusplus/releases/latest", -- cgit From 94d89124d139f6484d3d2fba0773ab9791ed1ef9 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 15 Nov 2017 09:09:09 +1000 Subject: $ Fix crashes related to client side calls from the server side. - Removed RFTools additions. --- .../core/handler/COMPAT_IntermodStaging.java | 4 - .../gtPlusPlus/core/item/bauble/ModularBauble.java | 2 +- .../core/item/general/books/ItemBaseBook.java | 19 +- .../gtPlusPlus/xmod/rftools/HANDLER_RfTools.java | 26 -- .../blocks/Block_RFT_AdvancedWorldBuilder.java | 45 -- .../xmod/rftools/blocks/RFT_Block_Registrator.java | 31 -- .../tileentities/TE_RFT_AdvancedWorldBuilder.java | 514 --------------------- 7 files changed, 17 insertions(+), 624 deletions(-) delete mode 100644 src/Java/gtPlusPlus/xmod/rftools/HANDLER_RfTools.java delete mode 100644 src/Java/gtPlusPlus/xmod/rftools/blocks/Block_RFT_AdvancedWorldBuilder.java delete mode 100644 src/Java/gtPlusPlus/xmod/rftools/blocks/RFT_Block_Registrator.java delete mode 100644 src/Java/gtPlusPlus/xmod/rftools/tileentities/TE_RFT_AdvancedWorldBuilder.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index b833ab023a..fe46e2befa 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -7,7 +7,6 @@ import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.growthcraft.HANDLER_GC; import gtPlusPlus.xmod.ic2.HANDLER_IC2; import gtPlusPlus.xmod.mekanism.HANDLER_Mekanism; -import gtPlusPlus.xmod.rftools.HANDLER_RfTools; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; public class COMPAT_IntermodStaging { @@ -20,7 +19,6 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.preInit(); HANDLER_Computronics.preInit(); HANDLER_BiomesOPlenty.preInit(); - HANDLER_RfTools.preInit(); HANDLER_Mekanism.preInit(); } @@ -33,7 +31,6 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.init(); HANDLER_Computronics.init(); HANDLER_BiomesOPlenty.init(); - HANDLER_RfTools.init(); HANDLER_Mekanism.init(); } @@ -45,7 +42,6 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.postInit(); HANDLER_Computronics.postInit(); HANDLER_BiomesOPlenty.postInit(); - HANDLER_RfTools.postInit(); HANDLER_Mekanism.postInit(); } diff --git a/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java b/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java index 0e7df1703c..de12a77c27 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java @@ -36,7 +36,6 @@ public class ModularBauble extends BaseBauble { private IIcon mTextureRing; @SideOnly(Side.CLIENT) private IIcon mTextureBelt; - @SideOnly(Side.CLIENT) private IIcon iconArray[] = new IIcon[3]; @SideOnly(Side.CLIENT) private IIcon mfallback; @@ -342,6 +341,7 @@ public class ModularBauble extends BaseBauble { }*/ @Override + @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int meta) { if (meta < this.iconArray.length && this.iconArray[meta] != null){ return this.iconArray[meta]; diff --git a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java index 8c4a262c32..fe0405d175 100644 --- a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java +++ b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java @@ -2,18 +2,21 @@ package gtPlusPlus.core.item.general.books; import static gtPlusPlus.core.handler.BookHandler.mBookMap; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.nbt.NBTUtils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreenBook; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -96,6 +99,7 @@ public class ItemBaseBook extends ItemWritableBook{ } @Override + @SideOnly(Side.CLIENT) public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { //player.displayGUIBook(item); int i = item.getItemDamage(); @@ -106,7 +110,16 @@ public class ItemBaseBook extends ItemWritableBook{ mBookMap.get(i).mPages); if (player.worldObj.isRemote){ - Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, bookstack, false)); + try { + Class clazz = Class.forName("net.minecraft.client.gui.GuiScreenBook"); + Constructor ctor = clazz.getConstructor(EntityPlayer.class, ItemStack.class, boolean.class); + Object object = ctor.newInstance(new Object[] { player, bookstack, false }); + Minecraft.getMinecraft().displayGuiScreen((GuiScreen) object); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, bookstack, false)); } return item; } diff --git a/src/Java/gtPlusPlus/xmod/rftools/HANDLER_RfTools.java b/src/Java/gtPlusPlus/xmod/rftools/HANDLER_RfTools.java deleted file mode 100644 index f44a6fece6..0000000000 --- a/src/Java/gtPlusPlus/xmod/rftools/HANDLER_RfTools.java +++ /dev/null @@ -1,26 +0,0 @@ -package gtPlusPlus.xmod.rftools; - -import gtPlusPlus.core.lib.LoadedMods; - -public class HANDLER_RfTools { - - public static void preInit(){ - if (LoadedMods.RFTools){ - //RFT_Block_Registrator.run(); - } - } - - public static void init(){ - if (LoadedMods.RFTools){ - - } - } - - public static void postInit(){ - if (LoadedMods.RFTools){ - - } - } - - -} diff --git a/src/Java/gtPlusPlus/xmod/rftools/blocks/Block_RFT_AdvancedWorldBuilder.java b/src/Java/gtPlusPlus/xmod/rftools/blocks/Block_RFT_AdvancedWorldBuilder.java deleted file mode 100644 index b4e606d790..0000000000 --- a/src/Java/gtPlusPlus/xmod/rftools/blocks/Block_RFT_AdvancedWorldBuilder.java +++ /dev/null @@ -1,45 +0,0 @@ -package gtPlusPlus.xmod.rftools.blocks; - -import java.util.List; - -import org.lwjgl.input.Keyboard; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.core.creative.AddToCreativeTab; -import mcjty.rftools.blocks.dimlets.DimensionBuilderBlock; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - -public class Block_RFT_AdvancedWorldBuilder extends DimensionBuilderBlock{ - - public Block_RFT_AdvancedWorldBuilder(boolean creative, String blockName) { - super(creative, blockName); - this.setCreativeTab(AddToCreativeTab.tabMachines); - } - - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) { - //super.addInformation(itemStack, player, list, whatIsThis); - - if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) { - list.add(EnumChatFormatting.WHITE + "This builds a dimension and powers it when"); - list.add(EnumChatFormatting.WHITE + "the dimension is ready."); - list.add(EnumChatFormatting.WHITE + "Use a dialing device to connect this to"); - list.add(EnumChatFormatting.WHITE + "your new dimension and then teleport."); - list.add(EnumChatFormatting.YELLOW + "Infusing bonus: reduced power consumption and"); - list.add(EnumChatFormatting.YELLOW + "faster dimension creation speed."); - } else { - list.add(EnumChatFormatting.WHITE + ""); - } - } - - /*@Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return null; - }*/ - -} diff --git a/src/Java/gtPlusPlus/xmod/rftools/blocks/RFT_Block_Registrator.java b/src/Java/gtPlusPlus/xmod/rftools/blocks/RFT_Block_Registrator.java deleted file mode 100644 index ec318954fd..0000000000 --- a/src/Java/gtPlusPlus/xmod/rftools/blocks/RFT_Block_Registrator.java +++ /dev/null @@ -1,31 +0,0 @@ -package gtPlusPlus.xmod.rftools.blocks; - -import cpw.mods.fml.common.registry.GameRegistry; -import mcjty.lib.container.GenericItemBlock; -import mcjty.rftools.blocks.dimlets.DimensionBuilderBlock; -import mcjty.rftools.blocks.dimlets.DimensionBuilderTileEntity; -import mcjty.rftools.blocks.teleporter.MatterTransmitterBlock; -import mcjty.rftools.blocks.teleporter.MatterTransmitterTileEntity; - -public class RFT_Block_Registrator { - - public static DimensionBuilderBlock dimensionBuilderBlockAdvanced; - public static DimensionBuilderBlock creativeDimensionBuilderBlockAdvanced; - public static MatterTransmitterBlock matterTransmitterBlockA; - - public static void run(){ - - matterTransmitterBlockA = new MatterTransmitterBlock(); - GameRegistry.registerBlock(matterTransmitterBlockA, GenericItemBlock.class, "matterTransmitterBlockA"); - GameRegistry.registerTileEntity(MatterTransmitterTileEntity.class, "MatterTransmitterTileEntityA"); - - dimensionBuilderBlockAdvanced = new DimensionBuilderBlock(false, "dimensionBuilderBlockAdvanced"); - GameRegistry.registerBlock(dimensionBuilderBlockAdvanced, GenericItemBlock.class, "dimensionBuilderBlockAdvanced"); - GameRegistry.registerTileEntity(DimensionBuilderTileEntity.class, "dimensionBuilderBlockAdvanced"); - - creativeDimensionBuilderBlockAdvanced = new DimensionBuilderBlock(true, "creativeDimensionBuilderBlockAdvanced"); - GameRegistry.registerBlock(creativeDimensionBuilderBlockAdvanced, GenericItemBlock.class, - "creativeDimensionBuilderBlockAdvanced"); - } - -} diff --git a/src/Java/gtPlusPlus/xmod/rftools/tileentities/TE_RFT_AdvancedWorldBuilder.java b/src/Java/gtPlusPlus/xmod/rftools/tileentities/TE_RFT_AdvancedWorldBuilder.java deleted file mode 100644 index 7b44a8d776..0000000000 --- a/src/Java/gtPlusPlus/xmod/rftools/tileentities/TE_RFT_AdvancedWorldBuilder.java +++ /dev/null @@ -1,514 +0,0 @@ -/*package gtPlusPlus.xmod.rftools.tileentities; - -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; -import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import java.util.Map; -import java.util.Random; -import mcjty.lib.container.ContainerFactory; -import mcjty.lib.container.InventoryHelper; -import mcjty.lib.entity.GenericEnergyReceiverTileEntity; -import mcjty.lib.network.Argument; -import mcjty.lib.network.PacketRequestIntegerFromServer; -import mcjty.lib.varia.BlockTools; -import mcjty.lib.varia.Logging; -import mcjty.rftools.blocks.RedstoneMode; -import mcjty.rftools.blocks.dimlets.DimensionBuilderContainer; -import mcjty.rftools.blocks.dimlets.DimletConfiguration; -import mcjty.rftools.blocks.dimlets.DimletSetup; -import mcjty.rftools.dimension.DimensionStorage; -import mcjty.rftools.dimension.RfToolsDimensionManager; -import mcjty.rftools.dimension.description.DimensionDescriptor; -import mcjty.rftools.network.RFToolsMessages; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -public class TE_RFT_AdvancedWorldBuilder extends GenericEnergyReceiverTileEntity - implements ISidedInventory { - public static final String CMD_GETBUILDING = "getBuilding"; - public static final String CLIENTCMD_GETBUILDING = "getBuilding"; - public static final String CMD_RSMODE = "rsMode"; - public static final String COMPONENT_NAME = "dimension_builder"; - private static int buildPercentage = 0; - - private int creative = -1; - private RedstoneMode redstoneMode = RedstoneMode.REDSTONE_IGNORED; - private int powered = 0; - - public static int OK = 0; - public static int ERROR_NOOWNER = -1; - public static int ERROR_TOOMANYDIMENSIONS = -2; - private int errorMode = 0; - - private InventoryHelper inventoryHelper = new InventoryHelper(???, DimensionBuilderContainer.factory, 1); - - private static int counter = 20; - - private static Random random = new Random(); - - public TE_RFT_AdvancedWorldBuilder() { - super(DimletConfiguration.BUILDER_MAXENERGY, DimletConfiguration.BUILDER_RECEIVEPERTICK); - } - - private boolean isCreative() { - if (this.creative == -1) { - Block block = this.field_145850_b.func_147439_a(this.field_145851_c, this.field_145848_d, - this.field_145849_e); - if (DimletSetup.creativeDimensionBuilderBlock.equals(block)) - this.creative = 1; - else { - this.creative = 0; - } - } - return (this.creative == 1); - } - - protected void checkStateServer() { - NBTTagCompound tagCompound = hasTab(); - if (tagCompound == null) { - setState(-1); - return; - } - - if (this.redstoneMode != RedstoneMode.REDSTONE_IGNORED) { - boolean rs = this.powered > 0; - if (this.redstoneMode == RedstoneMode.REDSTONE_OFFREQUIRED) { - if (rs) { - setState(-1); - return; - } - } else if ((this.redstoneMode == RedstoneMode.REDSTONE_ONREQUIRED) && (!(rs))) { - setState(-1); - return; - } - - } - - int ticksLeft = tagCompound.getInteger("ticksLeft"); - if (ticksLeft > 0) - ticksLeft = createDimensionTick(tagCompound, ticksLeft); - else { - maintainDimensionTick(tagCompound); - } - - setState(ticksLeft); - } - - public void setPowered(int powered) { - if (this.powered != powered) { - this.powered = powered; - markDirty(); - } - } - - private Object[] getBuildingPercentage() { - NBTTagCompound tagCompound = hasTab(); - if (tagCompound != null) { - int ticksLeft = tagCompound.getInteger("ticksLeft"); - int tickCost = tagCompound.getInteger("tickCost"); - int pct = (tickCost - ticksLeft) * 100 / tickCost; - return new Object[] { Integer.valueOf(pct) }; - } - return new Object[] { Integer.valueOf(0) }; - } - - private Object[] getDimensionPower() { - NBTTagCompound tagCompound = hasTab(); - if (tagCompound != null) { - int id = tagCompound.getInteger("id"); - int power = 0; - if (id != 0) { - DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(this.field_145850_b); - power = dimensionStorage.getEnergyLevel(id); - } - return new Object[] { Integer.valueOf(power) }; - } - return new Object[] { Integer.valueOf(0) }; - } - - private Object[] setRedstoneMode(String mode) { - RedstoneMode redstoneMode = RedstoneMode.getMode(mode); - if (redstoneMode == null) { - throw new IllegalArgumentException("Not a valid mode"); - } - setRedstoneMode(redstoneMode); - return null; - } - - public RedstoneMode getRedstoneMode() { - return this.redstoneMode; - } - - public void setRedstoneMode(RedstoneMode redstoneMode) { - this.redstoneMode = redstoneMode; - this.field_145850_b.func_147471_g(this.field_145851_c, this.field_145848_d, this.field_145849_e); - markDirty(); - } - - private NBTTagCompound hasTab() { - ItemStack itemStack = this.inventoryHelper.getStackInSlot(0); - if ((itemStack == null) || (itemStack.stackSize == 0)) { - return null; - } - - NBTTagCompound tagCompound = itemStack.getTagCompound(); - return tagCompound; - } - - private void maintainDimensionTick(NBTTagCompound tagCompound) { - int id = tagCompound.getInteger("id"); - - if (id != 0) { - DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(this.field_145850_b); - int rf; - int rf; - if (isCreative()) - rf = DimletConfiguration.BUILDER_MAXENERGY; - else { - rf = getEnergyStored(ForgeDirection.DOWN); - } - int energy = dimensionStorage.getEnergyLevel(id); - int maxEnergy = DimletConfiguration.MAX_DIMENSION_POWER - energy; - if (rf > maxEnergy) { - rf = maxEnergy; - } - counter -= 1; - if (counter < 0) { - counter = 20; - if (Logging.debugMode) { - Logging.log("#################### id:" + id + ", rf:" + rf + ", energy:" + energy + ", max:" - + maxEnergy); - } - } - if (!(isCreative())) { - consumeEnergy(rf); - } - dimensionStorage.setEnergyLevel(id, energy + rf); - dimensionStorage.save(this.field_145850_b); - } - } - - private int createDimensionTick(NBTTagCompound tagCompound, int ticksLeft) { - if (DimletConfiguration.dimensionBuilderNeedsOwner) { - if (getOwnerUUID() == null) { - this.errorMode = ERROR_NOOWNER; - return ticksLeft; - } - if (DimletConfiguration.maxDimensionsPerPlayer >= 0) { - int tickCost = tagCompound.getInteger("tickCost"); - if ((ticksLeft == tickCost) || (ticksLeft < 5)) { - RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(this.field_145850_b); - int cnt = manager.countOwnedDimensions(getOwnerUUID()); - if (cnt >= DimletConfiguration.maxDimensionsPerPlayer) { - this.errorMode = ERROR_TOOMANYDIMENSIONS; - return ticksLeft; - } - } - } - } - this.errorMode = OK; - - int createCost = tagCompound.getInteger("rfCreateCost"); - createCost = (int) (createCost * (2.0F - getInfusedFactor()) / 2.0F); - - if ((isCreative()) || (getEnergyStored(ForgeDirection.DOWN) >= createCost)) { - if (isCreative()) { - ticksLeft = 0; - } else { - consumeEnergy(createCost); - --ticksLeft; - if (random.nextFloat() < getInfusedFactor()) { - --ticksLeft; - if (ticksLeft < 0) { - ticksLeft = 0; - } - } - } - tagCompound.setInteger("ticksLeft", ticksLeft); - if (ticksLeft <= 0) { - RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(this.field_145850_b); - DimensionDescriptor descriptor = new DimensionDescriptor(tagCompound); - String name = tagCompound.getString("name"); - int id = manager.createNewDimension(this.field_145850_b, descriptor, name, getOwnerName(), - getOwnerUUID()); - tagCompound.setInteger("id", id); - } - } - return ticksLeft; - } - - private void setState(int ticksLeft) { - int state = 0; - if (ticksLeft == 0) - state = 0; - else if (ticksLeft == -1) - state = 1; - else if ((ticksLeft >> 2 & 0x1) == 0) - state = 2; - else { - state = 3; - } - int metadata = this.field_145850_b.func_72805_g(this.field_145851_c, this.field_145848_d, this.field_145849_e); - int newmeta = BlockTools.setState(metadata, state); - if (newmeta != metadata) - this.field_145850_b.func_72921_c(this.field_145851_c, this.field_145848_d, this.field_145849_e, newmeta, 2); - } - - public int[] func_94128_d(int side) { - return DimensionBuilderContainer.factory.getAccessibleSlots(); - } - - public boolean func_102007_a(int index, ItemStack item, int side) { - return DimensionBuilderContainer.factory.isInputSlot(index); - } - - public boolean func_102008_b(int index, ItemStack item, int side) { - return DimensionBuilderContainer.factory.isOutputSlot(index); - } - - public int func_70302_i_() { - return this.inventoryHelper.getCount(); - } - - public ItemStack func_70301_a(int index) { - return this.inventoryHelper.getStackInSlot(index); - } - - public ItemStack func_70298_a(int index, int amount) { - return this.inventoryHelper.decrStackSize(index, amount); - } - - public ItemStack func_70304_b(int index) { - return null; - } - - public void func_70299_a(int index, ItemStack stack) { - this.inventoryHelper.setInventorySlotContents(func_70297_j_(), index, stack); - } - - public String func_145825_b() { - return "Builder Inventory"; - } - - public boolean func_145818_k_() { - return false; - } - - public int func_70297_j_() { - return 1; - } - - public boolean func_70300_a(EntityPlayer player) { - return canPlayerAccess(player); - } - - public void func_70295_k_() { - } - - public void func_70305_f() { - } - - public boolean func_94041_b(int index, ItemStack stack) { - return true; - } - - public void requestBuildingPercentage() { - RFToolsMessages.INSTANCE.sendToServer(new PacketRequestIntegerFromServer(this.field_145851_c, - this.field_145848_d, this.field_145849_e, "getBuilding", "getBuilding", new Argument[0])); - } - - public Integer executeWithResultInteger(String command, Map args) { - Integer rc = super.executeWithResultInteger(command, args); - if (rc != null) { - return rc; - } - if ("getBuilding".equals(command)) { - ItemStack itemStack = this.inventoryHelper.getStackInSlot(0); - if ((itemStack == null) || (itemStack.stackSize == 0)) { - return Integer.valueOf(0); - } - NBTTagCompound tagCompound = itemStack.getTagCompound(); - if (tagCompound == null) { - return Integer.valueOf(0); - } - if (this.errorMode != OK) { - return Integer.valueOf(this.errorMode); - } - int ticksLeft = tagCompound.getInteger("ticksLeft"); - int tickCost = tagCompound.getInteger("tickCost"); - return Integer.valueOf((tickCost - ticksLeft) * 100 / tickCost); - } - - return null; - } - - public boolean execute(String command, Integer result) { - boolean rc = super.execute(command, result); - if (rc) { - return true; - } - if ("getBuilding".equals(command)) { - buildPercentage = result.intValue(); - return true; - } - return false; - } - - public boolean execute(EntityPlayerMP playerMP, String command, Map args) { - boolean rc = super.execute(playerMP, command, args); - if (rc) { - return true; - } - if ("rsMode".equals(command)) { - String m = ((Argument) args.get("rs")).getString(); - setRedstoneMode(RedstoneMode.getMode(m)); - return true; - } - return false; - } - - public static int getBuildPercentage() { - return buildPercentage; - } - - public void func_145839_a(NBTTagCompound tagCompound) { - super.func_145839_a(tagCompound); - this.powered = tagCompound.getByte("powered"); - } - - public void readRestorableFromNBT(NBTTagCompound tagCompound) { - super.readRestorableFromNBT(tagCompound); - readBufferFromNBT(tagCompound); - int m = tagCompound.getByte("rsMode"); - this.redstoneMode = RedstoneMode.values()[m]; - } - - private void readBufferFromNBT(NBTTagCompound tagCompound) { - NBTTagList bufferTagList = tagCompound.getTagList("Items", 10); - for (int i = 0; i < bufferTagList.tagCount(); ++i) { - NBTTagCompound nbtTagCompound = bufferTagList.getCompoundTagAt(i); - this.inventoryHelper.setStackInSlot(i, ItemStack.loadItemStackFromNBT(nbtTagCompound)); - } - } - - public void func_145841_b(NBTTagCompound tagCompound) { - super.func_145841_b(tagCompound); - tagCompound.setByte("powered", (byte) this.powered); - } - - public void writeRestorableToNBT(NBTTagCompound tagCompound) { - super.writeRestorableToNBT(tagCompound); - writeBufferToNBT(tagCompound); - tagCompound.setByte("rsMode", (byte) this.redstoneMode.ordinal()); - } - - private void writeBufferToNBT(NBTTagCompound tagCompound) { - NBTTagList bufferTagList = new NBTTagList(); - for (int i = 0; i < this.inventoryHelper.getCount(); ++i) { - ItemStack stack = this.inventoryHelper.getStackInSlot(i); - NBTTagCompound nbtTagCompound = new NBTTagCompound(); - if (stack != null) { - stack.writeToNBT(nbtTagCompound); - } - bufferTagList.appendTag(nbtTagCompound); - } - tagCompound.setTag("Items", bufferTagList); - } - - @Override - public int getSizeInventory() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public ItemStack getStackInSlot(int p_70301_1_) { - // TODO Auto-generated method stub - return null; - } - - @Override - public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { - // TODO Auto-generated method stub - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - // TODO Auto-generated method stub - - } - - @Override - public String getInventoryName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean hasCustomInventoryName() { - // TODO Auto-generated method stub - return false; - } - - @Override - public int getInventoryStackLimit() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void openInventory() { - // TODO Auto-generated method stub - - } - - @Override - public void closeInventory() { - // TODO Auto-generated method stub - - } - - @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - // TODO Auto-generated method stub - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { - // TODO Auto-generated method stub - return false; - } -}*/ \ No newline at end of file -- cgit From 2cbc0ee9f27bc1d2a21d44d1b4a0c248a315c316 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 15 Nov 2017 10:26:36 +1000 Subject: + Added Wireless Chargers. > These are a basic design-only implementation for reference, so they may never be completed and are more of a proof of concept. --- build.gradle | 2 +- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 1 + src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- .../xmod/gregtech/api/enums/GregtechItemList.java | 7 +- .../basic/GregtechMetaWirelessCharger.java | 455 +++++++++++++++++++++ .../gregtech/GregtechWirelessChargers.java | 41 ++ src/resources/mcmod.info | 2 +- 7 files changed, 506 insertions(+), 4 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/build.gradle b/build.gradle index 244c177ce0..efbc8c0232 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ sourceCompatibility = 1.7 targetCompatibility = 1.7 archivesBaseName = "GT-PlusPlus" -version = "1.6.90-release" +version = "1.6.91-release" minecraft.version = "1.7.10-10.13.4.1448-1.7.10" diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 788d011733..23b2ad8e1a 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -97,6 +97,7 @@ public class COMPAT_HANDLER { GregtechIndustrialWashPlant.run(); GregtechSemiFluidgenerators.run(); GregtechAdvancedMixer.run(); + GregtechWirelessChargers.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index e9cddfecb8..71119ee00e 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -35,7 +35,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.6.90-release"; + public static final String VERSION = "1.6.91-release"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index e4da291b17..6a797d9ce0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -255,7 +255,12 @@ public enum GregtechItemList implements GregtechItemContainer { //Custom hatches Hatch_Input_Battery_MV, Hatch_Input_Battery_EV, - Hatch_Output_Battery_MV, Hatch_Output_Battery_EV, + Hatch_Output_Battery_MV, Hatch_Output_Battery_EV, + + //Wireless Chargers + Charger_LV, Charger_MV, Charger_HV, + Charger_EV, Charger_IV, Charger_LuV, + Charger_ZPM, Charger_UV, Charger_MAX, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java new file mode 100644 index 0000000000..7239dc41ac --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -0,0 +1,455 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import gregtech.api.enums.GT_Values; +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.array.BlockPos; +import gtPlusPlus.core.util.entity.EntityUtils; +import gtPlusPlus.core.util.player.PlayerUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { + + public GregtechMetaWirelessCharger(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaWirelessCharger(final String aName, final int aTier, final String aDescription, final ITexture[][][] aTextures, final int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {this.mDescription, + "3 Modes, Long-Range, Local and Mixed.", + "Long-Range: Can supply 2A of power to a single player upto "+(this.mTier*4)+"m away.", + "Local: Can supply 1A to each player within 50m.", + "Mixed: Provides both 2A of long range and 1A per player locally.", + "Mixed mode is more conservative of power and as a result only", + "gets half the distances each singular mode gets.", + CORE.GT_Tooltip}; + } + + @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_Machine_Screen_2)}; + } + + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_2)}; + } + + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier+3][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mMode >= 2){ + this.mMode = 0; + } + else { + this.mMode++; + } + if (this.mMode == 0){ + PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Mode."); + } + else if (this.mMode == 1){ + PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Now in Mixed Mode."); + } + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaWirelessCharger(this.mName, this.mTier, this.mDescription, this.mTextures, this.mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(final int aIndex) {return true;} + @Override public boolean isFacingValid(final byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @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 GT_Values.V[this.mTier]*32;} + + @Override + public int getCapacity() { + return (int) (GT_Values.V[this.mTier]*32); + } + + @Override + public long maxEUInput() { + return GT_Values.V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxAmperesIn() { + if (this.mMode == 0){ + return 2; + } + else if (this.mMode == 1){ + return this.mLocalChargingMap.size(); + } + else { + return (this.mLocalChargingMap.size()+this.mWirelessChargingMap.size()); + } + } + + @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; + } + return true; + } + + public int mMode = 0; + + @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 null; + } + + @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 false; + } + + @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) { + aNBT.setInteger("mMode", this.mMode); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + this.mMode = aNBT.getInteger("mMode"); + } + + @Override + public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { + if (this.getBaseMetaTileEntity().isServerSide()) { + + } + } + + + private Map mWirelessChargingMap = new HashMap(); + private Map mLocalChargingMap = new HashMap(); + + @Override + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.getBaseMetaTileEntity().isServerSide()) { + + + if (aTick % 20 == 0){ + if (!aBaseMetaTileEntity.getWorld().playerEntities.isEmpty()){ + for (Object mTempPlayer : aBaseMetaTileEntity.getWorld().playerEntities){ + if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){ + EntityPlayer mTemp = (EntityPlayer) mTempPlayer; + + if (this.mMode == 1 || this.mMode == 2){ + int tempRange = (this.mMode == 1 ? 50 : 25); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ + if (!mLocalChargingMap.containsKey(mTemp.getPersistentID())){ + if (mLocalChargingMap.put(mTemp.getPersistentID(), mTemp) != null){ + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); + } + } + + } + else { + if (mLocalChargingMap.containsKey(mTemp.getPersistentID())){ + if (mLocalChargingMap.remove(mTemp.getPersistentID()) != null){ + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + } + } + } + } + if (this.mMode == 0 || this.mMode == 2){ + int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); + if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ + if (!mWirelessChargingMap.containsKey(mTemp)){ + if (mWirelessChargingMap.put(mTemp, mTemp.getPersistentID()) != null){ + PlayerUtils.messagePlayer(mTemp, "You have entered charging range. ["+tempRange+"m]."); + } + } + + } + else { + if (mWirelessChargingMap.containsKey(mTemp)){ + if (mWirelessChargingMap.remove(mTemp) != null){ + PlayerUtils.messagePlayer(mTemp, "You have left charging range. ["+tempRange+"m]."); + } + } + } + } + + } + } + } + } + + + } + } + + private BlockPos getTileEntityPosition(){ + return new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); + } + + private BlockPos getPositionOfEntity(Entity mEntity){ + if (mEntity == null){ + return null; + } + return EntityUtils.findBlockPosUnderEntity(mEntity); + } + + private double getDistanceBetweenTwoPositions(BlockPos objectA, BlockPos objectB){ + int[] objectArray1 = new int[]{objectA.xPos, objectA.yPos, objectA.zPos}; + int[] objectArray2 = new int[]{objectB.xPos, objectB.yPos, objectB.zPos}; + if (objectA == null || objectB == null){ + return 0f; + } + final double distance = Math.sqrt( + (objectArray2[0]-objectArray1[0])*(objectArray2[0]-objectArray1[0]) + +(objectArray2[1]-objectArray1[1])*(objectArray2[1]-objectArray1[1]) + +(objectArray2[2]-objectArray1[2])*(objectArray2[2]-objectArray1[2])); + return distance; + } + + @Override + public void onRemoval() { + mWirelessChargingMap.clear(); + super.onRemoval(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, + EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + + int tempRange; + + if (this.mMode == 0 || this.mMode == 2){ + tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); + } + else { + tempRange = 50; + } + + if (this.mMode == 2){ + PlayerUtils.messagePlayer(aPlayer, "Mixed Mode | Local: 25m | Long: "+tempRange); + } + else if (this.mMode == 1){ + PlayerUtils.messagePlayer(aPlayer, "Local Mode: 50m"); + + } + else { + PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m"); + + } + + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public void onServerStart() { + mWirelessChargingMap.clear(); + super.onServerStart(); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java new file mode 100644 index 0000000000..f23dc3ab3d --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java @@ -0,0 +1,41 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; +import net.minecraft.item.ItemStack; + +public class GregtechWirelessChargers { + + + public static void run(){ + + long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; + int mID = 890; + + GregtechItemList.Charger_LV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.01.tier.single", + "Wireless Charger MK I", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_MV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.02.tier.single", + "Wireless Charger MK II", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_HV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.03.tier.single", + "Wireless Charger MK III", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_EV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.04.tier.single", + "Wireless Charger MK IV", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_IV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.05.tier.single", + "Wireless Charger MK V", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_LuV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.06.tier.single", + "Wireless Charger MK VI", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_ZPM.set(new GregtechMetaWirelessCharger(mID++, "wificharger.07.tier.single", + "Wireless Charger MK VII", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_UV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.08.tier.single", + "Wireless Charger MK VIII", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_MAX.set(new GregtechMetaWirelessCharger(mID++, "wificharger.09.tier.single", + "Wireless Charger MK IX", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + + } + +} diff --git a/src/resources/mcmod.info b/src/resources/mcmod.info index 898bf3b265..68f69d5530 100644 --- a/src/resources/mcmod.info +++ b/src/resources/mcmod.info @@ -5,7 +5,7 @@ "description": "Adds a few various Multiblocks, Machines, etc to Gregtech and a plethora of other mods (Nearly 30!)", "credits": "", "logoFile": "", - "version": "1.6.90-release", + "version": "1.6.91-release", "mcversion": "1.7.10", "url": "https://github.com/draknyte1/GTplusplus/wiki", "updateUrl": "https://github.com/draknyte1/GTplusplus/releases/latest", -- cgit From af9369d63b91b26515a45f7a3419c98e4d6f8f05 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 16 Nov 2017 17:50:23 +1000 Subject: + Added recipes for Wireless Chargers. $ Fixed exploit using Long-Range mode, temporarily disabled. --- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 47 ++++++++++++++++++ .../gregtech/common/helpers/ChargingHelper.java | 56 +++++++++++----------- .../basic/GregtechMetaWirelessCharger.java | 9 ++-- 3 files changed, 80 insertions(+), 32 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 124e109f25..a8a4e5ad13 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -1053,6 +1053,53 @@ public class RECIPES_Machines { "plateStainlessSteel",CI.emitter_ULV,"plateStainlessSteel", ItemUtils.getSimpleStack(ModBlocks.blockProjectTable)); } + + //Wireless Chargers + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_LV, CI.circuitTier1, CI.emitter_LV, + CI.component_Plate[3], CI.machineHull_LV, CI.component_Plate[3], + CI.sensor_LV, CI.fieldGenerator_LV, CI.sensor_LV, + GregtechItemList.Charger_LV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_MV, CI.circuitTier2, CI.emitter_MV, + CI.component_Plate[4], CI.machineHull_MV, CI.component_Plate[4], + CI.sensor_MV, CI.fieldGenerator_MV, CI.sensor_MV, + GregtechItemList.Charger_MV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_HV, CI.circuitTier3, CI.emitter_HV, + CI.component_Plate[5], CI.machineHull_HV, CI.component_Plate[5], + CI.sensor_HV, CI.fieldGenerator_HV, CI.sensor_HV, + GregtechItemList.Charger_HV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_EV, CI.circuitTier4, CI.emitter_EV, + CI.component_Plate[6], CI.machineHull_EV, CI.component_Plate[6], + CI.sensor_EV, CI.fieldGenerator_EV, CI.sensor_EV, + GregtechItemList.Charger_EV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_IV, CI.circuitTier5, CI.emitter_IV, + CI.component_Plate[7], CI.machineHull_IV, CI.component_Plate[7], + CI.sensor_IV, CI.fieldGenerator_IV, CI.sensor_IV, + GregtechItemList.Charger_IV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_LuV, CI.circuitTier6, CI.emitter_LuV, + CI.component_Plate[8], CI.machineHull_LuV, CI.component_Plate[8], + CI.sensor_LuV, CI.fieldGenerator_LuV, CI.sensor_LuV, + GregtechItemList.Charger_LuV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_ZPM, CI.circuitTier7, CI.emitter_ZPM, + CI.component_Plate[9], CI.machineHull_ZPM, CI.component_Plate[9], + CI.sensor_ZPM, CI.fieldGenerator_ZPM, CI.sensor_ZPM, + GregtechItemList.Charger_ZPM.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_UV, CI.circuitTier8, CI.emitter_UV, + CI.component_Plate[10], CI.machineHull_UV, CI.component_Plate[10], + CI.sensor_UV, CI.fieldGenerator_UV, CI.sensor_UV, + GregtechItemList.Charger_UV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_MAX, CI.circuitTier9, CI.emitter_MAX, + CI.component_Plate[11], CI.machineHull_MAX, CI.component_Plate[11], + CI.sensor_MAX, CI.fieldGenerator_MAX, CI.sensor_MAX, + GregtechItemList.Charger_MAX.get(1)); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 4a59a621f7..6ff0536c85 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -42,10 +42,10 @@ public class ChargingHelper { if (mPlayerMan != null){ - //Utils.LOG_INFO("Found Player."); + //Utils.LOG_WARNING("Found Player."); if (Utils.isServer()){ - //Utils.LOG_INFO("Found Server-Side."); + //Utils.LOG_WARNING("Found Server-Side."); mTickTimer++; if (mTickTimer % mTickMultiplier == 0){ @@ -73,10 +73,10 @@ public class ChargingHelper { long mEuUsed = 0; if (mEntityTemp.getMode() == 0){ - if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + /*if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } + }*/ } else if (mEntityTemp.getMode() == 1){ if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ @@ -85,10 +85,10 @@ public class ChargingHelper { } } else { - if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ + /*if (!LR.isEmpty() && LR.containsKey(mPlayerMan)){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); - } + }*/ if (!LO.isEmpty() && LO.containsValue(mPlayerMan)){ mCurrentEu = chargeItems(mEntityTemp, mArmourContents, mPlayerMan); mCurrentEu = chargeItems(mEntityTemp, mInventoryContents, mPlayerMan); @@ -130,7 +130,7 @@ public class ChargingHelper { } catch (Throwable t){ - //Utils.LOG_INFO("State of Wireless Charger changed in an invalid way, this prevented a crash."); + //Utils.LOG_WARNING("State of Wireless Charger changed in an invalid way, this prevented a crash."); if (!mChargerMap.isEmpty()){ for (GregtechMetaWirelessCharger r : mChargerMap.values()){ @@ -183,20 +183,20 @@ public class ChargingHelper { if (mEntity == null){ return false; } - Utils.LOG_INFO("trying to map new player"); + Utils.LOG_WARNING("trying to map new player"); if (mValidPlayers.containsKey(mPlayer)){ - Utils.LOG_INFO("Key contains player already?"); + Utils.LOG_WARNING("Key contains player already?"); return false; } else { - Utils.LOG_INFO("key not found, adding"); + Utils.LOG_WARNING("key not found, adding"); Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); if (mValidPlayers.put(mPlayer, mEntry) == null){ - Utils.LOG_INFO("Added a Player to the Tick Map."); + Utils.LOG_WARNING("Added a Player to the Tick Map."); return true; } else { - Utils.LOG_INFO("Tried to add player but it was already there?"); + Utils.LOG_WARNING("Tried to add player but it was already there?"); return false; } } @@ -206,21 +206,21 @@ public class ChargingHelper { if (mEntity == null){ return false; } - Utils.LOG_INFO("trying to remove player from map"); + Utils.LOG_WARNING("trying to remove player from map"); if (mValidPlayers.containsKey(mPlayer)){ - Utils.LOG_INFO("key found, removing"); + Utils.LOG_WARNING("key found, removing"); Pair mEntry = new Pair(mEntity, (byte) mEntity.getMode()); if (mValidPlayers.remove(mPlayer, mEntry)){ - Utils.LOG_INFO("Removed a Player to the Tick Map."); + Utils.LOG_WARNING("Removed a Player to the Tick Map."); return true; } else { - Utils.LOG_INFO("Tried to remove player but it was not there?"); + Utils.LOG_WARNING("Tried to remove player but it was not there?"); return false; } } else { - Utils.LOG_INFO("Key does not contain player?"); + Utils.LOG_WARNING("Key does not contain player?"); return false; } } @@ -267,17 +267,17 @@ public class ChargingHelper { for (ItemStack mTemp : mItems){ mItemSlot++; if (mTemp != null){ - Utils.LOG_INFO("Slot "+mItemSlot+" contains "+mTemp.getDisplayName()); + Utils.LOG_WARNING("Slot "+mItemSlot+" contains "+mTemp.getDisplayName()); } //Is item Electrical if (isItemValid(mTemp)){ - Utils.LOG_INFO("1"); + Utils.LOG_WARNING("1"); //Transfer Limit double mItemEuTLimit = ((IElectricItem) mTemp.getItem()).getTransferLimit(mTemp); //Check if Tile has more or equal EU to what can be transferred into the item. if (mEuStored >= mItemEuTLimit){ - Utils.LOG_INFO("2"); + Utils.LOG_WARNING("2"); double mItemMaxCharge = ((IElectricItem) mTemp.getItem()).getMaxCharge(mTemp); double mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); @@ -288,7 +288,7 @@ public class ChargingHelper { //Try get charge direct from NBT for GT and IC2 stacks try { - Utils.LOG_INFO("3"); + Utils.LOG_WARNING("3"); if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 @@ -326,7 +326,7 @@ public class ChargingHelper { mVoltageIncrease = mItemEuTLimit; } - Utils.LOG_INFO("4"); + Utils.LOG_WARNING("4"); int mMulti; if ((mitemCurrentCharge + (mVoltageIncrease*20)) <= (mItemMaxCharge - (mVoltageIncrease*20))){ @@ -341,15 +341,15 @@ public class ChargingHelper { else { mMulti = 1; } - Utils.LOG_INFO("5"); + Utils.LOG_WARNING("5"); int mMultiVoltage = (int) (mMulti*mVoltageIncrease); if ((mitemCurrentCharge + mMultiVoltage) <= mItemMaxCharge){ - Utils.LOG_INFO("6"); + Utils.LOG_WARNING("6"); if (GT_ModHandler.chargeElectricItem(mTemp, mMultiVoltage, mTier, true, false) == 0){ - Utils.LOG_INFO("6.5"); + Utils.LOG_WARNING("6.5"); for (int i=0; i mitemCurrentCharge){ - Utils.LOG_INFO("7"); + Utils.LOG_WARNING("7"); mEntity.setEUVar((long) (mEuStored-(mVoltage*mMulti))); mEuStored = mEntity.getEUVar(); - Utils.LOG_INFO("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); + Utils.LOG_WARNING("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); mChargedItems++; } } @@ -370,7 +370,7 @@ public class ChargingHelper { } else { if (mTemp != null){ - Utils.LOG_INFO("Found Non-Valid item. "+mTemp.getDisplayName()); + Utils.LOG_WARNING("Found Non-Valid item. "+mTemp.getDisplayName()); } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index a2714c4bab..0bd3e6b3bd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -45,6 +45,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { "Mixed: Provides both 2A of long range and 1A per player locally.", "Mixed mode is more conservative of power and as a result only", "gets half the distances each singular mode gets.", + "Long-Range mode currently disabled.", CORE.GT_Tooltip}; } @@ -158,7 +159,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { this.mMode++; } if (this.mMode == 0){ - PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Mode."); + PlayerUtils.messagePlayer(aPlayer, "Now in Long-Range Mode. [Disabled]"); } else if (this.mMode == 1){ PlayerUtils.messagePlayer(aPlayer, "Now in Local Charge Mode."); @@ -394,7 +395,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } } } - if (this.mMode == 0 || this.mMode == 2){ + /*if (this.mMode == 0 || this.mMode == 2){ int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]); if (getDistanceBetweenTwoPositions(getTileEntityPosition(), getPositionOfEntity(mTemp)) < tempRange){ if (!mWirelessChargingMap.containsKey(mTemp)){ @@ -411,7 +412,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } } } - } + } */ } } @@ -487,7 +488,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } else { - PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m"); + PlayerUtils.messagePlayer(aPlayer, "Long-range Mode: "+tempRange+"m [Disabled]"); } -- cgit From d7897d548e0d377df56a33b4be4a60717d97dd97 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 17 Nov 2017 01:20:46 +1000 Subject: + Added the Generator Array. --- src/Java/gregtech/api/util/Recipe_GT.java | 5 +- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 2 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 1 + .../xmod/gregtech/api/enums/GregtechItemList.java | 5 +- .../GregtechMetaTileEntityGeneratorArray.java | 236 +++++++++++++++++++++ .../gregtech/GregtechIndustrialGeneratorArray.java | 26 +++ .../registration/gregtech/GregtechRTG.java | 2 +- .../gregtech/GregtechWirelessChargers.java | 62 +++--- 8 files changed, 306 insertions(+), 33 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index b63a259f9c..8c9ae25d95 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -239,10 +239,11 @@ public class Recipe_GT extends GT_Recipe{ public static final GT_Recipe_Map sMatterFab2Recipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.matterfab2", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, E, 1, E, true, true); //public static final Gregtech_Recipe_Map sMatterFabRecipes = new Gregtech_Recipe_Map(new HashSet(200), "gt.recipe.matterfab", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 3, 1, 1, 1, E, 1, E, true, true); public static final Gregtech_Recipe_Map_Fuel sRocketFuels = new Gregtech_Recipe_Map_Fuel(new HashSet(10), "gt.recipe.rocketenginefuel", "Rocket Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 3000, " EU", true, true); - public static final Gregtech_Recipe_Map_Fuel sGeoThermalFuels = new Gregtech_Recipe_Map_Fuel(new HashSet(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map sGeoThermalFuels = new GT_Recipe_Map(new HashSet(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map sChemicalDehydratorRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.chemicaldehydrator", "Chemical Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAlloyBlastSmelterRecipes = new GT_Recipe_Map(new HashSet(200), "gt.recipe.alloyblastsmelter", "Alloy Blast Smelter", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 9, 1, 1, 0, 1, E, 1, E, true, true); - + public static final GT_Recipe_Map sSteamTurbineFuels = new GT_Recipe_Map(new HashSet(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + //LFTR recipes public static final GT_Recipe_Map sLiquidFluorineThoriumReactorRecipes = new GT_Recipe_Map(new HashSet(50), "gt.recipe.lftr", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); //Fission Fuel Plant Recipes diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 23b2ad8e1a..c59798ce21 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -6,7 +6,6 @@ import java.util.LinkedList; import java.util.Queue; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.MultiblockRecipeMapHandler; import gtPlusPlus.core.common.compat.*; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; @@ -98,6 +97,7 @@ public class COMPAT_HANDLER { GregtechSemiFluidgenerators.run(); GregtechAdvancedMixer.run(); GregtechWirelessChargers.run(); + GregtechIndustrialGeneratorArray.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 7f0bc7a8ca..623e5651e5 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -704,6 +704,7 @@ public class RECIPES_GREGTECH { new int[]{}, 0);*/ + ThermalFuel.addSteamTurbineFuel(FluidUtils.getFluidStack("steam", 1024)); //CORE.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); GT_Values.RA.addFuel(ItemUtils.getSimpleStack(Items.lava_bucket), null, 32, 2); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 6a797d9ce0..7d413a9796 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -260,7 +260,10 @@ public enum GregtechItemList implements GregtechItemContainer { //Wireless Chargers Charger_LV, Charger_MV, Charger_HV, Charger_EV, Charger_IV, Charger_LuV, - Charger_ZPM, Charger_UV, Charger_MAX, + Charger_ZPM, Charger_UV, Charger_MAX, + + //Generator Array + Generator_Array_Controller, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java new file mode 100644 index 0000000000..e6c82e203b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java @@ -0,0 +1,236 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.fluid.FluidUtils; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +public class GregtechMetaTileEntityGeneratorArray extends GT_MetaTileEntity_MultiBlockBase { + + GT_Recipe mLastRecipe; + + public GregtechMetaTileEntityGeneratorArray(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityGeneratorArray(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityGeneratorArray(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Generator Array", + "Runs supplied generators as if placed in the world", + "Size(WxHxD): 3x3x3 (Hollow), Controller (Front centered)", + "1x Input Hatch/Bus (Any casing)", + "1x Output Hatch/Bus (Any casing)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Robust Tungstensteel Machine Casings for the rest (16 at least!)", + "Place up to 16 Single Block GT Generators into the Controller Inventory"}; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[48], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_PROCESSING_ARRAY)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[48]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "ProcessingArray.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (mInventory[1] == null) return null; + String tmp = mInventory[1].getUnlocalizedName().replaceAll("gt\\.blockmachines\\.basicgenerator\\.", ""); + if (tmp.startsWith("steamturbine")) { + return Gregtech_Recipe_Map.sSteamTurbineFuels; + } + else if (tmp.startsWith("diesel")) { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + else if (tmp.startsWith("gasturbine")) { + return GT_Recipe.GT_Recipe_Map.sTurbineFuels; + } + else if (tmp.startsWith("semifluid")) { + return GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels; + } + else if (tmp.startsWith("rtg")) { + return Gregtech_Recipe_Map.sRTGFuels; + } + + + tmp = mInventory[1].getUnlocalizedName().replaceAll("gt\\.blockmachines\\.advancedgenerator\\.", ""); + if (tmp.startsWith("rocket")) { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + else if (tmp.startsWith("geothermalFuel")) { + return Gregtech_Recipe_Map.sGeoThermalFuels; + } + + return null; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + if (aStack != null && aStack.getUnlocalizedName().startsWith("gt.blockmachines.")) { + return true; + } + return false; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public String mMachine = ""; + public boolean checkRecipe(ItemStack aStack) { + if (!isCorrectMachinePart(mInventory[1])) { + return false; + } + GT_Recipe.GT_Recipe_Map map = getRecipeMap(); + if (map == null) return false; + ArrayList tInputList = getStoredInputs(); + int tTier = 0; + if (mInventory[1].getUnlocalizedName().endsWith("1")) { + tTier = 1; + }else if (mInventory[1].getUnlocalizedName().endsWith("2")) { + tTier = 2; + }else if (mInventory[1].getUnlocalizedName().endsWith("3")) { + tTier = 3; + }else if (mInventory[1].getUnlocalizedName().endsWith("4")) { + tTier = 4; + }else if (mInventory[1].getUnlocalizedName().endsWith("5")) { + tTier = 5; + }else if (mInventory[1].getUnlocalizedName().endsWith("6")) { + tTier = 6; + }else if (mInventory[1].getUnlocalizedName().endsWith("7")) { + tTier = 7; + }else if (mInventory[1].getUnlocalizedName().endsWith("8")) { + tTier = 8; + } + + int fuelConsumption = 0; + int fuelValue = 0; + int fuelRemaining = 0; + boolean boostEu = false; + + if(!mMachine.equals(mInventory[1].getUnlocalizedName()))mLastRecipe=null; + mMachine = mInventory[1].getUnlocalizedName(); + Utils.LOG_INFO("mMachine: "+mMachine); + ArrayList tFluids = getStoredFluids(); + Collection tRecipeList = this.getRecipeMap().mRecipeList; + Utils.LOG_INFO("tRecipeList: "+tRecipeList); + + if(tFluids.size() > 0 && tRecipeList != null) { //Does input hatch have a diesel fuel? + Utils.LOG_INFO("1"); + for (FluidStack hatchFluid1 : tFluids) { //Loops through hatches + Utils.LOG_INFO("2"); + for(GT_Recipe aFuel : tRecipeList) { //Loops through diesel fuel recipes + Utils.LOG_INFO("3"); + /*if (aFuel != null){ + for (FluidStack x : aFuel.mFluidInputs){ + if (x != null){ + Utils.LOG_INFO("Recipe: "+x.getLocalizedName()); + } + } + }*/ + FluidStack tLiquid; + tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], aFuel.mFluidInputs[0].amount); + Utils.LOG_INFO("5"); + fuelConsumption = aFuel.mFluidInputs[0].amount; + if(depleteInput(tLiquid)) { //Deplete that amount + Utils.LOG_INFO("6"); + boostEu = true; + Utils.LOG_INFO("7"); + + fuelValue = aFuel.mEUt*aFuel.mDuration; + fuelRemaining = hatchFluid1.amount; //Record available fuel + this.mEUt = mEfficiency < 2000 ? 0 : 2048; //Output 0 if startup is less than 20% + //this.mProgresstime = 1; + this.mMaxProgresstime = 20; + this.mEfficiencyIncrease = 9500; + Utils.LOG_INFO("9"); + return true; + } + } + // } + //} + } + } + this.mEUt = 0; + this.mEfficiency = 0; + return false; + } + + public static ItemStack[] clean(final ItemStack[] v) { + List list = new ArrayList(Arrays.asList(v)); + list.removeAll(Collections.singleton(null)); + return list.toArray(new ItemStack[list.size()]); + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 48)) && (!addInputToMachineList(tTileEntity, 48)) && (!addOutputToMachineList(tTileEntity, 48)) && (!addDynamoToMachineList(tTileEntity, 48))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings4) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java new file mode 100644 index 0000000000..b0b91af528 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java @@ -0,0 +1,26 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntityGeneratorArray; + +public class GregtechIndustrialGeneratorArray { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Utils.LOG_INFO("Gregtech5u Content | Registering Industrial Generator Array Multiblock."); + //if (CORE.configSwitches.enableMultiblock_IndustrialSifter) { // TODO + run1(); + //} + } + + } + + private static void run1() { + // Industrial Maceration Stack Multiblock + GregtechItemList.Generator_Array_Controller.set(new GregtechMetaTileEntityGeneratorArray( + 990, + "generatorarray.controller.tier.01", + "Large Generator Array").getStackForm(1L)); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRTG.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRTG.java index 4d3738f585..954f652b40 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRTG.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRTG.java @@ -15,7 +15,7 @@ public class GregtechRTG { private static void run1() { GregtechItemList.RTG.set( - new GregtechMetaTileEntity_RTG(869, "rtg.01.tier.single", "Radioisotope Thermoelectric Generator", 3) + new GregtechMetaTileEntity_RTG(869, "basicgenerator.rtg.tier.01", "Radioisotope Thermoelectric Generator", 3) .getStackForm(1L)); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java index 688b522c2b..48d516e4cf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechWirelessChargers.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.util.GT_ModHandler; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; @@ -9,35 +10,40 @@ import net.minecraftforge.common.MinecraftForge; public class GregtechWirelessChargers { - + public static void run(){ - - long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE - | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; - int mID = 890; - - FMLCommonHandler.instance().bus().register(new ChargingHelper()); - MinecraftForge.EVENT_BUS.register(new ChargingHelper()); - - GregtechItemList.Charger_LV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.01.tier.single", - "Wireless Charger MK I", 1, "Hopefully won't give you cancer.", 0).getStackForm(1L)); - GregtechItemList.Charger_MV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.02.tier.single", - "Wireless Charger MK II", 2, "Hopefully won't give you cancer.", 0).getStackForm(1L)); - GregtechItemList.Charger_HV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.03.tier.single", - "Wireless Charger MK III", 3, "Hopefully won't give you cancer.", 0).getStackForm(1L)); - GregtechItemList.Charger_EV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.04.tier.single", - "Wireless Charger MK IV", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); - GregtechItemList.Charger_IV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.05.tier.single", - "Wireless Charger MK V", 5, "Hopefully won't give you cancer.", 0).getStackForm(1L)); - GregtechItemList.Charger_LuV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.06.tier.single", - "Wireless Charger MK VI", 6, "Hopefully won't give you cancer.", 0).getStackForm(1L)); - GregtechItemList.Charger_ZPM.set(new GregtechMetaWirelessCharger(mID++, "wificharger.07.tier.single", - "Wireless Charger MK VII", 7, "Hopefully won't give you cancer.", 0).getStackForm(1L)); - GregtechItemList.Charger_UV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.08.tier.single", - "Wireless Charger MK VIII", 8, "Hopefully won't give you cancer.", 0).getStackForm(1L)); - GregtechItemList.Charger_MAX.set(new GregtechMetaWirelessCharger(mID++, "wificharger.09.tier.single", - "Wireless Charger MK IX", 9, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Utils.LOG_INFO("Gregtech5u Content | Registering Wireless Chargers."); + + + long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED; + int mID = 890; + + FMLCommonHandler.instance().bus().register(new ChargingHelper()); + MinecraftForge.EVENT_BUS.register(new ChargingHelper()); + + GregtechItemList.Charger_LV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.01.tier.single", + "Wireless Charger MK I", 1, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_MV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.02.tier.single", + "Wireless Charger MK II", 2, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_HV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.03.tier.single", + "Wireless Charger MK III", 3, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_EV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.04.tier.single", + "Wireless Charger MK IV", 4, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_IV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.05.tier.single", + "Wireless Charger MK V", 5, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_LuV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.06.tier.single", + "Wireless Charger MK VI", 6, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_ZPM.set(new GregtechMetaWirelessCharger(mID++, "wificharger.07.tier.single", + "Wireless Charger MK VII", 7, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_UV.set(new GregtechMetaWirelessCharger(mID++, "wificharger.08.tier.single", + "Wireless Charger MK VIII", 8, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + GregtechItemList.Charger_MAX.set(new GregtechMetaWirelessCharger(mID++, "wificharger.09.tier.single", + "Wireless Charger MK IX", 9, "Hopefully won't give you cancer.", 0).getStackForm(1L)); + + } } - + } -- cgit From 94389c154e4d517e4fcdebdacc3da9be414e8c75 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 17 Nov 2017 10:58:02 +1000 Subject: + Added the Cutting Factory Multiblock. + Added a config for the Cutting Factory. % Hid Generator Array Logging. --- src/Java/gregtech/api/util/ThermalFuel.java | 43 ++++ .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 3 +- src/Java/gtPlusPlus/core/lib/CORE.java | 2 + .../xmod/gregtech/api/enums/GregtechItemList.java | 7 +- .../common/blocks/GregtechMetaCasingBlocks2.java | 4 +- .../blocks/textures/CasingTextureHandler2.java | 2 +- .../GregtechMetaTileEntityGeneratorArray.java | 20 +- ...echMetaTileEntity_IndustrialCuttingMachine.java | 254 +++++++++++++++++++++ .../gregtech/GregtechIndustrialCuttingFactory.java | 25 ++ 9 files changed, 344 insertions(+), 16 deletions(-) create mode 100644 src/Java/gregtech/api/util/ThermalFuel.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCuttingFactory.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gregtech/api/util/ThermalFuel.java b/src/Java/gregtech/api/util/ThermalFuel.java new file mode 100644 index 0000000000..4f6637e13f --- /dev/null +++ b/src/Java/gregtech/api/util/ThermalFuel.java @@ -0,0 +1,43 @@ +package gregtech.api.util; + +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraftforge.fluids.FluidStack; + +public class ThermalFuel { + + public static void addThermalFuel(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int euValue, int aSpecialValue) { + GT_Recipe x = new GT_Recipe( + true, + null, + null, + null, + null, + new FluidStack[]{aInput1, aInput2}, + new FluidStack[]{aOutput1}, + 20, //1 Tick + euValue, //No Eu produced + aSpecialValue //Magic Number + ); + Recipe_GT.Gregtech_Recipe_Map.sGeoThermalFuels.addRecipe(x); + } + + public static void addSteamTurbineFuel(FluidStack aInput1) { + GT_Recipe x = new GT_Recipe( + true, + null, + null, + null, + null, + new FluidStack[]{aInput1}, + null, + 20, //1 Tick + MathUtils.findPercentageOfInt((aInput1.amount/2), 95), //No Eu produced + 0 //Magic Number + ); + Recipe_GT.Gregtech_Recipe_Map.sSteamTurbineFuels.addRecipe(x); + } + + + + +} diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index c59798ce21..e504e16761 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -98,7 +98,8 @@ public class COMPAT_HANDLER { GregtechAdvancedMixer.run(); GregtechWirelessChargers.run(); GregtechIndustrialGeneratorArray.run(); - + GregtechIndustrialCuttingFactory.run(); + //New Horizons Content NewHorizonsAccelerator.run(); } diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 71119ee00e..6cb37837aa 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -164,6 +164,7 @@ public class CORE { public static boolean enableMultiblock_IndustrialWashPlant = true; public static boolean enableMultiblock_LargeAutoCrafter = true; public static boolean enableMultiblock_ThermalBoiler = true; + public static boolean enableMultiblock_IndustrialCuttingMachine = true; //Visuals public static boolean enableTreeFarmerParticles = true; @@ -171,6 +172,7 @@ public class CORE { + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 7d413a9796..fbffa4adf1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -173,7 +173,7 @@ public enum GregtechItemList implements GregtechItemContainer { Casing_Autocrafter, - Casing_PlaceHolder13, + Casing_CuttingFactoryFrame, Casing_PlaceHolder14, Casing_PlaceHolder15, @@ -263,7 +263,10 @@ public enum GregtechItemList implements GregtechItemContainer { Charger_ZPM, Charger_UV, Charger_MAX, //Generator Array - Generator_Array_Controller, + Generator_Array_Controller, + + //Cutting Factory Controller + Industrial_CuttingFactoryController, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java index afce39b5d9..51a2c208e6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -32,7 +32,7 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Cyclotron Outer Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Thermal Containment Casing"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Autocrafter Frame"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Placeholder Casing"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Placeholder Casing "); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Placeholder Casing "); GregtechItemList.Casing_ThermalCentrifuge.set(new ItemStack(this, 1, 0)); @@ -48,7 +48,7 @@ extends GregtechMetaCasingBlocksAbstract { GregtechItemList.Casing_Cyclotron_External.set(new ItemStack(this, 1, 10)); GregtechItemList.Casing_ThermalContainment.set(new ItemStack(this, 1, 11)); GregtechItemList.Casing_Autocrafter.set(new ItemStack(this, 1, 12)); - GregtechItemList.Casing_PlaceHolder13.set(new ItemStack(this, 1, 13)); + GregtechItemList.Casing_CuttingFactoryFrame.set(new ItemStack(this, 1, 13)); GregtechItemList.Casing_PlaceHolder14.set(new ItemStack(this, 1, 14)); GregtechItemList.Casing_PlaceHolder15.set(new ItemStack(this, 1, 15)); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java index 82b2da069c..af9edb3e0c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java @@ -50,7 +50,7 @@ public class CasingTextureHandler2 { return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); //Reactor Casing II case 13: - return TexturesGtBlock._PlaceHolder.getIcon(); + return TexturesGtBlock.Casing_Machine_Ultra.getIcon(); case 14: return TexturesGtBlock._PlaceHolder.getIcon(); case 15: diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java index e6c82e203b..3923f65f29 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityGeneratorArray.java @@ -138,32 +138,32 @@ public class GregtechMetaTileEntityGeneratorArray extends GT_MetaTileEntity_Mult if(!mMachine.equals(mInventory[1].getUnlocalizedName()))mLastRecipe=null; mMachine = mInventory[1].getUnlocalizedName(); - Utils.LOG_INFO("mMachine: "+mMachine); + Utils.LOG_WARNING("mMachine: "+mMachine); ArrayList tFluids = getStoredFluids(); Collection tRecipeList = this.getRecipeMap().mRecipeList; - Utils.LOG_INFO("tRecipeList: "+tRecipeList); + Utils.LOG_WARNING("tRecipeList: "+tRecipeList); if(tFluids.size() > 0 && tRecipeList != null) { //Does input hatch have a diesel fuel? - Utils.LOG_INFO("1"); + Utils.LOG_WARNING("1"); for (FluidStack hatchFluid1 : tFluids) { //Loops through hatches - Utils.LOG_INFO("2"); + Utils.LOG_WARNING("2"); for(GT_Recipe aFuel : tRecipeList) { //Loops through diesel fuel recipes - Utils.LOG_INFO("3"); + Utils.LOG_WARNING("3"); /*if (aFuel != null){ for (FluidStack x : aFuel.mFluidInputs){ if (x != null){ - Utils.LOG_INFO("Recipe: "+x.getLocalizedName()); + Utils.LOG_WARNING("Recipe: "+x.getLocalizedName()); } } }*/ FluidStack tLiquid; tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], aFuel.mFluidInputs[0].amount); - Utils.LOG_INFO("5"); + Utils.LOG_WARNING("5"); fuelConsumption = aFuel.mFluidInputs[0].amount; if(depleteInput(tLiquid)) { //Deplete that amount - Utils.LOG_INFO("6"); + Utils.LOG_WARNING("6"); boostEu = true; - Utils.LOG_INFO("7"); + Utils.LOG_WARNING("7"); fuelValue = aFuel.mEUt*aFuel.mDuration; fuelRemaining = hatchFluid1.amount; //Record available fuel @@ -171,7 +171,7 @@ public class GregtechMetaTileEntityGeneratorArray extends GT_MetaTileEntity_Mult //this.mProgresstime = 1; this.mMaxProgresstime = 20; this.mEfficiencyIncrease = 9500; - Utils.LOG_INFO("9"); + Utils.LOG_WARNING("9"); return true; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java new file mode 100644 index 0000000000..ad1b9cc635 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -0,0 +1,254 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import java.util.ArrayList; + +import gregtech.api.enums.TAE; +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.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_IndustrialCuttingMachine +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialCuttingMachine(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_IndustrialCuttingMachine(final String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCuttingMachine(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Cutting Factory", + "60% faster than using single block machines of the same voltage", + "Size: 3x3x5 [WxHxL] (Hollow)", "Controller (front centered)", + "2x Input Bus (side centered)", + "2x Output Bus (side centered)", + "1x Energy Hatch (top or bottom centered)", + "1x Input Hatch (top or bottom centered)", + "1x Maintenance Hatch (back centered)", + "Cutting Factory Frames for the rest (32 at least!)", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(29)], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(29)]}; + } + + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "WireFactory.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sCutterRecipes; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(final ItemStack aStack) { + final ArrayList tInputList = this.getStoredInputs(); + final ArrayList tFluidList = this.getStoredFluids(); + for (final ItemStack tInput : tInputList) { + for (final FluidStack tFluid : tFluidList) { + final long tVoltage = this.getMaxInputVoltage(); + final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCutterRecipes.findRecipe(this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tFluid}, new ItemStack[]{tInput}); + //tRecipe = this.reduceRecipeTimeByPercentage(tRecipe, 60F); + if (tRecipe != null) { + + //More than or one input + if (tInputList.size() > 0) { + + if (tRecipe.isRecipeInputEqual(true, new FluidStack[]{tFluid}, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << (tTier - 1)) * (1 << (tTier - 1))); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + 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); + ItemStack[] mOutputStacks = new ItemStack[9]; + for (int i=0;i<9;i++){ + if (tRecipe.getOutput(i) != null){ + mOutputStacks[i] = tRecipe.getOutput(i); + } + } + this.mOutputItems = mOutputStacks.clone(); + //this.updateSlots(); + return true; + } + } + } + } + } + return false; + } + + @Override + public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + final byte tSide = this.getBaseMetaTileEntity().getBackFacing(); + if ((this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 1)) && (this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 2) && (this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 3)))) { + int tAirCount = 0; + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + for (byte k = -1; k < 2; k = (byte) (k + 1)) { + if (this.getBaseMetaTileEntity().getAirOffset(i, j, k)) { + tAirCount++; + } + } + } + } + if (tAirCount != 10) { + Utils.LOG_INFO("False 1"); + return false; + } + for (byte i = 2; i < 6; i = (byte) (i + 1)) { + IGregTechTileEntity tTileEntity; + if ((null != (tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == this.getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialCuttingMachine))) { + //Utils.LOG_INFO("False 1"); + return false; + } + } + final int tX = this.getBaseMetaTileEntity().getXCoord(); + final int tY = this.getBaseMetaTileEntity().getYCoord(); + final int tZ = this.getBaseMetaTileEntity().getZCoord(); + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 5; k = (byte) (k + 1)) { + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { + if ((this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock()) && (this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta())) { + } + else if (!this.addToMachineList(this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!this.addEnergyInputToMachineList(this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { + Utils.LOG_INFO("False 2"); + return false; + } + } + else if ((this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock()) && (this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta())) { + } + else { + Utils.LOG_INFO("False 3"); + return false; + } + } + } + } + } + if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() < 0)) { + Utils.LOG_INFO("Use Busses, Not Hatches for Input/Output."); + return false; + } + if ((this.mInputBusses.size() != 2) || (this.mOutputBusses.size() != 2)) { + Utils.LOG_INFO("Incorrect amount of Input & Output busses."); + return false; + } + this.mMaintenanceHatches.clear(); + final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this.getCasingTextureIndex(); + } else { + Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); + return false; + } + } + if ((this.mMaintenanceHatches.size() != 1) || (this.mEnergyHatches.size() != 1)) { + Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); + return false; + } + } else { + Utils.LOG_INFO("False 5"); + return false; + } + Utils.LOG_INFO("True"); + return true; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { + return 80; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + + public byte getCasingMeta() { + return 13; + } + + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(29); + } + + private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { + return ((this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()))); + } + + private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { + return ((this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()))); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCuttingFactory.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCuttingFactory.java new file mode 100644 index 0000000000..11d8b400d0 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCuttingFactory.java @@ -0,0 +1,25 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialCuttingMachine; + +public class GregtechIndustrialCuttingFactory { + + public static void run() { + if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { + Utils.LOG_INFO("Gregtech5u Content | Registering Industrial Cutting Factory Multiblock."); + if (CORE.configSwitches.enableMultiblock_IndustrialCuttingMachine) { + run1(); + } + } + } + + private static void run1() { + // Industrial Wire Factory Multiblock + GregtechItemList.Industrial_CuttingFactoryController.set(new GregtechMetaTileEntity_IndustrialCuttingMachine(992, + "industrialcuttingmachine.controller.tier.01", "Cutting Factory Controller").getStackForm(1L)); + + } +} \ No newline at end of file -- cgit From a9f330848748bf4c75fab648407124f70c70e462 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 17 Nov 2017 15:47:20 +1000 Subject: + Added in the Compact Fusion Reactor. % Did work on the CFR. $ Fixed a tooltip on the Pollution Detector. --- src/Java/gregtech/api/util/Recipe_GT.java | 6 + src/Java/gtPlusPlus/GTplusplus.java | 2 + .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 1 + .../xmod/gregtech/api/enums/GregtechItemList.java | 5 +- .../GT_MetaTileEntity_DeluxeMachine.java | 861 +++++++++++++++++++++ .../common/blocks/textures/TexturesGtBlock.java | 6 + .../basic/GregtechMetaPollutionDetector.java | 2 +- ...regtechMetaTileEntity_CompactFusionReactor.java | 687 ++++++++++++++++ .../gregtech/GregtechMiniRaFusion.java | 61 ++ .../TileEntities/MACHINE_CASING_FUSION_FRONT.png | Bin 0 -> 515 bytes .../MACHINE_CASING_FUSION_FRONT_ACTIVE.png | Bin 0 -> 502 bytes 11 files changed, 1629 insertions(+), 2 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT.png create mode 100644 src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE.png (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 8c9ae25d95..082dc6e264 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -271,6 +271,12 @@ public class Recipe_GT extends GT_Recipe{ "Advanced Material Combiner", null, "gregtech:textures/gui/basicmachines/MixerAdvanced", 4, 4, 1, 0, 2, "", 1, "", true, true); + //Mini Fusion + public static final GT_Recipe_Map sSlowFusionRecipes = new GT_Recipe_Map(new HashSet(50), "gt.recipe.slowfusionreactor", + "Slow Fusion Reactor", null, "gregtech:textures/gui/basicmachines/Default", 0, 0, 0, 2, 1, "Start: ", 1, + " EU", true, false); + + /** * HashMap of Recipes based on their Items */ diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 2c08414743..ae5ea3eda4 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -177,6 +177,8 @@ public class GTplusplus implements ActionListener { "gregtech", true, "Used to wash the dirt, riiiiight offff.."); CORE.configSwitches.enableMultiblock_ThermalBoiler = config.getBoolean("enableMachineThermalBoiler", "gregtech", true, "Thermal Boiler from GT4. Can Filter Lava for resources."); + CORE.configSwitches.enableMultiblock_IndustrialCuttingMachine = config.getBoolean("enableMultiblock_IndustrialCuttingMachine", + "gregtech", true, "Very fast and efficient Cutting Machine."); // Options RF2EU_Battery.rfPerEU = config.getInt("rfUsedPerEUForUniversalBatteries", "configurables", 4, 1, 1000, diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index e504e16761..eecbcec9e9 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -99,6 +99,7 @@ public class COMPAT_HANDLER { GregtechWirelessChargers.run(); GregtechIndustrialGeneratorArray.run(); GregtechIndustrialCuttingFactory.run(); + GregtechMiniRaFusion.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index fbffa4adf1..7a0df6c43c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -266,7 +266,10 @@ public enum GregtechItemList implements GregtechItemContainer { Generator_Array_Controller, //Cutting Factory Controller - Industrial_CuttingFactoryController, + Industrial_CuttingFactoryController, + + //Tiny Fusion + Miniature_Fusion, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java new file mode 100644 index 0000000000..ee0722069b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java @@ -0,0 +1,861 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_BasicMachine; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +import java.util.Arrays; + +import static gregtech.api.enums.GT_Values.V; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + *

+ * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public abstract class GT_MetaTileEntity_DeluxeMachine extends GT_MetaTileEntity_DeluxeTank { + /** + * return values for checkRecipe() + */ + protected static final int + DID_NOT_FIND_RECIPE = 0, + FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, + FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; + public static final int OTHER_SLOT_COUNT = 4; + public final ItemStack[] mOutputItems; + public final int mInputSlotCount, mAmperage; + public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; + public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; + public FluidStack mOutputFluid; + public String mGUIName = "", mNEIName = ""; + /** + * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered + */ + protected GT_Recipe mLastRecipe = null; + private FluidStack mFluidOut; + + /** + * @param aOverlays 0 = SideFacingActive + * 1 = SideFacingInactive + * 2 = FrontFacingActive + * 3 = FrontFacingInactive + * 4 = TopFacingActive + * 5 = TopFacingInactive + * 6 = BottomFacingActive + * 7 = BottomFacingInactive + * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- + * 8 = BottomFacingPipeActive + * 9 = BottomFacingPipeInactive + * 10 = TopFacingPipeActive + * 11 = TopFacingPipeInactive + * 12 = SideFacingPipeActive + * 13 = SideFacingPipeInactive + */ + public GT_MetaTileEntity_DeluxeMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { + super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public GT_MetaTileEntity_DeluxeMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); + mInputSlotCount = Math.max(0, aInputSlotCount); + mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; + mAmperage = aAmperage; + mGUIName = aGUIName; + mNEIName = aNEIName; + } + + public boolean setMainFacing(byte aDirection){ + mMainFacing = aDirection; + if(getBaseMetaTileEntity().getFrontFacing() == mMainFacing){ + getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aDirection)); + } + onFacingChange(); + onMachineBlockUpdate(); + return true; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[14][17][]; + aTextures = Arrays.copyOf(aTextures, 14); + + for (int i = 0; i < aTextures.length; i++) + if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { + if (rTextures[i][c + 1] == null) + rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; + } + + for (byte c = -1; c < 16; c++) { + if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); + if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); + if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); + if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); + if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); + if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); + if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); + if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); + if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); + if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); + if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); + if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); + if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); + if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isOverclockerUpgradable() { + return false; + } + + @Override + public boolean isTransformerUpgradable() { + return false; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return mMainFacing > 1 || aFacing > 1; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isLiquidInput(byte aSide) { + return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + } + + @Override + public boolean isLiquidOutput(byte aSide) { + return aSide != mMainFacing; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] * 16; + } + + @Override + public long maxEUStore() { + return V[mTier] * 64; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxSteamStore() { + return maxEUStore(); + } + + @Override + public long maxAmperesIn() { + return (mEUt * 2) / V[mTier] + 1; + } + + @Override + public int getInputSlot() { + return OTHER_SLOT_COUNT; + } + + @Override + public int getOutputSlot() { + return OTHER_SLOT_COUNT + mInputSlotCount; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + @Override + public int rechargerSlotStartIndex() { + return 1; + } + + @Override + public int dechargerSlotStartIndex() { + return 1; + } + + @Override + public int rechargerSlotCount() { + return mCharge ? 1 : 0; + } + + @Override + public int dechargerSlotCount() { + return mDecharge ? 1 : 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return mProgresstime; + } + + @Override + public int maxProgresstime() { + return mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + mProgresstime += aProgress; + return mMaxProgresstime - mProgresstime; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public boolean doesFillContainers() { + return false; + } + + @Override + public boolean doesEmptyContainers() { + return false; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return true; + } + + @Override + public FluidStack getDisplayedFluid() { + return displaysOutputFluid() ? getDrainableStack() : null; + } + + @Override + public FluidStack getDrainableStack() { + return mFluidOut; + } + + @Override + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluidOut = aFluid; + return mFluidOut; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + if(!GT_Mod.gregtechproxy.mForceFreeFace) { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + for(byte i=0;i < 6; i++){ + if(aBaseMetaTileEntity.getAirAtSide(i)){ + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + GT_Utility.sendChatToPlayer(aPlayer,"No free Side!"); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); + } + + @Override + public void initDefaultModes(NBTTagCompound aNBT) { + mMainFacing = -1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("mFluidTransfer", mFluidTransfer); + aNBT.setBoolean("mItemTransfer", mItemTransfer); + aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); + aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mMainFacing", mMainFacing); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); + if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); + + for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) + aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); + mItemTransfer = aNBT.getBoolean("mItemTransfer"); + mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); + mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); + mEUt = aNBT.getInteger("mEUt"); + mMainFacing = aNBT.getInteger("mMainFacing"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); + mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); + + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide()) { + + //Utils.LOG_INFO("Ticking Tank."); + mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; + mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; + + doDisplayThings(); + + boolean tSucceeded = false; + + if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { + aBaseMetaTileEntity.setActive(true); + if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { + if (++mProgresstime >= mMaxProgresstime) { + for (int i = 0; i < mOutputItems.length; i++) + for (int j = 0; j < mOutputItems.length; j++) + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) + break; + if (mOutputFluid != null) + if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); + else if (mOutputFluid.isFluidEqual(getDrainableStack())) + getDrainableStack().amount += mOutputFluid.amount; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + mEUt = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mStuttering = false; + tSucceeded = true; + endProcess(); + } + if (mProgresstime > 5) mStuttering = false; + XSTR aXSTR = new XSTR(); + if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + } else { + if (!mStuttering) { + stutterProcess(); + if (canHaveInsufficientEnergy()) mProgresstime = -100; + mStuttering = true; + } + } + } else { + aBaseMetaTileEntity.setActive(false); + } + + boolean tRemovedOutputFluid = false; + Utils.LOG_INFO("R0"); + + if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { + IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTank != null) { + FluidStack tDrained = drain(1000, false); + if (tDrained != null) { + int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + if (tFilledAmount > 0) + tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); + } + } + if (getDrainableStack() == null) tRemovedOutputFluid = true; + } + + if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { + TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); + for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { + tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); + } + } + + if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; + else mOutputBlocked++; + Utils.LOG_INFO("R1"); + if (allowToCheckRecipe()) { + Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_INFO("R2: (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe())"); + Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_INFO("R2-mMaxProgresstime: "+mMaxProgresstime); + Utils.LOG_INFO("R2-isAllowedToWork(): "+aBaseMetaTileEntity.isAllowedToWork()); + Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_INFO("R2-tRemovedOutputFluid: "+tRemovedOutputFluid); + Utils.LOG_INFO("R2-tSucceeded: "+tSucceeded); + Utils.LOG_INFO("R2-hasInventoryBeenModified(): "+aBaseMetaTileEntity.hasInventoryBeenModified()); + Utils.LOG_INFO("R2-(aTick % 600 == 0): "+(aTick % 600 == 0)); + Utils.LOG_INFO("R2-hasWorkJustBeenEnabled(): "+aBaseMetaTileEntity.hasWorkJustBeenEnabled()); + Utils.LOG_INFO("R2--------------------------------------------------"); + Utils.LOG_INFO("R2-hasEnoughEnergyToCheckRecipe(): "+hasEnoughEnergyToCheckRecipe()); + Utils.LOG_INFO("R2--------------------------------------------------"); + if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { + Utils.LOG_INFO("R3"); + if (checkRecipe() == 2) { + if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; + Utils.LOG_INFO("R4"); + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + for (int i = 0; i < mOutputItems.length; i++) { + mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); + if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) + mOutputItems[i].stackSize = 64; + mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); + } + if (mFluid != null && mFluid.amount <= 0) mFluid = null; + mMaxProgresstime = Math.max(1, mMaxProgresstime); + if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { + mEUt = mMaxProgresstime = 1; + } + startProcess(); + } else { + mMaxProgresstime = 0; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + mOutputFluid = null; + } + } + } else { + if (!mStuttering) { + stutterProcess(); + mStuttering = true; + } + } + } + } + + protected void doDisplayThings() { + if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { + mMainFacing = getBaseMetaTileEntity().getFrontFacing(); + } + if (mMainFacing >= 2 && !mHasBeenUpdated) { + mHasBeenUpdated = true; + //getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); + } + + if (displaysInputFluid()) { + int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + if (getFillableStack() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) + mInventory[tDisplayStackSlot] = null; + } else { + mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); + } + } + } + + protected boolean hasEnoughEnergyToCheckRecipe() { + return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); + } + + protected boolean drainEnergyForProcess(long aEUt) { + return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); + } + + protected void calculateOverclockedNess(GT_Recipe aRecipe) { + calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); + } + + protected void calculateOverclockedNess(int aEUt, int aDuration) { + if (aEUt <= 16) { + mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); + mMaxProgresstime = aDuration / (1 << (mTier - 1)); + } else { + mEUt = aEUt; + mMaxProgresstime = aDuration; + while (mEUt <= V[mTier - 1] * mAmperage) { + mEUt *= 4; + mMaxProgresstime /= 2; + } + } + } + + protected ItemStack getSpecialSlot() { + return mInventory[3]; + } + + protected ItemStack getOutputAt(int aIndex) { + return mInventory[getOutputSlot() + aIndex]; + } + + protected ItemStack[] getAllOutputs() { + ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; + for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); + return rOutputs; + } + + protected boolean canOutput(GT_Recipe aRecipe) { + return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); + } + + protected boolean canOutput(ItemStack... aOutputs) { + if (aOutputs == null) return true; + ItemStack[] tOutputSlots = getAllOutputs(); + for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) + if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { + mOutputBlocked++; + return false; + } + return true; + } + + protected boolean canOutput(FluidStack aOutput) { + return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); + } + + protected ItemStack getInputAt(int aIndex) { + return mInventory[getInputSlot() + aIndex]; + } + + protected ItemStack[] getAllInputs() { + ItemStack[] rInputs = new ItemStack[mInputSlotCount]; + for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); + return rInputs; + } + + protected boolean isOutputEmpty() { + boolean rIsEmpty = true; + for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; + return rIsEmpty; + } + + protected boolean displaysInputFluid() { + return true; + } + + protected boolean displaysOutputFluid() { + return true; + } + + @Override + public void onValueUpdate(byte aValue) { + mMainFacing = aValue; + } + + @Override + public byte getUpdateData() { + return (byte) mMainFacing; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + super.doSound(aIndex, aX, aY, aZ); + if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); + } + + public boolean doesAutoOutput() { + return mItemTransfer; + } + + public boolean doesAutoOutputFluids() { + return mFluidTransfer; + } + + public boolean allowToCheckRecipe() { + return true; + } + + public boolean showPipeFacing() { + return true; + } + + /** + * Called whenever the Machine successfully started a Process, useful for Sound Effects + */ + public void startProcess() { + // + } + + /** + * Called whenever the Machine successfully finished a Process, useful for Sound Effects + */ + public void endProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process, useful for Sound Effects + */ + public void abortProcess() { + // + } + + /** + * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects + */ + public void stutterProcess() { + if (useStandardStutterSound()) sendSound((byte) 8); + } + + /** + * If this Machine can have the Insufficient Energy Line Problem + */ + public boolean canHaveInsufficientEnergy() { + return true; + } + + public boolean useStandardStutterSound() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + mNEIName, + "Progress:", (mProgresstime / 20) + " secs", + (mMaxProgresstime / 20) + " secs", + "Stored Energy:", + getBaseMetaTileEntity().getStoredEU() + "EU", + getBaseMetaTileEntity().getEUCapacity() + "EU"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { + mAllowInputFromOutputSide = !mAllowInputFromOutputSide; + GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? trans("095","Input from Output Side allowed") : trans("096","Input from Output Side forbidden")); + } + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) + return false; + for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; + return true; + } + + /** + * @return the Recipe List which is used for this Machine, this is a useful Default Handler + */ + public GT_Recipe_Map getRecipeList() { + return null; + } + + /** + * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case + *

+ * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. + *

+ * Funny how Eclipse marks the word Enum as not correctly spelled. + * + * @return see constants above + */ + public int checkRecipe() { + return checkRecipe(false); + } + + public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId){ + return //TODO check or get a better solution + DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") || + DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") || + DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); + } + + + /** + * + * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... + * @return + */ + public int checkRecipe(boolean skipOC){ + GT_Recipe_Map tMap = getRecipeList(); + if (tMap == null) return DID_NOT_FIND_RECIPE; + GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); + if (tRecipe == null) return DID_NOT_FIND_RECIPE; + + if (GT_Mod.gregtechproxy.mLowGravProcessing && tRecipe.mSpecialValue == -100 && + !isValidForLowGravity(tRecipe,getBaseMetaTileEntity().getWorld().provider.dimensionId)) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; + if (!canOutput(tRecipe)) { + mOutputBlocked++; + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } + if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < mOutputItems.length; i++) + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) + mOutputItems[i] = tRecipe.getOutput(i); + mOutputFluid = tRecipe.getFluidOutput(0); + calculateOverclockedNess(tRecipe); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + + public ITexture[] getSideFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSideFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTopFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottomFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getTopFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getSideFacingPipeInactive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index fbf615a499..be1ceb2fd7 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -62,6 +62,12 @@ public class TexturesGtBlock { public static final CustomIcon _PlaceHolder = Internal_PlaceHolder; + //Controllers + private static final CustomIcon Internal_Casing_Fusion_Simple_Front = new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT"); + public static final CustomIcon Casing_Fusion_Simple_Front = Internal_Casing_Fusion_Simple_Front; + private static final CustomIcon Internal_Casing_Fusion_Simple_Front_Active = new CustomIcon("TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE"); + public static final CustomIcon Casing_Fusion_Simple_Front_Active = Internal_Casing_Fusion_Simple_Front_Active; + //Machine Casings //Simple private static final CustomIcon Internal_Casing_Machine_Simple_Top = new CustomIcon("TileEntities/machine_top"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java index 3474431355..8ca0a672b2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaPollutionDetector.java @@ -191,7 +191,7 @@ public class GregtechMetaPollutionDetector extends GregtechMetaTileEntity { } else { PlayerUtils.messagePlayer(playerIn, "This chunk contains "+getCurrentChunkPollution()+" pollution."); - PlayerUtils.messagePlayer(playerIn, "Average over last ten minutes: "+getAveragePollutionOverLastTen()+" pollution."); + PlayerUtils.messagePlayer(playerIn, "Emit Redstone at pollution level: "+this.mRedstoneLevel); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java new file mode 100644 index 0000000000..b604eb94a2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java @@ -0,0 +1,687 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.ArrayList; +import java.util.Random; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeMachine; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_CompactFusionReactor +extends +GT_MetaTileEntity_DeluxeMachine { + + private boolean mCanProcessRecipe = false; + private boolean mCharging = false; + private long mChargeConsumed = 0; + + private GT_Recipe mLastRecipe; + private long mEUStore; + private boolean mRunningOnLoad = false; + private boolean mMachine = false; + private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; + private int mStartUpCheck = 100, mUpdate = 0; + private FluidStack[] mOutputFluids = null; + + public GregtechMetaTileEntity_CompactFusionReactor(int aID, String aName, + String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, + 1, "PotionBrewer.png", ""); + } + + public GregtechMetaTileEntity_CompactFusionReactor(String aName, int aTier, + String aDescription, ITexture[][][] aTextures, String aGUIName, + String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, + aNEIName); + } + + @Override + public String[] getDescription() { + return new String[]{this.mDescription, + "Not Very Fast, but not very big either.", + "Each side pair in/out puts to different slots.", + "Top & Bottom Sides are Outputs.", + "Front & Back are Input Plasma 1.", "Sides are Input Plasma 2.", + CORE.GT_Tooltip}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_CompactFusionReactor(this.mName, + this.mTier, this.mDescription, this.mTextures, this.mGUIName, + this.mNEIName); + } + + public int tier() { + return this.mTier; + } + + public int tierOverclock() { + return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; + } + + private GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + + @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]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, + int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + && (getRecipeList().containsInput(aStack)); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().contains("plasma")) + || (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public void abortProcess() { + super.abortProcess(); + } + + long mFusionPoint = 20000000L; + @Override + public int checkRecipe() { + Utils.LOG_INFO("Recipe Tick 1."); + if (!this.mCanProcessRecipe) { + Utils.LOG_INFO("Recipe Tick 1.1 - Cannot Process Recipe."); + if (this.mChargeConsumed < mFusionPoint) { + Utils.LOG_INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); + this.mCharging = true; + this.mCanProcessRecipe = false; + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits( + (mFusionPoint / 100), false)) { + Utils.LOG_INFO("Recipe Tick 1.3 - Charging Internal storage. "+(mFusionPoint / 100)+"/"+mFusionPoint); + mChargeConsumed += (mFusionPoint / 100); + } + } else { + mChargeConsumed = 0; + this.mCharging = false; + this.mCanProcessRecipe = true; + + } + } else { + Utils.LOG_INFO("Recipe Tick 1.1 - Try to Process Recipe."); + if (checkRecipeMulti()) { + Utils.LOG_INFO("Recipe Tick 1.2 - Process Recipe was Successful."); + return 2; + } + } + Utils.LOG_INFO("Recipe Tick 2. - Process Recipe failed."); + return 0; + } + + public ArrayList getStoredFluids() { + ArrayList mList = new ArrayList(); + mList.add(this.mFluid); + mList.add(this.mFluid2); + return mList; + } + + public boolean checkRecipeMulti() { + ArrayList tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), + (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList + .get(i)).amount >= ((FluidStack) tFluidList + .get(j)).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } + } + } + } + if (tFluidList.size() > 1) { + FluidStack[] tFluids = tFluidList + .toArray(new FluidStack[tFluidList.size()]); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sFusionRecipes + .findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, + false, GT_Values.V[8], tFluids, new ItemStack[]{}); + if ((tRecipe == null && !mRunningOnLoad) + || (maxEUStore() < tRecipe.mSpecialValue)) { + this.mLastRecipe = null; + return false; + } + if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, + new ItemStack[]{})) { + this.mLastRecipe = tRecipe; + this.mEUt = (this.mLastRecipe.mEUt + * overclock(this.mLastRecipe.mSpecialValue)); + this.mMaxProgresstime = this.mLastRecipe.mDuration + / overclock(this.mLastRecipe.mSpecialValue); + + this.mEfficiencyIncrease = 10000; + + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + mRunningOnLoad = false; + return true; + } + } + return false; + } + + public int overclock(int mStartEnergy) { + if (tierOverclock() == 1) { + return 1; + } + if (tierOverclock() == 2) { + return mStartEnergy < 160000000 ? 2 : 1; + } + return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean doesAutoOutputFluids() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public long maxAmperesIn() { + return 16L; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower * 2); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + onRunningTickMulti(); + if ((aBaseMetaTileEntity.isClientSide()) + && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) + && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + if (MathUtils.randInt(0, 4) == 4) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.8F) + - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) + - (tRandom.nextFloat() * 1.6F), + 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.4F) + - (tRandom.nextFloat() * 0.3F), + aBaseMetaTileEntity.getYCoord() + 0.2f + + (tRandom.nextFloat() * 0.1F), + (aBaseMetaTileEntity.getZCoord() + 0.8F) + - (tRandom.nextFloat() * 0.6F), + 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.6F) + - (tRandom.nextFloat() * 0.9F), + aBaseMetaTileEntity.getYCoord() + 0.4f + + (tRandom.nextFloat() * 0.3F), + (aBaseMetaTileEntity.getZCoord() + 1.8F) + - (tRandom.nextFloat() * 2.6F), + 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); + aNBT.setBoolean("mCharging", this.mCharging); + aNBT.setLong("mChargeConsumed", this.mChargeConsumed); + aNBT.setInteger("mEfficiency", this.mEfficiency); + aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); + aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); + aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); + aNBT.setInteger("mUpdate", mUpdate); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); + aNBT.setBoolean("mMachine", this.mMachine); + aNBT.setLong("mEUStore", this.mEUStore); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (mMaxProgresstime > 0) + mRunningOnLoad = true; + this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); + this.mCharging = aNBT.getBoolean("mCharging"); + this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); + this.mEfficiency = aNBT.getInteger("mEfficiency"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); + this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); + this.mUpdate = aNBT.getInteger("mUpdate"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); + this.mMachine = aNBT.getBoolean("mMachine"); + this.mEUStore = aNBT.getLong("mEUStore"); + super.loadNBTData(aNBT); + } + + @Override + public String[] getInfoData() { + String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; + float plasmaOut = 0; + String fusionName = ""; + int powerRequired = 0; + if (this.mLastRecipe != null) { + fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName()+" Fusion."; + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount + / (float) this.mLastRecipe.mDuration; + } + } + + return new String[]{"Fusion Reactor MK " + tier, + "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), + "Plasma Output: " + plasmaOut + "L/t", + "Current Recipe: "+fusionName}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( + TexturesGtBlock.Overlay_MatterFab)}; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[]{this.getCasingTexture(),new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( + TexturesGtBlock.Overlay_Machine_Dimensional_Blue)}; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( + TexturesGtBlock.Overlay_MatterFab_Active)}; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[]{ + this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[]{ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( + TexturesGtBlock.Overlay_Machine_Dimensional_Blue)}; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, + long aTick) { + //super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + Utils.LOG_INFO("1"); + if (mEfficiency < 0) + mEfficiency = 0; + if (mRunningOnLoad) { + Utils.LOG_INFO("2"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipeMulti(); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + Utils.LOG_INFO("3"); + mMachine = true; + } + if (mStartUpCheck < 0) { + Utils.LOG_INFO("4"); + if (mMachine) { + Utils.LOG_INFO("5"); + + if (aBaseMetaTileEntity.getStoredEU() + + (2048 * tierOverclock()) < maxEUStore()) { + aBaseMetaTileEntity.increaseStoredEnergyUnits( + 2048 * tierOverclock(), true); + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + Utils.LOG_INFO("6"); + stopMachine(); + this.mLastRecipe = null; + } + if (mMaxProgresstime > 0) { + Utils.LOG_INFO("7"); + this.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) + if (tStack != null) + addOutput(tStack); + mEfficiency = Math.max(0, + (mEfficiency + mEfficiencyIncrease)); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + + } + this.mEUStore = (int) aBaseMetaTileEntity + .getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipeMulti(); + } + } else { + Utils.LOG_INFO("8"); + if (aTick % 100 == 0 + || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity + .hasInventoryBeenModified()) { + Utils.LOG_INFO("9"); + // turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + Utils.LOG_INFO("10"); + this.mEUStore = (int) aBaseMetaTileEntity + .getStoredEU(); + if (checkRecipeMulti()) { + Utils.LOG_INFO("11"); + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + Utils.LOG_INFO("12"); + mMaxProgresstime = 0; + // turnCasingActive(false); + } + aBaseMetaTileEntity + .decreaseStoredEnergyUnits( + this.mLastRecipe.mSpecialValue, + true); + } + } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + // turnCasingActive(false); + Utils.LOG_INFO("Bad"); + this.mLastRecipe = null; + stopMachine(); + } + } + Utils.LOG_INFO("Good"); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean onRunningTickMulti() { + if (mEUt < 0) { + if (!drainEnergyInput( + ((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + this.mLastRecipe = null; + stopMachine(); + return false; + } + } + if (this.mEUStore <= 0) { + this.mLastRecipe = null; + stopMachine(); + return false; + } + return true; + } + + public boolean drainEnergyInput(long aEU) { + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) + return false; + FluidStack copiedFluidStack = aLiquid.copy(); + this.mOutputFluid = copiedFluidStack; + return false; + } + + public void stopMachine() { + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + @Override + public boolean isLiquidInput(byte aSide) { + switch(aSide) { + case 0 : + return true; + case 1 : + return true; + case 2 : + return true; + case 3 : + return false; + case 4 : + return false; + case 5 : + return false; + default : + return false; + } + } + + @Override + public boolean isLiquidOutput(byte aSide) { + switch(aSide) { + case 0 : + return false; + case 1 : + return false; + case 2 : + return false; + case 3 : + return true; + case 4 : + return true; + case 5 : + return true; + default : + return true; + } + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + // TODO Auto-generated method stub + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + // TODO Auto-generated method stub + return super.drain(maxDrain, doDrain); + } + + @Override + public int getTankPressure() { + // TODO Auto-generated method stub + return 500; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return false; + } + else { + return super.canFill(aSide, aFluid); + } + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return super.canDrain(aSide, aFluid); + } + else { + return false; + } + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, + boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return 0; + } + else { + return super.fill_default(aSide, aFluid, doFill); + } + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return super.fill(aSide, aFluid, doFill); + } + else { + return 0; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, + boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return super.drain(aSide, aFluid, doDrain); + } + else { + return null; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, + boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN){ + return super.drain(aSide, maxDrain, doDrain); + } + else { + return null; + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java new file mode 100644 index 0000000000..d48815e563 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.gregtech.registration.gregtech; + +import java.util.Collection; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_BasicWasher; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_CompactFusionReactor; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMiniRaFusion { + + public static void run() { + //if (CORE.configSwitches.enableMachine_SimpleWasher){ + generateSlowFusionRecipes(); + // Register the Simple Fusion Entity. + GregtechItemList.Miniature_Fusion + .set(new GregtechMetaTileEntity_CompactFusionReactor(993, "simplefusion.tier.00", "Ra, Sun God - Mk I", 6) + .getStackForm(1L)); + //} + } + + private static boolean generateSlowFusionRecipes(){ + int mRecipeCount = 0; + GT_Recipe_Map r = GT_Recipe.GT_Recipe_Map.sFusionRecipes; + final Collection x = r.mRecipeList; + Utils.LOG_INFO("Dumping " + r.mUnlocalizedName + " Recipes for Debug."); + for (final GT_Recipe newBo : x) { + if (Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.addRecipe( + true, + newBo.mInputs, + newBo.mOutputs, + newBo.mSpecialItems, + newBo.mFluidInputs.clone(), //Fluid In + newBo.mFluidOutputs.clone(), //Fluid Out + newBo.mDuration*4, //Duration + newBo.mEUt, //Eu + newBo.mSpecialValue //Special + ) != null){ + mRecipeCount++; + } + } + + + + if (Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.mRecipeList.size() > mRecipeCount){ + return true; + } + return false; + } +} diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT.png new file mode 100644 index 0000000000..05c8741fa7 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE.png b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE.png new file mode 100644 index 0000000000..4f7290c571 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/TileEntities/MACHINE_CASING_FUSION_FRONT_ACTIVE.png differ -- cgit From 4487354c88d814123e1374198d96275ac8c85406 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 17 Nov 2017 15:54:35 +1000 Subject: ^ Version Bump. % Tweaked SFR side texture when active. --- build.gradle | 2 +- src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- .../machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java | 2 +- src/resources/mcmod.info | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/build.gradle b/build.gradle index efbc8c0232..1321368c96 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ sourceCompatibility = 1.7 targetCompatibility = 1.7 archivesBaseName = "GT-PlusPlus" -version = "1.6.91-release" +version = "1.6.93-release" minecraft.version = "1.7.10-10.13.4.1448-1.7.10" diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 6cb37837aa..cdccd4164f 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -35,7 +35,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.6.91-release"; + public static final String VERSION = "1.6.93-release"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java index b604eb94a2..2572f36372 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_CompactFusionReactor.java @@ -399,7 +399,7 @@ GT_MetaTileEntity_DeluxeMachine { public ITexture[] getSides(final byte aColor) { return new ITexture[]{this.getCasingTexture(), new GT_RenderedTexture( - TexturesGtBlock.Overlay_Machine_Dimensional_Blue)}; + TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; } public ITexture[] getFrontActive(final byte aColor) { diff --git a/src/resources/mcmod.info b/src/resources/mcmod.info index 68f69d5530..032322a414 100644 --- a/src/resources/mcmod.info +++ b/src/resources/mcmod.info @@ -5,7 +5,7 @@ "description": "Adds a few various Multiblocks, Machines, etc to Gregtech and a plethora of other mods (Nearly 30!)", "credits": "", "logoFile": "", - "version": "1.6.91-release", + "version": "1.6.93-release", "mcversion": "1.7.10", "url": "https://github.com/draknyte1/GTplusplus/wiki", "updateUrl": "https://github.com/draknyte1/GTplusplus/releases/latest", -- cgit From e8fa34d3ba219a21bcce0cdb07ede8dcdfe9dcb9 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 17 Nov 2017 18:38:00 +1000 Subject: $ Fixed capes. My bad. + Added new textures for capes. ^ Version bump. --- build.gradle | 2 +- src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- .../xmod/gregtech/common/render/GTPP_CapeRenderer.java | 12 ++++++------ src/resources/assets/miscutils/textures/DevCapeHD.png | Bin 0 -> 12011 bytes src/resources/assets/miscutils/textures/FancyCapeHD.png | Bin 0 -> 9643 bytes src/resources/assets/miscutils/textures/OrangeHD.png | Bin 0 -> 7652 bytes .../assets/miscutils/textures/TesterCapeHD.png | Bin 0 -> 8215 bytes src/resources/mcmod.info | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 src/resources/assets/miscutils/textures/DevCapeHD.png create mode 100644 src/resources/assets/miscutils/textures/FancyCapeHD.png create mode 100644 src/resources/assets/miscutils/textures/OrangeHD.png create mode 100644 src/resources/assets/miscutils/textures/TesterCapeHD.png (limited to 'src/Java/gtPlusPlus/core') diff --git a/build.gradle b/build.gradle index 1321368c96..c6bafd9207 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ sourceCompatibility = 1.7 targetCompatibility = 1.7 archivesBaseName = "GT-PlusPlus" -version = "1.6.93-release" +version = "1.6.94-release" minecraft.version = "1.7.10-10.13.4.1448-1.7.10" diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index cdccd4164f..1099679f5e 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -35,7 +35,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.6.93-release"; + public static final String VERSION = "1.6.94-release"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index 89b144fc5f..4cbd3c7205 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -17,7 +17,7 @@ import java.util.Collection; public class GTPP_CapeRenderer extends RenderPlayer { - private final ResourceLocation[] mCapes = {new ResourceLocation("miscutils:textures/Orange.png"), new ResourceLocation("miscutils:textures/TesterCape.png"), new ResourceLocation("miscutils:textures/FancyCape.png"), new ResourceLocation("miscutils:textures/DevCape.png")}; + private final ResourceLocation[] mCapes = {new ResourceLocation("miscutils:textures/OrangeHD.png"), new ResourceLocation("miscutils:textures/TesterCapeHD.png"), new ResourceLocation("miscutils:textures/FancyCapeHD.png"), new ResourceLocation("miscutils:textures/TesterCapeHD.png")}; private final Collection mCapeList; public GTPP_CapeRenderer(Collection aCapeList) { @@ -26,9 +26,9 @@ public class GTPP_CapeRenderer } private final String[] mOrangeCapes = {"ImmortalPharaoh7", "Walmart_Employee", "ArchonCerulean", "asturrial"}; //Orange.png - private final String[] mBlueCapes = {"fobius", "cantankerousrex", "stephen_2015", "Dyonovan", "Bear989Sr", "CrazyJ1984"}; //Fancycape.png - private final String[] mTestCapes = {"123_456_789", "doomsquirter", "ukdunc"}; //TesterCape.png - private final String[] mDevCapes = {"draknyte1", "redmage17"}; //Capes for Developers + private final String[] mTestCapes = {"123_456_789", "doomsquirter", "ukdunc"}; //TesterCape.png + private final String[] mBlueCapes = {"fobius", "cantankerousrex", "stephen_2015", "Dyonovan", "Bear989Sr", "CrazyJ1984"}; //Fancycape.png + private final String[] mDevCapes = {"draknyte1", "redmage17"}; //Capes for Developers public void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { @@ -52,12 +52,12 @@ public class GTPP_CapeRenderer tResource = this.mCapes[0]; } } - for (String mName : mBlueCapes){ + for (String mName : mTestCapes){ if (mName.toLowerCase().contains(aPlayer.getDisplayName().toLowerCase())) { tResource = this.mCapes[1]; } } - for (String mName : mTestCapes){ + for (String mName : mBlueCapes){ if (mName.toLowerCase().contains(aPlayer.getDisplayName().toLowerCase())) { tResource = this.mCapes[2]; } diff --git a/src/resources/assets/miscutils/textures/DevCapeHD.png b/src/resources/assets/miscutils/textures/DevCapeHD.png new file mode 100644 index 0000000000..e979848c69 Binary files /dev/null and b/src/resources/assets/miscutils/textures/DevCapeHD.png differ diff --git a/src/resources/assets/miscutils/textures/FancyCapeHD.png b/src/resources/assets/miscutils/textures/FancyCapeHD.png new file mode 100644 index 0000000000..d8da3ba76d Binary files /dev/null and b/src/resources/assets/miscutils/textures/FancyCapeHD.png differ diff --git a/src/resources/assets/miscutils/textures/OrangeHD.png b/src/resources/assets/miscutils/textures/OrangeHD.png new file mode 100644 index 0000000000..b7dfa6d79a Binary files /dev/null and b/src/resources/assets/miscutils/textures/OrangeHD.png differ diff --git a/src/resources/assets/miscutils/textures/TesterCapeHD.png b/src/resources/assets/miscutils/textures/TesterCapeHD.png new file mode 100644 index 0000000000..274ba1bd44 Binary files /dev/null and b/src/resources/assets/miscutils/textures/TesterCapeHD.png differ diff --git a/src/resources/mcmod.info b/src/resources/mcmod.info index 032322a414..7140a5b320 100644 --- a/src/resources/mcmod.info +++ b/src/resources/mcmod.info @@ -5,7 +5,7 @@ "description": "Adds a few various Multiblocks, Machines, etc to Gregtech and a plethora of other mods (Nearly 30!)", "credits": "", "logoFile": "", - "version": "1.6.93-release", + "version": "1.6.94-release", "mcversion": "1.7.10", "url": "https://github.com/draknyte1/GTplusplus/wiki", "updateUrl": "https://github.com/draknyte1/GTplusplus/releases/latest", -- cgit From 04344136279524749cc07dc979c18baee6a72e4d Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sat, 18 Nov 2017 05:46:28 +1000 Subject: + Added the Grindle, a portable E-reader for Data-Sticks. --- .../core/container/Container_Grindle.java | 182 ++++++++++++++++ .../gtPlusPlus/core/gui/item/GuiBaseGrindle.java | 141 ++++++++++++ src/Java/gtPlusPlus/core/handler/GuiHandler.java | 11 + .../core/inventories/BaseInventoryGrindle.java | 240 +++++++++++++++++++++ src/Java/gtPlusPlus/core/item/ModItems.java | 4 + .../core/item/general/BaseItemGrindle.java | 87 ++++++++ .../gregtech/common/render/GTPP_CapeRenderer.java | 2 +- .../assets/miscutils/textures/gui/itemGrindle.png | Bin 0 -> 1812 bytes .../assets/miscutils/textures/items/itemTablet.png | Bin 0 -> 372 bytes 9 files changed, 666 insertions(+), 1 deletion(-) create mode 100644 src/Java/gtPlusPlus/core/container/Container_Grindle.java create mode 100644 src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java create mode 100644 src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java create mode 100644 src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java create mode 100644 src/resources/assets/miscutils/textures/gui/itemGrindle.png create mode 100644 src/resources/assets/miscutils/textures/items/itemTablet.png (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/container/Container_Grindle.java b/src/Java/gtPlusPlus/core/container/Container_Grindle.java new file mode 100644 index 0000000000..8b218f5993 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_Grindle.java @@ -0,0 +1,182 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.slots.SlotDataStick; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class Container_Grindle extends Container +{ + /** The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer */ + public final BaseInventoryGrindle inventory; + + /** Using these will make transferStackInSlot easier to understand and implement + * INV_START is the index of the first slot in the Player's Inventory, so our + * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, so start at 5) + * Notice how we don't have to remember how many slots we made? We can just use + * BaseInventoryBackpack.INV_SIZE and if we ever change it, the Container updates automatically. */ + private static final int INV_START = BaseInventoryGrindle.INV_SIZE, INV_END = INV_START+0, + HOTBAR_START = INV_END, HOTBAR_END = HOTBAR_START+8; + + // If you're planning to add armor slots, put those first like this: + // ARMOR_START = BaseInventoryBackpack.INV_SIZE, ARMOR_END = ARMOR_START+3, + // INV_START = ARMOR_END+1, and then carry on like above. + + public Container_Grindle(final EntityPlayer par1Player, final InventoryPlayer inventoryPlayer, final BaseInventoryGrindle inventoryItem) + { + this.inventory = inventoryItem; + + int i; + + //Actual Scan Slot + this.addSlotToContainer(new SlotDataStick(this.inventory, 0, 152, 5)); + + for (i = 1; i < BaseInventoryGrindle.INV_SIZE; ++i){ + this.addSlotToContainer(new SlotDataStick(this.inventory, i, 153, 30+(18*i))); + } + + // PLAYER ACTION BAR - uses default locations for standard action bar texture file + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); + } + } + + @Override + public boolean canInteractWith(final EntityPlayer entityplayer) + { + // be sure to return the inventory's isUseableByPlayer method + // if you defined special behavior there: + return this.inventory.isUseableByPlayer(entityplayer); + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. + */ + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) + { + ItemStack itemstack = null; + final Slot slot = (Slot) this.inventorySlots.get(index); + + if ((slot != null) && slot.getHasStack()) + { + final ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + // If item is in our custom Inventory or armor slot + if (index < INV_START) + { + // try to place in player inventory / action bar + if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END+1, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + // Item is in inventory / hotbar, try to place in custom inventory or armor slots + else + { + /* + If your inventory only stores certain instances of Items, + you can implement shift-clicking to your inventory like this: + + // Check that the item is the right type + if (itemstack1.getItem() instanceof ItemCustom) + { + // Try to merge into your custom inventory slots + // We use 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case + // you also add armor or other custom slots + if (!this.mergeItemStack(itemstack1, 0, BaseInventoryBackpack.INV_SIZE, false)) + { + return null; + } + } + // If you added armor slots, check them here as well: + // Item being shift-clicked is armor - try to put in armor slot + if (itemstack1.getItem() instanceof ItemArmor) + { + int type = ((ItemArmor) itemstack1.getItem()).armorType; + if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false)) + { + return null; + } + } + Otherwise, you have basically 2 choices: + 1. shift-clicking between player inventory and custom inventory + 2. shift-clicking between action bar and inventory + + Be sure to choose only ONE of the following implementations!!! + */ + /** + * Implementation number 1: Shift-click into your custom inventory + */ + if (index >= INV_START) + { + // place in custom inventory + if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) + { + return null; + } + } + + /** + * Implementation number 2: Shift-click items between action bar and inventory + */ + // item is in player's inventory, but not in action bar + if ((index >= INV_START) && (index < HOTBAR_START)) + { + // place in action bar + if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END+1, false)) + { + return null; + } + } + // item in action bar - place in player inventory + else if ((index >= HOTBAR_START) && (index < (HOTBAR_END+1))) + { + if (!this.mergeItemStack(itemstack1, INV_START, INV_END+1, false)) + { + return null; + } + } + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + /** + * You should override this method to prevent the player from moving the stack that + * opened the inventory, otherwise if the player moves it, the inventory will not + * be able to save properly + */ + @Override + public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) { + // this will prevent the player from interacting with the item that opened the inventory: + if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) { + return null; + } + return super.slotClick(slot, button, flag, player); + } +} diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java new file mode 100644 index 0000000000..798b74b48f --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java @@ -0,0 +1,141 @@ +package gtPlusPlus.core.gui.item; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GT_Utility.ItemNBT; +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.nbt.NBTUtils; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.ResourceLocation; + +public class GuiBaseGrindle extends GuiContainer { + + /** The FontRenderer used by GuiScreen */ + protected FontRenderer fontRenderer; + + private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, "textures/gui/itemGrindle.png"); + + /** The inventory to render on screen */ + private final BaseInventoryGrindle inventory; + + public GuiBaseGrindle(final Container_Grindle containerItem){ + super(containerItem); + this.inventory = containerItem.inventory; + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(final int par1, final int par2, final float par3){ + super.drawScreen(par1, par2, par3); + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2){ + final String s = "Git"; + //Title + this.fontRendererObj.drawStringWithShadow(I18n.format("Gregtech Information Transponder", new Object[0]), 0, -12, Utils.rgbtoHexValue(255, 255, 255)); + + if (this.inventory.getStackInSlot(0) != null){ + this.fontRendererObj.drawString(I18n.format(""+NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), 10, 8, Utils.rgbtoHexValue(125, 255, 125)); + + if (!NBTUtils.tryIterateNBTData(this.inventory.getStackInSlot(0))){ + this.fontRendererObj.drawString(I18n.format("Very Bad prospection data.", new Object[0]), 10, 38, Utils.rgbtoHexValue(255, 125, 125)); + } + + NBTTagCompound tNBT = ItemNBT.getNBT(this.inventory.getStackInSlot(0)); + byte tTier = tNBT.getByte("prospection_tier"); + //List Tier + //this.fontRendererObj.drawStringWithShadow(I18n.format("Tier: "+tTier, new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125)); + + if (tTier == 0) { // basic prospection data + String tData = tNBT.getString("prospection"); + //List prospection + //this.fontRendererObj.drawStringWithShadow(I18n.format("Prospection : "+tData, new Object[0]), 10, 28, Utils.rgbtoHexValue(125, 255, 125)); + + String[] tDataArray = tData.split(","); + if (tDataArray.length > 6) { + tNBT.setString("author", "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2] + " Dim: " + tDataArray[3]); + //List prospection + this.fontRendererObj.drawString(I18n.format("X: " + tDataArray[0], new Object[0]), 10, 28, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Y: " + tDataArray[1], new Object[0]), 10, 38, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Z: " + tDataArray[2], new Object[0]), 10, 48, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Dim: " + tDataArray[3], new Object[0]), 10, 58, Utils.rgbtoHexValue(125, 125, 255)); + + //Divider + this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 63, Utils.rgbtoHexValue(125, 125, 255)); + + NBTTagList tNBTList = new NBTTagList(); + String[] mOreTypes = new String[50]; + String tOres = " Prospected Ores: "; + for (int i = 6; tDataArray.length > i; i++) { + mOreTypes[i] = (tDataArray[i] + " "); + if ((68+(i-6)*8) < (68+56)){ + this.fontRendererObj.drawString(I18n.format(mOreTypes[i], new Object[0]), 10, 68+((i-6)*8), Utils.rgbtoHexValue(125, 255, 125)); + } + } + Utils.LOG_INFO("test - "+tOres); + tNBTList.appendTag(new NBTTagString("Prospection Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres)); + tNBT.setTag("pages", tNBTList); + + + //List prospection + this.fontRendererObj.drawString(I18n.format("Tier: "+tTier+ " | Pages: "+tNBTList.tagCount(), new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125)); + //Divider + this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 23, Utils.rgbtoHexValue(125, 125, 255)); + + } + else { + this.fontRendererObj.drawString(I18n.format("Bad prospection data.", new Object[0]), 10, 68, Utils.rgbtoHexValue(255, 125, 125)); + } + } + } + else { + //Valid Datastick? + this.fontRendererObj.drawStringWithShadow(I18n.format("Insert device into port.", new Object[0]), 10, 8, Utils.rgbtoHexValue(255, 125, 125)); + } + + + + //Inventory Label + this.fontRendererObj.drawStringWithShadow(I18n.format("container.inventory", new Object[0]), 8, 131, Utils.rgbtoHexValue(255, 255, 255)); + + //this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 0, 4210752); + //this.fontRenderer.drawString(I18n.translate("container.inventory"), 26, this.ySize - 96 + 4, 4210752); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int i1; + //drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) - 50 - this.ySize_lo, this.mc.thePlayer); + } +} diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 70e2934349..124b01a2c0 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -7,9 +7,11 @@ import gtPlusPlus.core.container.*; import gtPlusPlus.core.gui.beta.Gui_ID_Registry; import gtPlusPlus.core.gui.beta.MU_GuiId; import gtPlusPlus.core.gui.item.GuiBaseBackpack; +import gtPlusPlus.core.gui.item.GuiBaseGrindle; import gtPlusPlus.core.gui.machine.*; import gtPlusPlus.core.interfaces.IGuiManager; import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; @@ -33,6 +35,7 @@ public class GuiHandler implements IGuiHandler { public static final int GUI6 = 5; //Fish trap public static final int GUI7 = 6; //Trade table public static final int GUI8 = 7; // + public static final int GUI9 = 8; // @@ -80,6 +83,10 @@ public class GuiHandler implements IGuiHandler { return new Container_TradeTable(player.inventory, (TileEntityTradeTable)te); } } + + if (ID == GUI9){ + return new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())); + } @@ -125,6 +132,10 @@ public class GuiHandler implements IGuiHandler { return new GUI_TradeTable(player.inventory, (TileEntityTradeTable)te, ((TileEntityBase) te).getOwner()); } } + + if (ID == GUI9){ + return new GuiBaseGrindle(new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem()))); + } return null; } diff --git a/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java b/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java new file mode 100644 index 0000000000..ca7fcd6d03 --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java @@ -0,0 +1,240 @@ +package gtPlusPlus.core.inventories; + +import java.util.UUID; + +import gtPlusPlus.core.item.base.BaseItemBackpack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.Constants; + +public class BaseInventoryGrindle implements IInventory{ + + private final String name = "Inventory Item"; + + /** Provides NBT Tag Compound to reference */ + private final ItemStack invItem; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 6; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private final ItemStack[] inventory = new ItemStack[INV_SIZE]; + + // declaration of variable: + protected String uniqueID; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public BaseInventoryGrindle(final ItemStack stack) + { + this.invItem = stack; + + /** initialize variable within the constructor: */ + this.uniqueID = ""; + + if (!stack.hasTagCompound()) + { + stack.setTagCompound(new NBTTagCompound()); + // no tag compound means the itemstack does not yet have a UUID, so assign one: + this.uniqueID = UUID.randomUUID().toString(); + } + + // Create a new NBT Tag Compound if one doesn't already exist, or you will crash + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + } + // note that it's okay to use stack instead of invItem right there + // both reference the same memory location, so whatever you change using + // either reference will change in the other + + // Read the inventory contents from NBT + this.readFromNBT(stack.getTagCompound()); + } + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + @Override + public ItemStack getStackInSlot(final int slot) + { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) + { + ItemStack stack = this.getStackInSlot(slot); + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) + { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) + { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() + { + for (int i = 0; i < this.getSizeInventory(); ++i) + { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.inventory[i] = null; + } + } + + // This line here does the work: + this.writeToNBT(this.invItem.getTagCompound()); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) + { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) + { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return !(itemstack.getItem() instanceof BaseItemBackpack); + } + + /** + * A custom method to read our inventory from an ItemStack's NBT compound + */ + public void readFromNBT(final NBTTagCompound compound) + { + // Gets the custom taglist we wrote to this compound, if any + // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + final NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + + if ("".equals(this.uniqueID)) + { + // try to read unique ID from NBT + this.uniqueID = compound.getString("uniqueID"); + // if it's still "", assign a new one: + if ("".equals(this.uniqueID)) + { + this.uniqueID = UUID.randomUUID().toString(); + } + } + + for (int i = 0; i < items.tagCount(); ++i) + { + // 1.7.2+ change to items.getCompoundTagAt(i) + final NBTTagCompound item = items.getCompoundTagAt(i); + final int slot = item.getInteger("Slot"); + + // Just double-checking that the saved slot index is within our inventory array bounds + if ((slot >= 0) && (slot < this.getSizeInventory())) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(item); + } + } + } + + /** + * A custom method to write our inventory to an ItemStack's NBT compound + */ + public void writeToNBT(final NBTTagCompound tagcompound) + { + // Create a new NBT Tag List to store itemstacks as NBT Tags + final NBTTagList items = new NBTTagList(); + + for (int i = 0; i < this.getSizeInventory(); ++i) + { + // Only write stacks that contain items + if (this.getStackInSlot(i) != null) + { + // Make a new NBT Tag Compound to write the itemstack and slot index to + final NBTTagCompound item = new NBTTagCompound(); + item.setInteger("Slot", i); + // Writes the itemstack in slot(i) to the Tag Compound we just made + this.getStackInSlot(i).writeToNBT(item); + + // add the tag compound to our tag list + items.appendTag(item); + } + } + tagcompound.setString("uniqueID", this.uniqueID); + // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" + tagcompound.setTag("ItemInventory", items); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index ec0e21c7bb..851db25325 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -240,6 +240,8 @@ public final class ModItems { public static Item itemModularBauble; public static Item itemCustomBook; + + public static Item itemGrindleTablet; public static final void init(){ @@ -616,6 +618,8 @@ public final class ModItems { itemAirFilter = new ItemAirFilter(); itemLavaFilter = new ItemLavaFilter(); + + itemGrindleTablet = new BaseItemGrindle(); //Chemistry CoalTar.run(); diff --git a/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java b/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java new file mode 100644 index 0000000000..66fd6968e4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java @@ -0,0 +1,87 @@ +package gtPlusPlus.core.item.general; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class BaseItemGrindle extends Item{ + + protected final String unlocalName; + + + public BaseItemGrindle(){ + this.unlocalName = "itemGrindleTablet"; + this.setUnlocalizedName("itemGrindleTablet"); + this.setTextureName(CORE.MODID + ":" + "itemTablet"); + GameRegistry.registerItem(this, "itemGrindleTablet"); + GT_OreDictUnificator.registerOre("tabletGit", ItemUtils.getSimpleStack(this)); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabOther); + } + + @Override + public int getMaxItemUseDuration(final ItemStack stack) { + return 1; + } + + @Override + public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) + { + if (!world.isRemote){ + if (!player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI9, world, 0, 0, 0); + } + } + + return itemstack; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return ("Git"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemTablet"); + } + + @Override + public String getPotionEffect(ItemStack p_150896_1_) { + // TODO Auto-generated method stub + return super.getPotionEffect(p_150896_1_); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, + List p_77624_3_, boolean p_77624_4_) { + // TODO Auto-generated method stub + super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack i) { + return EnumRarity.uncommon; + } + + @Override + public boolean isRepairable() { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index 4cbd3c7205..a287615315 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -17,7 +17,7 @@ import java.util.Collection; public class GTPP_CapeRenderer extends RenderPlayer { - private final ResourceLocation[] mCapes = {new ResourceLocation("miscutils:textures/OrangeHD.png"), new ResourceLocation("miscutils:textures/TesterCapeHD.png"), new ResourceLocation("miscutils:textures/FancyCapeHD.png"), new ResourceLocation("miscutils:textures/TesterCapeHD.png")}; + private final ResourceLocation[] mCapes = {new ResourceLocation("miscutils:textures/OrangeHD.png"), new ResourceLocation("miscutils:textures/TesterCapeHD.png"), new ResourceLocation("miscutils:textures/FancyCapeHD.png"), new ResourceLocation("miscutils:textures/DevCapeHD.png")}; private final Collection mCapeList; public GTPP_CapeRenderer(Collection aCapeList) { diff --git a/src/resources/assets/miscutils/textures/gui/itemGrindle.png b/src/resources/assets/miscutils/textures/gui/itemGrindle.png new file mode 100644 index 0000000000..cdc5de7715 Binary files /dev/null and b/src/resources/assets/miscutils/textures/gui/itemGrindle.png differ diff --git a/src/resources/assets/miscutils/textures/items/itemTablet.png b/src/resources/assets/miscutils/textures/items/itemTablet.png new file mode 100644 index 0000000000..8e10b0529a Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemTablet.png differ -- cgit From fd15ae499c11112c282a93c6cf342bc88698e8ac Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 20 Nov 2017 16:48:02 +1000 Subject: + Added a faster TC Alchemical Furnace. + Added a Wither-Proof block. % Tweaked Grindle GUI. --- src/Java/gtPlusPlus/core/block/ModBlocks.java | 4 + .../block/general/antigrief/BlockWitherProof.java | 104 +++++ .../gtPlusPlus/core/gui/item/GuiBaseGrindle.java | 7 +- .../core/handler/COMPAT_IntermodStaging.java | 4 + .../xmod/thaumcraft/common/HANDLER_Thaumcraft.java | 27 ++ .../common/block/BlockFastAlchemyFurnace.java | 94 +++++ .../thaumcraft/common/block/TC_BlockHandler.java | 13 + .../common/tile/TileFastAlchemyFurnace.java | 426 +++++++++++++++++++++ 8 files changed, 675 insertions(+), 4 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/common/HANDLER_Thaumcraft.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index a469acfc49..6ebb21bb9c 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -4,6 +4,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.BlockBaseOre; import gtPlusPlus.core.block.general.*; +import gtPlusPlus.core.block.general.antigrief.BlockWitherProof; import gtPlusPlus.core.block.machine.*; import gtPlusPlus.core.fluids.FluidRegistryHandler; import gtPlusPlus.core.lib.CORE; @@ -45,6 +46,8 @@ public final class ModBlocks { public static Block blockProjectTable; public static Block blockTradeTable; public static Block blockModularTable; + + public static Block blockWitherGuard; public static void init() { Utils.LOG_INFO("Initializing Blocks."); @@ -74,6 +77,7 @@ public final class ModBlocks { blockProjectTable = new Machine_ProjectTable(); blockTradeTable = new Machine_TradeTable(); blockModularTable = new Machine_ModularityTable(); + blockWitherGuard = new BlockWitherProof(); } diff --git a/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java new file mode 100644 index 0000000000..297bcb3061 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java @@ -0,0 +1,104 @@ +package gtPlusPlus.core.block.general.antigrief; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockWitherProof extends Block{ + + public BlockWitherProof(){ + super(Material.redstoneLight); + this.setBlockName(Utils.sanitizeString("blockBlackGate")); + this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(5000.0F); + this.setHarvestLevel("pickaxe", 3); + this.setStepSound(soundTypeMetal); + LanguageRegistry.addName(this, "Wither Cage"); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockBlackGate")); + + } + + public String GetProperName(){ + return "Wither Cage"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass(){ + return 1; + } + + @Override + public boolean isOpaqueCube(){ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); + } + + public void onBlockExploded(World world, int x, int y, int z, Explosion explosion){ + //prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion(World p_149723_1_, int p_149723_2_, + int p_149723_3_, int p_149723_4_, Explosion p_149723_5_) { + + } + + @Override + public boolean canDropFromExplosion(Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, + Entity entity) { + if (entity == null || !entity.isEntityAlive()){ + return false; + } + if (entity instanceof EntityWither || entity instanceof EntityDragon || entity instanceof IBossDisplayData){ + return false; + } + else { + return super.canEntityDestroy(world, x, y, z, entity); + } + } + + + //Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + + +} diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java index 798b74b48f..c7c14e9103 100644 --- a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java +++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java @@ -59,9 +59,9 @@ public class GuiBaseGrindle extends GuiContainer { if (this.inventory.getStackInSlot(0) != null){ this.fontRendererObj.drawString(I18n.format(""+NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), 10, 8, Utils.rgbtoHexValue(125, 255, 125)); - if (!NBTUtils.tryIterateNBTData(this.inventory.getStackInSlot(0))){ - this.fontRendererObj.drawString(I18n.format("Very Bad prospection data.", new Object[0]), 10, 38, Utils.rgbtoHexValue(255, 125, 125)); - } + //if (!NBTUtils.tryIterateNBTData(this.inventory.getStackInSlot(0))){ + // this.fontRendererObj.drawString(I18n.format("Very Bad prospection data.", new Object[0]), 10, 38, Utils.rgbtoHexValue(255, 125, 125)); + //} NBTTagCompound tNBT = ItemNBT.getNBT(this.inventory.getStackInSlot(0)); byte tTier = tNBT.getByte("prospection_tier"); @@ -94,7 +94,6 @@ public class GuiBaseGrindle extends GuiContainer { this.fontRendererObj.drawString(I18n.format(mOreTypes[i], new Object[0]), 10, 68+((i-6)*8), Utils.rgbtoHexValue(125, 255, 125)); } } - Utils.LOG_INFO("test - "+tOres); tNBTList.appendTag(new NBTTagString("Prospection Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres)); tNBT.setTag("pages", tNBTList); diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index fe46e2befa..1bf729cdc6 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -7,6 +7,7 @@ import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.growthcraft.HANDLER_GC; import gtPlusPlus.xmod.ic2.HANDLER_IC2; import gtPlusPlus.xmod.mekanism.HANDLER_Mekanism; +import gtPlusPlus.xmod.thaumcraft.common.HANDLER_Thaumcraft; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; public class COMPAT_IntermodStaging { @@ -20,6 +21,7 @@ public class COMPAT_IntermodStaging { HANDLER_Computronics.preInit(); HANDLER_BiomesOPlenty.preInit(); HANDLER_Mekanism.preInit(); + HANDLER_Thaumcraft.preInit(); } @@ -32,6 +34,7 @@ public class COMPAT_IntermodStaging { HANDLER_Computronics.init(); HANDLER_BiomesOPlenty.init(); HANDLER_Mekanism.init(); + HANDLER_Thaumcraft.init(); } public static void postInit(){ @@ -43,6 +46,7 @@ public class COMPAT_IntermodStaging { HANDLER_Computronics.postInit(); HANDLER_BiomesOPlenty.postInit(); HANDLER_Mekanism.postInit(); + HANDLER_Thaumcraft.postInit(); } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/HANDLER_Thaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/HANDLER_Thaumcraft.java new file mode 100644 index 0000000000..7c5d2407cd --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/HANDLER_Thaumcraft.java @@ -0,0 +1,27 @@ +package gtPlusPlus.xmod.thaumcraft.common; + +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.thaumcraft.common.block.TC_BlockHandler; + +public class HANDLER_Thaumcraft { + + public static void preInit(){ + if (LoadedMods.Thaumcraft){ + TC_BlockHandler.run(); + } + } + + public static void init(){ + if (LoadedMods.Thaumcraft){ + + } + } + + public static void postInit(){ + if (LoadedMods.Thaumcraft){ + + } + } + + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java new file mode 100644 index 0000000000..3d570dfe7e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java @@ -0,0 +1,94 @@ +package gtPlusPlus.xmod.thaumcraft.common.block; + +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import thaumcraft.common.blocks.BlockAlchemyFurnace; + +public class BlockFastAlchemyFurnace extends BlockAlchemyFurnace { + + public BlockFastAlchemyFurnace() { + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setBlockName("blockFastAlchemyFurnace"); + GameRegistry.registerBlock(this, "blockFastAlchemyFurnace"); + LanguageRegistry.addName(this, "Upgraded Alchemical Furnace"); + } + + public int func_149692_a(int metadata) { + if ((metadata == 1) || (metadata == 4)) + return 3; + if (metadata == 3) + return 9; + if (metadata == 2) + return 1; + return 0; + } + + public TileEntity createTileEntity(World world, int metadata) { + if (metadata == 0){ + return new TileFastAlchemyFurnace(); + } + return null; + } + + public int getLightValue(IBlockAccess world, int x, int y, int z){ + Block block = world.getBlock(x, y, z); + if (block != this) + { + return block.getLightValue(world, x, y, z); + } + return getLightValue(); + } + + /*public int func_149736_g(World world, int x, int y, int z, int rs) { + + }*/ + + public TileEntity func_149915_a(World var1, int md) { + return null; + } + + /* public void func_149749_a(World world, int x, int y, int z, Block bl, int md) { + + }*/ + + @SideOnly(Side.CLIENT) + public void func_149734_b(final World world, final int x, final int y, final int z, final Random rand) { + /*final int meta = world.func_72805_g(x, y, z); + if (meta == 0) { + final TileAlchemyFurnaceAdvanced tile = (TileAlchemyFurnaceAdvanced) world.func_147438_o(x, y, z); + if (tile != null && tile.vis > 0) { + final FXSlimyBubble ef = new FXSlimyBubble(world, (double) (x + rand.nextFloat()), (double) (y + 1), + (double) (z + rand.nextFloat()), 0.06f + rand.nextFloat() * 0.06f); + ef.func_82338_g(0.8f); + ef.func_70538_b(0.6f - rand.nextFloat() * 0.2f, 0.0f, 0.6f + rand.nextFloat() * 0.2f); + ParticleEngine.instance.addEffect(world, (EntityFX) ef); + if (rand.nextInt(50) == 0) { + final double var21 = x + rand.nextFloat(); + final double var22 = y + this.field_149756_F; + final double var23 = z + rand.nextFloat(); + world.func_72980_b(var21, var22, var23, "liquid.lavapop", 0.1f + rand.nextFloat() * 0.1f, + 0.9f + rand.nextFloat() * 0.15f, false); + } + final int q = rand.nextInt(2); + final int w = rand.nextInt(2); + final FXSlimyBubble ef2 = new FXSlimyBubble(world, x - 0.6 + rand.nextFloat() * 0.2 + q * 2, + (double) (y + 2), z - 0.6 + rand.nextFloat() * 0.2 + w * 2, 0.06f + rand.nextFloat() * 0.06f); + ef2.func_82338_g(0.8f); + ef2.func_70538_b(0.6f - rand.nextFloat() * 0.2f, 0.0f, 0.6f + rand.nextFloat() * 0.2f); + ParticleEngine.instance.addEffect(world, (EntityFX) ef2); + } + } + super.func_149734_b(world, x, y, z, rand);*/ + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java new file mode 100644 index 0000000000..fade8601f0 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java @@ -0,0 +1,13 @@ +package gtPlusPlus.xmod.thaumcraft.common.block; + +import net.minecraft.block.Block; + +public class TC_BlockHandler { + + static Block blockFurnace; + + public static void run(){ + blockFurnace = new BlockFastAlchemyFurnace(); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java new file mode 100644 index 0000000000..226c7cf393 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java @@ -0,0 +1,426 @@ +package gtPlusPlus.xmod.thaumcraft.common.tile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.world.EnumSkyBlock; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.config.ConfigItems; +import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager; +import thaumcraft.common.tiles.TileAlchemyFurnace; +import thaumcraft.common.tiles.TileAlembic; +import thaumcraft.common.tiles.TileBellows; + +public class TileFastAlchemyFurnace extends TileAlchemyFurnace { + private static final int[] slots_bottom = {1}; + private static final int[] slots_top = new int[0]; + private static final int[] slots_sides = {0}; + public AspectList aspects; + public int vis; + private int maxVis; + public int smeltTime; + int bellows; + boolean speedBoost; + private ItemStack[] furnaceItemStacks; + public int furnaceBurnTime; + public int currentItemBurnTime; + public int furnaceCookTime; + private String customName; + int count; + + public TileFastAlchemyFurnace() { + this.aspects = new AspectList(); + + this.maxVis = 100; + this.smeltTime = 25; + this.bellows = -1; + this.speedBoost = false; + + this.furnaceItemStacks = new ItemStack[2]; + + this.count = 0; + } + + public int func_70302_i_() { + return this.furnaceItemStacks.length; + } + + public ItemStack func_70301_a(int par1) { + return this.furnaceItemStacks[par1]; + } + + public ItemStack func_70298_a(int par1, int par2) { + if (this.furnaceItemStacks[par1] != null) { + if (this.furnaceItemStacks[par1].stackSize <= par2) { + ItemStack itemstack = this.furnaceItemStacks[par1]; + this.furnaceItemStacks[par1] = null; + return itemstack; + } + + ItemStack itemstack = this.furnaceItemStacks[par1].splitStack(par2); + + if (this.furnaceItemStacks[par1].stackSize == 0) { + this.furnaceItemStacks[par1] = null; + } + + return itemstack; + } + + return null; + } + + public ItemStack func_70304_b(int par1) { + if (this.furnaceItemStacks[par1] != null) { + ItemStack itemstack = this.furnaceItemStacks[par1]; + this.furnaceItemStacks[par1] = null; + return itemstack; + } + + return null; + } + + public void func_70299_a(int par1, ItemStack par2ItemStack) { + this.furnaceItemStacks[par1] = par2ItemStack; + + if ((par2ItemStack == null) || (par2ItemStack.stackSize <= func_70297_j_())) + return; + par2ItemStack.stackSize = func_70297_j_(); + } + + public String func_145825_b() { + return ((func_145818_k_()) ? this.customName : "container.alchemyfurnace"); + } + + public boolean func_145818_k_() { + return ((this.customName != null) && (this.customName.length() > 0)); + } + + public void setGuiDisplayName(String par1Str) { + this.customName = par1Str; + } + + public void readCustomNBT(NBTTagCompound nbttagcompound) { + this.furnaceBurnTime = nbttagcompound.getShort("BurnTime"); + this.vis = nbttagcompound.getShort("Vis"); + } + + public void writeCustomNBT(NBTTagCompound nbttagcompound) { + nbttagcompound.setShort("BurnTime", (short) this.furnaceBurnTime); + nbttagcompound.setShort("Vis", (short) this.vis); + } + + public void func_145839_a(NBTTagCompound nbtCompound) { + super.func_145839_a(nbtCompound); + NBTTagList nbttaglist = nbtCompound.getTagList("Items", 10); + this.furnaceItemStacks = new ItemStack[func_70302_i_()]; + + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + byte b0 = nbttagcompound1.getByte("Slot"); + + if ((b0 < 0) || (b0 >= this.furnaceItemStacks.length)) + continue; + this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + + this.speedBoost = nbtCompound.getBoolean("speedBoost"); + this.furnaceCookTime = nbtCompound.getShort("CookTime"); + this.currentItemBurnTime = TileEntityFurnace.getItemBurnTime(this.furnaceItemStacks[1]); + + if (nbtCompound.hasKey("CustomName")) { + this.customName = nbtCompound.getString("CustomName"); + } + + this.aspects.readFromNBT(nbtCompound); + this.vis = this.aspects.visSize(); + } + + public void func_145841_b(NBTTagCompound nbtCompound) { + super.func_145841_b(nbtCompound); + nbtCompound.setBoolean("speedBoost", this.speedBoost); + nbtCompound.setShort("CookTime", (short) this.furnaceCookTime); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.furnaceItemStacks.length; ++i) { + if (this.furnaceItemStacks[i] == null) + continue; + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + this.furnaceItemStacks[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + + nbtCompound.setTag("Items", nbttaglist); + + if (func_145818_k_()) { + nbtCompound.setString("CustomName", this.customName); + } + + this.aspects.writeToNBT(nbtCompound); + } + + public int func_70297_j_() { + return 64; + } + + @SideOnly(Side.CLIENT) + public int getCookProgressScaled(int par1) { + if (this.smeltTime <= 0) + this.smeltTime = 1; + return (this.furnaceCookTime * par1 / this.smeltTime); + } + + @SideOnly(Side.CLIENT) + public int getContentsScaled(int par1) { + return (this.vis * par1 / this.maxVis); + } + + @SideOnly(Side.CLIENT) + public int getBurnTimeRemainingScaled(int par1) { + if (this.currentItemBurnTime == 0) { + this.currentItemBurnTime = 200; + } + + return (this.furnaceBurnTime * par1 / this.currentItemBurnTime); + } + + public boolean isBurning() { + return (this.furnaceBurnTime > 0); + } + + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + super.onDataPacket(net, pkt); + if (this.worldObj != null) + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord); + } + + public boolean canUpdate() { + return true; + } + + public void func_145845_h() { + boolean flag = this.furnaceBurnTime > 0; + boolean flag1 = false; + this.count += 1; + if (this.furnaceBurnTime > 0) { + this.furnaceBurnTime -= 1; + } + + if (!(this.worldObj.isRemote)) { + if (this.bellows < 0) + getBellows(); + + if ((this.count % ((this.speedBoost) ? 20 : 40) == 0) && (this.aspects.size() > 0)) { + AspectList exlude = new AspectList(); + int deep = 0; + TileEntity tile = null; + while (deep < 5) { + ++deep; + tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord + deep, + this.zCoord); + if (!(tile instanceof TileAlembic)) + break; + TileAlembic alembic = (TileAlembic) tile; + if ((alembic.aspect != null) && (alembic.amount < alembic.maxAmount) + && (this.aspects.getAmount(alembic.aspect) > 0)) { + takeFromContainer(alembic.aspect, 1); + alembic.addToContainer(alembic.aspect, 1); + exlude.merge(alembic.aspect, 1); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, + this.zCoord); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord + deep, + this.zCoord); + } + tile = null; + } + + deep = 0; + while (deep < 5) { + ++deep; + tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord + deep, + this.zCoord); + if (!(tile instanceof TileAlembic)) + break; + TileAlembic alembic = (TileAlembic) tile; + if ((alembic.aspect == null) || (alembic.amount == 0)) + ; + Aspect as = null; + if (alembic.aspectFilter == null) { + as = takeRandomAspect(exlude); + } else if (takeFromContainer(alembic.aspectFilter, 1)) { + as = alembic.aspectFilter; + } + + if (as != null) { + alembic.addToContainer(as, 1); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, + this.zCoord); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord + deep, + this.zCoord); + break; + } + + } + + } + + if ((this.furnaceBurnTime == 0) && (canSmelt())) { + this.currentItemBurnTime = (this.furnaceBurnTime = TileEntityFurnace + .getItemBurnTime(this.furnaceItemStacks[1])); + + if (this.furnaceBurnTime > 0) { + flag1 = true; + this.speedBoost = false; + + if (this.furnaceItemStacks[1] != null) { + if (this.furnaceItemStacks[1].isItemEqual(new ItemStack(ConfigItems.itemResource, 1, 0))) { + this.speedBoost = true; + } + this.furnaceItemStacks[1].stackSize -= 1; + + if (this.furnaceItemStacks[1].stackSize == 0) { + this.furnaceItemStacks[1] = this.furnaceItemStacks[1].getItem() + .getContainerItem(this.furnaceItemStacks[1]); + } + } + } + } + + if ((isBurning()) && (canSmelt())) { + this.furnaceCookTime += 1; + + if (this.furnaceCookTime >= this.smeltTime) { + this.furnaceCookTime = 0; + smeltItem(); + flag1 = true; + } + } else { + this.furnaceCookTime = 0; + } + + if (flag != this.furnaceBurnTime > 0) { + flag1 = true; + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } + } + + if (!(flag1)) + return; + markDirty(); + } + + private boolean canSmelt() { + if (this.furnaceItemStacks[0] == null) { + return false; + } + + AspectList al = ThaumcraftCraftingManager.getObjectTags(this.furnaceItemStacks[0]); + al = ThaumcraftCraftingManager.getBonusTags(this.furnaceItemStacks[0], al); + + if ((al == null) || (al.size() == 0)) + return false; + int vs = al.visSize(); + if (vs > this.maxVis - this.vis) + return false; + this.smeltTime = (int) (vs * 10 * (1.0F - (0.125F * this.bellows))); + return true; + } + + public void getBellows() { + this.bellows = TileBellows.getBellows(this.worldObj, this.xCoord, this.yCoord, + this.zCoord, ForgeDirection.VALID_DIRECTIONS); + } + + public void smeltItem() { + if (!(canSmelt())) { + return; + } + AspectList al = ThaumcraftCraftingManager.getObjectTags(this.furnaceItemStacks[0]); + al = ThaumcraftCraftingManager.getBonusTags(this.furnaceItemStacks[0], al); + + for (Aspect a : al.getAspects()) { + this.aspects.add(a, al.getAmount(a)); + } + + this.vis = this.aspects.visSize(); + + this.furnaceItemStacks[0].stackSize -= 1; + + if (this.furnaceItemStacks[0].stackSize > 0) + return; + this.furnaceItemStacks[0] = null; + } + + public static boolean isItemFuel(ItemStack par0ItemStack) { + return (TileEntityFurnace.getItemBurnTime(par0ItemStack) > 0); + } + + public boolean func_70300_a(EntityPlayer par1EntityPlayer) { + return (this.worldObj.getTileEntity(this.xCoord, this.yCoord, + this.zCoord) == this); + } + + public void func_70295_k_() { + } + + public void func_70305_f() { + } + + public boolean func_94041_b(int par1, ItemStack par2ItemStack) { + if (par1 == 0) { + AspectList al = ThaumcraftCraftingManager.getObjectTags(par2ItemStack); + al = ThaumcraftCraftingManager.getBonusTags(par2ItemStack, al); + if ((al != null) && (al.size() > 0)) + return true; + } + return ((par1 == 1) ? isItemFuel(par2ItemStack) : false); + } + + public int[] func_94128_d(int par1) { + return ((par1 == 1) ? slots_top : (par1 == 0) ? slots_bottom : slots_sides); + } + + public boolean func_102007_a(int par1, ItemStack par2ItemStack, int par3) { + return ((par3 == 1) ? false : func_94041_b(par1, par2ItemStack)); + } + + public boolean func_102008_b(int par1, ItemStack par2ItemStack, int par3) { + return ((par3 != 0) || (par1 != 1) || (par2ItemStack.getItem() == Items.bucket)); + } + + public Aspect takeRandomAspect(AspectList exlude) { + if (this.aspects.size() > 0) { + AspectList temp = this.aspects.copy(); + if (exlude.size() > 0) + for (Aspect a : exlude.getAspects()) + temp.remove(a); + if (temp.size() > 0) { + Aspect tag = temp.getAspects()[this.worldObj.rand.nextInt(temp.getAspects().length)]; + this.aspects.remove(tag, 1); + this.vis -= 1; + return tag; + } + } + return null; + } + + public boolean takeFromContainer(Aspect tag, int amount) { + if ((this.aspects != null) && (this.aspects.getAmount(tag) >= amount)) { + this.aspects.remove(tag, amount); + this.vis -= amount; + return true; + } + return false; + } +} \ No newline at end of file -- cgit From 3a7576cc5a52ce052c1bc40ddb7dbcb63e2a6381 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 20 Nov 2017 17:11:11 +1000 Subject: + Added recipe for Wither Cage. --- src/Java/gtPlusPlus/core/recipe/RECIPES_General.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 67b9107b28..e9a2ee86b4 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -139,6 +139,12 @@ public class RECIPES_General { new ItemStack(ModItems.itemAlkalusDisk, 1, OreDictionary.WILDCARD_VALUE)); l++; } + + RecipeUtils.addShapedGregtechRecipe( + "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", + "plateTungstenSteel", "blockIron", "plateTungstenSteel", + "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", + ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard)); //Alkalus Coin /*AddGregtechRecipe.addAssemblylineRecipe( -- cgit From e480daed410bd80d5eda9abbd37f7bd96021e911 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 20 Nov 2017 20:19:10 +1000 Subject: $ Fixed the Upgraded Alchemical Furnace being built from heavily obfuscated code. % Adjusted Wither Guard recipe to now output 32x per craft, at the added cost of a Netherstar per craft. % Small formatting changes. --- src/Java/gtPlusPlus/core/handler/GuiHandler.java | 24 +- .../gtPlusPlus/core/recipe/RECIPES_General.java | 41 +-- src/Java/gtPlusPlus/core/util/item/ItemUtils.java | 45 +-- .../common/block/BlockFastAlchemyFurnace.java | 254 +++++++++++--- .../common/tile/TileFastAlchemyFurnace.java | 388 +++++++++++---------- 5 files changed, 461 insertions(+), 291 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 124b01a2c0..6791289f9f 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -3,12 +3,24 @@ package gtPlusPlus.core.handler; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.container.*; +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.container.Container_FishTrap; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.container.Container_ModularityTable; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.container.Container_TradeTable; +import gtPlusPlus.core.container.Container_Workbench; +import gtPlusPlus.core.container.Container_WorkbenchAdvanced; import gtPlusPlus.core.gui.beta.Gui_ID_Registry; import gtPlusPlus.core.gui.beta.MU_GuiId; import gtPlusPlus.core.gui.item.GuiBaseBackpack; import gtPlusPlus.core.gui.item.GuiBaseGrindle; -import gtPlusPlus.core.gui.machine.*; +import gtPlusPlus.core.gui.machine.GUI_FishTrap; +import gtPlusPlus.core.gui.machine.GUI_ModularityTable; +import gtPlusPlus.core.gui.machine.GUI_ProjectTable; +import gtPlusPlus.core.gui.machine.GUI_TradeTable; +import gtPlusPlus.core.gui.machine.GUI_Workbench; +import gtPlusPlus.core.gui.machine.GUI_WorkbenchAdvanced; import gtPlusPlus.core.interfaces.IGuiManager; import gtPlusPlus.core.inventories.BaseInventoryBackpack; import gtPlusPlus.core.inventories.BaseInventoryGrindle; @@ -34,8 +46,8 @@ public class GuiHandler implements IGuiHandler { public static final int GUI5 = 4; //Workbench Adv public static final int GUI6 = 5; //Fish trap public static final int GUI7 = 6; //Trade table - public static final int GUI8 = 7; // - public static final int GUI9 = 8; // + public static final int GUI8 = 7; //Alchemical Furnace + public static final int GUI9 = 8; //Grindle @@ -83,7 +95,7 @@ public class GuiHandler implements IGuiHandler { return new Container_TradeTable(player.inventory, (TileEntityTradeTable)te); } } - + if (ID == GUI9){ return new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())); } @@ -132,7 +144,7 @@ public class GuiHandler implements IGuiHandler { return new GUI_TradeTable(player.inventory, (TileEntityTradeTable)te, ((TileEntityBase) te).getOwner()); } } - + if (ID == GUI9){ return new GuiBaseGrindle(new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem()))); } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index e9a2ee86b4..f5f793da77 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -1,28 +1,19 @@ package gtPlusPlus.core.recipe; import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; -import gtPlusPlus.core.util.reflect.AddGregtechRecipe; -import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; public class RECIPES_General { @@ -102,18 +93,18 @@ public class RECIPES_General { "stickWood", "treeSapling", "stickWood", "stickWood", "dustBone", "stickWood", ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest))){ - Utils.LOG_INFO("Added a recipe for Rainforest oak Saplings."); + Utils.LOG_INFO("Added a recipe for Rainforest oak Saplings."); } //Iron bars - ItemStack ironBars = ItemUtils.getItemStack("minecraft:iron_bars", 1); + final ItemStack ironBars = ItemUtils.getItemStack("minecraft:iron_bars", 1); //Fish Trap if (RecipeUtils.recipeBuilder( ironBars, ironBars, ironBars, ironBars, "frameGtWroughtIron", ironBars, ironBars, ironBars, ironBars, ItemUtils.getSimpleStack(ModBlocks.blockFishTrap))){ - Utils.LOG_INFO("Added a recipe for the Fish Trap."); + Utils.LOG_INFO("Added a recipe for the Fish Trap."); } //Alkalus Coin @@ -122,31 +113,31 @@ public class RECIPES_General { "gemFlawlessRuby", ItemList.Credit_Greg_Naquadah.get(1), "gemFlawlessSapphire", "gemExquisiteEmerald", "gemFlawlessEmerald", "gemExquisiteSapphire", ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk))){ - Utils.LOG_INFO("Added a recipe for The Alkalus Disk."); + Utils.LOG_INFO("Added a recipe for The Alkalus Disk."); } - String fancyGems[] = new String[]{"gemExquisiteDiamond", "gemExquisiteEmerald", "gemExquisiteRuby", "gemExquisiteSapphire"}; - ItemStack gemShards[] = new ItemStack[]{ItemUtils.simpleMetaStack(ModItems.itemGemShards, 0, 1), + final String fancyGems[] = new String[]{"gemExquisiteDiamond", "gemExquisiteEmerald", "gemExquisiteRuby", "gemExquisiteSapphire"}; + final ItemStack gemShards[] = new ItemStack[]{ItemUtils.simpleMetaStack(ModItems.itemGemShards, 0, 1), ItemUtils.simpleMetaStack(ModItems.itemGemShards, 1, 1), ItemUtils.simpleMetaStack(ModItems.itemGemShards, 2, 1), ItemUtils.simpleMetaStack(ModItems.itemGemShards, 3, 1)}; - + int l=0; - for (String gem : fancyGems){ + for (final String gem : fancyGems){ GameRegistry.addShapelessRecipe( gemShards[l], ItemUtils.getItemStackOfAmountFromOreDict(gem, 1), new ItemStack(ModItems.itemAlkalusDisk, 1, OreDictionary.WILDCARD_VALUE)); l++; } - + RecipeUtils.addShapedGregtechRecipe( "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", - "plateTungstenSteel", "blockIron", "plateTungstenSteel", - "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", - ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard)); + "plateTungstenSteel", ItemUtils.getSimpleStack(Items.nether_star), "plateTungstenSteel", + "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", + ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 32)); - //Alkalus Coin + //Alkalus Coin /*AddGregtechRecipe.addAssemblylineRecipe( ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk), 288000, @@ -160,16 +151,16 @@ public class RECIPES_General { GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 16L), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 16L), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 16L), - GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NiobiumTitanium, 2L)}, + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NiobiumTitanium, 2L)}, new FluidStack[]{ Materials.Osmium.getMolten(144*32), Materials.Europium.getFluid(144*8)}, ItemUtils.getSimpleStack(Dimension_DarkWorld.portalItem), 30*20*60, 100000);*/ - - } } +} + diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index 337e301414..3680dfb59d 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -42,6 +42,9 @@ public class ItemUtils { public static ItemStack getSimpleStack(final Block x){ return getSimpleStack(Item.getItemFromBlock(x), 1); } + public static ItemStack getSimpleStack(final Block x, final int i){ + return getSimpleStack(Item.getItemFromBlock(x), i); + } public static ItemStack getSimpleStack(final Item x, final int i){ try { final ItemStack r = new ItemStack(x, i); @@ -61,8 +64,8 @@ public class ItemUtils { } public static final int WILDCARD_VALUE = Short.MAX_VALUE; - public static ItemStack getWildcardStack(Item x){ - ItemStack y = new ItemStack(x, 1, WILDCARD_VALUE); + public static ItemStack getWildcardStack(final Item x){ + final ItemStack y = new ItemStack(x, 1, WILDCARD_VALUE); return y; } @@ -265,8 +268,8 @@ public class ItemUtils { //Adds a check to grab dusts using GT methodology if possible. ItemStack returnValue = null; if (oredictName.toLowerCase().contains("dust")){ - String MaterialName = oredictName.toLowerCase().replace("dust", ""); - Materials m = Materials.get(MaterialName); + final String MaterialName = oredictName.toLowerCase().replace("dust", ""); + final Materials m = Materials.get(MaterialName); returnValue = getGregtechDust(m, amount); if (returnValue != null){ return returnValue; @@ -284,7 +287,7 @@ public class ItemUtils { Utils.LOG_WARNING(oredictName+" was not valid."); return null; } - catch (Throwable t){ + catch (final Throwable t){ return null; } } @@ -317,7 +320,7 @@ public class ItemUtils { return output; } - public static Item generateSpecialUsePlate(String internalName, String displayName, short[] rgb, int radioactivity){ + public static Item generateSpecialUsePlate(final String internalName, final String displayName, final short[] rgb, final int radioactivity){ return new BaseItemPlate_OLD(internalName, displayName, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), radioactivity); } @@ -344,7 +347,7 @@ public class ItemUtils { public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final Materials material){ final ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); - int enchantLevel = material.mEnchantmentToolsLevel; + final int enchantLevel = material.mEnchantmentToolsLevel; final Object enchant = new Pair(material.mEnchantmentTools, enchantLevel); return generateMultiPick(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, material.mRGBa, enchant); } @@ -575,24 +578,24 @@ public class ItemUtils { return outputs; } - private static String getModId(Item item) { + private static String getModId(final Item item) { try { - GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); - String modname = (id.modId == null ? id.name : id.modId); - return id == null || id.modId.equals("") ? "minecraft" : modname; - } catch (Throwable t){ + final GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); + final String modname = (id.modId == null ? id.name : id.modId); + return (id == null) || id.modId.equals("") ? "minecraft" : modname; + } catch (final Throwable t){ try { - UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); - String modname = (t2.modId == null ? t2.name : t2.modId); - return t2 == null || t2.modId.equals("") ? "minecraft" : modname; + final UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); + final String modname = (t2.modId == null ? t2.name : t2.modId); + return (t2 == null) || t2.modId.equals("") ? "minecraft" : modname; } - catch (Throwable t3){ + catch (final Throwable t3){ return "bad modid"; } } } - public static String getModId(ItemStack key) { + public static String getModId(final ItemStack key) { return getModId(key.getItem()); } @@ -602,13 +605,13 @@ public class ItemUtils { if (!oreDictList.isEmpty()){ ItemStack returnvalue; for (int xrc=0;xrc 0) { - final FXSlimyBubble ef = new FXSlimyBubble(world, (double) (x + rand.nextFloat()), (double) (y + 1), - (double) (z + rand.nextFloat()), 0.06f + rand.nextFloat() * 0.06f); - ef.func_82338_g(0.8f); - ef.func_70538_b(0.6f - rand.nextFloat() * 0.2f, 0.0f, 0.6f + rand.nextFloat() * 0.2f); - ParticleEngine.instance.addEffect(world, (EntityFX) ef); - if (rand.nextInt(50) == 0) { - final double var21 = x + rand.nextFloat(); - final double var22 = y + this.field_149756_F; - final double var23 = z + rand.nextFloat(); - world.func_72980_b(var21, var22, var23, "liquid.lavapop", 0.1f + rand.nextFloat() * 0.1f, - 0.9f + rand.nextFloat() * 0.15f, false); + public void randomDisplayTick(final World w, final int i, final int j, final int k, final Random r) { + final TileEntity te = w.getTileEntity(i, j, k); + if ((te != null) && (te instanceof TileFastAlchemyFurnace) && ((TileFastAlchemyFurnace) te).isBurning()) { + final float f = i + 0.5f; + final float f2 = j + 0.2f + ((r.nextFloat() * 5.0f) / 16.0f); + final float f3 = k + 0.5f; + final float f4 = 0.52f; + final float f5 = (r.nextFloat() * 0.5f) - 0.25f; + w.spawnParticle("smoke", f - f4, f2, f3 + f5, 0.0, 0.0, 0.0); + w.spawnParticle("flame", f - f4, f2, f3 + f5, 0.0, 0.0, 0.0); + w.spawnParticle("smoke", f + f4, f2, f3 + f5, 0.0, 0.0, 0.0); + w.spawnParticle("flame", f + f4, f2, f3 + f5, 0.0, 0.0, 0.0); + w.spawnParticle("smoke", f + f5, f2, f3 - f4, 0.0, 0.0, 0.0); + w.spawnParticle("flame", f + f5, f2, f3 - f4, 0.0, 0.0, 0.0); + w.spawnParticle("smoke", f + f5, f2, f3 + f4, 0.0, 0.0, 0.0); + w.spawnParticle("flame", f + f5, f2, f3 + f4, 0.0, 0.0, 0.0); + } + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister ir) { + this.iconPedestal[0] = ir.registerIcon("thaumcraft:pedestal_side"); + this.iconPedestal[1] = ir.registerIcon("thaumcraft:pedestal_top"); + this.iconFurnace[0] = ir.registerIcon("thaumcraft:al_furnace_side"); + this.iconFurnace[1] = ir.registerIcon("thaumcraft:al_furnace_top"); + this.iconFurnace[2] = ir.registerIcon("thaumcraft:al_furnace_front_off"); + this.iconFurnace[3] = ir.registerIcon("thaumcraft:al_furnace_front_on"); + this.iconFurnace[4] = ir.registerIcon("thaumcraft:al_furnace_top_filled"); + } + + @Override + public int getRenderType() { + return ConfigBlocks.blockStoneDeviceRI; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public IIcon getIcon(final int side, final int md) { + if (md == 0) { + if (side == 1) { + return this.iconFurnace[1]; + } + if (side > 1) { + return this.iconFurnace[2]; + } + } else if (md == 1) { + if (side <= 1) { + return this.iconPedestal[1]; + } + if (side > 1) { + return this.iconPedestal[0]; + } + } + return this.iconPedestal[1]; + } + + @Override + public IIcon getIcon(final IBlockAccess iblockaccess, final int i, final int j, final int k, final int side) { + final int metadata = iblockaccess.getBlockMetadata(i, j, k); + if (metadata == 0) { + final TileEntity te = iblockaccess.getTileEntity(i, j, k); + if (side == 1) { + if ((te != null) && (te instanceof TileFastAlchemyFurnace) && (((TileFastAlchemyFurnace) te).vis > 0)) { + return this.iconFurnace[4]; + } + return this.iconFurnace[1]; + } else if (side > 1) { + if ((te != null) && (te instanceof TileFastAlchemyFurnace) && ((TileFastAlchemyFurnace) te).isBurning()) { + return this.iconFurnace[3]; } - final int q = rand.nextInt(2); - final int w = rand.nextInt(2); - final FXSlimyBubble ef2 = new FXSlimyBubble(world, x - 0.6 + rand.nextFloat() * 0.2 + q * 2, - (double) (y + 2), z - 0.6 + rand.nextFloat() * 0.2 + w * 2, 0.06f + rand.nextFloat() * 0.06f); - ef2.func_82338_g(0.8f); - ef2.func_70538_b(0.6f - rand.nextFloat() * 0.2f, 0.0f, 0.6f + rand.nextFloat() * 0.2f); - ParticleEngine.instance.addEffect(world, (EntityFX) ef2); + return this.iconFurnace[2]; } + } else if ((metadata == 1) || (metadata == 5) || (metadata == 8) || (metadata == 12)) { + return super.getIcon(iblockaccess, i, j, k, side); } - super.func_149734_b(world, x, y, z, rand);*/ + return this.iconFurnace[0]; } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java index 226c7cf393..ec39e7f4af 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java @@ -22,12 +22,12 @@ import thaumcraft.common.tiles.TileAlembic; import thaumcraft.common.tiles.TileBellows; public class TileFastAlchemyFurnace extends TileAlchemyFurnace { - private static final int[] slots_bottom = {1}; - private static final int[] slots_top = new int[0]; - private static final int[] slots_sides = {0}; + private static final int[] slots_bottom; + private static final int[] slots_top; + private static final int[] slots_sides; public AspectList aspects; public int vis; - private int maxVis; + private final int maxVis; public int smeltTime; int bellows; boolean speedBoost; @@ -40,255 +40,247 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { public TileFastAlchemyFurnace() { this.aspects = new AspectList(); - - this.maxVis = 100; - this.smeltTime = 25; + this.maxVis = 150; + this.smeltTime = 100; this.bellows = -1; - this.speedBoost = false; - + this.speedBoost = true; this.furnaceItemStacks = new ItemStack[2]; - this.count = 0; } - public int func_70302_i_() { + @Override + public int getSizeInventory() { return this.furnaceItemStacks.length; } - public ItemStack func_70301_a(int par1) { + @Override + public ItemStack getStackInSlot(final int par1) { return this.furnaceItemStacks[par1]; } - public ItemStack func_70298_a(int par1, int par2) { - if (this.furnaceItemStacks[par1] != null) { - if (this.furnaceItemStacks[par1].stackSize <= par2) { - ItemStack itemstack = this.furnaceItemStacks[par1]; - this.furnaceItemStacks[par1] = null; - return itemstack; - } - - ItemStack itemstack = this.furnaceItemStacks[par1].splitStack(par2); - - if (this.furnaceItemStacks[par1].stackSize == 0) { - this.furnaceItemStacks[par1] = null; - } - + @Override + public ItemStack decrStackSize(final int par1, final int par2) { + if (this.furnaceItemStacks[par1] == null) { + return null; + } + if (this.furnaceItemStacks[par1].stackSize <= par2) { + final ItemStack itemstack = this.furnaceItemStacks[par1]; + this.furnaceItemStacks[par1] = null; return itemstack; } - - return null; + final ItemStack itemstack = this.furnaceItemStacks[par1].splitStack(par2); + if (this.furnaceItemStacks[par1].stackSize == 0) { + this.furnaceItemStacks[par1] = null; + } + return itemstack; } - public ItemStack func_70304_b(int par1) { + @Override + public ItemStack getStackInSlotOnClosing(final int par1) { if (this.furnaceItemStacks[par1] != null) { - ItemStack itemstack = this.furnaceItemStacks[par1]; + final ItemStack itemstack = this.furnaceItemStacks[par1]; this.furnaceItemStacks[par1] = null; return itemstack; } - return null; } - public void func_70299_a(int par1, ItemStack par2ItemStack) { + @Override + public void setInventorySlotContents(final int par1, final ItemStack par2ItemStack) { this.furnaceItemStacks[par1] = par2ItemStack; - - if ((par2ItemStack == null) || (par2ItemStack.stackSize <= func_70297_j_())) - return; - par2ItemStack.stackSize = func_70297_j_(); + if ((par2ItemStack != null) && (par2ItemStack.stackSize > this.getInventoryStackLimit())) { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } } - public String func_145825_b() { - return ((func_145818_k_()) ? this.customName : "container.alchemyfurnace"); + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.alchemyfurnace"; } - public boolean func_145818_k_() { - return ((this.customName != null) && (this.customName.length() > 0)); + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && (this.customName.length() > 0); } - public void setGuiDisplayName(String par1Str) { + @Override + public void setGuiDisplayName(final String par1Str) { this.customName = par1Str; } - public void readCustomNBT(NBTTagCompound nbttagcompound) { + @Override + public void readCustomNBT(final NBTTagCompound nbttagcompound) { this.furnaceBurnTime = nbttagcompound.getShort("BurnTime"); this.vis = nbttagcompound.getShort("Vis"); } - public void writeCustomNBT(NBTTagCompound nbttagcompound) { + @Override + public void writeCustomNBT(final NBTTagCompound nbttagcompound) { nbttagcompound.setShort("BurnTime", (short) this.furnaceBurnTime); nbttagcompound.setShort("Vis", (short) this.vis); } - public void func_145839_a(NBTTagCompound nbtCompound) { - super.func_145839_a(nbtCompound); - NBTTagList nbttaglist = nbtCompound.getTagList("Items", 10); - this.furnaceItemStacks = new ItemStack[func_70302_i_()]; - + @Override + public void readFromNBT(final NBTTagCompound nbtCompound) { + super.readFromNBT(nbtCompound); + final NBTTagList nbttaglist = nbtCompound.getTagList("Items", 10); + this.furnaceItemStacks = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - byte b0 = nbttagcompound1.getByte("Slot"); - - if ((b0 < 0) || (b0 >= this.furnaceItemStacks.length)) - continue; - this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + final NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + final byte b0 = nbttagcompound1.getByte("Slot"); + if ((b0 >= 0) && (b0 < this.furnaceItemStacks.length)) { + this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } } - this.speedBoost = nbtCompound.getBoolean("speedBoost"); this.furnaceCookTime = nbtCompound.getShort("CookTime"); this.currentItemBurnTime = TileEntityFurnace.getItemBurnTime(this.furnaceItemStacks[1]); - if (nbtCompound.hasKey("CustomName")) { this.customName = nbtCompound.getString("CustomName"); } - this.aspects.readFromNBT(nbtCompound); this.vis = this.aspects.visSize(); } - public void func_145841_b(NBTTagCompound nbtCompound) { - super.func_145841_b(nbtCompound); + @Override + public void writeToNBT(final NBTTagCompound nbtCompound) { + super.writeToNBT(nbtCompound); nbtCompound.setBoolean("speedBoost", this.speedBoost); nbtCompound.setShort("CookTime", (short) this.furnaceCookTime); - NBTTagList nbttaglist = new NBTTagList(); - + final NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.furnaceItemStacks.length; ++i) { - if (this.furnaceItemStacks[i] == null) - continue; - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - this.furnaceItemStacks[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); + if (this.furnaceItemStacks[i] != null) { + final NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + this.furnaceItemStacks[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } } - nbtCompound.setTag("Items", nbttaglist); - - if (func_145818_k_()) { + if (this.hasCustomInventoryName()) { nbtCompound.setString("CustomName", this.customName); } - this.aspects.writeToNBT(nbtCompound); } - public int func_70297_j_() { + @Override + public int getInventoryStackLimit() { return 64; } + @Override @SideOnly(Side.CLIENT) - public int getCookProgressScaled(int par1) { - if (this.smeltTime <= 0) + public int getCookProgressScaled(final int par1) { + if (this.smeltTime <= 0) { this.smeltTime = 1; - return (this.furnaceCookTime * par1 / this.smeltTime); + } + return (this.furnaceCookTime * par1) / this.smeltTime; } + @Override @SideOnly(Side.CLIENT) - public int getContentsScaled(int par1) { - return (this.vis * par1 / this.maxVis); + public int getContentsScaled(final int par1) { + return (this.vis * par1) / this.maxVis; } + @Override @SideOnly(Side.CLIENT) - public int getBurnTimeRemainingScaled(int par1) { + public int getBurnTimeRemainingScaled(final int par1) { if (this.currentItemBurnTime == 0) { this.currentItemBurnTime = 200; } - - return (this.furnaceBurnTime * par1 / this.currentItemBurnTime); + return (this.furnaceBurnTime * par1) / this.currentItemBurnTime; } + @Override public boolean isBurning() { - return (this.furnaceBurnTime > 0); + return this.furnaceBurnTime > 0; } - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); - if (this.worldObj != null) - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, - this.zCoord); + if (this.worldObj != null) { + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord); + } } + @Override public boolean canUpdate() { return true; } - public void func_145845_h() { - boolean flag = this.furnaceBurnTime > 0; - boolean flag1 = false; - this.count += 1; + @Override + public void updateEntity() { + final boolean flag = this.furnaceBurnTime > 0; + boolean flag2 = false; + ++this.count; if (this.furnaceBurnTime > 0) { - this.furnaceBurnTime -= 1; + --this.furnaceBurnTime; } - - if (!(this.worldObj.isRemote)) { - if (this.bellows < 0) - getBellows(); - - if ((this.count % ((this.speedBoost) ? 20 : 40) == 0) && (this.aspects.size() > 0)) { - AspectList exlude = new AspectList(); + if (!this.worldObj.isRemote) { + if (this.bellows < 0) { + this.getBellows(); + } + if (((this.count % (this.speedBoost ? 10 : 20)) == 0) && (this.aspects.size() > 0)) { + final AspectList exlude = new AspectList(); int deep = 0; TileEntity tile = null; while (deep < 5) { ++deep; - tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord + deep, - this.zCoord); - if (!(tile instanceof TileAlembic)) + tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord + deep, this.zCoord); + if (!(tile instanceof TileAlembic)) { break; - TileAlembic alembic = (TileAlembic) tile; + } + final TileAlembic alembic = (TileAlembic) tile; if ((alembic.aspect != null) && (alembic.amount < alembic.maxAmount) && (this.aspects.getAmount(alembic.aspect) > 0)) { - takeFromContainer(alembic.aspect, 1); + this.takeFromContainer(alembic.aspect, 1); alembic.addToContainer(alembic.aspect, 1); exlude.merge(alembic.aspect, 1); - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, - this.zCoord); - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord + deep, - this.zCoord); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord + deep, this.zCoord); } tile = null; } - deep = 0; while (deep < 5) { ++deep; - tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord + deep, - this.zCoord); - if (!(tile instanceof TileAlembic)) + tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord + deep, this.zCoord); + if (!(tile instanceof TileAlembic)) { break; - TileAlembic alembic = (TileAlembic) tile; - if ((alembic.aspect == null) || (alembic.amount == 0)) - ; + } + final TileAlembic alembic = (TileAlembic) tile; + if ((alembic.aspect != null) && (alembic.amount != 0)) { + continue; + } Aspect as = null; if (alembic.aspectFilter == null) { - as = takeRandomAspect(exlude); - } else if (takeFromContainer(alembic.aspectFilter, 1)) { + as = this.takeRandomAspect(exlude); + } else if (this.takeFromContainer(alembic.aspectFilter, 1)) { as = alembic.aspectFilter; } - if (as != null) { alembic.addToContainer(as, 1); - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, - this.zCoord); - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord + deep, - this.zCoord); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord + deep, this.zCoord); break; } - } - } - - if ((this.furnaceBurnTime == 0) && (canSmelt())) { - this.currentItemBurnTime = (this.furnaceBurnTime = TileEntityFurnace - .getItemBurnTime(this.furnaceItemStacks[1])); - + if ((this.furnaceBurnTime == 0) && this.canSmelt()) { + final int itemBurnTime = TileEntityFurnace.getItemBurnTime(this.furnaceItemStacks[1]); + this.furnaceBurnTime = itemBurnTime; + this.currentItemBurnTime = itemBurnTime; if (this.furnaceBurnTime > 0) { - flag1 = true; + flag2 = true; this.speedBoost = false; - if (this.furnaceItemStacks[1] != null) { if (this.furnaceItemStacks[1].isItemEqual(new ItemStack(ConfigItems.itemResource, 1, 0))) { this.speedBoost = true; } - this.furnaceItemStacks[1].stackSize -= 1; - + final ItemStack itemStack = this.furnaceItemStacks[1]; + --itemStack.stackSize; if (this.furnaceItemStacks[1].stackSize == 0) { this.furnaceItemStacks[1] = this.furnaceItemStacks[1].getItem() .getContainerItem(this.furnaceItemStacks[1]); @@ -296,126 +288,134 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { } } } - - if ((isBurning()) && (canSmelt())) { - this.furnaceCookTime += 1; - + if (this.isBurning() && this.canSmelt()) { + ++this.furnaceCookTime; if (this.furnaceCookTime >= this.smeltTime) { this.furnaceCookTime = 0; - smeltItem(); - flag1 = true; + this.smeltItem(); + flag2 = true; } } else { this.furnaceCookTime = 0; } - - if (flag != this.furnaceBurnTime > 0) { - flag1 = true; + if (flag != (this.furnaceBurnTime > 0)) { + flag2 = true; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } } - - if (!(flag1)) - return; - markDirty(); + if (flag2) { + this.markDirty(); + } } private boolean canSmelt() { if (this.furnaceItemStacks[0] == null) { return false; } - AspectList al = ThaumcraftCraftingManager.getObjectTags(this.furnaceItemStacks[0]); al = ThaumcraftCraftingManager.getBonusTags(this.furnaceItemStacks[0], al); - - if ((al == null) || (al.size() == 0)) + if ((al == null) || (al.size() == 0)) { return false; - int vs = al.visSize(); - if (vs > this.maxVis - this.vis) + } + final int vs = al.visSize(); + if (vs > (this.maxVis - this.vis)) { return false; - this.smeltTime = (int) (vs * 10 * (1.0F - (0.125F * this.bellows))); + } + this.smeltTime = (int) (vs * 10 * (1.0f - (0.125f * this.bellows))); return true; } + @Override public void getBellows() { - this.bellows = TileBellows.getBellows(this.worldObj, this.xCoord, this.yCoord, - this.zCoord, ForgeDirection.VALID_DIRECTIONS); + this.bellows = TileBellows.getBellows(this.worldObj, this.xCoord, this.yCoord, this.zCoord, + ForgeDirection.VALID_DIRECTIONS); } + @Override public void smeltItem() { - if (!(canSmelt())) { - return; - } - AspectList al = ThaumcraftCraftingManager.getObjectTags(this.furnaceItemStacks[0]); - al = ThaumcraftCraftingManager.getBonusTags(this.furnaceItemStacks[0], al); - - for (Aspect a : al.getAspects()) { - this.aspects.add(a, al.getAmount(a)); + if (this.canSmelt()) { + AspectList al = ThaumcraftCraftingManager.getObjectTags(this.furnaceItemStacks[0]); + al = ThaumcraftCraftingManager.getBonusTags(this.furnaceItemStacks[0], al); + for (final Aspect a : al.getAspects()) { + this.aspects.add(a, al.getAmount(a)); + } + this.vis = this.aspects.visSize(); + final ItemStack itemStack = this.furnaceItemStacks[0]; + --itemStack.stackSize; + if (this.furnaceItemStacks[0].stackSize <= 0) { + this.furnaceItemStacks[0] = null; + } } - - this.vis = this.aspects.visSize(); - - this.furnaceItemStacks[0].stackSize -= 1; - - if (this.furnaceItemStacks[0].stackSize > 0) - return; - this.furnaceItemStacks[0] = null; } - public static boolean isItemFuel(ItemStack par0ItemStack) { - return (TileEntityFurnace.getItemBurnTime(par0ItemStack) > 0); + public static boolean isItemFuel(final ItemStack par0ItemStack) { + return TileEntityFurnace.getItemBurnTime(par0ItemStack) > 0; } - public boolean func_70300_a(EntityPlayer par1EntityPlayer) { - return (this.worldObj.getTileEntity(this.xCoord, this.yCoord, - this.zCoord) == this); + @Override + public boolean isUseableByPlayer(final EntityPlayer par1EntityPlayer) { + return (this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this) + && (par1EntityPlayer.getDistanceSq(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5) <= 64.0); } - public void func_70295_k_() { + @Override + public void openInventory() { } - public void func_70305_f() { + @Override + public void closeInventory() { } - public boolean func_94041_b(int par1, ItemStack par2ItemStack) { + @Override + public boolean isItemValidForSlot(final int par1, final ItemStack par2ItemStack) { if (par1 == 0) { AspectList al = ThaumcraftCraftingManager.getObjectTags(par2ItemStack); al = ThaumcraftCraftingManager.getBonusTags(par2ItemStack, al); - if ((al != null) && (al.size() > 0)) + if ((al != null) && (al.size() > 0)) { return true; + } } - return ((par1 == 1) ? isItemFuel(par2ItemStack) : false); + return (par1 == 1) && isItemFuel(par2ItemStack); } - public int[] func_94128_d(int par1) { - return ((par1 == 1) ? slots_top : (par1 == 0) ? slots_bottom : slots_sides); + @Override + public int[] getAccessibleSlotsFromSide(final int par1) { + return (par1 == 0) + ? TileFastAlchemyFurnace.slots_bottom + : ((par1 == 1) ? TileFastAlchemyFurnace.slots_top : TileFastAlchemyFurnace.slots_sides); } - public boolean func_102007_a(int par1, ItemStack par2ItemStack, int par3) { - return ((par3 == 1) ? false : func_94041_b(par1, par2ItemStack)); + @Override + public boolean canInsertItem(final int par1, final ItemStack par2ItemStack, final int par3) { + return (par3 != 1) && this.isItemValidForSlot(par1, par2ItemStack); } - public boolean func_102008_b(int par1, ItemStack par2ItemStack, int par3) { - return ((par3 != 0) || (par1 != 1) || (par2ItemStack.getItem() == Items.bucket)); + @Override + public boolean canExtractItem(final int par1, final ItemStack par2ItemStack, final int par3) { + return (par3 != 0) || (par1 != 1) || (par2ItemStack.getItem() == Items.bucket); } - public Aspect takeRandomAspect(AspectList exlude) { + @Override + public Aspect takeRandomAspect(final AspectList exlude) { if (this.aspects.size() > 0) { - AspectList temp = this.aspects.copy(); - if (exlude.size() > 0) - for (Aspect a : exlude.getAspects()) + final AspectList temp = this.aspects.copy(); + if (exlude.size() > 0) { + for (final Aspect a : exlude.getAspects()) { temp.remove(a); + } + } if (temp.size() > 0) { - Aspect tag = temp.getAspects()[this.worldObj.rand.nextInt(temp.getAspects().length)]; + final Aspect tag = temp.getAspects()[this.worldObj.rand.nextInt(temp.getAspects().length)]; this.aspects.remove(tag, 1); - this.vis -= 1; + --this.vis; return tag; } } return null; } - public boolean takeFromContainer(Aspect tag, int amount) { + @Override + public boolean takeFromContainer(final Aspect tag, final int amount) { if ((this.aspects != null) && (this.aspects.getAmount(tag) >= amount)) { this.aspects.remove(tag, amount); this.vis -= amount; @@ -423,4 +423,10 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { } return false; } + + static { + slots_bottom = new int[]{1}; + slots_top = new int[0]; + slots_sides = new int[]{0}; + } } \ No newline at end of file -- cgit From 9d52b3d41d6dfdfb2e61cd59510b3a1d61925a16 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 20 Nov 2017 23:21:15 +1000 Subject: + Added the Upgraded Arcane Alembic.$ Fixed the Upgraded Alchemy Furnace GUI. % Tried to make the 'Upgraded' Alembic & Furnace work better with the vanilla TC versions. $ Fixed the Upgraded Alchemy Furnace causing the tesselator to throw issues. $ Fixes to the Upgraded Arcane Alembic. --- src/Java/gtPlusPlus/core/handler/GuiHandler.java | 9 + .../core/item/base/itemblock/ItemBlockBase.java | 21 -- .../item/base/itemblock/ItemBlockEntityBase.java | 23 ++ .../item/base/itemblock/ItemBlockTileEntity.java | 43 --- .../core/tileentities/ModTileEntities.java | 9 +- .../thaumcraft/common/ItemBlockThaumcraft.java | 34 ++ .../common/block/BlockFastAlchemyFurnace.java | 22 +- .../common/block/BlockFastArcaneAlembic.java | 373 +++++++++++++++++++++ .../thaumcraft/common/block/TC_BlockHandler.java | 10 +- .../common/tile/TileFastAlchemyFurnace.java | 17 +- .../common/tile/TileFastArcaneAlembic.java | 258 ++++++++++++++ .../gui/ContainerFastAlchemyFurnace.java | 143 ++++++++ .../xmod/thaumcraft/gui/GuiFastAlchemyFurnace.java | 45 +++ 13 files changed, 914 insertions(+), 93 deletions(-) delete mode 100644 src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java create mode 100644 src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java delete mode 100644 src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockTileEntity.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/common/ItemBlockThaumcraft.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastArcaneAlembic.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastArcaneAlembic.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/gui/ContainerFastAlchemyFurnace.java create mode 100644 src/Java/gtPlusPlus/xmod/thaumcraft/gui/GuiFastAlchemyFurnace.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 6791289f9f..cf7c90eca5 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -32,6 +32,9 @@ import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; +import gtPlusPlus.xmod.thaumcraft.gui.ContainerFastAlchemyFurnace; +import gtPlusPlus.xmod.thaumcraft.gui.GuiFastAlchemyFurnace; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; @@ -94,6 +97,9 @@ public class GuiHandler implements IGuiHandler { else if (ID == GUI7){ return new Container_TradeTable(player.inventory, (TileEntityTradeTable)te); } + else if (ID == GUI8){ + return new ContainerFastAlchemyFurnace(player.inventory, (TileFastAlchemyFurnace)te); + } } if (ID == GUI9){ @@ -143,6 +149,9 @@ public class GuiHandler implements IGuiHandler { else if (ID == GUI7){ return new GUI_TradeTable(player.inventory, (TileEntityTradeTable)te, ((TileEntityBase) te).getOwner()); } + else if (ID == GUI8){ + return new GuiFastAlchemyFurnace(player.inventory, (TileFastAlchemyFurnace)te); + } } if (ID == GUI9){ diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java deleted file mode 100644 index 372539ca7d..0000000000 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java +++ /dev/null @@ -1,21 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; - -public class ItemBlockBase extends ItemBlock { - - public ItemBlockBase(final Block block) { - super(block); - this.setCreativeTab(AddToCreativeTab.tabBlock); - } - - @Override - public int getColorFromItemStack(final ItemStack p_82790_1_, final int p_82790_2_) { - return super.getColorFromItemStack(p_82790_1_, p_82790_2_); - } - - -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java new file mode 100644 index 0000000000..43a37b423c --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java @@ -0,0 +1,23 @@ +package gtPlusPlus.core.item.base.itemblock; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class ItemBlockEntityBase extends ItemBlock { + + public ItemBlockEntityBase(final Block block) { + super(block); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public int getColorFromItemStack(final ItemStack p_82790_1_, final int p_82790_2_) { + return super.getColorFromItemStack(p_82790_1_, p_82790_2_); + } + + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockTileEntity.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockTileEntity.java deleted file mode 100644 index 7a5f20833f..0000000000 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockTileEntity.java +++ /dev/null @@ -1,43 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public class ItemBlockTileEntity extends ItemBlock{ - - String[] description; - - public ItemBlockTileEntity(final Block block) { - super(block); - } - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - for (int i =0; i< this.description.length; i++){ - if (!this.description[i].equals("")){ - list.add(this.description[i]); - } - } - - - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - - } - - public void setDecription(final String[] description){ - for (int i =0; i< description.length; i++){ - this.description[i] = description[i]; - } - } - -} diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index 6dd948bcd1..83d274473c 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -1,13 +1,18 @@ package gtPlusPlus.core.tileentities; import cpw.mods.fml.common.registry.GameRegistry; -import gtPlusPlus.core.tileentities.general.*; +import gtPlusPlus.core.tileentities.general.TileEntityFirepit; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; +import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastArcaneAlembic; public class ModTileEntities { @@ -30,6 +35,8 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); GameRegistry.registerTileEntity(TileEntityTradeTable.class, "TileTradeTable"); GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); + GameRegistry.registerTileEntity(TileFastAlchemyFurnace.class, "TileFastAlchemyFurnace"); + GameRegistry.registerTileEntity(TileFastArcaneAlembic.class, "TileFastArcaneAlembic"); } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/ItemBlockThaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/ItemBlockThaumcraft.java new file mode 100644 index 0000000000..465f443906 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/ItemBlockThaumcraft.java @@ -0,0 +1,34 @@ +package gtPlusPlus.xmod.thaumcraft.common; + +import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ItemBlockThaumcraft extends ItemBlockEntityBase{ + + public ItemBlockThaumcraft(final Block block) { + super(block); + } + + @Override + public int getMetadata(final int par1) { + return par1; + } + + @Override + public String getUnlocalizedName(final ItemStack par1ItemStack) { + return super.getUnlocalizedName() + "." + par1ItemStack.getItemDamage(); + } + + public boolean placeBlockAt(final ItemStack stack, final EntityPlayer player, final World world, final int x, + final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ, + final int metadata) { + final boolean ret = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + return ret; + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java index eee996f6f9..bf4a61cfc9 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java @@ -10,12 +10,14 @@ import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.GTplusplus; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.xmod.thaumcraft.common.ItemBlockThaumcraft; import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; @@ -24,17 +26,15 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import thaumcraft.common.Thaumcraft; -import thaumcraft.common.blocks.BlockStoneDevice; -import thaumcraft.common.config.ConfigBlocks; import thaumcraft.common.lib.utils.InventoryUtils; -public class BlockFastAlchemyFurnace extends BlockStoneDevice { +public class BlockFastAlchemyFurnace extends BlockContainer { public IIcon[] iconFurnace; public IIcon[] iconPedestal; public BlockFastAlchemyFurnace() { + super(Material.iron); this.iconFurnace = new IIcon[5]; this.iconPedestal = new IIcon[2]; this.setCreativeTab(AddToCreativeTab.tabMachines); @@ -43,7 +43,7 @@ public class BlockFastAlchemyFurnace extends BlockStoneDevice { this.setResistance(25.0f); this.setStepSound(Block.soundTypeStone); this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); - GameRegistry.registerBlock(this, "blockFastAlchemyFurnace"); + GameRegistry.registerBlock(this, ItemBlockThaumcraft.class, "blockFastAlchemyFurnace"); LanguageRegistry.addName(this, "Upgraded Alchemical Furnace"); } @@ -122,13 +122,13 @@ public class BlockFastAlchemyFurnace extends BlockStoneDevice { @Override public boolean onBlockEventReceived(final World par1World, final int par2, final int par3, final int par4, final int par5, final int par6) { - if (par5 == 1) { + /*if (par5 == 1) { if (par1World.isRemote) { Thaumcraft.proxy.blockSparkle(par1World, par2, par3, par4, 11960575, 2); par1World.playAuxSFX(2001, par2, par3, par4, Block.getIdFromBlock(Blocks.stonebrick) + 0); } return true; - } + }*/ return super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); } @@ -192,10 +192,10 @@ public class BlockFastAlchemyFurnace extends BlockStoneDevice { this.iconFurnace[4] = ir.registerIcon("thaumcraft:al_furnace_top_filled"); } - @Override + /*@Override public int getRenderType() { return ConfigBlocks.blockStoneDeviceRI; - } + }*/ @Override public boolean isOpaqueCube() { @@ -243,8 +243,6 @@ public class BlockFastAlchemyFurnace extends BlockStoneDevice { } return this.iconFurnace[2]; } - } else if ((metadata == 1) || (metadata == 5) || (metadata == 8) || (metadata == 12)) { - return super.getIcon(iblockaccess, i, j, k, side); } return this.iconFurnace[0]; } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastArcaneAlembic.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastArcaneAlembic.java new file mode 100644 index 0000000000..04c0673b49 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastArcaneAlembic.java @@ -0,0 +1,373 @@ +package gtPlusPlus.xmod.thaumcraft.common.block; + +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.xmod.thaumcraft.common.ItemBlockThaumcraft; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastArcaneAlembic; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.aspects.IEssentiaContainerItem; +import thaumcraft.common.blocks.ItemJarFilled; +import thaumcraft.common.config.ConfigBlocks; +import thaumcraft.common.config.ConfigItems; +import thaumcraft.common.lib.utils.InventoryUtils; + +public class BlockFastArcaneAlembic extends BlockContainer { + public IIcon[] icon; + public IIcon iconGlow; + private final int delay; + + public BlockFastArcaneAlembic() { + super(Material.iron); + this.icon = new IIcon[23]; + this.delay = 0; + this.setStepSound(Block.soundTypeMetal); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setBlockName("blockFastArcaneAlembic"); + this.setHardness(3.0f); + this.setResistance(25.0f); + this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + GameRegistry.registerBlock(this, ItemBlockThaumcraft.class, "blockFastArcaneAlembic"); + LanguageRegistry.addName(this, "Upgraded Arcane Alembic"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister ir) { + this.icon[0] = ir.registerIcon("thaumcraft:metalbase"); + for (int a = 1; a <= 6; ++a) { + this.icon[a] = ir.registerIcon("thaumcraft:crucible" + a); + } + this.icon[7] = ir.registerIcon("thaumcraft:goldbase"); + this.iconGlow = ir.registerIcon("thaumcraft:animatedglow"); + } + + @Override + public IIcon getIcon(final int i, final int md) { + return ((md == 0) || (md == 1) || (md == 5) || (md == 6)) ? this.icon[0] : this.icon[7]; + } + + @Override + public IIcon getIcon(final IBlockAccess iblockaccess, final int i, final int j, final int k, final int side) { + if (side == 1) { + return this.icon[1]; + } + if (side == 0) { + return this.icon[2]; + } + return this.icon[3]; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) { + par3List.add(new ItemStack(par1, 1, 1)); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public void onEntityCollidedWithBlock(final World world, final int i, final int j, final int k, + final Entity entity) { + if (!world.isRemote) { + + } + } + + @Override + public void addCollisionBoxesToList(final World world, final int i, final int j, final int k, + final AxisAlignedBB axisalignedbb, final List arraylist, final Entity par7Entity) { + this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World w, final int i, final int j, final int k, final Random r) { + + } + + @Override + public int damageDropped(final int metadata) { + return metadata; + } + + @Override + public TileEntity createTileEntity(final World world, final int metadata) { + + if (metadata == 1) { + return new TileFastArcaneAlembic(); + } + return super.createTileEntity(world, metadata); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(final World world, final int x, final int y, final int z, final int rs) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileFastArcaneAlembic)) { + final float r = ((TileFastArcaneAlembic) te).amount / ((TileFastArcaneAlembic) te).maxAmount; + return MathHelper.floor_float(r * 14.0f) + ((((TileFastArcaneAlembic) te).amount > 0) ? 1 : 0); + } + return 0; + } + + @Override + public TileEntity createNewTileEntity(final World var1, final int md) { + return null; + } + + @Override + public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block nbid) { + final TileEntity te = world.getTileEntity(x, y, z); + if (!world.isRemote) { + if ((te != null) && (te instanceof TileFastArcaneAlembic)) { + world.markBlockForUpdate(x, y, z); + } + } + super.onNeighborBlockChange(world, x, y, z, nbid); + } + + @Override + public void breakBlock(final World par1World, final int par2, final int par3, final int par4, final Block par5, + final int par6) { + InventoryUtils.dropItems(par1World, par2, par3, par4); + final TileEntity te = par1World.getTileEntity(par2, par3, par4); + if ((te != null) && (te instanceof TileFastArcaneAlembic) && (((TileFastArcaneAlembic) te).aspectFilter != null)) { + par1World.spawnEntityInWorld(new EntityItem(par1World, par2 + 0.5f, + par3 + 0.5f, par4 + 0.5f, new ItemStack(ConfigItems.itemResource, 1, 13))); + } + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float par7, final float par8, final float par9) { + final int metadata = world.getBlockMetadata(x, y, z); + + if ((metadata == 1) && !world.isRemote && !player.isSneaking() && (player.getHeldItem() == null)) { + final TileEntity te2 = world.getTileEntity(x, y, z); + if ((te2 != null) && (te2 instanceof TileFastArcaneAlembic)) { + final TileFastArcaneAlembic tile2 = (TileFastArcaneAlembic) te2; + String msg = ""; + if ((tile2.aspect == null) || (tile2.amount == 0)) { + msg = StatCollector.translateToLocal("tile.alembic.msg.1"); + } else if (tile2.amount < (tile2.maxAmount * 0.4)) { + msg = StatCollector.translateToLocal("tile.alembic.msg.2"); + } else if (tile2.amount < (tile2.maxAmount * 0.8)) { + msg = StatCollector.translateToLocal("tile.alembic.msg.3"); + } else if (tile2.amount < tile2.maxAmount) { + msg = StatCollector.translateToLocal("tile.alembic.msg.4"); + } else if (tile2.amount == tile2.maxAmount) { + msg = StatCollector.translateToLocal("tile.alembic.msg.5"); + } + player.addChatMessage(new ChatComponentTranslation("§3" + msg, new Object[0])); + world.playSoundEffect(x, y, z, "thaumcraft:alembicknock", 0.2f, 1.0f); + } + } + if (metadata == 1) { + final TileEntity te2 = world.getTileEntity(x, y, z); + if ((te2 != null) && (te2 instanceof TileFastArcaneAlembic)) { + if (player.isSneaking() && (((TileFastArcaneAlembic) te2).aspectFilter != null)) { + ((TileFastArcaneAlembic) te2).aspectFilter = null; + world.markBlockForUpdate(x, y, z); + te2.markDirty(); + if (world.isRemote) { + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "thaumcraft:page", 1.0f, 1.1f, false); + } else { + final ForgeDirection fd = ForgeDirection.getOrientation(side); + world.spawnEntityInWorld(new EntityItem(world, x + 0.5f + (fd.offsetX / 3.0f), + y + 0.5f, z + 0.5f + (fd.offsetZ / 3.0f), + new ItemStack(ConfigItems.itemResource, 1, 13))); + } + return true; + } + if (player.isSneaking() && (player.getHeldItem() == null)) { + ((TileFastArcaneAlembic) te2).amount = 0; + ((TileFastArcaneAlembic) te2).aspect = null; + if (world.isRemote) { + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "thaumcraft:alembicknock", 0.2f, 1.0f, false); + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "game.neutral.swim", 0.5f, + 1.0f + ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.3f), false); + } + } else if ((player.getHeldItem() != null) && (((TileFastArcaneAlembic) te2).aspectFilter == null) + && (player.getHeldItem().getItem() == ConfigItems.itemResource) + && (player.getHeldItem().getItemDamage() == 13)) { + if ((((TileFastArcaneAlembic) te2).amount == 0) && (((IEssentiaContainerItem) player.getHeldItem().getItem()) + .getAspects(player.getHeldItem()) == null)) { + return true; + } + if ((((TileFastArcaneAlembic) te2).amount == 0) && (((IEssentiaContainerItem) player.getHeldItem().getItem()) + .getAspects(player.getHeldItem()) != null)) { + ((TileFastArcaneAlembic) te2).aspect = ((IEssentiaContainerItem) player.getHeldItem().getItem()) + .getAspects(player.getHeldItem()).getAspects()[0]; + } + final ItemStack heldItem = player.getHeldItem(); + --heldItem.stackSize; + ((TileFastArcaneAlembic) te2).aspectFilter = ((TileFastArcaneAlembic) te2).aspect; + world.markBlockForUpdate(x, y, z); + te2.markDirty(); + if (world.isRemote) { + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "thaumcraft:page", 1.0f, 0.9f, false); + } + return true; + } else if ((player.getHeldItem() != null) && (((TileFastArcaneAlembic) te2).amount > 0) + && ((player.getHeldItem().getItem() == ConfigItems.itemJarFilled) + || player.getHeldItem().isItemEqual(new ItemStack(ConfigBlocks.blockJar, 1, 0)) + || player.getHeldItem().isItemEqual(new ItemStack(ConfigBlocks.blockJar, 1, 3)))) { + boolean doit = false; + ItemStack drop = null; + if (player.getHeldItem().isItemEqual(new ItemStack(ConfigBlocks.blockJar, 1, 0)) + || player.getHeldItem().isItemEqual(new ItemStack(ConfigBlocks.blockJar, 1, 3))) { + drop = new ItemStack(ConfigItems.itemJarFilled, 1, player.getHeldItem().getItemDamage()); + doit = true; + ((ItemJarFilled) drop.getItem()).setAspects(drop, + new AspectList().add(((TileFastArcaneAlembic) te2).aspect, ((TileFastArcaneAlembic) te2).amount)); + ((TileFastArcaneAlembic) te2).amount = 0; + ((TileFastArcaneAlembic) te2).aspect = null; + final ItemStack heldItem2 = player.getHeldItem(); + --heldItem2.stackSize; + if (!player.inventory.addItemStackToInventory(drop) && !world.isRemote) { + world.spawnEntityInWorld( + new EntityItem(world, player.posX, player.posY, player.posZ, drop)); + } + } else { + drop = player.getHeldItem(); + if (((((ItemJarFilled) drop.getItem()).getAspects(drop) == null) + || (((ItemJarFilled) drop.getItem()).getAspects(drop).visSize() == 0) + || (((ItemJarFilled) drop.getItem()).getAspects(drop) + .getAmount(((TileFastArcaneAlembic) te2).aspect) > 0)) + && ((((ItemJarFilled) drop.getItem()).getFilter(drop) == null) + || (((ItemJarFilled) drop.getItem()) + .getFilter(drop) == ((TileFastArcaneAlembic) te2).aspect))) { + int amount = Math.min( + (((ItemJarFilled) drop.getItem()).getAspects(drop) == null) + ? 64 + : (64 - ((ItemJarFilled) drop.getItem()).getAspects(drop).visSize()), + ((TileFastArcaneAlembic) te2).amount); + if (drop.getItemDamage() == 3) { + amount = ((TileFastArcaneAlembic) te2).amount; + } + if (amount > 0) { + final TileFastArcaneAlembic TileFastArcaneAlembic = (TileFastArcaneAlembic) te2; + TileFastArcaneAlembic.amount -= amount; + AspectList as = ((ItemJarFilled) drop.getItem()).getAspects(drop); + if (as == null) { + as = new AspectList(); + } + as.add(((TileFastArcaneAlembic) te2).aspect, amount); + if (as.getAmount(((TileFastArcaneAlembic) te2).aspect) > 64) { + final int q = as.getAmount(((TileFastArcaneAlembic) te2).aspect) - 64; + as.reduce(((TileFastArcaneAlembic) te2).aspect, q); + } + ((ItemJarFilled) drop.getItem()).setAspects(drop, as); + if (((TileFastArcaneAlembic) te2).amount <= 0) { + ((TileFastArcaneAlembic) te2).aspect = null; + } + doit = true; + player.setCurrentItemOrArmor(0, drop); + } + } + } + if (doit) { + te2.markDirty(); + world.markBlockForUpdate(x, y, z); + if (world.isRemote) { + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "game.neutral.swim", 0.5f, + 1.0f + ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.3f), false); + } + } + return true; + } + } + } + + if (world.isRemote) { + return true; + } + + return super.onBlockActivated(world, x, y, z, player, side, par7, par8, par9); + } + + public void onPoweredBlockChange(final World par1World, final int par2, final int par3, final int par4, + final boolean flag) { + final int l = par1World.getBlockMetadata(par2, par3, par4); + if ((l == 5) && flag) { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 6, 2); + par1World.playAuxSFXAtEntity((EntityPlayer) null, 1003, par2, par3, par4, 0); + } else if ((l == 6) && !flag) { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); + par1World.playAuxSFXAtEntity((EntityPlayer) null, 1003, par2, par3, par4, 0); + } + } + + @Override + public void onBlockPlacedBy(final World world, final int par2, final int par3, final int par4, + final EntityLivingBase ent, final ItemStack stack) { + final int l = MathHelper.floor_double(((ent.rotationYaw * 4.0f) / 360.0f) + 0.5) & 0x3; + if (stack.getItemDamage() == 1) { + final TileEntity tile = world.getTileEntity(par2, par3, par4); + if (tile instanceof TileFastArcaneAlembic) { + if (l == 0) { + ((TileFastArcaneAlembic) tile).facing = 2; + } + if (l == 1) { + ((TileFastArcaneAlembic) tile).facing = 5; + } + if (l == 2) { + ((TileFastArcaneAlembic) tile).facing = 3; + } + if (l == 3) { + ((TileFastArcaneAlembic) tile).facing = 4; + } + } + } + } + + @Override + public int getLightValue(final IBlockAccess world, final int x, final int y, final int z) { + return super.getLightValue(world, x, y, z); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java index fade8601f0..0b8d18f7d2 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java @@ -4,10 +4,12 @@ import net.minecraft.block.Block; public class TC_BlockHandler { - static Block blockFurnace; - + public static Block blockFastAlchemyFurnace; + public static Block blockFastArcaneAlembic; + public static void run(){ - blockFurnace = new BlockFastAlchemyFurnace(); + blockFastAlchemyFurnace = new BlockFastAlchemyFurnace(); + blockFastArcaneAlembic = new BlockFastArcaneAlembic(); } - + } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java index ec39e7f4af..756578a536 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java @@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -13,15 +14,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.world.EnumSkyBlock; import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.TileThaumcraft; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.common.config.ConfigItems; import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager; -import thaumcraft.common.tiles.TileAlchemyFurnace; import thaumcraft.common.tiles.TileAlembic; import thaumcraft.common.tiles.TileBellows; -public class TileFastAlchemyFurnace extends TileAlchemyFurnace { +public class TileFastAlchemyFurnace extends TileThaumcraft implements ISidedInventory { private static final int[] slots_bottom; private static final int[] slots_top; private static final int[] slots_sides; @@ -103,7 +104,6 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { return (this.customName != null) && (this.customName.length() > 0); } - @Override public void setGuiDisplayName(final String par1Str) { this.customName = par1Str; } @@ -168,7 +168,6 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { return 64; } - @Override @SideOnly(Side.CLIENT) public int getCookProgressScaled(final int par1) { if (this.smeltTime <= 0) { @@ -177,13 +176,11 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { return (this.furnaceCookTime * par1) / this.smeltTime; } - @Override @SideOnly(Side.CLIENT) public int getContentsScaled(final int par1) { return (this.vis * par1) / this.maxVis; } - @Override @SideOnly(Side.CLIENT) public int getBurnTimeRemainingScaled(final int par1) { if (this.currentItemBurnTime == 0) { @@ -192,7 +189,6 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { return (this.furnaceBurnTime * par1) / this.currentItemBurnTime; } - @Override public boolean isBurning() { return this.furnaceBurnTime > 0; } @@ -229,9 +225,10 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { while (deep < 5) { ++deep; tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord + deep, this.zCoord); - if (!(tile instanceof TileAlembic)) { + if (!(tile instanceof TileAlembic) || !(tile instanceof TileFastArcaneAlembic)) { break; } + final TileAlembic alembic = (TileAlembic) tile; if ((alembic.aspect != null) && (alembic.amount < alembic.maxAmount) && (this.aspects.getAmount(alembic.aspect) > 0)) { @@ -325,13 +322,11 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { return true; } - @Override public void getBellows() { this.bellows = TileBellows.getBellows(this.worldObj, this.xCoord, this.yCoord, this.zCoord, ForgeDirection.VALID_DIRECTIONS); } - @Override public void smeltItem() { if (this.canSmelt()) { AspectList al = ThaumcraftCraftingManager.getObjectTags(this.furnaceItemStacks[0]); @@ -395,7 +390,6 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { return (par3 != 0) || (par1 != 1) || (par2ItemStack.getItem() == Items.bucket); } - @Override public Aspect takeRandomAspect(final AspectList exlude) { if (this.aspects.size() > 0) { final AspectList temp = this.aspects.copy(); @@ -414,7 +408,6 @@ public class TileFastAlchemyFurnace extends TileAlchemyFurnace { return null; } - @Override public boolean takeFromContainer(final Aspect tag, final int amount) { if ((this.aspects != null) && (this.aspects.getAmount(tag) >= amount)) { this.aspects.remove(tag, amount); diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastArcaneAlembic.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastArcaneAlembic.java new file mode 100644 index 0000000000..b89f9a4229 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastArcaneAlembic.java @@ -0,0 +1,258 @@ +package gtPlusPlus.xmod.thaumcraft.common.tile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.xmod.thaumcraft.common.block.TC_BlockHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.config.ConfigBlocks; +import thaumcraft.common.tiles.TileAlembic; + +public class TileFastArcaneAlembic extends TileAlembic { + public Aspect aspect; + public Aspect aspectFilter; + public int amount; + public int maxAmount; + public int facing; + public boolean aboveAlembic; + public boolean aboveFurnace; + ForgeDirection fd; + + public TileFastArcaneAlembic() { + this.aspectFilter = null; + this.amount = 0; + this.maxAmount = 64; + this.facing = 2; + this.aboveAlembic = false; + this.aboveFurnace = false; + this.fd = null; + } + + @Override + public AspectList getAspects() { + return (this.aspect != null) ? new AspectList().add(this.aspect, this.amount) : new AspectList(); + } + + @Override + public void setAspects(final AspectList aspects) { + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(this.xCoord - 1, this.yCoord, + this.zCoord - 1, this.xCoord + 2, this.yCoord + 1, + this.zCoord + 2); + } + + @Override + public void readCustomNBT(final NBTTagCompound nbttagcompound) { + this.facing = nbttagcompound.getByte("facing"); + this.aspectFilter = Aspect.getAspect(nbttagcompound.getString("AspectFilter")); + final String tag = nbttagcompound.getString("aspect"); + if (tag != null) { + this.aspect = Aspect.getAspect(tag); + } + this.amount = nbttagcompound.getShort("amount"); + this.fd = ForgeDirection.getOrientation(this.facing); + } + + @Override + public void writeCustomNBT(final NBTTagCompound nbttagcompound) { + if (this.aspect != null) { + nbttagcompound.setString("aspect", this.aspect.getTag()); + } + if (this.aspectFilter != null) { + nbttagcompound.setString("AspectFilter", this.aspectFilter.getTag()); + } + nbttagcompound.setShort("amount", (short) this.amount); + nbttagcompound.setByte("facing", (byte) this.facing); + } + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public int addToContainer(final Aspect tt, int am) { + if (((this.amount < this.maxAmount) && (tt == this.aspect)) || (this.amount == 0)) { + this.aspect = tt; + final int added = Math.min(am, this.maxAmount - this.amount); + this.amount += added; + am -= added; + } + this.markDirty(); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + return am; + } + + @Override + public boolean takeFromContainer(final Aspect tt, final int am) { + if ((this.amount == 0) || (this.aspect == null)) { + this.aspect = null; + this.amount = 0; + } + if ((this.aspect != null) && (this.amount >= am) && (tt == this.aspect)) { + this.amount -= am; + if (this.amount <= 0) { + this.aspect = null; + this.amount = 0; + } + this.markDirty(); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + return true; + } + return false; + } + + @Override + public boolean doesContainerContain(final AspectList ot) { + return (this.amount > 0) && (this.aspect != null) && (ot.getAmount(this.aspect) > 0); + } + + @Override + public boolean doesContainerContainAmount(final Aspect tt, final int am) { + return (this.amount >= am) && (tt == this.aspect); + } + + @Override + public int containerContains(final Aspect tt) { + return (tt == this.aspect) ? this.amount : 0; + } + + @Override + public boolean doesContainerAccept(final Aspect tag) { + return true; + } + + @Override + public boolean takeFromContainer(final AspectList ot) { + return false; + } + + @Override + public void getAppearance() { + this.aboveAlembic = false; + this.aboveFurnace = false; + if ((this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord) == ConfigBlocks.blockStoneDevice) + && (this.worldObj.getBlockMetadata(this.xCoord, this.yCoord - 1, this.zCoord) == 0)) { + this.aboveFurnace = true; + } + else if ((this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord) == TC_BlockHandler.blockFastAlchemyFurnace) + && (this.worldObj.getBlockMetadata(this.xCoord, this.yCoord - 1, this.zCoord) == 0)) { + this.aboveFurnace = true; + } + + if ((this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord) == ConfigBlocks.blockMetalDevice) + && (this.worldObj.getBlockMetadata(this.xCoord, this.yCoord - 1, this.zCoord) == this + .getBlockMetadata())) { + this.aboveAlembic = true; + } + else if ((this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord) == TC_BlockHandler.blockFastArcaneAlembic) + && (this.worldObj.getBlockMetadata(this.xCoord, this.yCoord - 1, this.zCoord) == 1)) { + this.aboveAlembic = true; + } + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + super.onDataPacket(net, pkt); + this.getAppearance(); + } + + @Override + public int onWandRightClick(final World world, final ItemStack wandstack, final EntityPlayer player, final int x, + final int y, final int z, final int side, final int md) { + if (side <= 1) { + return 0; + } + this.facing = side; + this.fd = ForgeDirection.getOrientation(this.facing); + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + player.swingItem(); + this.markDirty(); + return 0; + } + + @Override + public ItemStack onWandRightClick(final World world, final ItemStack wandstack, final EntityPlayer player) { + return null; + } + + @Override + public void onUsingWandTick(final ItemStack wandstack, final EntityPlayer player, final int count) { + } + + @Override + public void onWandStoppedUsing(final ItemStack wandstack, final World world, final EntityPlayer player, + final int count) { + } + + @Override + public boolean isConnectable(final ForgeDirection face) { + return (face != ForgeDirection.getOrientation(this.facing)) && (face != ForgeDirection.DOWN); + } + + @Override + public boolean canInputFrom(final ForgeDirection face) { + return false; + } + + @Override + public boolean canOutputTo(final ForgeDirection face) { + return (face != ForgeDirection.getOrientation(this.facing)) && (face != ForgeDirection.DOWN); + } + + @Override + public void setSuction(final Aspect aspect, final int amount) { + } + + @Override + public Aspect getSuctionType(final ForgeDirection loc) { + return null; + } + + @Override + public int getSuctionAmount(final ForgeDirection loc) { + return 0; + } + + @Override + public Aspect getEssentiaType(final ForgeDirection loc) { + return this.aspect; + } + + @Override + public int getEssentiaAmount(final ForgeDirection loc) { + return this.amount; + } + + @Override + public int takeEssentia(final Aspect aspect, final int amount, final ForgeDirection face) { + return (this.canOutputTo(face) && this.takeFromContainer(aspect, amount)) ? amount : 0; + } + + @Override + public int addEssentia(final Aspect aspect, final int amount, final ForgeDirection loc) { + return 0; + } + + @Override + public int getMinimumSuction() { + return 0; + } + + @Override + public boolean renderExtendedTube() { + return true; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/gui/ContainerFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/gui/ContainerFastAlchemyFurnace.java new file mode 100644 index 0000000000..e06d83846e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/gui/ContainerFastAlchemyFurnace.java @@ -0,0 +1,143 @@ +package gtPlusPlus.xmod.thaumcraft.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.container.SlotLimitedHasAspects; +import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager; + +public class ContainerFastAlchemyFurnace extends Container { + private final TileFastAlchemyFurnace furnace; + private int lastCookTime; + private int lastBurnTime; + private int lastItemBurnTime; + private int lastVis; + private int lastSmelt; + + public ContainerFastAlchemyFurnace(final InventoryPlayer par1InventoryPlayer, final TileFastAlchemyFurnace tileEntity) { + this.furnace = tileEntity; + this.addSlotToContainer(new SlotLimitedHasAspects(tileEntity, 0, 80, 8)); + this.addSlotToContainer(new Slot(tileEntity, 1, 80, 48)); + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { + this.addSlotToContainer( + new Slot(par1InventoryPlayer, j + (i * 9) + 9, 8 + (j * 18), 84 + (i * 18))); + } + } + for (int i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + (i * 18), 142)); + } + } + + @Override + public void addCraftingToCrafters(final ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + par1ICrafting.sendProgressBarUpdate(this, 0, this.furnace.furnaceCookTime); + par1ICrafting.sendProgressBarUpdate(this, 1, this.furnace.furnaceBurnTime); + par1ICrafting.sendProgressBarUpdate(this, 2, this.furnace.currentItemBurnTime); + par1ICrafting.sendProgressBarUpdate(this, 3, this.furnace.vis); + par1ICrafting.sendProgressBarUpdate(this, 4, this.furnace.smeltTime); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) { + final ICrafting icrafting = (ICrafting) this.crafters.get(i); + if (this.lastCookTime != this.furnace.furnaceCookTime) { + icrafting.sendProgressBarUpdate(this, 0, this.furnace.furnaceCookTime); + } + if (this.lastBurnTime != this.furnace.furnaceBurnTime) { + icrafting.sendProgressBarUpdate(this, 1, this.furnace.furnaceBurnTime); + } + if (this.lastItemBurnTime != this.furnace.currentItemBurnTime) { + icrafting.sendProgressBarUpdate(this, 2, this.furnace.currentItemBurnTime); + } + if (this.lastVis != this.furnace.vis) { + icrafting.sendProgressBarUpdate(this, 3, this.furnace.vis); + } + if (this.lastSmelt != this.furnace.smeltTime) { + icrafting.sendProgressBarUpdate(this, 4, this.furnace.smeltTime); + } + } + this.lastCookTime = this.furnace.furnaceCookTime; + this.lastBurnTime = this.furnace.furnaceBurnTime; + this.lastItemBurnTime = this.furnace.currentItemBurnTime; + this.lastVis = this.furnace.vis; + this.lastSmelt = this.furnace.smeltTime; + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(final int par1, final int par2) { + if (par1 == 0) { + this.furnace.furnaceCookTime = par2; + } + if (par1 == 1) { + this.furnace.furnaceBurnTime = par2; + } + if (par1 == 2) { + this.furnace.currentItemBurnTime = par2; + } + if (par1 == 3) { + this.furnace.vis = par2; + } + if (par1 == 4) { + this.furnace.smeltTime = par2; + } + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + return this.furnace.isUseableByPlayer(par1EntityPlayer); + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack itemstack = null; + final Slot slot = (Slot) this.inventorySlots.get(par2); + if ((slot != null) && slot.getHasStack()) { + final ItemStack itemstack2 = slot.getStack(); + itemstack = itemstack2.copy(); + if ((par2 != 1) && (par2 != 0)) { + AspectList al = ThaumcraftCraftingManager.getObjectTags(itemstack2); + al = ThaumcraftCraftingManager.getBonusTags(itemstack2, al); + if (TileFastAlchemyFurnace.isItemFuel(itemstack2)) { + if (!this.mergeItemStack(itemstack2, 1, 2, false) + && !this.mergeItemStack(itemstack2, 0, 1, false)) { + return null; + } + } else if ((al != null) && (al.size() > 0)) { + if (!this.mergeItemStack(itemstack2, 0, 1, false)) { + return null; + } + } else if ((par2 >= 2) && (par2 < 29)) { + if (!this.mergeItemStack(itemstack2, 29, 38, false)) { + return null; + } + } else if ((par2 >= 29) && (par2 < 38) && !this.mergeItemStack(itemstack2, 2, 29, false)) { + return null; + } + } else if (!this.mergeItemStack(itemstack2, 2, 38, false)) { + return null; + } + if (itemstack2.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + if (itemstack2.stackSize == itemstack.stackSize) { + return null; + } + slot.onPickupFromSlot(par1EntityPlayer, itemstack2); + } + return itemstack; + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/gui/GuiFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/gui/GuiFastAlchemyFurnace.java new file mode 100644 index 0000000000..5f23568bc1 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/gui/GuiFastAlchemyFurnace.java @@ -0,0 +1,45 @@ +package gtPlusPlus.xmod.thaumcraft.gui; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import thaumcraft.client.lib.UtilsFX; + +@SideOnly(Side.CLIENT) +public class GuiFastAlchemyFurnace extends GuiContainer { + private final TileFastAlchemyFurnace furnaceInventory; + + public GuiFastAlchemyFurnace(final InventoryPlayer par1InventoryPlayer, + final TileFastAlchemyFurnace par2TileEntityFurnace) { + super(new ContainerFastAlchemyFurnace(par1InventoryPlayer, par2TileEntityFurnace)); + this.furnaceInventory = par2TileEntityFurnace; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + UtilsFX.bindTexture("textures/gui/gui_alchemyfurnace.png"); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + GL11.glEnable(3042); + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + if (this.furnaceInventory.isBurning()) { + final int i1 = this.furnaceInventory.getBurnTimeRemainingScaled(20); + this.drawTexturedModalRect(k + 80, (l + 26 + 20) - i1, 176, 20 - i1, 16, i1); + } + int i1 = this.furnaceInventory.getCookProgressScaled(46); + this.drawTexturedModalRect(k + 106, (l + 13 + 46) - i1, 216, 46 - i1, 9, i1); + i1 = this.furnaceInventory.getContentsScaled(48); + this.drawTexturedModalRect(k + 61, (l + 12 + 48) - i1, 200, 48 - i1, 8, i1); + this.drawTexturedModalRect(k + 60, l + 8, 232, 0, 10, 55); + GL11.glDisable(3042); + } +} \ No newline at end of file -- cgit From 7bd2240747945f0c4b4287ef106049b7e1505fb6 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 22 Nov 2017 13:47:37 +1000 Subject: + Added the basic framework for Ore Regen commands. + Added more missing Blast Smelter recipes. $ Fixed Alloy Blast Smelter not using fluids as expected. --- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 198 ++++++++++++++++----- .../base/GregtechMeta_MultiBlockBase.java | 150 +++++++++++----- .../command/regen/GTPP_WorldRegenerator.java | 135 ++++++++++++++ .../common/command/regen/HANDLER_GT_Commands.java | 129 ++++++++++++++ .../GregtechMetaTileEntity_AlloyBlastSmelter.java | 50 +++--- .../gregtech/loaders/RecipeGen_BlastSmelter.java | 30 +++- 6 files changed, 574 insertions(+), 118 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/command/regen/GTPP_WorldRegenerator.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/command/regen/HANDLER_GT_Commands.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 623e5651e5..39d09935d2 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1,8 +1,16 @@ package gtPlusPlus.core.recipe; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; -import gregtech.api.util.*; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.HotFuel; +import gregtech.api.util.ThermalFuel; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; @@ -55,7 +63,7 @@ public class RECIPES_GREGTECH { sifterRecipes(); electroMagneticSeperatorRecipes(); addFuels(); - } + } private static void blastSmelterRecipes() { @@ -65,9 +73,9 @@ public class RECIPES_GREGTECH { ItemUtils.getGregtechCircuit(13), ItemUtils.getItemStackOfAmountFromOreDict("dustGold", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSilver", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3), + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3), }, - FluidUtils.getFluidStack("molten.blackbronze", 5*144), + FluidUtils.getFluidStack("molten.blackbronze", 5*144), 0, MathUtils.findPercentageOfInt(200*20, 80), 120); @@ -80,9 +88,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustSteel", 15), ItemUtils.getItemStackOfAmountFromOreDict("dustGold", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSilver", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3) + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3) }, - FluidUtils.getFluidStack("molten.blacksteel", 25*144), + FluidUtils.getFluidStack("molten.blacksteel", 25*144), 0, MathUtils.findPercentageOfInt(60*20, 80), 120); @@ -96,9 +104,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustZinc", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustBismuth", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSteel", 10), - ItemUtils.getItemStackOfAmountFromOreDict("dustBlackSteel", 20) + ItemUtils.getItemStackOfAmountFromOreDict("dustBlackSteel", 20) }, - FluidUtils.getFluidStack("molten.redsteel", 40*144), + FluidUtils.getFluidStack("molten.redsteel", 40*144), 0, MathUtils.findPercentageOfInt(65*20, 80), 120); @@ -111,10 +119,10 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 18), ItemUtils.getItemStackOfAmountFromOreDict("dustZinc", 5), ItemUtils.getItemStackOfAmountFromOreDict("dustSteel", 30), - ItemUtils.getItemStackOfAmountFromOreDict("dustBlackSteel", 60) + ItemUtils.getItemStackOfAmountFromOreDict("dustBlackSteel", 60) }, - FluidUtils.getFluidStack("molten.bluesteel", 125*144), + FluidUtils.getFluidStack("molten.bluesteel", 125*144), 0, MathUtils.findPercentageOfInt(70*20, 80), 120); @@ -124,9 +132,9 @@ public class RECIPES_GREGTECH { new ItemStack[]{ ItemUtils.getGregtechCircuit(2), ItemUtils.getItemStackOfAmountFromOreDict("ingotTungsten", 1), - ItemUtils.getItemStackOfAmountFromOreDict("ingotSteel", 1) + ItemUtils.getItemStackOfAmountFromOreDict("ingotSteel", 1) }, - FluidUtils.getFluidStack("molten.tungstensteel", 2*144), + FluidUtils.getFluidStack("molten.tungstensteel", 2*144), 0, MathUtils.findPercentageOfInt(300*20, 80), 120); @@ -138,9 +146,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 6), ItemUtils.getItemStackOfAmountFromOreDict("dustNickel", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustManganese", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1) + ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1) }, - FluidUtils.getFluidStack("molten.stainlesssteel", 9*144), + FluidUtils.getFluidStack("molten.stainlesssteel", 9*144), 0, MathUtils.findPercentageOfInt(85*20, 80), 120); @@ -155,9 +163,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 3), ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 3), - ItemUtils.getItemStackOfAmountFromOreDict("dustSilicon", 12) + ItemUtils.getItemStackOfAmountFromOreDict("dustSilicon", 12) }, - FluidUtils.getFluidStack("molten.eglinsteel", 48*144), + FluidUtils.getFluidStack("molten.eglinsteel", 48*144), 0, MathUtils.findPercentageOfInt(30*20, 80), 120); @@ -169,9 +177,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustTungstenSteel", 5), ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustMolybdenum", 2), - ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1) + ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1) }, - FluidUtils.getFluidStack("molten.hssg", 9*144), + FluidUtils.getFluidStack("molten.hssg", 9*144), 0, MathUtils.findPercentageOfInt(450*20, 80), 120); @@ -184,9 +192,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustSteel", 5), ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 2), ItemUtils.getItemStackOfAmountFromOreDict("dustMolybdenum", 4), - ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 2) + ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 2) }, - FluidUtils.getFluidStack("molten.hssg", 18*144), + FluidUtils.getFluidStack("molten.hssg", 18*144), 0, MathUtils.findPercentageOfInt(900*20, 80), 120); @@ -198,9 +206,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustHSSG", 6), ItemUtils.getItemStackOfAmountFromOreDict("dustCobalt", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSilicon", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustManganese", 1) + ItemUtils.getItemStackOfAmountFromOreDict("dustManganese", 1) }, - FluidUtils.getFluidStack("molten.hsse", 9*144), + FluidUtils.getFluidStack("molten.hsse", 9*144), 0, MathUtils.findPercentageOfInt(540*20, 80), 120); @@ -211,20 +219,128 @@ public class RECIPES_GREGTECH { ItemUtils.getGregtechCircuit(3), ItemUtils.getItemStackOfAmountFromOreDict("dustHSSG", 6), ItemUtils.getItemStackOfAmountFromOreDict("dustOsmium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 2) + ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 2) }, - FluidUtils.getFluidStack("molten.hsss", 9*144), + FluidUtils.getFluidStack("molten.hsss", 9*144), 0, MathUtils.findPercentageOfInt(810*20, 80), 120); + //Osmiridium + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 3), + ItemUtils.getItemStackOfAmountFromOreDict("dustOsmium", 1) + }, + FluidUtils.getFluidStack("molten.osmiridium", 4*144), + 0, + MathUtils.findPercentageOfInt(1920*20, 80), + 500); + + //Naq Alloy + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustNaquadah", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustOsmiridium", 1) + }, + FluidUtils.getFluidStack("molten.naquadahalloy", 2*144), + 0, + MathUtils.findPercentageOfInt(30720*20, 80), + 500); + + //Nickel-Zinc-Ferrite + if (Materials.get("NickelZincFerrite") != null){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustFerriteMixture", 6) + }, + Materials.Oxygen.getGas(2000), + FluidUtils.getFluidStack("molten.nickelzincferrite", 2*144), + 0, + MathUtils.findPercentageOfInt(600*20, 80), + 120); + } + + //Gallium-Arsenide + if (Materials.get("GalliumArsenide") != null){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustGallium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustArsenic", 1) + }, + FluidUtils.getFluidStack("molten.galliumarsenide", 2*144), + 0, + MathUtils.findPercentageOfInt(600*20, 80), + 120); + } + + + + + + + + + + + + + + //TungstenCarbide + if (Materials.get("TungstenCarbide") != null){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustTungsten", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 1) + }, + FluidUtils.getFluidStack("molten.tungstencarbide", 2*144), + 0, + MathUtils.findPercentageOfInt((int) Math.max(Materials.TungstenCarbide.getMass() / 40L, 1L) * Materials.TungstenCarbide.mBlastFurnaceTemp*20, 80), + 480); + } + + + //Vanadium-Gallium + if (Materials.get("VanadiumGallium") != null){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustGallium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 3) + }, + FluidUtils.getFluidStack("molten.vanadiumgallium", 4*144), + 0, + MathUtils.findPercentageOfInt((int) Math.max(Materials.VanadiumGallium.getMass() / 40L, 1L) * Materials.VanadiumGallium.mBlastFurnaceTemp*20, 80), + 480); + } + + //EIO + //Dark Steel + if (ItemUtils.getItemStackOfAmountFromOreDict("dustElectricalSteel", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustElectricalSteel", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustObsidian", 1) + }, + FluidUtils.getFluidStack("molten.darksteel", 2*144), + 0, + MathUtils.findPercentageOfInt(500*20, 80), + 120); + } + } private static void fluidcannerRecipes() { //Sulfuric Acid GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), FluidUtils.getFluidStack("sulfuricacid", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); - + GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); + //Hydrofluoric Acid GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), FluidUtils.getFluidStack("hydrofluoricacid", 250), null); GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 250)); @@ -239,7 +355,7 @@ public class RECIPES_GREGTECH { 20, GT_ModHandler.getSteam(1000), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), - FluidUtils.getFluidStack("fluid.coalgas", 1440), + FluidUtils.getFluidStack("fluid.coalgas", 1440), 60, 30); @@ -249,7 +365,7 @@ public class RECIPES_GREGTECH { 22, GT_ModHandler.getSteam(1000), ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 10), - FluidUtils.getFluidStack("fluid.coalgas", 2880), + FluidUtils.getFluidStack("fluid.coalgas", 2880), 30, 120); @@ -610,12 +726,12 @@ public class RECIPES_GREGTECH { addAR(ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloy020", 16), ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloyMA956", 4), null, GregtechItemList.Casing_Power_SubStation.get(4), 80, 128); } - private static boolean addAR(ItemStack inputA, ItemStack inputB, ItemStack outputA, int seconds, int voltage){ + private static boolean addAR(final ItemStack inputA, final ItemStack inputB, final ItemStack outputA, final int seconds, final int voltage){ //return GT_Values.RA.addAssemblerRecipe(inputA, inputB, outputA, seconds*20, voltage); return addAR(inputA, inputB, null, outputA, seconds*20, voltage); } - private static boolean addAR(ItemStack inputA, ItemStack inputB, FluidStack inputFluidA, ItemStack outputA, int seconds, int voltage){ + private static boolean addAR(final ItemStack inputA, final ItemStack inputB, final FluidStack inputFluidA, final ItemStack outputA, final int seconds, final int voltage){ //return GT_Values.RA.addAssemblerRecipe(inputA, inputB, outputA, seconds*20, voltage); return GT_Values.RA.addAssemblerRecipe(inputA, inputB, inputFluidA, outputA, seconds*20, voltage); } @@ -953,12 +1069,12 @@ public class RECIPES_GREGTECH { FluidUtils.getFluidStack("molten.bismuth", 1), new ItemStack[]{GregtechItemList.Pellet_RTG_PO210.get(1)}, null, - new int[]{100}, - 20*300, - 2040, - 500*20); + new int[]{100}, + 20*300, + 2040, + 500*20); } - + private static void sifterRecipes() { //Zirconium GT_Values.RA.addSifterRecipe( @@ -970,10 +1086,10 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1) - }, + }, new int[]{10000, 5000, 1500, 1000, 500, 500}, 20*30, - 60); + 60); //Zirconium GT_Values.RA.addSifterRecipe( @@ -985,12 +1101,12 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1) - }, + }, new int[]{10000, 5000, 1500, 1000, 500, 500}, 20*30, 60); } - + private static void electroMagneticSeperatorRecipes(){ GT_Values.RA.addElectromagneticSeparatorRecipe( ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedBauxite", 1), @@ -1001,7 +1117,7 @@ public class RECIPES_GREGTECH { 20*20, 24); } - + private static void advancedMixerRecipes(){ //HgBa2Ca2Cu3O8 CORE.RA.addMixerRecipe( 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 e9831d96e0..bf7dc58db3 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 @@ -6,8 +6,12 @@ import java.util.Iterator; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.*; -import gregtech.api.util.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.util.GT_Recipe; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; @@ -19,8 +23,8 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public abstract class GregtechMeta_MultiBlockBase - extends - GT_MetaTileEntity_MultiBlockBase { +extends +GT_MetaTileEntity_MultiBlockBase { public static boolean disableMaintenance; public ArrayList mChargeHatches = new ArrayList(); @@ -77,16 +81,17 @@ public abstract class GregtechMeta_MultiBlockBase } @Override - public boolean isCorrectMachinePart(ItemStack paramItemStack) { + public boolean isCorrectMachinePart(final ItemStack paramItemStack) { return true; } @Override - public int getDamageToComponent(ItemStack paramItemStack) { + public int getDamageToComponent(final ItemStack paramItemStack) { return 0; } - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + @Override + public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { } public void startProcess() { @@ -102,20 +107,23 @@ public abstract class GregtechMeta_MultiBlockBase int tValidOutputHatches = 0; for (final GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) { - if (!isValidMetaTileEntity(tHatch)) + if (!isValidMetaTileEntity(tHatch)) { continue; + } int tEmptySlots = 0; boolean foundRoom = false; final IInventory tHatchInv = tHatch.getBaseMetaTileEntity(); - for (int i = 0; i < tHatchInv.getSizeInventory() + for (int i = 0; (i < tHatchInv.getSizeInventory()) && !foundRoom; ++i) { - if (tHatchInv.getStackInSlot(i) != null) + if (tHatchInv.getStackInSlot(i) != null) { continue; + } tEmptySlots++; - if (tEmptySlots < outputItemCount) + if (tEmptySlots < outputItemCount) { continue; + } tValidOutputHatches++; foundRoom = true; @@ -125,25 +133,25 @@ public abstract class GregtechMeta_MultiBlockBase return tValidOutputHatches; } - public GT_Recipe reduceRecipeTimeByPercentage(GT_Recipe tRecipe, - float percentage) { + public GT_Recipe reduceRecipeTimeByPercentage(final GT_Recipe tRecipe, + final float percentage) { int cloneTime = 0; GT_Recipe baseRecipe; GT_Recipe cloneRecipe = null; baseRecipe = tRecipe.copy(); - if (cloneRecipe != baseRecipe || cloneRecipe == null) { + if ((cloneRecipe != baseRecipe) || (cloneRecipe == null)) { cloneRecipe = baseRecipe.copy(); Utils.LOG_WARNING("Setting Recipe"); } - if (cloneTime != baseRecipe.mDuration || cloneTime == 0) { + if ((cloneTime != baseRecipe.mDuration) || (cloneTime == 0)) { cloneTime = baseRecipe.mDuration; Utils.LOG_WARNING("Setting Time"); } if (cloneRecipe.mDuration > 0) { - int originalTime = cloneRecipe.mDuration; - int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration, + final int originalTime = cloneRecipe.mDuration; + final int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration, (100 - percentage)); cloneRecipe.mDuration = tempTime; if (cloneRecipe.mDuration < originalTime) { @@ -162,8 +170,8 @@ public abstract class GregtechMeta_MultiBlockBase } @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, - long aTick) { + public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, + final long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); //this.mChargeHatches.clear(); //this.mDischargeHatches.clear(); @@ -172,58 +180,71 @@ public abstract class GregtechMeta_MultiBlockBase @Override public void explodeMultiblock() { MetaTileEntity tTileEntity; - for (Iterator localIterator = this.mChargeHatches + for (final Iterator localIterator = this.mChargeHatches .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) - tTileEntity = (MetaTileEntity) localIterator.next(); + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } tTileEntity = null; - for (Iterator localIterator = this.mDischargeHatches + for (final Iterator localIterator = this.mDischargeHatches .iterator(); localIterator.hasNext(); tTileEntity - .getBaseMetaTileEntity() - .doExplosion(gregtech.api.enums.GT_Values.V[8])) - tTileEntity = (MetaTileEntity) localIterator.next(); + .getBaseMetaTileEntity() + .doExplosion(gregtech.api.enums.GT_Values.V[8])) { + tTileEntity = localIterator.next(); + } super.explodeMultiblock(); } + @Override public void updateSlots() { - for (GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) - if (isValidMetaTileEntity(tHatch)) + for (final GT_MetaTileEntity_Hatch_InputBattery tHatch : this.mChargeHatches) { + if (isValidMetaTileEntity(tHatch)) { tHatch.updateSlots(); - for (GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) - if (isValidMetaTileEntity(tHatch)) + } + } + for (final GT_MetaTileEntity_Hatch_OutputBattery tHatch : this.mDischargeHatches) { + if (isValidMetaTileEntity(tHatch)) { tHatch.updateSlots(); + } + } super.updateSlots(); } - public boolean addToMachineList(IGregTechTileEntity aTileEntity, - int aBaseCasingIndex) { - if (aTileEntity == null) + @Override + public boolean addToMachineList(final IGregTechTileEntity aTileEntity, + final int aBaseCasingIndex) { + if (aTileEntity == null) { return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { return false; - - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) + } + + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) { return this.mChargeHatches.add( (GT_MetaTileEntity_Hatch_InputBattery) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) { return this.mDischargeHatches.add( (GT_MetaTileEntity_Hatch_OutputBattery) aMetaTileEntity); + } return super.addToMachineList(aTileEntity, aBaseCasingIndex); } - public boolean addChargeableToMachineList(IGregTechTileEntity aTileEntity, - int aBaseCasingIndex) { + public boolean addChargeableToMachineList(final IGregTechTileEntity aTileEntity, + final int aBaseCasingIndex) { if (aTileEntity == null) { return false; } - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBattery) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity) - .updateTexture(aBaseCasingIndex); + .updateTexture(aBaseCasingIndex); return this.mChargeHatches.add( (GT_MetaTileEntity_Hatch_InputBattery) aMetaTileEntity); } @@ -231,20 +252,53 @@ public abstract class GregtechMeta_MultiBlockBase } public boolean addDischargeableInputToMachineList( - IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { if (aTileEntity == null) { return false; } - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBattery) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity) - .updateTexture(aBaseCasingIndex); + .updateTexture(aBaseCasingIndex); return this.mDischargeHatches.add( (GT_MetaTileEntity_Hatch_OutputBattery) aMetaTileEntity); } return false; } + + public boolean addFluidInputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + return false; + } + + public boolean addFluidOutputToMachineList(final IGregTechTileEntity aTileEntity, final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } + return false; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/command/regen/GTPP_WorldRegenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/command/regen/GTPP_WorldRegenerator.java new file mode 100644 index 0000000000..ebe26c8645 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/command/regen/GTPP_WorldRegenerator.java @@ -0,0 +1,135 @@ +package gtPlusPlus.xmod.gregtech.common.command.regen; + +import java.util.HashSet; +import java.util.Random; + +import cpw.mods.fml.common.IWorldGenerator; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_Log; +import gregtech.api.world.GT_Worldgen; +import gregtech.common.GT_Worldgen_GT_Ore_Layer; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; + +public class GTPP_WorldRegenerator implements IWorldGenerator { + private static int mEndAsteroidProbability = 300; + private static int mGCAsteroidProbability = 50; + private static int mSize = 100; + private static int endMinSize = 50; + private static int endMaxSize = 200; + private static int gcMinSize = 100; + private static int gcMaxSize = 400; + private static boolean endAsteroids = true; + private static boolean gcAsteroids = true; + + + public GTPP_WorldRegenerator() { + GameRegistry.registerWorldGenerator(this, 1073741823); + } + + @Override + public synchronized void generate(final Random aRandom, final int aX, final int aZ, final World aWorld, final IChunkProvider aChunkGenerator, final IChunkProvider aChunkProvider) { + int tempDimensionId = aWorld.provider.dimensionId; + if ((tempDimensionId != -1) && (tempDimensionId != 1) && !aChunkGenerator.getClass().getName().contains("galacticraft")) { + tempDimensionId = 0; + } + new WorldGenContainer(aX * 16, aZ * 16, tempDimensionId, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords((aX * 16) + 8, (aZ * 16) + 8).biomeName).run(); + } + + public static class WorldGenContainer implements Runnable { + public int mX; + public int mZ; + public final int mDimensionType; + public final World mWorld; + public final IChunkProvider mChunkGenerator; + public final IChunkProvider mChunkProvider; + public final String mBiome; + public static HashSet mGenerated = new HashSet<>(2000); + + public WorldGenContainer(final int aX, final int aZ, final int aDimensionType, final World aWorld, final IChunkProvider aChunkGenerator, final IChunkProvider aChunkProvider, final String aBiome) { + this.mX = aX; + this.mZ = aZ; + this.mDimensionType = aDimensionType; + this.mWorld = aWorld; + this.mChunkGenerator = aChunkGenerator; + this.mChunkProvider = aChunkProvider; + this.mBiome = aBiome; + } + + //returns a coordinate of a center chunk of 3x3 square; the argument belongs to this square + public int getVeinCenterCoordinate(int c) { + c += c < 0 ? 1 : 3; + return c - (c % 3) - 2; + } + + public boolean surroundingChunksLoaded(final int xCenter, final int zCenter) { + return this.mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16); + } + + public Random getRandom(final int xChunk, final int zChunk) { + final long worldSeed = this.mWorld.getSeed(); + final Random fmlRandom = new Random(worldSeed); + final long xSeed = fmlRandom.nextLong() >> (2 + 1L); + final long zSeed = fmlRandom.nextLong() >> (2 + 1L); + final long chunkSeed = ((xSeed * xChunk) + (zSeed * zChunk)) ^ worldSeed; + fmlRandom.setSeed(chunkSeed); + return new XSTR(fmlRandom.nextInt()); + } + + @Override + public void run() { + int xCenter = this.getVeinCenterCoordinate(this.mX >> 4); + int zCenter = this.getVeinCenterCoordinate(this.mZ >> 4); + final Random random = this.getRandom(xCenter, zCenter); + xCenter <<= 4; + zCenter <<= 4; + final ChunkCoordIntPair centerChunk = new ChunkCoordIntPair(xCenter, zCenter); + if (!mGenerated.contains(centerChunk) && this.surroundingChunksLoaded(xCenter, zCenter)) { + mGenerated.add(centerChunk); + if ((GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) { + boolean temp = true; + int tRandomWeight; + for (int i = 0; (i < 256) && (temp); i++) { + tRandomWeight = random.nextInt(GT_Worldgen_GT_Ore_Layer.sWeight); + for (final GT_Worldgen tWorldGen : GT_Worldgen_GT_Ore_Layer.sList) { + tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer) tWorldGen).mWeight; + if (tRandomWeight <= 0) { + try { + if (tWorldGen.executeWorldgen(this.mWorld, random, this.mBiome, this.mDimensionType, xCenter, zCenter, this.mChunkGenerator, this.mChunkProvider)) { + temp = false; + } + break; + } catch (final Throwable e) { + e.printStackTrace(GT_Log.err); + } + } + } + } + } + int i = 0; + for (int tX = xCenter - 16; i < 3; tX += 16) { + int j = 0; + for (int tZ = zCenter - 16; j < 3; tZ += 16) { + try { + for (final GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) { + tWorldGen.executeWorldgen(this.mWorld, random, this.mBiome, this.mDimensionType, tX, tZ, this.mChunkGenerator, this.mChunkProvider); + } + } catch (final Throwable e) { + e.printStackTrace(GT_Log.err); + } + j++; + } + i++; + } + } + final Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ); + if (tChunk != null) { + tChunk.isModified = true; + } + } + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/command/regen/HANDLER_GT_Commands.java b/src/Java/gtPlusPlus/xmod/gregtech/common/command/regen/HANDLER_GT_Commands.java new file mode 100644 index 0000000000..6e3d4fda93 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/command/regen/HANDLER_GT_Commands.java @@ -0,0 +1,129 @@ +package gtPlusPlus.xmod.gregtech.common.command.regen; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import bloodasp.galacticgreg.GT_Worldgenerator_Space; +import cpw.mods.fml.common.Loader; +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Materials; +import gregtech.common.GT_Worldgen_GT_Ore_SmallPieces; +import gregtech.common.GT_Worldgen_Stone; +import gregtech.common.GT_Worldgenerator; + +public class HANDLER_GT_Commands { + + public static void preInit(){ + + } + + public static void init(){ + + } + + public static void postInit(){ + final boolean tPFAA = (GregTech_API.sWorldgenFile.get(ConfigCategories.general, "AutoDetectPFAA", true)) && (Loader.isModLoaded("PFAAGeologica")); + new GT_Worldgenerator(); + if (Loader.isModLoaded("GalacticraftCore") && Loader.isModLoaded("GalacticraftMars")) { + new GT_Worldgenerator_Space(); + } + + new GT_Worldgen_Stone("overworld.stone.blackgranite.tiny", true, GregTech_API.sBlockGranites, 0, 0, 1, 50, 48, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.blackgranite.small", true, GregTech_API.sBlockGranites, 0, 0, 1, 100, 96, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.blackgranite.medium", true, GregTech_API.sBlockGranites, 0, 0, 1, 200, 144, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.blackgranite.large", true, GregTech_API.sBlockGranites, 0, 0, 1, 300, 192, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.blackgranite.huge", true, GregTech_API.sBlockGranites, 0, 0, 1, 400, 240, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.redgranite.tiny", true, GregTech_API.sBlockGranites, 8, 0, 1, 50, 48, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.redgranite.small", true, GregTech_API.sBlockGranites, 8, 0, 1, 100, 96, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.redgranite.medium", true, GregTech_API.sBlockGranites, 8, 0, 1, 200, 144, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.redgranite.large", true, GregTech_API.sBlockGranites, 8, 0, 1, 300, 192, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.redgranite.huge", true, GregTech_API.sBlockGranites, 8, 0, 1, 400, 240, 0, 120, null, false); + + new GT_Worldgen_Stone("nether.stone.blackgranite.tiny", false, GregTech_API.sBlockGranites, 0, -1, 1, 50, 48, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.blackgranite.small", false, GregTech_API.sBlockGranites, 0, -1, 1, 100, 96, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.blackgranite.medium", false, GregTech_API.sBlockGranites, 0, -1, 1, 200, 144, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.blackgranite.large", false, GregTech_API.sBlockGranites, 0, -1, 1, 300, 192, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.blackgranite.huge", false, GregTech_API.sBlockGranites, 0, -1, 1, 400, 240, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.redgranite.tiny", false, GregTech_API.sBlockGranites, 8, -1, 1, 50, 48, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.redgranite.small", false, GregTech_API.sBlockGranites, 8, -1, 1, 100, 96, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.redgranite.medium", false, GregTech_API.sBlockGranites, 8, -1, 1, 200, 144, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.redgranite.large", false, GregTech_API.sBlockGranites, 8, -1, 1, 300, 192, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.redgranite.huge", false, GregTech_API.sBlockGranites, 8, -1, 1, 400, 240, 0, 120, null, false); + + new GT_Worldgen_Stone("overworld.stone.marble.tiny", true, GregTech_API.sBlockStones, 0, 0, 1, 50, 48, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.marble.small", true, GregTech_API.sBlockStones, 0, 0, 1, 100, 96, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.marble.medium", true, GregTech_API.sBlockStones, 0, 0, 1, 200, 144, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.marble.large", true, GregTech_API.sBlockStones, 0, 0, 1, 300, 192, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.marble.huge", true, GregTech_API.sBlockStones, 0, 0, 1, 400, 240, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.basalt.tiny", true, GregTech_API.sBlockStones, 8, 0, 1, 50, 48, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.basalt.small", true, GregTech_API.sBlockStones, 8, 0, 1, 100, 96, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.basalt.medium", true, GregTech_API.sBlockStones, 8, 0, 1, 200, 144, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.basalt.large", true, GregTech_API.sBlockStones, 8, 0, 1, 300, 192, 0, 120, null, false); + new GT_Worldgen_Stone("overworld.stone.basalt.huge", true, GregTech_API.sBlockStones, 8, 0, 1, 400, 240, 0, 120, null, false); + + new GT_Worldgen_Stone("nether.stone.marble.tiny", false, GregTech_API.sBlockStones, 0, -1, 1, 50, 48, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.marble.small", false, GregTech_API.sBlockStones, 0, -1, 1, 100, 96, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.marble.medium", false, GregTech_API.sBlockStones, 0, -1, 1, 200, 144, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.marble.large", false, GregTech_API.sBlockStones, 0, -1, 1, 300, 192, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.marble.huge", false, GregTech_API.sBlockStones, 0, -1, 1, 400, 240, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.basalt.tiny", false, GregTech_API.sBlockStones, 8, -1, 1, 50, 48, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.basalt.small", false, GregTech_API.sBlockStones, 8, -1, 1, 100, 96, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.basalt.medium", false, GregTech_API.sBlockStones, 8, -1, 1, 200, 144, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.basalt.large", false, GregTech_API.sBlockStones, 8, -1, 1, 300, 192, 0, 120, null, false); + new GT_Worldgen_Stone("nether.stone.basalt.huge", false, GregTech_API.sBlockStones, 8, -1, 1, 400, 240, 0, 120, null, false); + + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.copper", true, 60, 120, 32, !tPFAA, true, true, true, true, false, Materials.Copper); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.tin", true, 60, 120, 32, !tPFAA, true, true, true, true, true, Materials.Tin); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.bismuth", true, 80, 120, 8, !tPFAA, true, false, true, true, false, Materials.Bismuth); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.coal", true, 60, 100, 24, !tPFAA, false, false, false, false, false, Materials.Coal); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.iron", true, 40, 80, 16, !tPFAA, true, true, true, true, false, Materials.Iron); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.lead", true, 40, 80, 16, !tPFAA, true, true, true, true, true, Materials.Lead); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.zinc", true, 30, 60, 12, !tPFAA, true, true, true, true, false, Materials.Zinc); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.gold", true, 20, 40, 8, !tPFAA, true, true, true, true, true, Materials.Gold); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.silver", true, 20, 40, 8, !tPFAA, true, true, true, true, true, Materials.Silver); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.nickel", true, 20, 40, 8, !tPFAA, true, true, true, true, true, Materials.Nickel); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.lapis", true, 20, 40, 4, !tPFAA, false, false, true, false, true, Materials.Lapis); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.diamond", true, 5, 10, 2, !tPFAA, true, false, true, true, true, Materials.Diamond); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.emerald", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Emerald); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.ruby", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Ruby); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.sapphire", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Sapphire); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.greensapphire", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.GreenSapphire); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.olivine", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Olivine); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.topaz", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Topaz); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.tanzanite", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Tanzanite); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.amethyst", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Amethyst); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.opal", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Opal); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.jasper", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Jasper); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.bluetopaz", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.BlueTopaz); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.amber", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.Amber); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.foolsruby", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.FoolsRuby); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.garnetred", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.GarnetRed); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.garnetyellow", true, 5, 250, 1, !tPFAA, true, false, false, true, true, Materials.GarnetYellow); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.redstone", true, 5, 20, 8, !tPFAA, true, false, true, true, true, Materials.Redstone); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.platinum", true, 20, 40, 8, false, false, true, false, true, true, Materials.Platinum); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.iridium", true, 20, 40, 8, false, false, true, false, true, true, Materials.Iridium); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.netherquartz", true, 30, 120, 64, false, true, false, false, false, false, Materials.NetherQuartz); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.saltpeter", true, 10, 60, 8, false, true, false, false, false, false, Materials.Saltpeter); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.sulfur_n", true, 10, 60, 32, false, true, false, false, false, false, Materials.Sulfur); + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.sulfur_o", true, 5, 15, 8, !tPFAA, false, false, false, false, false, Materials.Sulfur); + + int i = 0; + for (final int j = GregTech_API.sWorldgenFile.get("worldgen", "AmountOfCustomSmallOreSlots", 16); i < j; i++) { + new GT_Worldgen_GT_Ore_SmallPieces("ore.small.custom." + (i < 10 ? "0" : "") + i, false, 0, 0, 0, false, false, false, false, false, false, Materials._NULL); + } + if (GregTech_API.mImmersiveEngineering && GT_Mod.gregtechproxy.mImmersiveEngineeringRecipes) { + Class rC; + try { + rC = Class.forName("blusunrize.immersiveengineering.api.tool.ExcavatorHandler"); + final Method method = rC.getMethod("recalculateChances", new Class[]{boolean.class}); + method.invoke(null, true); + } + catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + } + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java index 647b4c8a2a..bdb514ba84 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -10,7 +10,6 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -18,13 +17,14 @@ import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_AlloyBlastSmelter -extends GT_MetaTileEntity_MultiBlockBase { +extends GregtechMeta_MultiBlockBase { private int mHeatingCapacity = 0; public GregtechMetaTileEntity_AlloyBlastSmelter(final int aID, final String aName, final String aNameRegional) { @@ -55,6 +55,7 @@ extends GT_MetaTileEntity_MultiBlockBase { "1x Energy Hatch (one of bottom)", "1x Maintenance Hatch (one of bottom)", "1x Muffler Hatch (top middle)", + "1x Fluid Input Hatch (optional, top layer)", "Blast Smelter Casings for the rest", CORE.GT_Tooltip}; } @@ -81,17 +82,19 @@ extends GT_MetaTileEntity_MultiBlockBase { public boolean isCorrectMachinePart(final ItemStack aStack) { return true; } - - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(208)), 10, 1.0F, aX, aY, aZ); - } - } - public void startProcess() { - sendLoopStart((byte) 1); - } + @Override + public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(208)), 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } @Override public boolean isFacingValid(final byte aFacing) { @@ -192,11 +195,13 @@ extends GT_MetaTileEntity_MultiBlockBase { if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != 14) { return false; } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 15) { - return false; + if (!this.addFluidInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j), 11)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 15) { + return false; + } } } } @@ -218,11 +223,11 @@ extends GT_MetaTileEntity_MultiBlockBase { } this.mHeatingCapacity += 100 * (GT_Utility.getTier(this.getMaxInputVoltage()) - 2); - if ( this.mMaintenanceHatches.size() != 1 || - this.mMufflerHatches.size() != 1 || - this.mInputBusses.size() < 1 || - this.mOutputHatches.size() < 1 || - this.mEnergyHatches.size() != 1 ) { + if ( (this.mMaintenanceHatches.size() != 1) || + (this.mMufflerHatches.size() != 1) || + (this.mInputBusses.size() < 1) || + (this.mOutputHatches.size() < 1) || + (this.mEnergyHatches.size() != 1) ) { return false; } @@ -244,6 +249,7 @@ extends GT_MetaTileEntity_MultiBlockBase { return 0; } + @Override public int getAmountOfOutputs() { return 2; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java index d66649850a..6d1da0881e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_BlastSmelter.java @@ -4,13 +4,19 @@ import java.util.ArrayList; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; +import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.*; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.material.nuclear.NUCLIDE; +import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; public class RecipeGen_BlastSmelter implements Runnable{ @@ -87,10 +93,10 @@ public class RecipeGen_BlastSmelter implements Runnable{ } if (duration <= 0){ - int second = 20; + final int second = 20; duration = 14*second*mMaterialListSize; } - + Utils.LOG_WARNING("[BAS] Size: "+mMaterialListSize); @@ -125,7 +131,7 @@ public class RecipeGen_BlastSmelter implements Runnable{ } if (GT_Values.RA.addFluidExtractionRecipe(M.getTinyDust(1), null, M.getFluid(16), 100, duration/9, 120)){ Utils.LOG_WARNING("[BAS] Success, Also added a Fluid Extractor recipe."); - } + } } } else { @@ -189,11 +195,21 @@ public class RecipeGen_BlastSmelter implements Runnable{ //Builds me an ItemStack[] of the materials. - Without a circuit - this gets a good count for the 144L fluid multiplier components = new ItemStack[9]; inputStackCount=0; + FluidStack componentsFluid = null; for (int irc=0;irc 0) && (xr <= 100)){ + final int mathmatics = (xr <= 10 ? 1000 : ((xr/10)*1000)); + componentsFluid = FluidUtils.getFluidStack(M.getComposites().get(irc).getStackMaterial().getFluid(mathmatics), mathmatics); + } + } + else { + components[irc] = M.getComposites().get(irc).getDustStack(r); + } } } @@ -230,7 +246,7 @@ public class RecipeGen_BlastSmelter implements Runnable{ //Adds Recipe if (M.requiresBlastFurnace()) { - if (CORE.RA.addBlastSmelterRecipe(components, M.getFluid(fluidAmount), 100, duration, 500)){ + if (CORE.RA.addBlastSmelterRecipe(components, componentsFluid, M.getFluid(fluidAmount), 100, duration, 500)){ Utils.LOG_WARNING("[BAS] Success."); } else { @@ -238,7 +254,7 @@ public class RecipeGen_BlastSmelter implements Runnable{ } } else { - if (CORE.RA.addBlastSmelterRecipe(components, M.getFluid(fluidAmount), 100, duration, 240)){ + if (CORE.RA.addBlastSmelterRecipe(components, componentsFluid, M.getFluid(fluidAmount), 100, duration, 240)){ Utils.LOG_WARNING("[BAS] Success."); } else { -- cgit From dd3c71beeee4105829678a15f0b333bc0feb92c5 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 22 Nov 2017 14:07:05 +1000 Subject: $ Small fixes to previously added ABS recipes. --- src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 39d09935d2..4f83afa197 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -233,10 +233,11 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 3), ItemUtils.getItemStackOfAmountFromOreDict("dustOsmium", 1) }, + Materials.Helium.getGas(1000), FluidUtils.getFluidStack("molten.osmiridium", 4*144), 0, - MathUtils.findPercentageOfInt(1920*20, 80), - 500); + MathUtils.findPercentageOfInt(500*20, 80), + 1920); //Naq Alloy CORE.RA.addBlastSmelterRecipe( @@ -245,10 +246,11 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustNaquadah", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustOsmiridium", 1) }, + Materials.Argon.getGas(1000), FluidUtils.getFluidStack("molten.naquadahalloy", 2*144), 0, - MathUtils.findPercentageOfInt(30720*20, 80), - 500); + MathUtils.findPercentageOfInt(500*20, 80), + 30720); //Nickel-Zinc-Ferrite if (Materials.get("NickelZincFerrite") != null){ @@ -300,7 +302,7 @@ public class RECIPES_GREGTECH { }, FluidUtils.getFluidStack("molten.tungstencarbide", 2*144), 0, - MathUtils.findPercentageOfInt((int) Math.max(Materials.TungstenCarbide.getMass() / 40L, 1L) * Materials.TungstenCarbide.mBlastFurnaceTemp*20, 80), + MathUtils.findPercentageOfInt((int) Math.max(Materials.TungstenCarbide.getMass() / 40L, 1L) * Materials.TungstenCarbide.mBlastFurnaceTemp, 80), 480); } @@ -309,13 +311,13 @@ public class RECIPES_GREGTECH { if (Materials.get("VanadiumGallium") != null){ CORE.RA.addBlastSmelterRecipe( new ItemStack[]{ - ItemUtils.getGregtechCircuit(2), + ItemUtils.getGregtechCircuit(12), ItemUtils.getItemStackOfAmountFromOreDict("dustGallium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 3) }, FluidUtils.getFluidStack("molten.vanadiumgallium", 4*144), 0, - MathUtils.findPercentageOfInt((int) Math.max(Materials.VanadiumGallium.getMass() / 40L, 1L) * Materials.VanadiumGallium.mBlastFurnaceTemp*20, 80), + MathUtils.findPercentageOfInt((int) Math.max(Materials.VanadiumGallium.getMass() / 40L, 1L) * Materials.VanadiumGallium.mBlastFurnaceTemp, 80), 480); } -- cgit From b86f9e013b478725a3772b98e67490a3f2a044f6 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Thu, 23 Nov 2017 17:06:21 +1000 Subject: + Added Ink Sacs to Fish trap loot. + Added recycling recipes for all material components. + Added EnderIO alloys to the Alloy Blast Smelter. - Reduced rate of Sand from Fish Trap by 5%. - Removed some logging. $ Fixed Tooltip of Large Sifter stating it only required 9 Sieves, now says 18 as intended. $ Fixed Recipe Recycling not working as intended. --- .../core/material/MaterialGenerator.java | 24 ++- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 54 ++++-- .../tileentities/general/TileEntityFishTrap.java | 127 +++++++------ .../GregtechMetaTileEntity_IndustrialSifter.java | 96 +++++----- .../gregtech/loaders/RecipeGen_DustGeneration.java | 10 +- .../xmod/gregtech/loaders/RecipeGen_Recycling.java | 197 +++++++++++++++++++++ 6 files changed, 369 insertions(+), 139 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java index 0b6848846b..6e529b3e92 100644 --- a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java +++ b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java @@ -19,8 +19,15 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; -import gtPlusPlus.xmod.gregtech.loaders.*; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_AlloySmelter; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Assembler; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_BlastSmelter; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_DustGeneration; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Extruder; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Fluids; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plates; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_ShapedCrafting; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -49,7 +56,7 @@ public class MaterialGenerator { } int sRadiation = 0; - if (ItemUtils.isRadioactive(materialName) || matInfo.vRadiationLevel != 0){ + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)){ sRadiation = matInfo.vRadiationLevel; } @@ -121,7 +128,7 @@ public class MaterialGenerator { temp = new BaseItemNugget(matInfo); temp = new BaseItemPlate(matInfo); temp = new BaseItemPlateDouble(matInfo); - } + } else if (matInfo.getState() == MaterialState.PURE_LIQUID){ FluidUtils.generateFluidNoPrefix(unlocalizedName, materialName, matInfo.getMeltingPointK(), C); return true; @@ -138,8 +145,9 @@ public class MaterialGenerator { RecipeGen_Fluids.generateRecipes(matInfo); RecipeGen_Plates.generateRecipes(matInfo); RecipeGen_ShapedCrafting.generateRecipes(matInfo); + RecipeGen_Recycling.generateRecipes(matInfo); return true; - } catch (Throwable t) + } catch (final Throwable t) { Utils.LOG_INFO(""+matInfo.getLocalizedName()+" failed to generate."); return false; @@ -158,7 +166,7 @@ public class MaterialGenerator { } int sRadiation = 0; - if (ItemUtils.isRadioactive(materialName) || matInfo.vRadiationLevel != 0){ + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)){ sRadiation = matInfo.vRadiationLevel; } @@ -172,6 +180,7 @@ public class MaterialGenerator { //Add A jillion Recipes - old code RecipeGen_DustGeneration.addMixerRecipe_Standalone(matInfo); RecipeGen_Fluids.generateRecipes(matInfo); + //RecipeGen_Recycling.generateRecipes(matInfo); } public static void generateNuclearMaterial(final Material matInfo){ @@ -209,7 +218,8 @@ public class MaterialGenerator { RecipeGen_Fluids.generateRecipes(matInfo); RecipeGen_Assembler.generateRecipes(matInfo); RecipeGen_DustGeneration.generateRecipes(matInfo, true); - } catch (Throwable t){ + RecipeGen_Recycling.generateRecipes(matInfo); + } catch (final Throwable t){ Utils.LOG_INFO(""+matInfo.getLocalizedName()+" failed to generate."); } } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 4f83afa197..365218e28e 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -280,18 +280,6 @@ public class RECIPES_GREGTECH { 120); } - - - - - - - - - - - - //TungstenCarbide if (Materials.get("TungstenCarbide") != null){ CORE.RA.addBlastSmelterRecipe( @@ -332,9 +320,49 @@ public class RECIPES_GREGTECH { }, FluidUtils.getFluidStack("molten.darksteel", 2*144), 0, - MathUtils.findPercentageOfInt(500*20, 80), + MathUtils.findPercentageOfInt(200*20, 80), 120); } + //Pulsating Iron + if (ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1), + ItemUtils.getSimpleStack(Items.ender_pearl) + }, + FluidUtils.getFluidStack("molten.pulsatingiron", 2*144), + 0, + MathUtils.findPercentageOfInt(8*20, 80), + 120); + } + //Energetic Alloy + if (ItemUtils.getItemStackOfAmountFromOreDict("dustEnergeticAlloy", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1), + ItemUtils.getSimpleStack(Items.glowstone_dust) + }, + FluidUtils.getFluidStack("molten.redstone", 144), + FluidUtils.getFluidStack("molten.energeticalloy", 144), + 0, + MathUtils.findPercentageOfInt(9*20, 80), + 120); + } + //Vibrant Alloy + if (ItemUtils.getItemStackOfAmountFromOreDict("dustVibrantAlloy", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustEnergeticAlloy", 1), + ItemUtils.getSimpleStack(Items.ender_pearl) + }, + FluidUtils.getFluidStack("molten.vibrantalloy", 144), + 0, + MathUtils.findPercentageOfInt(16*20, 80), + 480); + } } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java index bd2f8b727c..d73de219e4 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -9,7 +9,6 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.api.objects.XSTR; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -101,24 +100,24 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { int checkingSlot = 0; final ItemStack loot = this.generateLootForFishTrap().copy(); try { - //Utils.LOG_INFO("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); + //Utils.LOG_WARNING("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); for (final ItemStack contents : this.getInventory().getInventory()) { if (GT_Utility.areStacksEqual(loot, contents)){ if (contents.stackSize < contents.getMaxStackSize()) { - //Utils.LOG_INFO("3-Trying to add one more "+loot.getDisplayName()+"meta: "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); + //Utils.LOG_WARNING("3-Trying to add one more "+loot.getDisplayName()+"meta: "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); contents.stackSize++; this.markDirty(); - return true; + return true; } } checkingSlot++; } checkingSlot = 0; for (final ItemStack contents : this.getInventory().getInventory()) { - if (contents == null) { - //Utils.LOG_INFO("Adding Item To Empty Slot. "+(checkingSlot+1)); + if (contents == null) { + //Utils.LOG_WARNING("Adding Item To Empty Slot. "+(checkingSlot+1)); this.getInventory().setInventorySlotContents(checkingSlot, loot); this.markDirty(); return true; @@ -126,7 +125,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { checkingSlot++; } } - catch (NullPointerException n) { + catch (final NullPointerException n) { } } this.markDirty(); @@ -142,9 +141,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { else if (lootWeight <= 10) { loot = ItemUtils.getSimpleStack(Items.bone); } - else if (lootWeight <= 20) { + else if (lootWeight <= 15) { loot = ItemUtils.getSimpleStack(Blocks.sand); } + else if (lootWeight <= 20) { + loot = ItemUtils.simpleMetaStack(Items.dye, 0, 1); + } // Junk Loot else if (lootWeight <= 23) { if (LoadedMods.PamsHarvestcraft) { @@ -156,12 +158,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } // Pam Fish else if (lootWeight <= 99) { - Random xstr = new Random(); + final Random xstr = new Random(); loot = FishingHooks.getRandomFishable(xstr, 100); } else if (lootWeight == 100){ - int rareLoot = MathUtils.randInt(1, 10); + final int rareLoot = MathUtils.randInt(1, 10); if (rareLoot <= 4) { loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetIron", 1); if (loot == null){ @@ -173,7 +175,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { if (loot == null){ loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotGold", 1); } - } + } else if (rareLoot <= 9){ loot = ItemUtils.getSimpleStack(Items.emerald); } @@ -192,47 +194,47 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { @Override public void updateEntity() { try{ - if (!this.worldObj.isRemote) { - this.tickCount++; - // Utils.LOG_WARNING("Ticking "+this.tickCount); - // Check if the Tile is within water once per second. - if ((this.tickCount % 20) == 0) { - this.isInWater = this.isSurroundedByWater(); - } - else { - - } + if (!this.worldObj.isRemote) { + this.tickCount++; + // Utils.LOG_WARNING("Ticking "+this.tickCount); + // Check if the Tile is within water once per second. + if ((this.tickCount % 20) == 0) { + this.isInWater = this.isSurroundedByWater(); + } + else { - if (this.isInWater) { - this.calculateTickrate(); - } + } - // Try add some loot once every 30 seconds. - if ((this.tickCount % this.baseTickRate) == 0) { if (this.isInWater) { - // Add loot - // Utils.LOG_WARNING("Adding Loot to the fishtrap at - // x["+this.locationX+"] y["+this.locationY+"] - // z["+this.locationZ+"] (Ticking for loot every - // "+this.baseTickRate+" ticks)"); - this.tryAddLoot(); - this.markDirty(); + this.calculateTickrate(); } - else { - Utils.LOG_INFO("This Trap does not have enough water around it."); - Utils.LOG_WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY - + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); - this.markDirty(); + + // Try add some loot once every 30 seconds. + if ((this.tickCount % this.baseTickRate) == 0) { + if (this.isInWater) { + // Add loot + // Utils.LOG_WARNING("Adding Loot to the fishtrap at + // x["+this.locationX+"] y["+this.locationY+"] + // z["+this.locationZ+"] (Ticking for loot every + // "+this.baseTickRate+" ticks)"); + this.tryAddLoot(); + this.markDirty(); + } + else { + Utils.LOG_WARNING("This Trap does not have enough water around it."); + Utils.LOG_WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY + + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); + this.markDirty(); + } + this.tickCount = 0; + } + if (this.tickCount > (this.baseTickRate + 500)) { + this.tickCount = 0; } - this.tickCount = 0; - } - if (this.tickCount > (this.baseTickRate + 500)) { - this.tickCount = 0; - } + } } - } - catch (Throwable t){} + catch (final Throwable t){} } public void calculateTickrate() { @@ -293,13 +295,6 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { "Crayfish", "Eel", "Frog", "Grouper", "Herring", "Jellyfish", "Mudfish", "Octopus", "Perch", "Scallop", "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walleye" }; - private static final ItemStack[] minecraftFish = { - ItemUtils.simpleMetaStack(Items.fish, 0, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 1, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 2, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 3, 1).copy() - }; - public static void pamsHarvestCraftCompat() { for (int i = 0; i < harvestcraftFish.length; i++) { @@ -312,22 +307,22 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } @Override - public ItemStack getStackInSlot(int slot) { + public ItemStack getStackInSlot(final int slot) { return this.getInventory().getStackInSlot(slot); } @Override - public ItemStack decrStackSize(int slot, int count) { + public ItemStack decrStackSize(final int slot, final int count) { return this.getInventory().decrStackSize(slot, count); } @Override - public ItemStack getStackInSlotOnClosing(int slot) { + public ItemStack getStackInSlotOnClosing(final int slot) { return this.getInventory().getStackInSlotOnClosing(slot); } @Override - public void setInventorySlotContents(int slot, ItemStack stack) { + public void setInventorySlotContents(final int slot, final ItemStack stack) { this.getInventory().setInventorySlotContents(slot, stack); } @@ -337,7 +332,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { return this.getInventory().isUseableByPlayer(entityplayer); } @@ -346,7 +341,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); + this.getInventory().openInventory(); } @Override @@ -354,17 +349,17 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); + this.getInventory().closeInventory(); } @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { return this.getInventory().isItemValidForSlot(slot, itemstack); } @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - int[] accessibleSides = new int[this.getSizeInventory()]; + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; for (int r=0; r 0) && (tValidOutputSlots >= 1)) { - if ((cloneRecipe != null) && (cloneRecipe.isRecipeInputEqual(true, null, tInputs))) { - Utils.LOG_WARNING("Valid Recipe found - size "+cloneRecipe.mOutputs.length); + if ((this.cloneRecipe != null) && (this.cloneRecipe.isRecipeInputEqual(true, null, tInputs))) { + Utils.LOG_WARNING("Valid Recipe found - size "+this.cloneRecipe.mOutputs.length); this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); this.mEfficiencyIncrease = 10000; - this.mEUt = (-cloneRecipe.mEUt); - this.mMaxProgresstime = Math.max(1, (cloneRecipe.mDuration/5)); - final ItemStack[] outputs = new ItemStack[cloneRecipe.mOutputs.length]; - for (int i = 0; i < cloneRecipe.mOutputs.length; i++){ - if (this.getBaseMetaTileEntity().getRandomNumber(7500) < cloneRecipe.getOutputChance(i)){ + this.mEUt = (-this.cloneRecipe.mEUt); + this.mMaxProgresstime = Math.max(1, (this.cloneRecipe.mDuration/5)); + final ItemStack[] outputs = new ItemStack[this.cloneRecipe.mOutputs.length]; + for (int i = 0; i < this.cloneRecipe.mOutputs.length; i++){ + if (this.getBaseMetaTileEntity().getRandomNumber(7500) < this.cloneRecipe.getOutputChance(i)){ Utils.LOG_WARNING("Adding a bonus output"); - outputs[i] = cloneRecipe.getOutput(i); + outputs[i] = this.cloneRecipe.getOutput(i); } else { Utils.LOG_WARNING("Adding null output"); @@ -255,7 +255,7 @@ extends GregtechMeta_MultiBlockBase { final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; int tAmount = 0; - controller = false; + this.controller = false; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { for (int h = 0; h < 3; h++) { @@ -275,7 +275,7 @@ extends GregtechMeta_MultiBlockBase { // Sifter Floor/Roof inner 3x3 if (((i != -2) && (i != 2)) && ((j != -2) && (j != 2))) { - if (h != 0){ + if (h != 0){ if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(21))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { Utils.LOG_MACHINE_INFO("Sifter Casing(s) Missing from one of the "+sHeight+" layers inner 3x3."); @@ -302,12 +302,12 @@ extends GregtechMeta_MultiBlockBase { tAmount++; } } - } + } else { //Dealt with inner 5x5, now deal with the exterior. //Deal with all 4 sides (Sifter walls) boolean checkController = false; - if (((xDir + i) != 0) || ((zDir + j) != 0) && h == 0) {//no controller + if (((xDir + i) != 0) || (((zDir + j) != 0) && (h == 0))) {//no controller checkController = true; } else { @@ -317,7 +317,7 @@ extends GregtechMeta_MultiBlockBase { if (!this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(21))) { if (!checkController){ if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasings2Misc) { - if (tTileEntity instanceof GregtechMetaTileEntity_IndustrialSifter || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == GregTech_API.sBlockMachines){ + if ((tTileEntity instanceof GregtechMetaTileEntity_IndustrialSifter) || (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == GregTech_API.sBlockMachines)){ if (h != 0){ Utils.LOG_MACHINE_INFO("Found a secondary controller at the wrong Y level."); return false; @@ -328,24 +328,24 @@ extends GregtechMeta_MultiBlockBase { Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } - } - - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 5) { - if (tTileEntity instanceof GregtechMetaTileEntity_IndustrialSifter || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == GregTech_API.sBlockMachines){ - } - else { - Utils.LOG_MACHINE_INFO("Sifter Casings Missing from somewhere in the "+sHeight+" layer edge."); - Utils.LOG_MACHINE_INFO("Incorrect Meta value for block, expected 5."); - Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)+"."); - return false; + + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 5) { + if ((tTileEntity instanceof GregtechMetaTileEntity_IndustrialSifter) || (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == GregTech_API.sBlockMachines)){ + + } + else { + Utils.LOG_MACHINE_INFO("Sifter Casings Missing from somewhere in the "+sHeight+" layer edge."); + Utils.LOG_MACHINE_INFO("Incorrect Meta value for block, expected 5."); + Utils.LOG_MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j)+"."); + return false; + } } } - } - tAmount++; + tAmount++; } else { - tAmount++; + tAmount++; } } } @@ -383,7 +383,7 @@ extends GregtechMeta_MultiBlockBase { } public boolean ignoreController(final Block tTileEntity) { - if (!controller && (tTileEntity == GregTech_API.sBlockMachines)) { + if (!this.controller && (tTileEntity == GregTech_API.sBlockMachines)) { return true; } return false; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java index a8a4cf963f..46bf36c445 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -177,7 +177,7 @@ public class RecipeGen_DustGeneration implements Runnable{ //Add Shapeless recipe for low tier alloys. if (tVoltageMultiplier <= 30){ if (RecipeUtils.addShapedGregtechRecipe(inputStacks, outputStacks)){ - Utils.LOG_INFO("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Success"); + Utils.LOG_INFO("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Success"); } else { Utils.LOG_INFO("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Failed"); @@ -194,7 +194,7 @@ public class RecipeGen_DustGeneration implements Runnable{ } - public static boolean addMixerRecipe_Standalone(Material material){ + public static boolean addMixerRecipe_Standalone(final Material material){ final ItemStack[] inputStacks = material.getMaterialComposites(); final ItemStack outputStacks = material.getDust(material.smallestStackSizeWhenProcessing); //Is this a composite? @@ -264,14 +264,14 @@ public class RecipeGen_DustGeneration implements Runnable{ } else { Utils.LOG_INFO("inputStackSize == NUll - "+material.getLocalizedName()); - } + } } else { Utils.LOG_INFO("InputStacks is out range 1-4 - "+material.getLocalizedName()); - } + } } else { - Utils.LOG_INFO("InputStacks == NUll - "+material.getLocalizedName()); + Utils.LOG_INFO("InputStacks == NUll - "+material.getLocalizedName()); } return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java new file mode 100644 index 0000000000..cf48516354 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java @@ -0,0 +1,197 @@ +package gtPlusPlus.xmod.gregtech.loaders; + +import static gregtech.api.enums.GT_Values.M; + +import java.util.ArrayList; +import java.util.Map; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.ItemStack; + +public class RecipeGen_Recycling implements Runnable{ + + final Material toGenerate; + static Map mNameMap; + + public RecipeGen_Recycling(final Material M){ + this.toGenerate = M; + mNameMap = this.getNameMap(); + } + + @Override + public void run() { + generateRecipes(this.toGenerate); + } + + public static void generateRecipes(final Material material){ + + Utils.LOG_INFO("Generating Recycling recipes for "+material.getLocalizedName()); + + final OrePrefixes[] mValidPrefixesAsString = { + OrePrefixes.ingot, + OrePrefixes.ingotHot, + OrePrefixes.nugget, + OrePrefixes.plate, + OrePrefixes.plateDense, + OrePrefixes.plateDouble, + OrePrefixes.plateTriple, + OrePrefixes.plateQuadruple, + OrePrefixes.plateQuintuple, + OrePrefixes.stick, + OrePrefixes.stickLong, + OrePrefixes.bolt, + OrePrefixes.screw, + OrePrefixes.ring, + OrePrefixes.rotor, + OrePrefixes.gearGt, + OrePrefixes.gearGtSmall + }; + + Utils.LOG_INFO("Found "+mValidPrefixesAsString.length+" valid OreDict prefixes."); + if (mValidPrefixesAsString.length >= 1){ + for (final OrePrefixes validPrefix : mValidPrefixesAsString){ + + try { + final ItemStack tempStack = ItemUtils.getItemStackOfAmountFromOreDict(validPrefix+material.getLocalizedName(), 1); + + if ((tempStack != null) && (tempStack != ItemUtils.getSimpleStack(ModItems.AAA_Broken))){ + //mValidItems[mSlotIndex++] = tempStack; + final ItemStack mDust = getDust(material, validPrefix); + if ((mDust != null) && GT_ModHandler.addPulverisationRecipe(tempStack, mDust)){ + Utils.LOG_INFO("Recycle Recipe: "+material.getLocalizedName()+" - Success - Recycle "+tempStack.getDisplayName()+" and obtain "+mDust.getDisplayName()); + } + else { + Utils.LOG_INFO("Recycle Recipe: "+material.getLocalizedName()+" - Failed"); + if (mDust == null){ + Utils.LOG_INFO("Invalid Dust output."); + } + } + } + } catch (final Throwable t){ + t.printStackTrace(); + Utils.LOG_INFO("Returning Null. Throwable Info: "+t.getMessage()); + Utils.LOG_INFO("Throwable Info: "+t.toString()); + Utils.LOG_INFO("Throwable Info: "+t.getCause().toString()); + + } + + } + } + } + + + + public static ItemStack getDust(final Material aMaterial, final OrePrefixes aPrefix) { + return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getDust(final Material aMaterial, final long aMaterialAmount) { + if (aMaterialAmount <= 0) { + return null; + } + ItemStack rStack = null; + if ((((aMaterialAmount % M) == 0) || (aMaterialAmount >= (M * 16)))) { + rStack = get(OrePrefixes.dust, aMaterial, aMaterialAmount / M); + } + if ((rStack == null) && ((((aMaterialAmount * 4) % M) == 0) || (aMaterialAmount >= (M * 8)))) { + rStack = get(OrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M); + } + if ((rStack == null) && (((aMaterialAmount * 9) >= M))) { + rStack = get(OrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M); + } + if (rStack == null){ + Utils.LOG_INFO("Returning Null. Method: "+ReflectionUtils.getMethodName(0)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(1)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(2)); + } + + return rStack; + } + + public static ItemStack get(final Object aName, final long aAmount) { + return get(aName, null, aAmount, true, true); + } + + public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount) { + return get(aName, aReplacement, aAmount, true, true); + } + + public static ItemStack get(final OrePrefixes aPrefix, final Object aMaterial, final long aAmount) { + return get(aPrefix, aMaterial, null, aAmount); + } + + public static ItemStack get(final OrePrefixes aPrefix, final Object aMaterial, final ItemStack aReplacement, + final long aAmount) { + if (OrePrefixes.mPreventableComponents.contains(aPrefix) && aPrefix.mDisabledItems.contains(aMaterial)) { + return aReplacement; + } + return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); + } + + public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount, + final boolean aMentionPossibleTypos, final boolean aNoInvalidAmounts) { + if (aNoInvalidAmounts && (aAmount < 1L)) { + Utils.LOG_INFO("Returning Null. Method: "+ReflectionUtils.getMethodName(0)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(1)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(2)); + return null; + } + if (!mNameMap.containsKey(aName.toString()) && aMentionPossibleTypos) { + Utils.LOG_INFO("Unknown Key for Unification, Typo? " + aName); + } + return GT_Utility.copyAmount(aAmount, new Object[]{mNameMap.get(aName.toString()), + getFirstOre(aName, aAmount), aReplacement}); + } + + + public static ItemStack getFirstOre(final Object aName, final long aAmount) { + if (GT_Utility.isStringInvalid(aName)) { + Utils.LOG_INFO("Returning Null. Method: "+ReflectionUtils.getMethodName(0)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(1)); + Utils.LOG_INFO("Called from method: "+ReflectionUtils.getMethodName(2)); + return null; + } + final ItemStack tStack = (ItemStack) mNameMap.get(aName.toString()); + if (GT_Utility.isStackValid(tStack)) { + return GT_Utility.copyAmount(aAmount, new Object[]{tStack}); + } + return GT_Utility.copyAmount(aAmount, getOres(aName).toArray()); + } + + public static ArrayList getOres(final Object aOreName) { + final String aName = (aOreName == null) ? "" : aOreName.toString(); + final ArrayList rList = new ArrayList(); + if (GT_Utility.isStringValid(aName)) { + rList.addAll(getOres(aName)); + } + return rList; + } + + public Map getNameMap(){ + Map tempMap; + try { + tempMap = (Map) FieldUtils.readStaticField(GT_OreDictUnificator.class, "sName2StackMap", true); + if (tempMap != null){ + return tempMap; + } + } + catch (final IllegalAccessException e) { + e.printStackTrace(); + } + Utils.LOG_INFO("Invalid map stored in GT_OreDictUnificator.class, unable to find sName2StackMap field."); + return null; + } + + + +} -- cgit From be05aadfba9659ec68219554ae96b81de5549034 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 24 Nov 2017 13:41:48 +1000 Subject: + Added a simple block that can convert liquid xp to mob essence and back. + Added some Enchantment utilities. --- src/Java/gtPlusPlus/core/block/ModBlocks.java | 23 ++- .../core/block/general/BlockTankXpConverter.java | 105 ++++++++++ .../item/base/itemblock/ItemBlockEntityBase.java | 18 ++ .../general/TileEntityXpConverter.java | 193 ++++++++++++++++++ .../core/util/enchantment/EnchantmentUtils.java | 102 ++++++++++ .../gtPlusPlus/core/util/fluid/FluidUtils.java | 218 +++++++++++---------- 6 files changed, 553 insertions(+), 106 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java create mode 100644 src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java create mode 100644 src/Java/gtPlusPlus/core/util/enchantment/EnchantmentUtils.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index 6ebb21bb9c..992cd7e991 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -3,9 +3,20 @@ package gtPlusPlus.core.block; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.BlockBaseOre; -import gtPlusPlus.core.block.general.*; +import gtPlusPlus.core.block.general.BlockTankXpConverter; +import gtPlusPlus.core.block.general.FirePit; +import gtPlusPlus.core.block.general.FluidTankInfinite; +import gtPlusPlus.core.block.general.HellFire; +import gtPlusPlus.core.block.general.LightGlass; +import gtPlusPlus.core.block.general.MiningExplosives; import gtPlusPlus.core.block.general.antigrief.BlockWitherProof; -import gtPlusPlus.core.block.machine.*; +import gtPlusPlus.core.block.machine.FishTrap; +import gtPlusPlus.core.block.machine.HeliumGenerator; +import gtPlusPlus.core.block.machine.Machine_ModularityTable; +import gtPlusPlus.core.block.machine.Machine_ProjectTable; +import gtPlusPlus.core.block.machine.Machine_TradeTable; +import gtPlusPlus.core.block.machine.Machine_Workbench; +import gtPlusPlus.core.block.machine.Machine_WorkbenchAdvanced; import gtPlusPlus.core.fluids.FluidRegistryHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -38,16 +49,17 @@ public final class ModBlocks { public static Block blockFirePit; public static Block blockOreFluorite; - + public static Block blockMiningExplosive; - + public static Block blockHellfire; public static Block blockInfiniteFLuidTank; public static Block blockProjectTable; public static Block blockTradeTable; public static Block blockModularTable; - + public static Block blockWitherGuard; + public static Block blockXpConverter; public static void init() { Utils.LOG_INFO("Initializing Blocks."); @@ -78,6 +90,7 @@ public final class ModBlocks { blockTradeTable = new Machine_TradeTable(); blockModularTable = new Machine_ModularityTable(); blockWitherGuard = new BlockWitherProof(); + blockXpConverter = new BlockTankXpConverter(); } diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java new file mode 100644 index 0000000000..aa19556317 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -0,0 +1,105 @@ +package gtPlusPlus.core.block.general; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; +import gtPlusPlus.core.util.enchantment.EnchantmentUtils; +import gtPlusPlus.core.util.player.PlayerUtils; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockTankXpConverter extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + @SuppressWarnings("deprecation") + public BlockTankXpConverter() { + super(Material.iron); + this.setBlockName("blockTankXpConverter"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockEntityBase.class, "blockTankXpConverter"); + LanguageRegistry.addName(this, "Xp Converter"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) { + return p_149691_1_ == 1 ? this.textureTop + : (p_149691_1_ == 0 ? this.textureBottom + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { + if (world.isRemote) { + return true; + } + else { + final TileEntityXpConverter tank = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tank != null){ + if (tank.tankEssence.getFluid() != null){ + PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankEssence.getFluidAmount()+"L of "+tank.tankEssence.getFluid().getLocalizedName()); + } + if (tank.tankLiquidXp.getFluid() != null){ + PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankLiquidXp.getFluidAmount()+"L of "+tank.tankLiquidXp.getFluid().getLocalizedName()); + } + if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)){ + PlayerUtils.messagePlayer(player, "This is worth "+EnchantmentUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount())); + } + } + } + return true; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityXpConverter(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + +} diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java index 43a37b423c..0dda165b6b 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java @@ -1,9 +1,14 @@ package gtPlusPlus.core.item.base.itemblock; +import java.util.List; + +import gtPlusPlus.core.block.general.BlockTankXpConverter; import gtPlusPlus.core.creative.AddToCreativeTab; import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; public class ItemBlockEntityBase extends ItemBlock { @@ -19,5 +24,18 @@ public class ItemBlockEntityBase extends ItemBlock { return super.getColorFromItemStack(p_82790_1_, p_82790_2_); } + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ + list.add(EnumChatFormatting.GRAY+"Liquid Xp can be filled or drained from all four sides."); + list.add(EnumChatFormatting.GRAY+"Mob Essence can be filled or drained from the top and bottom."); + } + else if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ + //list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); + } + super.addInformation(stack, aPlayer, list, bool); + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java new file mode 100644 index 0000000000..990304cf07 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -0,0 +1,193 @@ +package gtPlusPlus.core.tileentities.general; + +import gtPlusPlus.core.util.enchantment.EnchantmentUtils; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class TileEntityXpConverter extends TileEntity implements IFluidHandler { + + public FluidTank tankEssence = new FluidTank((int) (64000*EnchantmentUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + public FluidTank tankLiquidXp = new FluidTank(64000); + private boolean needsUpdate = false; + private int updateTimer = 0; + + public TileEntityXpConverter() { + } + + @Override + public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) { + this.needsUpdate = true; + if (resource.isFluidEqual(EnchantmentUtils.getLiquidXP(1))){ + return this.tankLiquidXp.fill(resource, doFill); + } + else if (resource.isFluidEqual(EnchantmentUtils.getMobEssence(1))){ + return this.tankEssence.fill(resource, doFill); + } + else { + return 0; + } + } + + @Override + public FluidStack drain(final ForgeDirection from, final FluidStack resource, final boolean doDrain) { + this.needsUpdate = true; + if (resource.isFluidEqual(EnchantmentUtils.getLiquidXP(1))){ + return this.tankLiquidXp.drain(resource.amount, doDrain); + } + else if (resource.isFluidEqual(EnchantmentUtils.getMobEssence(1))){ + return this.tankEssence.drain(resource.amount, doDrain); + } + else { + return null; + } + + } + + @Override + public FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) { + this.needsUpdate = true; + final FluidStack fluid_Essence = this.tankEssence.getFluid(); + final FluidStack fluid_Xp = this.tankLiquidXp.getFluid(); + if ((fluid_Essence == null) && (fluid_Xp == null)) { + return null; + } + + FluidStack fluid; + FluidTank tank; + + if ((from == ForgeDirection.UP) || (from == ForgeDirection.DOWN)){ + fluid = fluid_Essence; + tank = this.tankEssence; + } + else { + fluid = fluid_Xp; + tank = this.tankLiquidXp; + } + + int drained = maxDrain; + if (fluid.amount < drained) { + drained = fluid.amount; + } + + final FluidStack stack = new FluidStack(fluid, drained); + if (doDrain) { + fluid.amount -= drained; + if (fluid.amount <= 0) { + fluid = null; + } + + if (this != null) { + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorldObj(), this.xCoord, + this.yCoord, this.zCoord, tank, 0)); + } + } + return stack; + } + + @Override + public boolean canFill(final ForgeDirection from, final Fluid fluid) { + return true; + } + + @Override + public boolean canDrain(final ForgeDirection from, final Fluid fluid) { + return true; + } + + @Override + public FluidTankInfo[] getTankInfo(final ForgeDirection from) { + if ((from == ForgeDirection.UP) || (from == ForgeDirection.DOWN)){ + return new FluidTankInfo[] { this.tankEssence.getInfo() }; + } + else { + return new FluidTankInfo[] { this.tankLiquidXp.getInfo() }; + } + } + + public float getAdjustedVolume() { + this.needsUpdate = true; + final float amount = this.tankLiquidXp.getFluidAmount(); + final float capacity = this.tankLiquidXp.getCapacity(); + final float volume = (amount / capacity) * 0.8F; + return volume; + } + + @Override + public void updateEntity() { + + if (this.tankEssence.getFluid() != null){ + final FluidStack bigStorage = this.tankEssence.getFluid(); + bigStorage.amount = this.tankEssence.getCapacity(); + this.tankEssence.setFluid(bigStorage); + } + + if (this.tankLiquidXp.getFluid() != null){ + final FluidStack bigStorage = this.tankLiquidXp.getFluid(); + bigStorage.amount = this.tankLiquidXp.getCapacity(); + this.tankLiquidXp.setFluid(bigStorage); + } + + if (this.needsUpdate) { + + if (this.tankEssence.getFluid() != null){ + final FluidStack bigStorage = this.tankEssence.getFluid(); + bigStorage.amount = this.tankEssence.getCapacity(); + this.tankEssence.setFluid(bigStorage); + } + + if (this.tankLiquidXp.getFluid() != null){ + final FluidStack bigStorage = this.tankLiquidXp.getFluid(); + bigStorage.amount = this.tankLiquidXp.getCapacity(); + this.tankLiquidXp.setFluid(bigStorage); + } + + if (this.updateTimer == 0) { + this.updateTimer = 10; // every 10 ticks it will send an update + } else { + --this.updateTimer; + if (this.updateTimer == 0) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.needsUpdate = false; + } + } + } + } + + @Override + public void readFromNBT(final NBTTagCompound tag) { + this.tankEssence.readFromNBT(tag); + this.tankLiquidXp.readFromNBT(tag); + super.readFromNBT(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound tag) { + this.tankEssence.writeToNBT(tag); + this.tankLiquidXp.writeToNBT(tag); + super.writeToNBT(tag); + } + + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + final NBTTagCompound tag = pkt.func_148857_g(); + this.readFromNBT(tag); + } + +} diff --git a/src/Java/gtPlusPlus/core/util/enchantment/EnchantmentUtils.java b/src/Java/gtPlusPlus/core/util/enchantment/EnchantmentUtils.java new file mode 100644 index 0000000000..49c625685c --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/enchantment/EnchantmentUtils.java @@ -0,0 +1,102 @@ +package gtPlusPlus.core.util.enchantment; + +import gtPlusPlus.core.util.Utils; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class EnchantmentUtils { + + + public static final int XP_PER_BOTTLE = 8; + public static final int RATIO = 20; + public static final int LIQUID_PER_XP_BOTTLE = 160; + public static final double RATIO_MOB_ESSENCE_TO_LIQUID_XP = 13.32; + + public static int liquidToXpRatio(final int liquid) { + return liquid / RATIO; + } + + public static int xpToLiquidRatio(final int xp) { + return xp * RATIO; + } + + public static FluidStack getEssenceFromLiquidXp(final int xpAmount){ + if (xpAmount <= 0){ + return null; + } + return getMobEssence((int) (xpAmount*RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + } + + public static FluidStack getLiquidXpFromEssence(final int essenceAmount){ + if (essenceAmount <= 0){ + return null; + } + return getLiquidXP((int) (essenceAmount/RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + } + + public static int getLiquidForLevel(final int level) { + final int xp = getExperienceForLevel(level); + return xpToLiquidRatio(xp); + } + + public static int getLevelForLiquid(final int liquid) { + final int xp = liquidToXpRatio(liquid); + return getLevelForExperience(xp); + } + + public static int getExperienceForLevel(final int level) { + if (level == 0) { + return 0; + } + if ((level > 0) && (level < 16)) { + return level * 17; + } + if ((level > 15) && (level < 31)) { + return (int) (((1.5 * Math.pow(level, 2.0)) - (29.5 * level)) + 360.0); + } + return (int) (((3.5 * Math.pow(level, 2.0)) - (151.5 * level)) + 2220.0); + } + + public static int getXpToNextLevel(final int level) { + final int levelXP = getLevelForExperience(level); + final int nextXP = getExperienceForLevel(level + 1); + return nextXP - levelXP; + } + + public static int getLevelForExperience(final int experience) { + int i; + for (i = 0; getExperienceForLevel(i) <= experience; ++i) { + } + return i - 1; + } + + + + + + + + //Xp Fluids + public static FluidStack getMobEssence(final int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of Mob Essence."); + try { + return FluidRegistry.getFluidStack("mobessence", amount).copy(); + } + catch (final Throwable e){ + return null; + } + + } + + public static FluidStack getLiquidXP(final int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of Liquid XP."); + try { + return FluidRegistry.getFluidStack("xpjuice", amount).copy(); + } + catch (final Throwable e){ + return null; + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java index 47020b536b..b0b6102504 100644 --- a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java @@ -1,6 +1,8 @@ package gtPlusPlus.core.util.fluid; -import gregtech.api.enums.*; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.core.fluids.GenericFluid; import gtPlusPlus.core.item.base.BaseItemComponent; @@ -9,12 +11,17 @@ import gtPlusPlus.core.item.base.cell.BaseItemPlasmaCell; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.enchantment.EnchantmentUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; public class FluidUtils { @@ -87,24 +94,24 @@ public class FluidUtils { public static Fluid generateFluid(final String displayName, final String fluidName, final int tempK, final short[] rgba ,final int aState){ Fluid generatedFluid = null; switch (aState) { - case 0: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 10000, false, rgba); - break; - } - default: - case 1: - case 4: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 1000, false, rgba); - break; - } - case 2: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, -100, tempK, 200, true, rgba); - break; - } - case 3: { - generatedFluid = new GenericFluid(displayName, fluidName, 15, -10000, tempK, 10, true, rgba); - break; - } + case 0: { + generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 10000, false, rgba); + break; + } + default: + case 1: + case 4: { + generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 1000, false, rgba); + break; + } + case 2: { + generatedFluid = new GenericFluid(displayName, fluidName, 0, -100, tempK, 200, true, rgba); + break; + } + case 3: { + generatedFluid = new GenericFluid(displayName, fluidName, 15, -10000, tempK, 10, true, rgba); + break; + } } return generatedFluid; } @@ -122,24 +129,24 @@ public class FluidUtils { final int tempK = material.getMeltingPointC(); Fluid generatedFluid = null; switch (aState) { - case 0: { - generatedFluid = new GenericFluid(material, 0, 100, tempK, 10000, false); - break; - } - default: - case 1: - case 4: { - generatedFluid = new GenericFluid(material, 0, 100, tempK, 1000, false); - break; - } - case 2: { - generatedFluid = new GenericFluid(material, 0, -100, tempK, 200, true); - break; - } - case 3: { - generatedFluid = new GenericFluid(material, 15, -10000, tempK, 10, true); - break; - } + case 0: { + generatedFluid = new GenericFluid(material, 0, 100, tempK, 10000, false); + break; + } + default: + case 1: + case 4: { + generatedFluid = new GenericFluid(material, 0, 100, tempK, 1000, false); + break; + } + case 2: { + generatedFluid = new GenericFluid(material, 0, -100, tempK, 200, true); + break; + } + case 3: { + generatedFluid = new GenericFluid(material, 15, -10000, tempK, 10, true); + break; + } } return generatedFluid; } @@ -167,30 +174,30 @@ public class FluidUtils { GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), (aLocalized == null) ? aName : aLocalized); if (FluidRegistry.registerFluid(rFluid)) { switch (aState) { - case 0: { - rFluid.setGaseous(false); - rFluid.setViscosity(10000); - break; - } - case 1: - case 4: { - rFluid.setGaseous(false); - rFluid.setViscosity(1000); - break; - } - case 2: { - rFluid.setGaseous(true); - rFluid.setDensity(-100); - rFluid.setViscosity(200); - break; - } - case 3: { - rFluid.setGaseous(true); - rFluid.setDensity(-10000); - rFluid.setViscosity(10); - rFluid.setLuminosity(15); - break; - } + case 0: { + rFluid.setGaseous(false); + rFluid.setViscosity(10000); + break; + } + case 1: + case 4: { + rFluid.setGaseous(false); + rFluid.setViscosity(1000); + break; + } + case 2: { + rFluid.setGaseous(true); + rFluid.setDensity(-100); + rFluid.setViscosity(200); + break; + } + case 3: { + rFluid.setGaseous(true); + rFluid.setDensity(-10000); + rFluid.setViscosity(10); + rFluid.setLuminosity(15); + break; + } } } else { @@ -201,18 +208,18 @@ public class FluidUtils { } if (aMaterial != null) { switch (aState) { - case 1: { - aMaterial.mFluid = (rFluid); - break; - } - case 2: { - aMaterial.mGas = (rFluid); - break; - } - case 3: { - aMaterial.mPlasma = (rFluid); - break; - } + case 1: { + aMaterial.mFluid = (rFluid); + break; + } + case 2: { + aMaterial.mGas = (rFluid); + break; + } + case 3: { + aMaterial.mPlasma = (rFluid); + break; + } } } if ((aFullContainer != null) && (aEmptyContainer != null) && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { @@ -234,7 +241,7 @@ public class FluidUtils { } public static Fluid addGTPlasma(final Material aMaterial) { - if (aMaterial.getLocalizedName().toLowerCase().contains("clay") || aMaterial.getComposites().size()>1 || aMaterial.getLocalizedName().toLowerCase().contains("wrought")){ + if (aMaterial.getLocalizedName().toLowerCase().contains("clay") || (aMaterial.getComposites().size()>1) || aMaterial.getLocalizedName().toLowerCase().contains("wrought")){ return null; } Utils.LOG_INFO("Generating a "+aMaterial.getLocalizedName()+" Plasma Cell"); @@ -277,30 +284,30 @@ public class FluidUtils { GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), (aLocalized == null) ? aName : aLocalized); if (FluidRegistry.registerFluid(rFluid)) { switch (aState) { - case 0: { - rFluid.setGaseous(false); - rFluid.setViscosity(10000); - break; - } - case 1: - case 4: { - rFluid.setGaseous(false); - rFluid.setViscosity(1000); - break; - } - case 2: { - rFluid.setGaseous(true); - rFluid.setDensity(-100); - rFluid.setViscosity(200); - break; - } - case 3: { - rFluid.setGaseous(true); - rFluid.setDensity(-10000); - rFluid.setViscosity(10); - rFluid.setLuminosity(15); - break; - } + case 0: { + rFluid.setGaseous(false); + rFluid.setViscosity(10000); + break; + } + case 1: + case 4: { + rFluid.setGaseous(false); + rFluid.setViscosity(1000); + break; + } + case 2: { + rFluid.setGaseous(true); + rFluid.setDensity(-100); + rFluid.setViscosity(200); + break; + } + case 3: { + rFluid.setGaseous(true); + rFluid.setDensity(-10000); + rFluid.setViscosity(10); + rFluid.setLuminosity(15); + break; + } } } else { @@ -435,8 +442,8 @@ public class FluidUtils { Utils.LOG_INFO("FLUID GENERATION FAILED FOR "+localizedName); return null; } - - public final static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, ItemStack dustStack, final ItemStack dustStack2){ + + public final static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, final ItemStack dustStack, final ItemStack dustStack2){ return generateFluidNonMolten(unlocalizedName, localizedName, MeltingPoint, RGBA, dustStack, dustStack2, 144); } @@ -516,4 +523,13 @@ public class FluidUtils { } + public static FluidStack getMobEssence(final int amount){ + return EnchantmentUtils.getMobEssence(amount); + } + + public static FluidStack getLiquidXP(final int amount){ + return EnchantmentUtils.getLiquidXP(amount); + } + + } -- cgit From 27a3675ced121616092334e68b8ae2719a86abaf Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 24 Nov 2017 13:50:31 +1000 Subject: % Refactored a package and class name. --- .../core/block/general/BlockTankXpConverter.java | 4 +- .../general/TileEntityXpConverter.java | 12 +-- .../core/util/enchanting/EnchantingUtils.java | 102 +++++++++++++++++++++ .../core/util/enchantment/EnchantmentUtils.java | 102 --------------------- .../gtPlusPlus/core/util/fluid/FluidUtils.java | 6 +- 5 files changed, 113 insertions(+), 113 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java delete mode 100644 src/Java/gtPlusPlus/core/util/enchantment/EnchantmentUtils.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index aa19556317..d9cbfc9fe5 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -8,7 +8,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; -import gtPlusPlus.core.util.enchantment.EnchantmentUtils; +import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -75,7 +75,7 @@ public class BlockTankXpConverter extends BlockContainer { PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankLiquidXp.getFluidAmount()+"L of "+tank.tankLiquidXp.getFluid().getLocalizedName()); } if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)){ - PlayerUtils.messagePlayer(player, "This is worth "+EnchantmentUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount())); + PlayerUtils.messagePlayer(player, "This is worth "+EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount())); } } } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java index 990304cf07..ca190802dc 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.tileentities.general; -import gtPlusPlus.core.util.enchantment.EnchantmentUtils; +import gtPlusPlus.core.util.enchanting.EnchantingUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -16,7 +16,7 @@ import net.minecraftforge.fluids.IFluidHandler; public class TileEntityXpConverter extends TileEntity implements IFluidHandler { - public FluidTank tankEssence = new FluidTank((int) (64000*EnchantmentUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + public FluidTank tankEssence = new FluidTank((int) (64000*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)); public FluidTank tankLiquidXp = new FluidTank(64000); private boolean needsUpdate = false; private int updateTimer = 0; @@ -27,10 +27,10 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { @Override public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) { this.needsUpdate = true; - if (resource.isFluidEqual(EnchantmentUtils.getLiquidXP(1))){ + if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ return this.tankLiquidXp.fill(resource, doFill); } - else if (resource.isFluidEqual(EnchantmentUtils.getMobEssence(1))){ + else if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ return this.tankEssence.fill(resource, doFill); } else { @@ -41,10 +41,10 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { @Override public FluidStack drain(final ForgeDirection from, final FluidStack resource, final boolean doDrain) { this.needsUpdate = true; - if (resource.isFluidEqual(EnchantmentUtils.getLiquidXP(1))){ + if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ return this.tankLiquidXp.drain(resource.amount, doDrain); } - else if (resource.isFluidEqual(EnchantmentUtils.getMobEssence(1))){ + else if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ return this.tankEssence.drain(resource.amount, doDrain); } else { diff --git a/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java b/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java new file mode 100644 index 0000000000..76336d4298 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java @@ -0,0 +1,102 @@ +package gtPlusPlus.core.util.enchanting; + +import gtPlusPlus.core.util.Utils; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class EnchantingUtils { + + + public static final int XP_PER_BOTTLE = 8; + public static final int RATIO = 20; + public static final int LIQUID_PER_XP_BOTTLE = 160; + public static final double RATIO_MOB_ESSENCE_TO_LIQUID_XP = 13.32; + + public static int liquidToXpRatio(final int liquid) { + return liquid / RATIO; + } + + public static int xpToLiquidRatio(final int xp) { + return xp * RATIO; + } + + public static FluidStack getEssenceFromLiquidXp(final int xpAmount){ + if (xpAmount <= 0){ + return null; + } + return getMobEssence((int) (xpAmount*RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + } + + public static FluidStack getLiquidXpFromEssence(final int essenceAmount){ + if (essenceAmount <= 0){ + return null; + } + return getLiquidXP((int) (essenceAmount/RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + } + + public static int getLiquidForLevel(final int level) { + final int xp = getExperienceForLevel(level); + return xpToLiquidRatio(xp); + } + + public static int getLevelForLiquid(final int liquid) { + final int xp = liquidToXpRatio(liquid); + return getLevelForExperience(xp); + } + + public static int getExperienceForLevel(final int level) { + if (level == 0) { + return 0; + } + if ((level > 0) && (level < 16)) { + return level * 17; + } + if ((level > 15) && (level < 31)) { + return (int) (((1.5 * Math.pow(level, 2.0)) - (29.5 * level)) + 360.0); + } + return (int) (((3.5 * Math.pow(level, 2.0)) - (151.5 * level)) + 2220.0); + } + + public static int getXpToNextLevel(final int level) { + final int levelXP = getLevelForExperience(level); + final int nextXP = getExperienceForLevel(level + 1); + return nextXP - levelXP; + } + + public static int getLevelForExperience(final int experience) { + int i; + for (i = 0; getExperienceForLevel(i) <= experience; ++i) { + } + return i - 1; + } + + + + + + + + //Xp Fluids + public static FluidStack getMobEssence(final int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of Mob Essence."); + try { + return FluidRegistry.getFluidStack("mobessence", amount).copy(); + } + catch (final Throwable e){ + return null; + } + + } + + public static FluidStack getLiquidXP(final int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of Liquid XP."); + try { + return FluidRegistry.getFluidStack("xpjuice", amount).copy(); + } + catch (final Throwable e){ + return null; + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/util/enchantment/EnchantmentUtils.java b/src/Java/gtPlusPlus/core/util/enchantment/EnchantmentUtils.java deleted file mode 100644 index 49c625685c..0000000000 --- a/src/Java/gtPlusPlus/core/util/enchantment/EnchantmentUtils.java +++ /dev/null @@ -1,102 +0,0 @@ -package gtPlusPlus.core.util.enchantment; - -import gtPlusPlus.core.util.Utils; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -public class EnchantmentUtils { - - - public static final int XP_PER_BOTTLE = 8; - public static final int RATIO = 20; - public static final int LIQUID_PER_XP_BOTTLE = 160; - public static final double RATIO_MOB_ESSENCE_TO_LIQUID_XP = 13.32; - - public static int liquidToXpRatio(final int liquid) { - return liquid / RATIO; - } - - public static int xpToLiquidRatio(final int xp) { - return xp * RATIO; - } - - public static FluidStack getEssenceFromLiquidXp(final int xpAmount){ - if (xpAmount <= 0){ - return null; - } - return getMobEssence((int) (xpAmount*RATIO_MOB_ESSENCE_TO_LIQUID_XP)); - } - - public static FluidStack getLiquidXpFromEssence(final int essenceAmount){ - if (essenceAmount <= 0){ - return null; - } - return getLiquidXP((int) (essenceAmount/RATIO_MOB_ESSENCE_TO_LIQUID_XP)); - } - - public static int getLiquidForLevel(final int level) { - final int xp = getExperienceForLevel(level); - return xpToLiquidRatio(xp); - } - - public static int getLevelForLiquid(final int liquid) { - final int xp = liquidToXpRatio(liquid); - return getLevelForExperience(xp); - } - - public static int getExperienceForLevel(final int level) { - if (level == 0) { - return 0; - } - if ((level > 0) && (level < 16)) { - return level * 17; - } - if ((level > 15) && (level < 31)) { - return (int) (((1.5 * Math.pow(level, 2.0)) - (29.5 * level)) + 360.0); - } - return (int) (((3.5 * Math.pow(level, 2.0)) - (151.5 * level)) + 2220.0); - } - - public static int getXpToNextLevel(final int level) { - final int levelXP = getLevelForExperience(level); - final int nextXP = getExperienceForLevel(level + 1); - return nextXP - levelXP; - } - - public static int getLevelForExperience(final int experience) { - int i; - for (i = 0; getExperienceForLevel(i) <= experience; ++i) { - } - return i - 1; - } - - - - - - - - //Xp Fluids - public static FluidStack getMobEssence(final int amount){ - Utils.LOG_WARNING("Trying to get a fluid stack of Mob Essence."); - try { - return FluidRegistry.getFluidStack("mobessence", amount).copy(); - } - catch (final Throwable e){ - return null; - } - - } - - public static FluidStack getLiquidXP(final int amount){ - Utils.LOG_WARNING("Trying to get a fluid stack of Liquid XP."); - try { - return FluidRegistry.getFluidStack("xpjuice", amount).copy(); - } - catch (final Throwable e){ - return null; - } - - } - -} diff --git a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java index b0b6102504..611c7fe897 100644 --- a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java @@ -11,7 +11,7 @@ import gtPlusPlus.core.item.base.cell.BaseItemPlasmaCell; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.enchantment.EnchantmentUtils; +import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import net.minecraft.init.Items; @@ -524,11 +524,11 @@ public class FluidUtils { public static FluidStack getMobEssence(final int amount){ - return EnchantmentUtils.getMobEssence(amount); + return EnchantingUtils.getMobEssence(amount); } public static FluidStack getLiquidXP(final int amount){ - return EnchantmentUtils.getLiquidXP(amount); + return EnchantingUtils.getLiquidXP(amount); } -- cgit From b5fd7c514de976e5f0b550e751ae3a73001ac67e Mon Sep 17 00:00:00 2001 From: Alkalus Date: Fri, 24 Nov 2017 17:20:03 +1000 Subject: $ Fixed issue where all my blocks allowed mobs to spawn. % More Work on the Xp Converter. % Formatting. --- .../gtPlusPlus/core/block/base/AdvancedBlock.java | 7 +++ .../gtPlusPlus/core/block/base/BasicBlock.java | 7 +++ .../gtPlusPlus/core/block/base/BlockBaseNBT.java | 19 ++++-- .../gtPlusPlus/core/block/base/BlockBaseOre.java | 6 ++ src/Java/gtPlusPlus/core/block/base/MetaBlock.java | 7 +++ .../core/block/general/BlockTankXpConverter.java | 59 ++++++++++++++++--- .../gtPlusPlus/core/block/general/HellFire.java | 41 ++++++++----- .../block/general/antigrief/BlockWitherProof.java | 38 ++++++------ .../block/general/fluids/BlockFluidSludge.java | 6 ++ .../core/block/machine/BlockGtFrameBox.java | 6 ++ .../gtPlusPlus/core/block/machine/FishTrap.java | 25 +++++--- .../block/machine/Machine_ModularityTable.java | 13 ++++- .../core/block/machine/Machine_ProjectTable.java | 8 ++- .../core/block/machine/Machine_TradeTable.java | 18 +++--- .../core/block/machine/Machine_Workbench.java | 7 +++ src/Java/gtPlusPlus/core/item/ModItems.java | 67 ++++++++++++++++------ .../core/tileentities/ModTileEntities.java | 10 +--- .../general/TileEntityXpConverter.java | 31 +++++++--- .../gtPlusPlus/core/util/player/PlayerUtils.java | 31 +++++----- 19 files changed, 294 insertions(+), 112 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java index 7a0b715138..d8e59f96c8 100644 --- a/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java @@ -4,7 +4,9 @@ import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class AdvancedBlock extends Block { @@ -28,4 +30,9 @@ public class AdvancedBlock extends Block { return false; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java index 9e3a5fc37f..f97763dd54 100644 --- a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java @@ -5,7 +5,9 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BasicBlock extends BlockContainer { @@ -62,4 +64,9 @@ public class BasicBlock extends BlockContainer { return null; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java index 3ecb556e09..da308e270b 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java @@ -9,10 +9,12 @@ import gtPlusPlus.core.item.base.itemblock.ItemBlockNBT; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public abstract class BlockBaseNBT extends BlockContainer @@ -25,7 +27,7 @@ public abstract class BlockBaseNBT extends BlockContainer private IIcon textureFront; @SuppressWarnings("deprecation") - public BlockBaseNBT(Material material, String unlocalName, String displayName){ + public BlockBaseNBT(final Material material, final String unlocalName, final String displayName){ super(material); this.setBlockName(unlocalName); this.setCreativeTab(AddToCreativeTab.tabMachines); @@ -46,28 +48,33 @@ public abstract class BlockBaseNBT extends BlockContainer public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int meta) { super.breakBlock(world, x, y, z, block, meta); } @Override - public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) { + public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta) { super.onBlockDestroyedByPlayer(world, x, y, z, meta); } @Override - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { + public void onBlockDestroyedByExplosion(final World world, final int x, final int y, final int z, final Explosion explosion) { super.onBlockDestroyedByExplosion(world, x, y, z, explosion); } @Override - public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) { + public void onBlockHarvested(final World world, final int x, final int y, final int z, final int meta, final EntityPlayer player) { super.onBlockHarvested(world, x, y, z, meta, player); } @Override - public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { super.onBlockExploded(world, x, y, z, explosion); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index c1e58e9393..285f394971 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -6,6 +6,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -71,6 +72,11 @@ public class BlockBaseOre extends BlockBaseModular{ return this.blockColour; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + diff --git a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java index 3e116eeb7f..880bb3a597 100644 --- a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java @@ -4,8 +4,10 @@ import java.util.List; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; public class MetaBlock extends MultiTextureBlock { @@ -25,4 +27,9 @@ public class MetaBlock extends MultiTextureBlock { } } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index d9cbfc9fe5..97a9ff2af6 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -4,6 +4,8 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.IToolStats; +import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; import gtPlusPlus.core.lib.CORE; @@ -13,9 +15,13 @@ import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockTankXpConverter extends BlockContainer { @@ -66,16 +72,48 @@ public class BlockTankXpConverter extends BlockContainer { return true; } else { - final TileEntityXpConverter tank = (TileEntityXpConverter) world.getTileEntity(x, y, z); - if (tank != null){ - if (tank.tankEssence.getFluid() != null){ - PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankEssence.getFluidAmount()+"L of "+tank.tankEssence.getFluid().getLocalizedName()); + boolean mDidScrewDriver = false; + //Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(player); + final Item mHandItem = PlayerUtils.getItemInPlayersHand(player); + if (mHandItem instanceof IToolStats){ + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))){ + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null){ + mDidScrewDriver = true; + tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + + } } - if (tank.tankLiquidXp.getFluid() != null){ - PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankLiquidXp.getFluidAmount()+"L of "+tank.tankLiquidXp.getFluid().getLocalizedName()); + } + catch (final Throwable t){ + mDidScrewDriver = false; + } + + if (!mDidScrewDriver){ + + + try { + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null){ + tile.onRightClick((byte) side, player, x, y, z); + } } - if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)){ - PlayerUtils.messagePlayer(player, "This is worth "+EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount())); + catch (final Throwable t){} + + final TileEntityXpConverter tank = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tank != null){ + if (tank.tankEssence.getFluid() != null){ + PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankEssence.getFluidAmount()+"L of "+tank.tankEssence.getFluid().getLocalizedName()); + } + if (tank.tankLiquidXp.getFluid() != null){ + PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankLiquidXp.getFluidAmount()+"L of "+tank.tankLiquidXp.getFluid().getLocalizedName()); + } + if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)){ + PlayerUtils.messagePlayer(player, "This is worth "+EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount())+" levels."); + } } } } @@ -102,4 +140,9 @@ public class BlockTankXpConverter extends BlockContainer { super.onBlockAdded(world, x, y, z); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/general/HellFire.java b/src/Java/gtPlusPlus/core/block/general/HellFire.java index 2adab5d5e7..d73d0eb085 100644 --- a/src/Java/gtPlusPlus/core/block/general/HellFire.java +++ b/src/Java/gtPlusPlus/core/block/general/HellFire.java @@ -1,6 +1,11 @@ package gtPlusPlus.core.block.general; -import static net.minecraftforge.common.util.ForgeDirection.*; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; import java.util.IdentityHashMap; import java.util.Map.Entry; @@ -21,6 +26,7 @@ import net.minecraft.block.BlockFire; import net.minecraft.block.material.MapColor; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -44,29 +50,29 @@ public class HellFire extends BlockFire { this.setCreativeTab(AddToCreativeTab.tabBlock); GameRegistry.registerBlock(this, "blockHellFire"); LanguageRegistry.addName(this, "Hellish Fire"); - enableBrutalFire(); + this.enableBrutalFire(); } private void enableBrutalFire() { - for (Object o : Block.blockRegistry.getKeys()) + for (final Object o : Block.blockRegistry.getKeys()) { - String name = (String)o; - Block b = Block.getBlockFromName(name); + final String name = (String)o; + final Block b = Block.getBlockFromName(name); - if (b == Blocks.grass || b == Blocks.mycelium){ - int spread = 3; - int flamm = 3; + if ((b == Blocks.grass) || (b == Blocks.mycelium)){ + final int spread = 3; + final int flamm = 3; this.setFireInfo(b, spread * 4, flamm * 4); } if (b != Blocks.air) { - int spread = Blocks.fire.getEncouragement(b); - int flamm = Blocks.fire.getFlammability(b); + final int spread = Blocks.fire.getEncouragement(b); + final int flamm = Blocks.fire.getFlammability(b); this.setFireInfo(b, spread * 4, flamm * 4); } } - + //Special Case madness this.setFireInfo(Blocks.brown_mushroom_block, 20, 100); this.setFireInfo(Blocks.red_mushroom_block, 20, 100); @@ -89,7 +95,7 @@ public class HellFire extends BlockFire { @Override public void updateTick(final World world, final int x, final int y, final int z, Random random) { - random = new XSTR(); + random = new XSTR(); if (world.getGameRules().getGameRuleBooleanValue("doFireTick")) { final boolean flag = world.getBlock(x, y - 1, z).isFireSource(world, x, y - 1, z, UP); @@ -296,13 +302,18 @@ public class HellFire extends BlockFire { //Burn @Override - public void onEntityWalking(World world, int i, int j, int k, Entity entity) { + public void onEntityWalking(final World world, final int i, final int j, final int k, final Entity entity) { entity.setFire(10); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + //Burn @Override - public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) { + public void onEntityCollidedWithBlock(final World world, final int i, final int j, final int k, final Entity entity) { entity.setFire(10); } @@ -399,7 +410,7 @@ public class HellFire extends BlockFire { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(final IIconRegister IIconRegister) { - this.IIconArray = new IIcon[] { + this.IIconArray = new IIcon[] { IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_0"), IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_1") }; } diff --git a/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java index 297bcb3061..d093bf2e2f 100644 --- a/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java +++ b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java @@ -7,11 +7,11 @@ import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.boss.IBossDisplayData; @@ -56,39 +56,40 @@ public class BlockWitherProof extends Block{ this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); } - public void onBlockExploded(World world, int x, int y, int z, Explosion explosion){ + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion){ //prevent from being destroyed by wither and nukes. } @Override - public void onBlockDestroyedByExplosion(World p_149723_1_, int p_149723_2_, - int p_149723_3_, int p_149723_4_, Explosion p_149723_5_) { - + public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, + final int p_149723_3_, final int p_149723_4_, final Explosion p_149723_5_) { + } @Override - public boolean canDropFromExplosion(Explosion p_149659_1_) { + public boolean canDropFromExplosion(final Explosion p_149659_1_) { return false; } @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, - Entity entity) { - if (entity == null || !entity.isEntityAlive()){ + public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, + final Entity entity) { + if ((entity == null) || !entity.isEntityAlive()){ return false; - } - if (entity instanceof EntityWither || entity instanceof EntityDragon || entity instanceof IBossDisplayData){ + } + if ((entity instanceof EntityWither) || (entity instanceof EntityDragon) || (entity instanceof IBossDisplayData)){ return false; } else { - return super.canEntityDestroy(world, x, y, z, entity); - } + return super.canEntityDestroy(world, x, y, z, entity); + } } - - + + //Colour Handling private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); - + @Override public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ return mWitherColour; @@ -99,6 +100,11 @@ public class BlockWitherProof extends Block{ return mWitherColour; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java index f40c1dbe7d..b87054748d 100644 --- a/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java +++ b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java @@ -6,6 +6,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -52,4 +53,9 @@ public class BlockFluidSludge extends BlockFluidClassic { return super.displaceIfPossible(world, x, y, z); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java index cab02f9db6..0ed3aa5afd 100644 --- a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java +++ b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java @@ -4,6 +4,7 @@ import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.MetaBlock; import gtPlusPlus.core.lib.CORE; import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.IBlockAccess; public class BlockGtFrameBox extends MetaBlock { @@ -32,4 +33,9 @@ public class BlockGtFrameBox extends MetaBlock { return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/machine/FishTrap.java b/src/Java/gtPlusPlus/core/block/machine/FishTrap.java index f2e15e24b6..fad1dff490 100644 --- a/src/Java/gtPlusPlus/core/block/machine/FishTrap.java +++ b/src/Java/gtPlusPlus/core/block/machine/FishTrap.java @@ -14,10 +14,12 @@ import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class FishTrap extends BlockContainer @@ -95,23 +97,28 @@ public class FishTrap extends BlockContainer } @Override - public void onBlockAdded(World world, int x, int y, int z) { + public void onBlockAdded(final World world, final int x, final int y, final int z) { super.onBlockAdded(world, x, y, z); } @Override - public void breakBlock(World world, int x, int y, int z, Block block, int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { if (stack.hasDisplayName()) { - ((TileEntityFishTrap) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } + ((TileEntityFishTrap) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); } - + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + /*@Override public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java index 9a11c9dadc..1b4c5ebd01 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java @@ -12,9 +12,11 @@ import gtPlusPlus.core.util.Utils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class Machine_ModularityTable extends BlockContainer @@ -67,9 +69,9 @@ public class Machine_ModularityTable extends BlockContainer } final TileEntity te = world.getTileEntity(x, y, z); if ((te != null) && (te instanceof TileEntityModularityTable)){ - player.openGui(GTplusplus.instance, 1, world, x, y, z); - Utils.LOG_INFO("Player opened GUI"); - return true; + player.openGui(GTplusplus.instance, 1, world, x, y, z); + Utils.LOG_INFO("Player opened GUI"); + return true; } return false; } @@ -79,4 +81,9 @@ public class Machine_ModularityTable extends BlockContainer return new TileEntityModularityTable(); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java index 2c742b99db..939015adf7 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -10,7 +10,6 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; -import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -18,10 +17,12 @@ import ic2.core.item.tool.ItemToolWrench; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") @@ -151,4 +152,9 @@ public class Machine_ProjectTable extends BlockContainer return false; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java index 540ba61837..724b438b13 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java @@ -1,22 +1,19 @@ package gtPlusPlus.core.block.machine; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.GTplusplus; import gtPlusPlus.core.block.base.BlockBaseNBT; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.itemblock.ItemBlockNBT; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.util.Utils; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class Machine_TradeTable extends BlockBaseNBT @@ -53,9 +50,9 @@ public class Machine_TradeTable extends BlockBaseNBT final TileEntity te = world.getTileEntity(x, y, z); if ((te != null) && (te instanceof TileEntityTradeTable)) { - //Utils.LOG_INFO("Clicked on TE - ok"); - player.openGui(GTplusplus.instance, 6, world, x, y, z); - return true; + //Utils.LOG_INFO("Clicked on TE - ok"); + player.openGui(GTplusplus.instance, 6, world, x, y, z); + return true; } else { Utils.LOG_INFO("Bad TE"); @@ -68,4 +65,9 @@ public class Machine_TradeTable extends BlockBaseNBT return new TileEntityTradeTable(); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 64a5c5af8b..b5c54ad9a8 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -17,10 +17,12 @@ import ic2.core.item.tool.ItemToolWrench; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") @@ -150,4 +152,9 @@ public class Machine_Workbench extends BlockContainer return false; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 851db25325..bd43da11fa 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -8,7 +8,12 @@ import gregtech.api.enums.Materials; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.common.compat.COMPAT_Baubles; import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.*; +import gtPlusPlus.core.item.base.BaseEuItem; +import gtPlusPlus.core.item.base.BaseItemBackpack; +import gtPlusPlus.core.item.base.BaseItemBurnable; +import gtPlusPlus.core.item.base.BaseItemDamageable; +import gtPlusPlus.core.item.base.BaseItemTCShard; +import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.item.base.dusts.decimal.BaseItemCentidust; import gtPlusPlus.core.item.base.dusts.decimal.BaseItemDecidust; import gtPlusPlus.core.item.base.foods.BaseItemFood; @@ -23,19 +28,36 @@ import gtPlusPlus.core.item.bauble.HealthBoostBauble; import gtPlusPlus.core.item.bauble.ModularBauble; import gtPlusPlus.core.item.chemistry.CoalTar; import gtPlusPlus.core.item.effects.RarityUncommon; -import gtPlusPlus.core.item.general.*; +import gtPlusPlus.core.item.general.BaseItemGrindle; +import gtPlusPlus.core.item.general.BufferCore; +import gtPlusPlus.core.item.general.ItemAirFilter; +import gtPlusPlus.core.item.general.ItemAreaClear; +import gtPlusPlus.core.item.general.ItemBasicFirestarter; +import gtPlusPlus.core.item.general.ItemBlueprint; +import gtPlusPlus.core.item.general.ItemEmpty; +import gtPlusPlus.core.item.general.ItemGemShards; +import gtPlusPlus.core.item.general.ItemHalfCompleteCasings; +import gtPlusPlus.core.item.general.ItemLavaFilter; +import gtPlusPlus.core.item.general.RF2EU_Battery; import gtPlusPlus.core.item.general.books.ItemBaseBook; -import gtPlusPlus.core.item.general.chassis.*; +import gtPlusPlus.core.item.general.chassis.itemBoilerChassis; +import gtPlusPlus.core.item.general.chassis.itemDehydratorCoil; +import gtPlusPlus.core.item.general.chassis.itemDehydratorCoilWire; import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.init.ItemsMultiTools; import gtPlusPlus.core.item.tool.misc.SandstoneHammer; -import gtPlusPlus.core.item.tool.staballoy.*; +import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; +import gtPlusPlus.core.item.tool.staballoy.StaballoyAxe; +import gtPlusPlus.core.item.tool.staballoy.StaballoyPickaxe; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.configSwitches; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.material.*; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.material.nuclear.NUCLIDE; import gtPlusPlus.core.util.StringUtils; @@ -44,12 +66,15 @@ import gtPlusPlus.core.util.debug.DEBUG_INIT; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.materials.MaterialUtils; -import net.minecraft.block.Block; -import net.minecraft.item.*; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; public final class ModItems { @@ -240,7 +265,7 @@ public final class ModItems { public static Item itemModularBauble; public static Item itemCustomBook; - + public static Item itemGrindleTablet; public static final void init(){ @@ -309,7 +334,7 @@ public final class ModItems { itemHydrofluoricPotion = new ItemHydrofluoricAcidPotion("itemHydrofluoricPotion", "Thowable Vial of Hydrofluoric Acid", "They won't see this coming, nor anything after!").setTextureName(CORE.MODID + ":itemPotion"); //Start meta Item Generation ItemsFoods.load(); - + try{ @@ -590,6 +615,14 @@ public final class ModItems { //Create Multi-tools ItemsMultiTools.load(); + //Xp Fluids - Dev + if (!FluidRegistry.isFluidRegistered("mobessence")){ + FluidUtils.generateFluidNoPrefix("mobessence", "mobessence", 0, new short[]{125, 175, 125, 100}); + } + if (!FluidRegistry.isFluidRegistered("xpjuice")){ + FluidUtils.generateFluidNoPrefix("xpjuice", "xpjuice", 0, new short[]{50, 150, 50, 100}); + } + //Just an unusual plate needed for some black magic. itemPlateClay = new BaseItemPlate(MaterialUtils.generateMaterialFromGtENUM(Materials.Clay)); itemDoublePlateClay = new BaseItemPlateDouble(MaterialUtils.generateMaterialFromGtENUM(Materials.Clay)); @@ -605,10 +638,10 @@ public final class ModItems { } //A plate of Europium. - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateEuropium", 1) == null && CORE.configSwitches.enableCustom_Pipes){ + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateEuropium", 1) == null) && CORE.configSwitches.enableCustom_Pipes){ itemPlateEuropium = new BaseItemPlate(MaterialUtils.generateMaterialFromGtENUM(Materials.Europium)); } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null && CORE.configSwitches.enableCustom_Pipes){ + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null) && CORE.configSwitches.enableCustom_Pipes){ itemDoublePlateEuropium = new BaseItemPlateDouble(MaterialUtils.generateMaterialFromGtENUM(Materials.Europium)); } @@ -618,7 +651,7 @@ public final class ModItems { itemAirFilter = new ItemAirFilter(); itemLavaFilter = new ItemLavaFilter(); - + itemGrindleTablet = new BaseItemGrindle(); //Chemistry @@ -662,7 +695,7 @@ public final class ModItems { itemPlatePulsatingIron = ItemUtils.generateSpecialUsePlate("itemPlate"+"PhasedIron", "Phased Iron", new short[]{50, 91, 21}, 0); itemPlateEnergeticAlloy = ItemUtils.generateSpecialUsePlate("itemPlate"+"EnergeticAlloy", "Energetic Alloy", new short[]{252, 152, 45}, 0); itemPlateVibrantAlloy = ItemUtils.generateSpecialUsePlate("itemPlate"+"VibrantAlloy", "Vibrant Alloy", new short[]{204, 242, 142}, 0); - itemPlateConductiveIron = ItemUtils.generateSpecialUsePlate("itemPlate"+"ConductiveIron", "Conductive Iron", new short[]{164, 109, 100}, 0); + itemPlateConductiveIron = ItemUtils.generateSpecialUsePlate("itemPlate"+"ConductiveIron", "Conductive Iron", new short[]{164, 109, 100}, 0); //Register dumb naming conventions - Who chose fucking phased Iron/Gold? GT_OreDictUnificator.registerOre("dustPhasedGold", ItemUtils.getSimpleStack(itemDustVibrantAlloy)); @@ -677,7 +710,7 @@ public final class ModItems { //Big Reactors if (LoadedMods.Big_Reactors|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("BigReactors Found - Loading Resources."); - //Item Init + //Item Init itemPlateBlutonium = ItemUtils.generateSpecialUsePlate("itemPlate"+"Blutonium", "Blutonium", new short[]{0, 0, 255}, 0); itemPlateBlutonium = ItemUtils.generateSpecialUsePlate("itemPlate"+"Cyanite", "Cyanite", new short[]{0, 191, 255}, 0); itemPlateLudicrite = ItemUtils.generateSpecialUsePlate("itemPlate"+"Ludicrite", "Ludicrite", new short[]{167, 5, 179}, 0); @@ -692,7 +725,7 @@ public final class ModItems { //Item Init try { ItemUtils.getItemForOreDict("Thaumcraft:ItemResource", "ingotVoidMetal", "Void Metal Ingot", 16); - itemPlateVoidMetal = ItemUtils.generateSpecialUsePlate("itemPlate"+"Void", "Void", new short[]{82, 17, 82}, 0); + itemPlateVoidMetal = ItemUtils.generateSpecialUsePlate("itemPlate"+"Void", "Void", new short[]{82, 17, 82}, 0); GT_OreDictUnificator.registerOre("plateVoidMetal", new ItemStack(ModItems.itemPlateVoidMetal)); } catch (final NullPointerException e){ e.getClass(); @@ -742,7 +775,7 @@ public final class ModItems { if (LoadedMods.RFTools|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("rfTools Found - Loading Resources."); //Item Init - itemPlateDimensionShard = ItemUtils.generateSpecialUsePlate("itemPlate"+"DimensionShard", "Dimensional Shard", new short[]{170, 230, 230}, 0); + itemPlateDimensionShard = ItemUtils.generateSpecialUsePlate("itemPlate"+"DimensionShard", "Dimensional Shard", new short[]{170, 230, 230}, 0); } else { Utils.LOG_WARNING("rfTools not Found - Skipping Resources."); @@ -810,7 +843,7 @@ public final class ModItems { //ItemBlockGtFrameBox = new ItemBlockGtFrameBox(ModBlocks.blockGtFrameSet1); //GameRegistry.registerItem(ItemBlockGtFrameBox, "itemGtFrameBoxSet1"); - + itemCustomBook = new ItemBaseBook(); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index 83d274473c..87fb8ef76d 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -5,6 +5,7 @@ import gtPlusPlus.core.tileentities.general.TileEntityFirepit; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; +import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; @@ -18,14 +19,6 @@ public class ModTileEntities { public static void init() { Utils.LOG_INFO("Registering Tile Entities."); - // GameRegistry.registerTileEntity(TileEntityReverter.class, - // "TE_blockGriefSaver"); - // GameRegistry.registerTileEntity(TileEntityReverter.class, "Tower - // Reverter"); - // GameRegistry.registerTileEntity(TileEntityNHG.class, - // "NuclearFueledHeliumGenerator"); - // GameRegistry.registerTileEntity(TileEntityCharger.class, - // "TE_Charger"); GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "HeliumGenerator"); GameRegistry.registerTileEntity(TileEntityWorkbench.class, "TileWorkbench"); GameRegistry.registerTileEntity(TileEntityWorkbenchAdvanced.class, "TileWorkbenchAdvanced"); @@ -37,6 +30,7 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); GameRegistry.registerTileEntity(TileFastAlchemyFurnace.class, "TileFastAlchemyFurnace"); GameRegistry.registerTileEntity(TileFastArcaneAlembic.class, "TileFastArcaneAlembic"); + GameRegistry.registerTileEntity(TileEntityXpConverter.class, "TileEntityXpConverter"); } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java index ca190802dc..09fea921a5 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -1,6 +1,8 @@ package gtPlusPlus.core.tileentities.general; import gtPlusPlus.core.util.enchanting.EnchantingUtils; +import gtPlusPlus.core.util.player.PlayerUtils; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -91,6 +93,14 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.yCoord, this.zCoord, tank, 0)); } } + + if ((from == ForgeDirection.UP) || (from == ForgeDirection.DOWN)){ + this.tankEssence = tank; + } + else { + this.tankLiquidXp = tank; + } + return stack; } @@ -125,7 +135,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { @Override public void updateEntity() { - if (this.tankEssence.getFluid() != null){ + /*if (this.tankEssence.getFluid() != null){ final FluidStack bigStorage = this.tankEssence.getFluid(); bigStorage.amount = this.tankEssence.getCapacity(); this.tankEssence.setFluid(bigStorage); @@ -135,20 +145,19 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { final FluidStack bigStorage = this.tankLiquidXp.getFluid(); bigStorage.amount = this.tankLiquidXp.getCapacity(); this.tankLiquidXp.setFluid(bigStorage); - } + }*/ if (this.needsUpdate) { - if (this.tankEssence.getFluid() != null){ + /*if (this.tankEssence.getFluid() != null){ final FluidStack bigStorage = this.tankEssence.getFluid(); bigStorage.amount = this.tankEssence.getCapacity(); this.tankEssence.setFluid(bigStorage); - } + }*/ if (this.tankLiquidXp.getFluid() != null){ - final FluidStack bigStorage = this.tankLiquidXp.getFluid(); - bigStorage.amount = this.tankLiquidXp.getCapacity(); - this.tankLiquidXp.setFluid(bigStorage); + final FluidStack bigStorage = EnchantingUtils.getEssenceFromLiquidXp(this.tankLiquidXp.getFluidAmount()); + this.tankEssence.setFluid(bigStorage); } if (this.updateTimer == 0) { @@ -190,4 +199,12 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.readFromNBT(tag); } + public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { + PlayerUtils.messagePlayer(aPlayer, "Screwdriver Rightclick."); + } + + public void onRightClick(final byte aSide, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) { + PlayerUtils.messagePlayer(aPlayer, "Rightclick."); + } + } diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java index 543fd65b71..f1462ba51e 100644 --- a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java +++ b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java @@ -1,6 +1,9 @@ package gtPlusPlus.core.util.player; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -104,7 +107,7 @@ public class PlayerUtils { }catch(final NullPointerException e){ e.printStackTrace(); return null; - } + } if (heldItem != null){ return heldItem; } @@ -125,32 +128,32 @@ public class PlayerUtils { return null; } - - public static Item getItemInPlayersHand(EntityPlayer player){ + + public static Item getItemInPlayersHand(final EntityPlayer player){ Item heldItem = null; - try{heldItem = player.getHeldItem().getItem(); + try{ + heldItem = player.getHeldItem().getItem(); }catch(final NullPointerException e){return null;} if (heldItem != null){ return heldItem; } - return null; } - - public final static EntityPlayer getPlayerEntityByName(String aPlayerName){ - EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); + + public final static EntityPlayer getPlayerEntityByName(final String aPlayerName){ + final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); if (player != null){ return player; - } + } return null; } - - public final static UUID getPlayersUUIDByName(String aPlayerName){ - EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); + + public final static UUID getPlayersUUIDByName(final String aPlayerName){ + final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); if (player != null){ return player.getUniqueID(); - } + } return null; } -- cgit From ecbe25305fedc7119d034abc68547ebfed8b6725 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sat, 25 Nov 2017 15:25:40 +1000 Subject: $ More Fixes to the Xp Converter. --- .../core/block/general/BlockTankXpConverter.java | 19 ++- .../general/TileEntityXpConverter.java | 158 +++++++++++++++------ 2 files changed, 119 insertions(+), 58 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index 97a9ff2af6..e4270061cb 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -4,7 +4,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.interfaces.IToolStats; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; @@ -75,17 +74,15 @@ public class BlockTankXpConverter extends BlockContainer { boolean mDidScrewDriver = false; //Check For Screwdriver try { - final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(player); - final Item mHandItem = PlayerUtils.getItemInPlayersHand(player); - if (mHandItem instanceof IToolStats){ - if (((mHandItem instanceof GT_MetaGenerated_Tool_01) && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))){ - final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); - if (tile != null){ - mDidScrewDriver = true; - tile.onScrewdriverRightClick((byte) side, player, x, y, z); - } - + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))){ + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null){ + mDidScrewDriver = true; + tile.onScrewdriverRightClick((byte) side, player, x, y, z); } + } } catch (final Throwable t){ diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java index 09fea921a5..e3650b5dca 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -1,5 +1,6 @@ package gtPlusPlus.core.tileentities.general; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.entity.player.EntityPlayer; @@ -22,6 +23,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public FluidTank tankLiquidXp = new FluidTank(64000); private boolean needsUpdate = false; private int updateTimer = 0; + private boolean mConvertToEssence = true; public TileEntityXpConverter() { } @@ -29,35 +31,52 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { @Override public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) { this.needsUpdate = true; - if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ - return this.tankLiquidXp.fill(resource, doFill); - } - else if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ - return this.tankEssence.fill(resource, doFill); + Utils.LOG_INFO("Ticking. | mConvertToEssence: "+this.mConvertToEssence); + if (this.mConvertToEssence){ + if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ + Utils.LOG_INFO("fill(tankLiquidXp)"); + return this.tankLiquidXp.fill(resource, doFill); + } + else { + Utils.LOG_INFO("Looking for Liquid Xp, Instead found "+resource.getLocalizedName()+"."); + } } else { - return 0; + if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ + Utils.LOG_INFO("fill(tankEssence)"); + return this.tankEssence.fill(resource, doFill); + } + else { + Utils.LOG_INFO("Looking for Essence, Instead found "+resource.getLocalizedName()+"."); + } } + Utils.LOG_INFO("fill(0)"); + return 0; } @Override public FluidStack drain(final ForgeDirection from, final FluidStack resource, final boolean doDrain) { this.needsUpdate = true; - if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ - return this.tankLiquidXp.drain(resource.amount, doDrain); - } - else if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ - return this.tankEssence.drain(resource.amount, doDrain); + if (this.mConvertToEssence){ + if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ + Utils.LOG_INFO("drain(mConvertToEssence)"); + return this.tankEssence.drain(resource.amount, doDrain); + } } else { - return null; + if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ + Utils.LOG_INFO("drain(tankLiquidXp)"); + return this.tankLiquidXp.drain(resource.amount, doDrain); + } } - + Utils.LOG_INFO("drain(null)"); + return null; } @Override public FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) { this.needsUpdate = true; + Utils.LOG_INFO("drain(Ex)"); final FluidStack fluid_Essence = this.tankEssence.getFluid(); final FluidStack fluid_Xp = this.tankLiquidXp.getFluid(); if ((fluid_Essence == null) && (fluid_Xp == null)) { @@ -67,7 +86,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { FluidStack fluid; FluidTank tank; - if ((from == ForgeDirection.UP) || (from == ForgeDirection.DOWN)){ + if (this.mConvertToEssence){ fluid = fluid_Essence; tank = this.tankEssence; } @@ -94,29 +113,55 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { } } - if ((from == ForgeDirection.UP) || (from == ForgeDirection.DOWN)){ + + if (this.mConvertToEssence){ this.tankEssence = tank; } else { this.tankLiquidXp = tank; } + Utils.LOG_INFO("drain(Ex2)"); return stack; } @Override public boolean canFill(final ForgeDirection from, final Fluid fluid) { - return true; + if (this.mConvertToEssence){ + if (this.tankEssence.getFluidAmount() < this.tankEssence.getCapacity()){ + Utils.LOG_INFO("canFill(mConvertToEssence)"); + return true; + } + } + else { + if (this.tankLiquidXp.getFluidAmount() < this.tankLiquidXp.getCapacity()){ + Utils.LOG_INFO("canFill(tankLiquidXp)"); + return true; + } + } + Utils.LOG_INFO("canFill(false)"); + return false; } @Override public boolean canDrain(final ForgeDirection from, final Fluid fluid) { - return true; + if (this.mConvertToEssence){ + if (this.tankEssence.getFluidAmount() > 0){ + return true; + } + } + else { + if (this.tankLiquidXp.getFluidAmount() > 0){ + return true; + } + } + Utils.LOG_INFO("canDrain(false)"); + return false; } @Override public FluidTankInfo[] getTankInfo(final ForgeDirection from) { - if ((from == ForgeDirection.UP) || (from == ForgeDirection.DOWN)){ + if (this.mConvertToEssence){ return new FluidTankInfo[] { this.tankEssence.getInfo() }; } else { @@ -125,6 +170,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { } public float getAdjustedVolume() { + Utils.LOG_INFO("AdjustedVolume()"); this.needsUpdate = true; final float amount = this.tankLiquidXp.getFluidAmount(); final float capacity = this.tankLiquidXp.getCapacity(); @@ -135,47 +181,52 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { @Override public void updateEntity() { - /*if (this.tankEssence.getFluid() != null){ - final FluidStack bigStorage = this.tankEssence.getFluid(); - bigStorage.amount = this.tankEssence.getCapacity(); - this.tankEssence.setFluid(bigStorage); - } + if (!this.getWorldObj().isRemote){ - if (this.tankLiquidXp.getFluid() != null){ - final FluidStack bigStorage = this.tankLiquidXp.getFluid(); - bigStorage.amount = this.tankLiquidXp.getCapacity(); - this.tankLiquidXp.setFluid(bigStorage); - }*/ + //Utils.LOG_INFO("Ticking. | mConvertToEssence: "+this.mConvertToEssence); - if (this.needsUpdate) { + if (this.needsUpdate) { - /*if (this.tankEssence.getFluid() != null){ - final FluidStack bigStorage = this.tankEssence.getFluid(); - bigStorage.amount = this.tankEssence.getCapacity(); - this.tankEssence.setFluid(bigStorage); - }*/ - - if (this.tankLiquidXp.getFluid() != null){ - final FluidStack bigStorage = EnchantingUtils.getEssenceFromLiquidXp(this.tankLiquidXp.getFluidAmount()); - this.tankEssence.setFluid(bigStorage); + if (this.updateTimer == 0) { + this.updateTimer = 10; // every 10 ticks it will send an update + } else { + --this.updateTimer; + if (this.updateTimer == 0) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.needsUpdate = false; + } + } } - if (this.updateTimer == 0) { - this.updateTimer = 10; // every 10 ticks it will send an update - } else { - --this.updateTimer; - if (this.updateTimer == 0) { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - this.needsUpdate = false; + + if (this.mConvertToEssence){ + if ((this.tankLiquidXp.getFluid() != null) && (this.tankLiquidXp.getFluidAmount() >= 100) && (this.tankEssence.getFluidAmount() <= (this.tankEssence.getCapacity()-(100*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)))){ + final FluidStack bigStorage = EnchantingUtils.getEssenceFromLiquidXp(100); + this.tankEssence.fill(bigStorage, true); + this.tankLiquidXp.drain(100, true); + this.needsUpdate = true; + Utils.LOG_INFO("B->A"); + } + } + else { + final double rm = EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP; + if ((this.tankEssence.getFluid() != null) && (this.tankEssence.getFluidAmount() >= rm) && (this.tankLiquidXp.getFluidAmount() <= (this.tankLiquidXp.getCapacity()-rm))){ + final FluidStack bigStorage = EnchantingUtils.getLiquidXP(1); + this.tankLiquidXp.fill(bigStorage, true); + this.tankEssence.drain((int) rm, true); + this.needsUpdate = true; + Utils.LOG_INFO("A->B"); } } } + } @Override public void readFromNBT(final NBTTagCompound tag) { this.tankEssence.readFromNBT(tag); this.tankLiquidXp.readFromNBT(tag); + tag.setBoolean("mConvertToEssence", this.mConvertToEssence); super.readFromNBT(tag); } @@ -183,6 +234,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public void writeToNBT(final NBTTagCompound tag) { this.tankEssence.writeToNBT(tag); this.tankLiquidXp.writeToNBT(tag); + this.mConvertToEssence = tag.getBoolean("mConvertToEssence"); super.writeToNBT(tag); } @@ -200,11 +252,23 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { } public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { - PlayerUtils.messagePlayer(aPlayer, "Screwdriver Rightclick."); + + if (!this.getWorldObj().isRemote){ + + if (this.mConvertToEssence){ + PlayerUtils.messagePlayer(aPlayer, "Converting from Mob Essence to Liquid Xp."); + this.mConvertToEssence = false; + } + else { + PlayerUtils.messagePlayer(aPlayer, "Converting from Liquid Xp to Mob Essence."); + this.mConvertToEssence = true; + } + } + } public void onRightClick(final byte aSide, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) { - PlayerUtils.messagePlayer(aPlayer, "Rightclick."); + } } -- cgit From a8442c40315db01d24845faac17c52af11191036 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sun, 26 Nov 2017 17:19:56 +1000 Subject: $ Fixed the Xp Converter not retaining its mode. --- .../general/TileEntityXpConverter.java | 54 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java index e3650b5dca..8491cf8f6e 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -1,5 +1,7 @@ package gtPlusPlus.core.tileentities.general; +import org.lwjgl.input.Keyboard; + import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.player.PlayerUtils; @@ -28,6 +30,26 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public TileEntityXpConverter() { } + private void changeMode(){ + if (this.mConvertToEssence){ + this.mConvertToEssence = false; + return; + } + else { + this.mConvertToEssence = true; + return; + } + } + + private boolean isServerSide(){ + if (this.getWorldObj().isRemote){ + return false; + } + else { + return true; + } + } + @Override public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) { this.needsUpdate = true; @@ -181,7 +203,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { @Override public void updateEntity() { - if (!this.getWorldObj().isRemote){ + if (this.isServerSide()){ //Utils.LOG_INFO("Ticking. | mConvertToEssence: "+this.mConvertToEssence); @@ -226,7 +248,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public void readFromNBT(final NBTTagCompound tag) { this.tankEssence.readFromNBT(tag); this.tankLiquidXp.readFromNBT(tag); - tag.setBoolean("mConvertToEssence", this.mConvertToEssence); + this.mConvertToEssence = tag.getBoolean("mConvertToEssence"); super.readFromNBT(tag); } @@ -234,7 +256,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public void writeToNBT(final NBTTagCompound tag) { this.tankEssence.writeToNBT(tag); this.tankLiquidXp.writeToNBT(tag); - this.mConvertToEssence = tag.getBoolean("mConvertToEssence"); + tag.setBoolean("mConvertToEssence", this.mConvertToEssence); super.writeToNBT(tag); } @@ -252,23 +274,37 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { } public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { - - if (!this.getWorldObj().isRemote){ - + if (this.isServerSide()){ if (this.mConvertToEssence){ PlayerUtils.messagePlayer(aPlayer, "Converting from Mob Essence to Liquid Xp."); - this.mConvertToEssence = false; } else { PlayerUtils.messagePlayer(aPlayer, "Converting from Liquid Xp to Mob Essence."); - this.mConvertToEssence = true; } + //Mode Change + this.changeMode(); } - } public void onRightClick(final byte aSide, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) { + if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) { + String mInput; + String mOutput; + + if (this.mConvertToEssence){ + mInput = "Liquid Xp"; + mOutput = "Mob Essence"; + } + else { + mInput = "Mob Essence"; + mOutput = "Liquid Xp"; + } + + PlayerUtils.messagePlayer(aPlayer, "Input: "+mInput+"."); + PlayerUtils.messagePlayer(aPlayer, "Output: "+mOutput+"."); + } + } } -- cgit From 2b28b0849d64b320e42a478f83af6a29c4f28ac1 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sun, 26 Nov 2017 17:54:25 +1000 Subject: $ Fixed Large Sifter, Tree Farm & Power Sub-Station not forming on SMP. $ Fixed issue where INFO_MACHINE_LOGGING would cause NPE's on SMP. - Removed logging from the Xp Converter. --- .../item/base/itemblock/ItemBlockEntityBase.java | 4 +- .../general/TileEntityXpConverter.java | 38 ++++++------- src/Java/gtPlusPlus/core/util/Utils.java | 65 ++++++++++++++-------- 3 files changed, 64 insertions(+), 43 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java index 0dda165b6b..b13e6b22bc 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java @@ -28,8 +28,8 @@ public class ItemBlockEntityBase extends ItemBlock { @Override public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ - list.add(EnumChatFormatting.GRAY+"Liquid Xp can be filled or drained from all four sides."); - list.add(EnumChatFormatting.GRAY+"Mob Essence can be filled or drained from the top and bottom."); + list.add(EnumChatFormatting.GRAY+"Can convert Liquid Xp to Mob Essence and back."); + list.add(EnumChatFormatting.GRAY+"Right click with a Screwdriver to change mode."); } else if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ //list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java index 8491cf8f6e..98da5a40fc 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -53,26 +53,26 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { @Override public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) { this.needsUpdate = true; - Utils.LOG_INFO("Ticking. | mConvertToEssence: "+this.mConvertToEssence); + Utils.LOG_WARNING("Ticking. | mConvertToEssence: "+this.mConvertToEssence); if (this.mConvertToEssence){ if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ - Utils.LOG_INFO("fill(tankLiquidXp)"); + Utils.LOG_WARNING("fill(tankLiquidXp)"); return this.tankLiquidXp.fill(resource, doFill); } else { - Utils.LOG_INFO("Looking for Liquid Xp, Instead found "+resource.getLocalizedName()+"."); + Utils.LOG_WARNING("Looking for Liquid Xp, Instead found "+resource.getLocalizedName()+"."); } } else { if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ - Utils.LOG_INFO("fill(tankEssence)"); + Utils.LOG_WARNING("fill(tankEssence)"); return this.tankEssence.fill(resource, doFill); } else { - Utils.LOG_INFO("Looking for Essence, Instead found "+resource.getLocalizedName()+"."); + Utils.LOG_WARNING("Looking for Essence, Instead found "+resource.getLocalizedName()+"."); } } - Utils.LOG_INFO("fill(0)"); + Utils.LOG_WARNING("fill(0)"); return 0; } @@ -81,24 +81,24 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.needsUpdate = true; if (this.mConvertToEssence){ if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ - Utils.LOG_INFO("drain(mConvertToEssence)"); + Utils.LOG_WARNING("drain(mConvertToEssence)"); return this.tankEssence.drain(resource.amount, doDrain); } } else { if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ - Utils.LOG_INFO("drain(tankLiquidXp)"); + Utils.LOG_WARNING("drain(tankLiquidXp)"); return this.tankLiquidXp.drain(resource.amount, doDrain); } } - Utils.LOG_INFO("drain(null)"); + Utils.LOG_WARNING("drain(null)"); return null; } @Override public FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) { this.needsUpdate = true; - Utils.LOG_INFO("drain(Ex)"); + Utils.LOG_WARNING("drain(Ex)"); final FluidStack fluid_Essence = this.tankEssence.getFluid(); final FluidStack fluid_Xp = this.tankLiquidXp.getFluid(); if ((fluid_Essence == null) && (fluid_Xp == null)) { @@ -143,7 +143,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.tankLiquidXp = tank; } - Utils.LOG_INFO("drain(Ex2)"); + Utils.LOG_WARNING("drain(Ex2)"); return stack; } @@ -151,17 +151,17 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public boolean canFill(final ForgeDirection from, final Fluid fluid) { if (this.mConvertToEssence){ if (this.tankEssence.getFluidAmount() < this.tankEssence.getCapacity()){ - Utils.LOG_INFO("canFill(mConvertToEssence)"); + Utils.LOG_WARNING("canFill(mConvertToEssence)"); return true; } } else { if (this.tankLiquidXp.getFluidAmount() < this.tankLiquidXp.getCapacity()){ - Utils.LOG_INFO("canFill(tankLiquidXp)"); + Utils.LOG_WARNING("canFill(tankLiquidXp)"); return true; } } - Utils.LOG_INFO("canFill(false)"); + Utils.LOG_WARNING("canFill(false)"); return false; } @@ -177,7 +177,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { return true; } } - Utils.LOG_INFO("canDrain(false)"); + Utils.LOG_WARNING("canDrain(false)"); return false; } @@ -192,7 +192,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { } public float getAdjustedVolume() { - Utils.LOG_INFO("AdjustedVolume()"); + Utils.LOG_WARNING("AdjustedVolume()"); this.needsUpdate = true; final float amount = this.tankLiquidXp.getFluidAmount(); final float capacity = this.tankLiquidXp.getCapacity(); @@ -205,7 +205,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { if (this.isServerSide()){ - //Utils.LOG_INFO("Ticking. | mConvertToEssence: "+this.mConvertToEssence); + //Utils.LOG_WARNING("Ticking. | mConvertToEssence: "+this.mConvertToEssence); if (this.needsUpdate) { @@ -227,7 +227,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.tankEssence.fill(bigStorage, true); this.tankLiquidXp.drain(100, true); this.needsUpdate = true; - Utils.LOG_INFO("B->A"); + Utils.LOG_WARNING("B->A"); } } else { @@ -237,7 +237,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.tankLiquidXp.fill(bigStorage, true); this.tankEssence.drain((int) rm, true); this.needsUpdate = true; - Utils.LOG_INFO("A->B"); + Utils.LOG_WARNING("A->B"); } } } diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index f9315a2966..979c1f0287 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -1,12 +1,16 @@ package gtPlusPlus.core.util; -import static gtPlusPlus.core.handler.BookHandler.mBookKeeperCount; - import java.awt.Color; import java.awt.Graphics; import java.io.File; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; import org.apache.commons.lang3.EnumUtils; import org.apache.logging.log4j.LogManager; @@ -15,7 +19,6 @@ import org.apache.logging.log4j.Logger; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.FMLRelaunchLog; -import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.TC_Aspects.TC_AspectStack; @@ -23,7 +26,6 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; @@ -38,7 +40,6 @@ import ic2.core.item.resources.ItemCell; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; -import net.minecraft.init.Items; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -49,7 +50,9 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraftforge.common.util.EnumHelper; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; public class Utils { @@ -183,8 +186,21 @@ public class Utils { // Non-Dev Comments public static void LOG_MACHINE_INFO(final String s) { - if (CORE.configSwitches.MACHINE_INFO || ClientProxy.playerName.toLowerCase().contains("draknyte1")) { - String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); + + boolean localPlayer = false; + try { + if (ClientProxy.playerName != null){ + if (ClientProxy.playerName.toLowerCase().contains("draknyte1")){ + localPlayer = true; + } + } + } + catch (final Throwable t){ + + } + + if (CORE.configSwitches.MACHINE_INFO || localPlayer) { + final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); modLogger.info("Machine Info: " + s + " | " + name1); } } @@ -504,7 +520,7 @@ public class Utils { } public static File getMcDir() { - if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDedicatedServer()) { + if ((MinecraftServer.getServer() != null) && MinecraftServer.getServer().isDedicatedServer()) { return new File("."); } return Minecraft.getMinecraft().mcDataDir; @@ -604,7 +620,7 @@ public class Utils { } - public static int calculateVoltageTier(int Voltage) { + public static int calculateVoltageTier(final int Voltage) { int V; if (Voltage == 8) { V = 0; @@ -732,34 +748,39 @@ public class Utils { return sBookCount; } - public static ItemStack getWrittenBook(ItemStack aBook, int aID, String aMapping, String aTitle, String aAuthor, - String[] aPages) { - if (GT_Utility.isStringInvalid(aMapping)) + public static ItemStack getWrittenBook(final ItemStack aBook, final int aID, final String aMapping, final String aTitle, final String aAuthor, + final String[] aPages) { + if (GT_Utility.isStringInvalid(aMapping)) { return null; - ItemStack rStack = (ItemStack) CORE.sBookList.get(aMapping); - if (rStack != null) + } + ItemStack rStack = CORE.sBookList.get(aMapping); + if (rStack != null) { return GT_Utility.copyAmount(1L, new Object[] { rStack }); - if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) + } + if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) { return null; + } sBookCount += 1; - int vMeta = (aID == -1 ? sBookCount : aID); + final int vMeta = (aID == -1 ? sBookCount : aID); rStack = (aBook == null ? new ItemStack(ModItems.itemCustomBook, 1, vMeta) : aBook); - NBTTagCompound tNBT = new NBTTagCompound(); + final NBTTagCompound tNBT = new NBTTagCompound(); tNBT.setString("title", GT_LanguageManager.addStringLocalization( new StringBuilder().append("Book.").append(aTitle).append(".Name").toString(), aTitle)); tNBT.setString("author", aAuthor); - NBTTagList tNBTList = new NBTTagList(); + final NBTTagList tNBTList = new NBTTagList(); for (byte i = 0; i < aPages.length; i = (byte) (i + 1)) { aPages[i] = GT_LanguageManager .addStringLocalization(new StringBuilder().append("Book.").append(aTitle).append(".Page") .append((i < 10) ? new StringBuilder().append("0").append(i).toString() : Byte.valueOf(i)) .toString(), aPages[i]); if (i < 48) { - if (aPages[i].length() < 256) + if (aPages[i].length() < 256) { tNBTList.appendTag(new NBTTagString(aPages[i])); - else + } + else { GT_Log.err.println(new StringBuilder().append("WARNING: String for written Book too long! -> ") .append(aPages[i]).toString()); + } } else { GT_Log.err.println(new StringBuilder().append("WARNING: Too much Pages for written Book! -> ") .append(aTitle).toString()); -- cgit From f30d9f3ad55ae18cec5e86cc6a7b0124847b9a1f Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sun, 26 Nov 2017 19:09:55 +1000 Subject: % Made the Xp Converter more colourful. --- .../core/block/general/BlockTankXpConverter.java | 104 ++++++++++++++++++++- .../general/TileEntityXpConverter.java | 15 ++- 2 files changed, 111 insertions(+), 8 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index e4270061cb..c2afdfd21f 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -1,5 +1,9 @@ package gtPlusPlus.core.block.general; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @@ -9,6 +13,8 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.array.Triplet; import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.block.BlockContainer; @@ -32,6 +38,10 @@ public class BlockTankXpConverter extends BlockContainer { @SideOnly(Side.CLIENT) private IIcon textureFront; + private int mRainbowTick = 0; + private int mRainbowTickMax = 0; + private final Map> mRainbowMap = new HashMap>(); + @SuppressWarnings("deprecation") public BlockTankXpConverter() { super(Material.iron); @@ -39,6 +49,10 @@ public class BlockTankXpConverter extends BlockContainer { this.setCreativeTab(AddToCreativeTab.tabMachines); GameRegistry.registerBlock(this, ItemBlockEntityBase.class, "blockTankXpConverter"); LanguageRegistry.addName(this, "Xp Converter"); + this.generateRainbowMap(); + if (!this.getTickRandomly()){ + this.setTickRandomly(true); + } } /** @@ -55,10 +69,10 @@ public class BlockTankXpConverter extends BlockContainer { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(final IIconRegister p_149651_1_) { - this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); - this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlYellow"); + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); } /** @@ -142,4 +156,86 @@ public class BlockTankXpConverter extends BlockContainer { return false; } + private final boolean generateRainbowMap(){ + int id = 0; + this.mRainbowMap.put(id++, new Triplet( 0, 255, 0)); + this.mRainbowMap.put(id++, new Triplet( 51, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(102, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(153, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(204, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 204, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 153, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 102, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 51, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 51)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 102)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 153)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 204)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(204, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(153, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(102, 0, 255)); + this.mRainbowMap.put(id++, new Triplet( 51, 0, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 0, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 51, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 102, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 153, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 204, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 255)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 204)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 153)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 102)); + this.mRainbowMap.put(id++, new Triplet( 0, 255, 51)); + this.mRainbowTickMax = this.mRainbowMap.size(); + return true; + } + + @Override + public int getBlockColor() { + return Utils.rgbtoHexValue(0, 0, 0); + } + + @Override + public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, final int p_149720_4_) { + + if ((this.mRainbowTick < 0) || (this.mRainbowTick > this.mRainbowTickMax)){ + this.mRainbowTick = 0; + } + //Utils.LOG_INFO("x: "+this.mRainbowTick); + if (this.mRainbowTick <= this.mRainbowTickMax){ + Triplet mT = this.mRainbowMap.get(this.mRainbowTick); + try { + return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1()); + } catch (final Throwable t){ + try { + mT = this.mRainbowMap.get(this.mRainbowTick-1); + return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1()); + } catch (final Throwable t1){ + return Utils.rgbtoHexValue(0, 0, 0); + } + } + } + + return Utils.rgbtoHexValue(0, 0, 0); + } + + @Override + public void updateTick(final World world, final int x, final int y, final int z, final Random rand) { + //this.mRainbowTick++; + super.updateTick(world, x, y, z, rand); + } + + @Override + public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { + this.mRainbowTick++; + super.randomDisplayTick(world, x, y, z, rand); + } + + @Override + public int tickRate(final World p_149738_1_) { + return 20; + } + } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java index 98da5a40fc..b886299afd 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -24,8 +24,9 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public FluidTank tankEssence = new FluidTank((int) (64000*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)); public FluidTank tankLiquidXp = new FluidTank(64000); private boolean needsUpdate = false; - private int updateTimer = 0; private boolean mConvertToEssence = true; + private int updateTimer = 0; + private long mTickTime = 0; public TileEntityXpConverter() { } @@ -204,11 +205,9 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public void updateEntity() { if (this.isServerSide()){ - - //Utils.LOG_WARNING("Ticking. | mConvertToEssence: "+this.mConvertToEssence); + this.mTickTime++; if (this.needsUpdate) { - if (this.updateTimer == 0) { this.updateTimer = 10; // every 10 ticks it will send an update } else { @@ -241,6 +240,14 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { } } } + else { + } + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.markDirty(); + + if ((this.mTickTime % 20) == 0){ + + } } -- cgit From 9e4dcc750d9aa3c37d278aec7404a9ded134f0b6 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sun, 26 Nov 2017 20:55:02 +1000 Subject: + Added Xp Converter crafting recipe. + Added compressed obsidian. + Added inverted obsidian. + Added crafting & uncrafting recipes for the compressed & inverted obsidian. % Formatting. --- src/Java/gtPlusPlus/core/block/ModBlocks.java | 3 + .../block/general/BlockCompressedObsidian.java | 90 +++++++++++++++ .../core/block/general/BlockTankXpConverter.java | 122 +++++++++++---------- .../core/item/base/itemblock/ItemBlockMeta.java | 44 ++++++++ .../gtPlusPlus/core/recipe/RECIPES_General.java | 43 +++++++- src/Java/gtPlusPlus/core/util/item/ItemUtils.java | 9 +- src/resources/assets/miscutils/lang/en_US.lang | 92 +++++----------- .../assets/miscutils/textures/blocks/SwirlGray.png | Bin 0 -> 270 bytes .../textures/blocks/compressed/obsidian1.png | Bin 0 -> 656 bytes .../textures/blocks/compressed/obsidian2.png | Bin 0 -> 757 bytes .../textures/blocks/compressed/obsidian3.png | Bin 0 -> 856 bytes .../textures/blocks/compressed/obsidian4.png | Bin 0 -> 1022 bytes .../textures/blocks/compressed/obsidian5.png | Bin 0 -> 1245 bytes .../textures/blocks/compressed/obsidian_invert.png | Bin 0 -> 770 bytes 14 files changed, 280 insertions(+), 123 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java create mode 100644 src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java create mode 100644 src/resources/assets/miscutils/textures/blocks/SwirlGray.png create mode 100644 src/resources/assets/miscutils/textures/blocks/compressed/obsidian1.png create mode 100644 src/resources/assets/miscutils/textures/blocks/compressed/obsidian2.png create mode 100644 src/resources/assets/miscutils/textures/blocks/compressed/obsidian3.png create mode 100644 src/resources/assets/miscutils/textures/blocks/compressed/obsidian4.png create mode 100644 src/resources/assets/miscutils/textures/blocks/compressed/obsidian5.png create mode 100644 src/resources/assets/miscutils/textures/blocks/compressed/obsidian_invert.png (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index 992cd7e991..770494c9f0 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -3,6 +3,7 @@ package gtPlusPlus.core.block; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.BlockBaseOre; +import gtPlusPlus.core.block.general.BlockCompressedObsidian; import gtPlusPlus.core.block.general.BlockTankXpConverter; import gtPlusPlus.core.block.general.FirePit; import gtPlusPlus.core.block.general.FluidTankInfinite; @@ -60,6 +61,7 @@ public final class ModBlocks { public static Block blockWitherGuard; public static Block blockXpConverter; + public static Block blockCompressedObsidian; public static void init() { Utils.LOG_INFO("Initializing Blocks."); @@ -91,6 +93,7 @@ public final class ModBlocks { blockModularTable = new Machine_ModularityTable(); blockWitherGuard = new BlockWitherProof(); blockXpConverter = new BlockTankXpConverter(); + blockCompressedObsidian = new BlockCompressedObsidian(); } diff --git a/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java b/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java new file mode 100644 index 0000000000..48ee7709ec --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java @@ -0,0 +1,90 @@ +package gtPlusPlus.core.block.general; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.BlockObsidian; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockCompressedObsidian extends BlockObsidian { + + @SideOnly(Side.CLIENT) + private final IIcon textureArray[] = new IIcon[6]; + + public BlockCompressedObsidian() { + this.setBlockName("blockCompressedObsidian"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockCompressedObsidian"); + } + + @Override + public MapColor getMapColor(final int meta) { + if (meta != 5) { + return MapColor.obsidianColor; + } + else { + return MapColor.sandColor; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iicon) { + this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian1"); + this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian2"); + this.textureArray[2] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian3"); + this.textureArray[3] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian4"); + this.textureArray[4] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian5"); + this.textureArray[5] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian_invert"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int side, final int meta) { + return this.textureArray[meta]; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < 6; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public ArrayList getDrops(final World world, final int x, final int y, final int z, final int metadata, + final int fortune) { + int m = metadata; + if (m == 5) { + m = 1; + } + return super.getDrops(world, x, y, z, m, fortune); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index c2afdfd21f..7e1ab75b84 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -50,7 +50,7 @@ public class BlockTankXpConverter extends BlockContainer { GameRegistry.registerBlock(this, ItemBlockEntityBase.class, "blockTankXpConverter"); LanguageRegistry.addName(this, "Xp Converter"); this.generateRainbowMap(); - if (!this.getTickRandomly()){ + if (!this.getTickRandomly()) { this.setTickRandomly(true); } } @@ -86,44 +86,48 @@ public class BlockTankXpConverter extends BlockContainer { } else { boolean mDidScrewDriver = false; - //Check For Screwdriver + // Check For Screwdriver try { final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); final Item mHandItem = mHandStack.getItem(); - if (((mHandItem instanceof GT_MetaGenerated_Tool_01) && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))){ + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); - if (tile != null){ + if (tile != null) { mDidScrewDriver = true; tile.onScrewdriverRightClick((byte) side, player, x, y, z); } } } - catch (final Throwable t){ + catch (final Throwable t) { mDidScrewDriver = false; } - if (!mDidScrewDriver){ - + if (!mDidScrewDriver) { try { final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); - if (tile != null){ + if (tile != null) { tile.onRightClick((byte) side, player, x, y, z); } } - catch (final Throwable t){} + catch (final Throwable t) { + } final TileEntityXpConverter tank = (TileEntityXpConverter) world.getTileEntity(x, y, z); - if (tank != null){ - if (tank.tankEssence.getFluid() != null){ - PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankEssence.getFluidAmount()+"L of "+tank.tankEssence.getFluid().getLocalizedName()); + if (tank != null) { + if (tank.tankEssence.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankEssence.getFluidAmount() + + "L of " + tank.tankEssence.getFluid().getLocalizedName()); } - if (tank.tankLiquidXp.getFluid() != null){ - PlayerUtils.messagePlayer(player, "This tank contains "+tank.tankLiquidXp.getFluidAmount()+"L of "+tank.tankLiquidXp.getFluid().getLocalizedName()); + if (tank.tankLiquidXp.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankLiquidXp.getFluidAmount() + + "L of " + tank.tankLiquidXp.getFluid().getLocalizedName()); } - if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)){ - PlayerUtils.messagePlayer(player, "This is worth "+EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount())+" levels."); + if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)) { + PlayerUtils.messagePlayer(player, "This is worth " + + EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount()) + " levels."); } } } @@ -152,42 +156,43 @@ public class BlockTankXpConverter extends BlockContainer { } @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { return false; } - private final boolean generateRainbowMap(){ + private final boolean generateRainbowMap() { int id = 0; - this.mRainbowMap.put(id++, new Triplet( 0, 255, 0)); - this.mRainbowMap.put(id++, new Triplet( 51, 255, 0)); - this.mRainbowMap.put(id++, new Triplet(102, 255, 0)); - this.mRainbowMap.put(id++, new Triplet(153, 255, 0)); - this.mRainbowMap.put(id++, new Triplet(204, 255, 0)); - this.mRainbowMap.put(id++, new Triplet(255, 255, 0)); - this.mRainbowMap.put(id++, new Triplet(255, 204, 0)); - this.mRainbowMap.put(id++, new Triplet(255, 153, 0)); - this.mRainbowMap.put(id++, new Triplet(255, 102, 0)); - this.mRainbowMap.put(id++, new Triplet(255, 51, 0)); - this.mRainbowMap.put(id++, new Triplet(255, 0, 0)); - this.mRainbowMap.put(id++, new Triplet(255, 0, 51)); - this.mRainbowMap.put(id++, new Triplet(255, 0, 102)); - this.mRainbowMap.put(id++, new Triplet(255, 0, 153)); - this.mRainbowMap.put(id++, new Triplet(255, 0, 204)); - this.mRainbowMap.put(id++, new Triplet(255, 0, 255)); - this.mRainbowMap.put(id++, new Triplet(204, 0, 255)); - this.mRainbowMap.put(id++, new Triplet(153, 0, 255)); - this.mRainbowMap.put(id++, new Triplet(102, 0, 255)); - this.mRainbowMap.put(id++, new Triplet( 51, 0, 255)); - this.mRainbowMap.put(id++, new Triplet( 0, 0, 255)); - this.mRainbowMap.put(id++, new Triplet( 0, 51, 255)); - this.mRainbowMap.put(id++, new Triplet( 0, 102, 255)); - this.mRainbowMap.put(id++, new Triplet( 0, 153, 255)); - this.mRainbowMap.put(id++, new Triplet( 0, 204, 255)); - this.mRainbowMap.put(id++, new Triplet( 0, 255, 255)); - this.mRainbowMap.put(id++, new Triplet( 0, 255, 204)); - this.mRainbowMap.put(id++, new Triplet( 0, 255, 153)); - this.mRainbowMap.put(id++, new Triplet( 0, 255, 102)); - this.mRainbowMap.put(id++, new Triplet( 0, 255, 51)); + this.mRainbowMap.put(id++, new Triplet(0, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(51, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(102, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(153, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(204, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 255, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 204, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 153, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 102, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 51, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 0)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 51)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 102)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 153)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 204)); + this.mRainbowMap.put(id++, new Triplet(255, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(204, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(153, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(102, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(51, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(0, 0, 255)); + this.mRainbowMap.put(id++, new Triplet(0, 51, 255)); + this.mRainbowMap.put(id++, new Triplet(0, 102, 255)); + this.mRainbowMap.put(id++, new Triplet(0, 153, 255)); + this.mRainbowMap.put(id++, new Triplet(0, 204, 255)); + this.mRainbowMap.put(id++, new Triplet(0, 255, 255)); + this.mRainbowMap.put(id++, new Triplet(0, 255, 204)); + this.mRainbowMap.put(id++, new Triplet(0, 255, 153)); + this.mRainbowMap.put(id++, new Triplet(0, 255, 102)); + this.mRainbowMap.put(id++, new Triplet(0, 255, 51)); this.mRainbowTickMax = this.mRainbowMap.size(); return true; } @@ -198,21 +203,24 @@ public class BlockTankXpConverter extends BlockContainer { } @Override - public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, final int p_149720_4_) { + public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, + final int p_149720_4_) { - if ((this.mRainbowTick < 0) || (this.mRainbowTick > this.mRainbowTickMax)){ + if ((this.mRainbowTick < 0) || (this.mRainbowTick > this.mRainbowTickMax)) { this.mRainbowTick = 0; } - //Utils.LOG_INFO("x: "+this.mRainbowTick); - if (this.mRainbowTick <= this.mRainbowTickMax){ + // Utils.LOG_INFO("x: "+this.mRainbowTick); + if (this.mRainbowTick <= this.mRainbowTickMax) { Triplet mT = this.mRainbowMap.get(this.mRainbowTick); try { return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1()); - } catch (final Throwable t){ + } + catch (final Throwable t) { try { - mT = this.mRainbowMap.get(this.mRainbowTick-1); + mT = this.mRainbowMap.get(this.mRainbowTick - 1); return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1()); - } catch (final Throwable t1){ + } + catch (final Throwable t1) { return Utils.rgbtoHexValue(0, 0, 0); } } @@ -223,12 +231,12 @@ public class BlockTankXpConverter extends BlockContainer { @Override public void updateTick(final World world, final int x, final int y, final int z, final Random rand) { - //this.mRainbowTick++; + // this.mRainbowTick++; super.updateTick(world, x, y, z, rand); } @Override - public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { + public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { this.mRainbowTick++; super.randomDisplayTick(world, x, y, z, rand); } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java new file mode 100644 index 0000000000..9cf3f796df --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java @@ -0,0 +1,44 @@ +package gtPlusPlus.core.item.base.itemblock; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlockWithMetadata; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class ItemBlockMeta extends ItemBlockWithMetadata +{ + private final Block mBlock; + + public ItemBlockMeta(final Block p_i45326_1_) + { + super(p_i45326_1_, p_i45326_1_); + this.mBlock = p_i45326_1_; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + /** + * Gets an icon index based on an item's damage value + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(final int p_77617_1_) + { + return this.mBlock.getIcon(2, p_77617_1_); + } + + /** + * Returns the metadata of the block which this Item (ItemBlock) can place + */ + @Override + public int getMetadata(final int p_77647_1_) + { + return p_77647_1_; + } + + @Override + public String getUnlocalizedName(final ItemStack stack) { + return this.getUnlocalizedName() + "." + stack.getItemDamage(); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index f5f793da77..973a653302 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -1,5 +1,7 @@ package gtPlusPlus.core.recipe; +import static gtPlusPlus.core.util.item.ItemUtils.getSimpleStack; + import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; import gregtech.api.util.GT_ModHandler; @@ -35,6 +37,7 @@ public class RECIPES_General { if (LoadedMods.Gregtech){ RECIPE_BasicCasingIC2 = ItemUtils.getItemStack("IC2:blockMachine", 1); run(); + addCompressedObsidian(); } } @@ -133,10 +136,16 @@ public class RECIPES_General { RecipeUtils.addShapedGregtechRecipe( "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", - "plateTungstenSteel", ItemUtils.getSimpleStack(Items.nether_star), "plateTungstenSteel", + "plateTungstenSteel", getSimpleStack(Items.nether_star), "plateTungstenSteel", "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 32)); + RecipeUtils.addShapedGregtechRecipe( + getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), + ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.nether_star), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), + getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), + ItemUtils.getSimpleStack(ModBlocks.blockXpConverter, 1)); + //Alkalus Coin /*AddGregtechRecipe.addAssemblylineRecipe( ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk), @@ -161,6 +170,38 @@ public class RECIPES_General { } + private static boolean addCompressedObsidian(){ + //Invert Obsidian + RecipeUtils.addShapedGregtechRecipe( + getSimpleStack(Items.redstone), getSimpleStack(Items.glowstone_dust), getSimpleStack(Items.redstone), + getSimpleStack(Items.glowstone_dust), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 1, 1), getSimpleStack(Items.glowstone_dust), + getSimpleStack(Items.redstone), getSimpleStack(Items.glowstone_dust), getSimpleStack(Items.redstone), + ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1)); + + final ItemStack[] mItems = new ItemStack[6]; + mItems[0] = ItemUtils.getSimpleStack(Blocks.obsidian); + for (int r=0;r<5;r++){ + mItems[r+1] = ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, r, 1); + } + + //Compressed Obsidian 1-5 + for (int r=0;r<5;r++){ + + final ItemStack input = mItems[r]; + final ItemStack output = mItems[r+1]; + + RecipeUtils.addShapedGregtechRecipe( + input, input, input, + input, input, input, + input, input, input, + output); + + RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{output}, ItemUtils.getSimpleStack(input, 9)); + + } + return true; + } + } diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index 3680dfb59d..fb20c87bac 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -163,7 +163,7 @@ public class ItemUtils { } @SuppressWarnings("unused") - public static ItemStack simpleMetaStack(final Item item, final int meta, final int itemstackSize){ + public static ItemStack simpleMetaStack(final Item item, final int meta, final int size){ try { if (item == null){ return null; @@ -176,7 +176,7 @@ public class ItemUtils { em = em1; } if (em != null){ - final ItemStack metaStack = new ItemStack(em,itemstackSize,meta); + final ItemStack metaStack = new ItemStack(em,size,meta); return metaStack; } } @@ -187,6 +187,10 @@ public class ItemUtils { } } + public static ItemStack simpleMetaStack(final Block block, final int meta, final int size) { + return simpleMetaStack(Item.getItemFromBlock(block), meta, size); + } + public static ItemStack getCorrectStacktype(final String fqrn, final int stackSize){ final String oreDict = "ore:"; ItemStack temp; @@ -634,4 +638,5 @@ public class ItemUtils { return getItemStackOfAmountFromOreDictNoBroken(oredictName, amount); } + } diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index c2d177de48..d81815e0d3 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -1,3 +1,4 @@ +//Creative Tabs itemGroup.MiscUtilBlockTab=[GT++] Blocks itemGroup.MiscUtilMiscTab=[GT++] Items itemGroup.MiscUtilCombatTab=[GT++] Combat @@ -5,77 +6,33 @@ itemGroup.MiscUtilToolsTab=[GT++] Tools itemGroup.MiscUtilMachineTab=[GT++] Machines itemGroup.MiscUtilOtherTab=[GT++] Items II -item.itemPLACEHOLDER_Circuit.name=Quark Manipulator (UV) - -item.itemPlateEnrichedSoularium.name=Enriched Soularium Plate - -item.itemHeliumBlob.name=Mysterious Hydrogen Substance +//Debug +item.AAA_Broken.name=[Non-existent Item] Report This Recipe On Github, Please. +item.itemBedLocator_Base.name=Bed Locator [NBT Test] +item.itemBaseItemWithCharge.name=Base Chargeable Item +item.miscutils_itemDebugShapeSpawner.name=[Debug] Shapes +//Alternative Materials item.itemPlateBatteryAlloy.name=Plate of Battery Alloy item.itemIngotBatteryAlloy.name=Ingot of Battery Alloy - item.itemStickyRubber.name=Gumlet of Sticky Rubber +//Unused Fuel rods item.itemFuelRod_Empty.name=Empty Fuel Rod item.itemFuelRod_Thorium.name=Thorium Fuel Rod item.itemFuelRod_Uranium.name=Uranium Fuel Rod item.itemFuelRod_Plutonium.name=Plutonium Fuel Rod - -item.itemBedLocator_Base.name=Bed Locator [NBT Test] -item.itemBaseItemWithCharge.name=Base Chargeable Item - -item.miscutils_itemDebugShapeSpawner.name=[Debug] Shapes - -tile.fluidJackDaniels.name=Jack Daniels -tile.blockGriefSaver.name=Anti-Griefer [WIP] -tile.helium_collector.name=Helium Collector -tile.blockNuclearFueledHeliumGenerator.name=Nuclear Fueled Helium Generator [NFHG] -tile.blockMachineCharger.name=Charging Machine -container.Charger=Charging Machine -container.NHG=Nuclear Fueled Helium Generator -container.helium_collector.name=Helium Collector -tile.blockStaballoy.name=Block of Staballoy -tile.blockBloodSteel.name=Block of Blood Steel - - +//Tile Entities tile.blockToolBuilder.name=GregTech Tool Constructor + +//Tools item.itemBufferCore.name=Buffer Core item.itemStaballoyPickaxe.name=Tunnel Digger item.itemStaballoyAxe.name=Tree Feller item.itemSandstoneHammer.name=Cobblestone Breaker - -item.bucket.fluid.grc.jackDanielsWhiskey0.name=Jack Daniels (0) -item.bucket.fluid.grc.jackDanielsWhiskey1.name=Jack Daniels (1) -item.bucket.fluid.grc.jackDanielsWhiskey2.name=Jack Daniels (2) -item.bucket.fluid.grc.jackDanielsWhiskey3.name=Jack Daniels (3) -item.bucket.fluid.grc.jackDanielsWhiskey4.name=Jack Daniels (4) -fluid.grc.jackDanielsWhiskey=Jack Daniels -fluid.grc.jackDanielsWhiskey0=Jack Daniels (0) -fluid.grc.jackDanielsWhiskey1=Jack Daniels (1) -fluid.grc.jackDanielsWhiskey2=Jack Daniels (2) -fluid.grc.jackDanielsWhiskey3=Jack Daniels (3) -fluid.grc.jackDanielsWhiskey4=Jack Daniels (4) -fluid.fluidJackDaniels=Jack Daniels -fluid.grc.jackDanielsWhiskey0.Modifier=Jack Daniels (0) -fluid.grc.jackDanielsWhiskey1.Modifier=Jack Daniels (1) -fluid.grc.jackDanielsWhiskey2.Modifier=Jack Daniels (2) -fluid.grc.jackDanielsWhiskey3.Modifier=Jack Daniels (3) -fluid.grc.jackDanielsWhiskey4.Modifier=Jack Daniels (4) -tile.fluidBlockJackDaniels.name=Jack Daniels -tile.fluid.grc.jackDanielsWhiskey0.name=Jack Daniels (0) -tile.fluid.grc.jackDanielsWhiskey1.name=Jack Daniels (1) -tile.fluid.grc.jackDanielsWhiskey2.name=Jack Daniels (2) -tile.fluid.grc.jackDanielsWhiskey3.name=Jack Daniels (3) -tile.fluid.grc.jackDanielsWhiskey4.name=Jack Daniels (4) -fluid.psc_JD.ferment.2=Fermenting Jack Daniels -fluid.psc_JD.dmature=D Matured Jack Daniels -fluid.psc_JD.mature=Jack Daniels -fluid.psc_JD.distill=Jack Daniels Wash -fluid.psc_JD.name=Jack Daniels -fluid.psc_JD=Jack Daniels - +//Thermal Foundation Stuff item.MiscUtils.bucket.bucketPyrotheum.name=Blazing Pyrotheum Bucket item.MiscUtils.bucket.bucketCryotheum.name=Gelid Cryotheum Bucket item.MiscUtils.bucket.bucketEnder.name=Resonant Ender Bucket @@ -85,11 +42,9 @@ item.MiscUtils.material.rodBlizz.name=Blizz Rod item.MiscUtils.material.dustBlizz.name=Blizz Powder tile.MiscUtils.fluid.pyrotheum.name=Blazing Pyrotheum tile.MiscUtils.fluid.cryotheum.name=Gelid Cryotheum - -tile.miscutils.fluid.cryotheum.name=Gelid Cryotheum -tile.miscutils.fluid.pyrotheum.name=Blazing Pyrotheum tile.miscutils.fluid.ender.name=Resonant Ender +//Forestry Stuff item.frameAccelerated.name=Accelerated Frame item.frameVoid.name=Void Frame item.frameMutagenic.name=Mutagenic Frame @@ -100,22 +55,33 @@ item.frameSoul.name=Soul Frame item.frameHealing.name=Healing Frame item.frameNova.name=Nova Frame +//IC2 stuff item.itemEnergeticRotorBlade.name=Energetic Alloy Rotor Blade item.itemTungstenSteelRotorBlade.name=TungstenSteel Rotor Blade item.itemVibrantRotorBlade.name=Vibrant Alloy Rotor Blade item.itemIridiumRotorBlade.name=Iridium Rotor Blade - item.itemEnergeticShaft.name=Energetic Alloy Shaft item.itemTungstenSteelShaft.name=TungstenSteel Shaft item.itemVibrantShaft.name=Vibrant Alloy Shaft item.itemIridiumShaft.name=Iridium Shaft - item.itemMagnaliumRotorBlade.name=Magnalium Rotor Blade item.itemUltimetRotorBlade.name=Ultimet Blade item.itemMagnaliumShaft.name=Magnalium Shaft item.itemUltimetShaft.name=Ultimet Shaft -item.itemHotIngotRaisinBread.name= Hot Loaf of Raisin Bread -item.AAA_Broken.name=[Non-existent Item] Report This Recipe On Github, Please. + +//Misc Items +item.itemPLACEHOLDER_Circuit.name=Quark Manipulator (UV) +item.itemPlateEnrichedSoularium.name=Enriched Soularium Plate +item.itemHeliumBlob.name=Mysterious Hydrogen Substance item.itemAlkalusDisk.name=Alkalus Disk -item.itemIngotRaisinBread.name=§5ImQ009's §fRaisin Bread \ No newline at end of file +item.itemHotIngotRaisinBread.name= Hot Loaf of Raisin Bread +item.itemIngotRaisinBread.name=§5ImQ009's §fRaisin Bread + +//Misc Blocks +tile.blockCompressedObsidian.0.name=Compressed Obsidian (9) +tile.blockCompressedObsidian.1.name=Compressed Obsidian (81) +tile.blockCompressedObsidian.2.name=Compressed Obsidian (729) +tile.blockCompressedObsidian.3.name=Compressed Obsidian (6561) +tile.blockCompressedObsidian.4.name=Compressed Obsidian (59049) +tile.blockCompressedObsidian.5.name=Inverted Obsidian \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/blocks/SwirlGray.png b/src/resources/assets/miscutils/textures/blocks/SwirlGray.png new file mode 100644 index 0000000000..337d5fd1bc Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/SwirlGray.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/compressed/obsidian1.png b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian1.png new file mode 100644 index 0000000000..0970b27745 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian1.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/compressed/obsidian2.png b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian2.png new file mode 100644 index 0000000000..6cf79c75c4 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian2.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/compressed/obsidian3.png b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian3.png new file mode 100644 index 0000000000..1241b24fad Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian3.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/compressed/obsidian4.png b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian4.png new file mode 100644 index 0000000000..3d07d55d0c Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian4.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/compressed/obsidian5.png b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian5.png new file mode 100644 index 0000000000..5f83804605 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian5.png differ diff --git a/src/resources/assets/miscutils/textures/blocks/compressed/obsidian_invert.png b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian_invert.png new file mode 100644 index 0000000000..8c55fdddd3 Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/compressed/obsidian_invert.png differ -- cgit From cef36da8db2cf886f0720dd656eac736cba15dfc Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sun, 26 Nov 2017 22:15:59 +1000 Subject: + Added Rope & Net block. + Added English localization for the Staballoy Construct. % Made the Xp Converter give of light as it cycles colours. % Formatting. --- src/Java/gtPlusPlus/core/block/ModBlocks.java | 3 ++ .../block/general/BlockCompressedObsidian.java | 3 ++ .../gtPlusPlus/core/block/general/BlockNet.java | 35 ++++++++++++++++++ .../core/block/general/BlockTankXpConverter.java | 40 +++++++++++++++++++-- src/Java/gtPlusPlus/core/item/ModItems.java | 9 ++--- src/resources/assets/miscutils/lang/en_US.lang | 3 ++ .../assets/miscutils/textures/blocks/net.png | Bin 0 -> 350 bytes .../assets/miscutils/textures/items/itemRope.png | Bin 0 -> 316 bytes 8 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/block/general/BlockNet.java create mode 100644 src/resources/assets/miscutils/textures/blocks/net.png create mode 100644 src/resources/assets/miscutils/textures/items/itemRope.png (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index 770494c9f0..81d3a84dc9 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -4,6 +4,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.BlockBaseOre; import gtPlusPlus.core.block.general.BlockCompressedObsidian; +import gtPlusPlus.core.block.general.BlockNet; import gtPlusPlus.core.block.general.BlockTankXpConverter; import gtPlusPlus.core.block.general.FirePit; import gtPlusPlus.core.block.general.FluidTankInfinite; @@ -62,6 +63,7 @@ public final class ModBlocks { public static Block blockWitherGuard; public static Block blockXpConverter; public static Block blockCompressedObsidian; + public static Block blockNet; public static void init() { Utils.LOG_INFO("Initializing Blocks."); @@ -94,6 +96,7 @@ public final class ModBlocks { blockWitherGuard = new BlockWitherProof(); blockXpConverter = new BlockTankXpConverter(); blockCompressedObsidian = new BlockCompressedObsidian(); + blockNet = new BlockNet(); } diff --git a/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java b/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java index 48ee7709ec..853abe3edf 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java @@ -26,6 +26,9 @@ public class BlockCompressedObsidian extends BlockObsidian { public BlockCompressedObsidian() { this.setBlockName("blockCompressedObsidian"); + this.setHardness(50.0F); + this.setResistance(2000.0F); + this.setStepSound(soundTypePiston); this.setCreativeTab(AddToCreativeTab.tabMachines); GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockCompressedObsidian"); } diff --git a/src/Java/gtPlusPlus/core/block/general/BlockNet.java b/src/Java/gtPlusPlus/core/block/general/BlockNet.java new file mode 100644 index 0000000000..26871662b2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/BlockNet.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.block.general; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.BlockWeb; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; + +public class BlockNet extends BlockWeb{ + + public BlockNet(){ + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setLightOpacity(1); + this.setHardness(4.0F); + this.setBlockName("blockNet"); + GameRegistry.registerBlock(this, "blockNet"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "net"); + } + + @Override + public Item getItemDropped(final int p_149650_1_, final Random p_149650_2_, final int p_149650_3_){ + return ModItems.itemRope; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index 7e1ab75b84..ea55a9177d 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -119,11 +119,11 @@ public class BlockTankXpConverter extends BlockContainer { if (tank != null) { if (tank.tankEssence.getFluid() != null) { PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankEssence.getFluidAmount() - + "L of " + tank.tankEssence.getFluid().getLocalizedName()); + + "L of " + tank.tankEssence.getFluid().getLocalizedName()); } if (tank.tankLiquidXp.getFluid() != null) { PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankLiquidXp.getFluidAmount() - + "L of " + tank.tankLiquidXp.getFluid().getLocalizedName()); + + "L of " + tank.tankLiquidXp.getFluid().getLocalizedName()); } if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)) { PlayerUtils.messagePlayer(player, "This is worth " @@ -209,7 +209,7 @@ public class BlockTankXpConverter extends BlockContainer { if ((this.mRainbowTick < 0) || (this.mRainbowTick > this.mRainbowTickMax)) { this.mRainbowTick = 0; } - // Utils.LOG_INFO("x: "+this.mRainbowTick); + //Utils.LOG_INFO("x: "+this.mRainbowTick); if (this.mRainbowTick <= this.mRainbowTickMax) { Triplet mT = this.mRainbowMap.get(this.mRainbowTick); try { @@ -246,4 +246,38 @@ public class BlockTankXpConverter extends BlockContainer { return 20; } + @Override + public int getLightValue() { + final int mTicker = this.mRainbowTick; + if ((mTicker == 0) || (mTicker == 17)){ + return 1; + } + else if ((mTicker == 1) || (mTicker == 16)){ + return 2; + } + else if ((mTicker == 2) || (mTicker == 15)){ + return 3; + } + else if ((mTicker == 3) || (mTicker == 14)){ + return 4; + } + else if ((mTicker == 4) || (mTicker == 13)){ + return 6; + } + else if ((mTicker == 5) || (mTicker == 12)){ + return 8; + } + else if ((mTicker == 6) || (mTicker == 11)){ + return 10; + } + else if ((mTicker == 7) || (mTicker == 10)){ + return 12; + } + else if ((mTicker == 8) || (mTicker == 9)){ + return 14; + } + return 0; + + } + } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index bd43da11fa..103639074f 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -268,6 +268,8 @@ public final class ModItems { public static Item itemGrindleTablet; + public static Item itemRope; + public static final void init(){ //Default item used when recipes fail, handy for debugging. @@ -290,20 +292,19 @@ public final class ModItems { GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStack(CORE.MODID+":itemStickyRubber", 1)); - - - //Register Hydrogen Blobs first, so we can replace old helium blobs. itemCoalCoke = new BaseItemBurnable("itemCoalCoke", "Coking Coal", tabMisc, 64, 0, "Used for metallurgy.", "fuelCoke", 3200, 0).setTextureName(CORE.MODID + ":itemCoalCoke"); //Register Hydrogen Blobs first, so we can replace old helium blobs. itemHydrogenBlob = new CoreItem("itemHydrogenBlob", "Mysterious Hydrogen Blob", tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); - //GT_OreDictUnificator.registerOre("dustHydrogen", new ItemStack(ModItems.itemHydrogenBlob)); //Register Old Helium Blob, this will be replaced when held by a player. itemHeliumBlob = new CoreItem("itemHeliumBlob", tabMisc, ItemUtils.getSimpleStack(itemHydrogenBlob)).setTextureName(CORE.MODID + ":itemHydrogenBlob"); //Register this neato device, for making some fires. itemBasicFireMaker = new ItemBasicFirestarter(); + //Register Rope + itemRope = new CoreItem("itemRope", "Rope", tabMisc); + //Make some backpacks //Primary colours backpack_Red = new BaseItemBackpack("backpackRed", Utils.rgbtoHexValue(200, 0, 0)); diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index d81815e0d3..c10f904056 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -23,6 +23,9 @@ item.itemFuelRod_Thorium.name=Thorium Fuel Rod item.itemFuelRod_Uranium.name=Uranium Fuel Rod item.itemFuelRod_Plutonium.name=Plutonium Fuel Rod +//Entities +entity.miscutils.constructStaballoy.name=Staballoy Construct + //Tile Entities tile.blockToolBuilder.name=GregTech Tool Constructor diff --git a/src/resources/assets/miscutils/textures/blocks/net.png b/src/resources/assets/miscutils/textures/blocks/net.png new file mode 100644 index 0000000000..e885ed12db Binary files /dev/null and b/src/resources/assets/miscutils/textures/blocks/net.png differ diff --git a/src/resources/assets/miscutils/textures/items/itemRope.png b/src/resources/assets/miscutils/textures/items/itemRope.png new file mode 100644 index 0000000000..061938234d Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemRope.png differ -- cgit From 9d57f7f2f399689f5d39e0a130f363e5f5aa6877 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 27 Nov 2017 00:34:03 +1000 Subject: + Added plant fibre to craft ropes with. + Added recipes for Plant Fibre, Rope and Nets. --- src/Java/gtPlusPlus/core/item/ModItems.java | 2 ++ .../gtPlusPlus/core/recipe/RECIPES_General.java | 26 +++++++++++++++++++++ src/resources/assets/miscutils/lang/en_US.lang | 11 +++++---- .../assets/miscutils/textures/items/itemFiber.png | Bin 0 -> 455 bytes 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 src/resources/assets/miscutils/textures/items/itemFiber.png (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 103639074f..5afd82b7d4 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -269,6 +269,7 @@ public final class ModItems { public static Item itemGrindleTablet; public static Item itemRope; + public static Item itemFiber; public static final void init(){ @@ -303,6 +304,7 @@ public final class ModItems { itemBasicFireMaker = new ItemBasicFirestarter(); //Register Rope + itemFiber = new CoreItem("itemFiber", "Plant Fiber", tabMisc); itemRope = new CoreItem("itemRope", "Rope", tabMisc); //Make some backpacks diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 973a653302..180294c597 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -8,6 +8,7 @@ import gregtech.api.util.GT_ModHandler; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; @@ -168,6 +169,31 @@ public class RECIPES_General { 30*20*60, 100000);*/ + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDictNoBroken(CI.craftingToolKnife, 1), ItemUtils.getSimpleStack(Blocks.reeds)}, + ItemUtils.getSimpleStack(ModItems.itemFiber, 16) + ); + + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDictNoBroken(CI.craftingToolKnife, 1), ItemUtils.getSimpleStack(Blocks.sapling)}, + ItemUtils.getSimpleStack(ModItems.itemFiber, 32) + ); + + RecipeUtils.recipeBuilder( + null, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), null, + ItemUtils.getSimpleStack(ModItems.itemFiber, 1), CI.craftingToolKnife, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), + null, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), null, + ItemUtils.getSimpleStack(ModItems.itemRope, 3)); + + RecipeUtils.recipeBuilder( + ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), + ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), + null, null, null, + ItemUtils.getSimpleStack(ModBlocks.blockNet, 2)); + + } private static boolean addCompressedObsidian(){ diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index c10f904056..962cce198b 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -83,8 +83,9 @@ item.itemIngotRaisinBread.name=§5ImQ009's §fRaisin Bread //Misc Blocks tile.blockCompressedObsidian.0.name=Compressed Obsidian (9) -tile.blockCompressedObsidian.1.name=Compressed Obsidian (81) -tile.blockCompressedObsidian.2.name=Compressed Obsidian (729) -tile.blockCompressedObsidian.3.name=Compressed Obsidian (6561) -tile.blockCompressedObsidian.4.name=Compressed Obsidian (59049) -tile.blockCompressedObsidian.5.name=Inverted Obsidian \ No newline at end of file +tile.blockCompressedObsidian.1.name=Double Compressed Obsidian (81) +tile.blockCompressedObsidian.2.name=Triple Compressed Obsidian (729) +tile.blockCompressedObsidian.3.name=Quadruple Compressed Obsidian (6561) +tile.blockCompressedObsidian.4.name=Quintuple Compressed Obsidian (59049) +tile.blockCompressedObsidian.5.name=Inverted Obsidian +tile.blockNet.name=Net \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/items/itemFiber.png b/src/resources/assets/miscutils/textures/items/itemFiber.png new file mode 100644 index 0000000000..c2eb959c6c Binary files /dev/null and b/src/resources/assets/miscutils/textures/items/itemFiber.png differ -- cgit From 5fb4cdd13a452737f2bb62d84779de5067791a9b Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 27 Nov 2017 00:53:16 +1000 Subject: - Removed Mekanism changes if RedTech is loaded. --- .../core/handler/COMPAT_IntermodStaging.java | 8 +- src/Java/gtPlusPlus/core/lib/LoadedMods.java | 8 +- .../gtPlusPlus/preloader/Preloader_GT_OreDict.java | 54 +++--- .../gtPlusPlus/xmod/mekanism/HANDLER_Mekanism.java | 190 ++++++++++----------- 4 files changed, 132 insertions(+), 128 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index 1bf729cdc6..b534cd11cd 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -6,7 +6,6 @@ import gtPlusPlus.xmod.forestry.HANDLER_FR; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.growthcraft.HANDLER_GC; import gtPlusPlus.xmod.ic2.HANDLER_IC2; -import gtPlusPlus.xmod.mekanism.HANDLER_Mekanism; import gtPlusPlus.xmod.thaumcraft.common.HANDLER_Thaumcraft; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; @@ -20,9 +19,8 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.preInit(); HANDLER_Computronics.preInit(); HANDLER_BiomesOPlenty.preInit(); - HANDLER_Mekanism.preInit(); + //HANDLER_Mekanism.preInit(); HANDLER_Thaumcraft.preInit(); - } public static void init(){ @@ -33,7 +31,7 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.init(); HANDLER_Computronics.init(); HANDLER_BiomesOPlenty.init(); - HANDLER_Mekanism.init(); + //HANDLER_Mekanism.init(); HANDLER_Thaumcraft.init(); } @@ -45,7 +43,7 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.postInit(); HANDLER_Computronics.postInit(); HANDLER_BiomesOPlenty.postInit(); - HANDLER_Mekanism.postInit(); + //HANDLER_Mekanism.postInit(); HANDLER_Thaumcraft.postInit(); } diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index d97b41641d..dda50a0d84 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -45,6 +45,7 @@ public class LoadedMods { public static boolean PamsHarvestcraft = false; public static boolean GalacticraftCore = false; public static boolean Mekanism = false; + public static boolean RedTech = false; @@ -242,8 +243,13 @@ public class LoadedMods { Utils.LOG_INFO("Components disabled for: Computronics - This feature will enable itself if you remove Computronics."); totalMods++; } + if (Loader.isModLoaded("GTRedtech") == true){ + RedTech = true; + Utils.LOG_INFO("Components enabled for: GTRedtech"); + totalMods++; + } else { - Utils.LOG_INFO("Components enabled for: Computronics - This feature will disable itself if you add Computronics."); + Utils.LOG_INFO("Components enabled for: Computronics - This feature will disable itself if you add Computronics."); } Utils.LOG_INFO("Content found for "+totalMods+" mods"); diff --git a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java index 26cefe7254..018e0bee82 100644 --- a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java +++ b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java @@ -10,48 +10,48 @@ import net.minecraft.item.ItemStack; public class Preloader_GT_OreDict { - public static boolean shouldPreventRegistration(String string, ItemStack bannedItem) { + public static boolean shouldPreventRegistration(final String string, final ItemStack bannedItem) { try { if (CORE_Preloader.enableOldGTcircuits){ - if (bannedItem != null && ItemUtils.getModId(bannedItem).toLowerCase().equals("gregtech")){ - int damageValue = bannedItem.getItemDamage() - 32000; + if ((bannedItem != null) && ItemUtils.getModId(bannedItem).toLowerCase().equals("gregtech")){ + final int damageValue = bannedItem.getItemDamage() - 32000; if (bannedItem.getItem() instanceof GT_MetaGenerated_Item_01) { // 700-720 - if (damageValue >= 700 && damageValue <= 720) { + if ((damageValue >= 700) && (damageValue <= 720)) { return true; } } else { try { if (Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03") != null) { // 6/11/12/14/16/20/30-57/69-73/79-96 - Class MetaItem03 = Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03"); + final Class MetaItem03 = Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03"); if (isInstanceOf(MetaItem03, bannedItem.getItem())) { - if (damageValue == 6 || damageValue == 7 || damageValue == 11 || damageValue == 12 || damageValue == 14 - || damageValue == 16 || damageValue == 20 || damageValue == 21 || damageValue == 22) { + if ((damageValue == 6) || (damageValue == 7) || (damageValue == 11) || (damageValue == 12) || (damageValue == 14) + || (damageValue == 16) || (damageValue == 20) || (damageValue == 21) || (damageValue == 22)) { return true; } - else if (damageValue >= 30 && damageValue <= 57) { + else if ((damageValue >= 30) && (damageValue <= 57)) { return true; } - else if (damageValue >= 69 && damageValue <= 73) { + else if ((damageValue >= 69) && (damageValue <= 73)) { return true; } - else if (damageValue >= 78 && damageValue <= 96) { + else if ((damageValue >= 78) && (damageValue <= 96)) { return true; } } } } - catch (ClassNotFoundException e) { + catch (final ClassNotFoundException e) { } } } } - + //Mekanism Support - Let's not make Mek Osmium useful in GT anymore. - if (bannedItem != null && (ItemUtils.getModId(bannedItem).toLowerCase().equals("mekanism") || LoadedMods.Mekanism)){ + if ((((bannedItem != null) && (ItemUtils.getModId(bannedItem).toLowerCase().equals("mekanism"))) || (LoadedMods.Mekanism)) && !LoadedMods.RedTech){ //Circuits if (Class.forName("mekanism.common.item.ItemControlCircuit") != null) { - Class MekCircuit = Class.forName("mekanism.common.item.ItemControlCircuit"); + final Class MekCircuit = Class.forName("mekanism.common.item.ItemControlCircuit"); if (isInstanceOf(MekCircuit, bannedItem.getItem())) { for (int r=0;r<4;r++){ if (bannedItem.getItemDamage() == r){ @@ -63,7 +63,7 @@ public class Preloader_GT_OreDict { } //Ingots if (Class.forName("mekanism.common.item.ItemIngot") != null) { - Class MekIngot = Class.forName("mekanism.common.item.ItemIngot"); + final Class MekIngot = Class.forName("mekanism.common.item.ItemIngot"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 1){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing "+bannedItem.getDisplayName()+" from the OreDictionary to balance Mekanism."); @@ -73,7 +73,7 @@ public class Preloader_GT_OreDict { } //Dirty Dust if (Class.forName("mekanism.common.item.ItemDirtyDust") != null) { - Class MekIngot = Class.forName("mekanism.common.item.ItemDirtyDust"); + final Class MekIngot = Class.forName("mekanism.common.item.ItemDirtyDust"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing "+bannedItem.getDisplayName()+" from the OreDictionary to balance Mekanism."); @@ -83,27 +83,27 @@ public class Preloader_GT_OreDict { } //Dust if (Class.forName("mekanism.common.item.ItemDust") != null) { - Class MekIngot = Class.forName("mekanism.common.item.ItemDust"); + final Class MekIngot = Class.forName("mekanism.common.item.ItemDust"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing "+bannedItem.getDisplayName()+" from the OreDictionary to balance Mekanism."); return true; } } - } + } //Crystal if (Class.forName("mekanism.common.item.ItemCrystal") != null) { - Class MekIngot = Class.forName("mekanism.common.item.ItemCrystal"); + final Class MekIngot = Class.forName("mekanism.common.item.ItemCrystal"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing "+bannedItem.getDisplayName()+" from the OreDictionary to balance Mekanism."); return true; } } - } + } //Shard if (Class.forName("mekanism.common.item.ItemShard") != null) { - Class MekIngot = Class.forName("mekanism.common.item.ItemShard"); + final Class MekIngot = Class.forName("mekanism.common.item.ItemShard"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing "+bannedItem.getDisplayName()+" from the OreDictionary to balance Mekanism."); @@ -113,18 +113,18 @@ public class Preloader_GT_OreDict { } //Clump if (Class.forName("mekanism.common.item.ItemClump") != null) { - Class MekIngot = Class.forName("mekanism.common.item.ItemClump"); + final Class MekIngot = Class.forName("mekanism.common.item.ItemClump"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing "+bannedItem.getDisplayName()+" from the OreDictionary to balance Mekanism."); return true; } } - } + } //Ores if (Class.forName("mekanism.common.item.ItemBlockOre") != null) { - Class MekOre = Class.forName("mekanism.common.item.ItemBlockOre"); - if (isInstanceOf(MekOre, bannedItem.getItem()) || bannedItem == ItemUtils.simpleMetaStack("Mekanism:OreBlock", 0, 1)) { + final Class MekOre = Class.forName("mekanism.common.item.ItemBlockOre"); + if (isInstanceOf(MekOre, bannedItem.getItem()) || (bannedItem == ItemUtils.simpleMetaStack("Mekanism:OreBlock", 0, 1))) { if (bannedItem.getItemDamage() == 0){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing "+bannedItem.getDisplayName()+" from the OreDictionary to balance Mekanism."); return true; @@ -133,7 +133,7 @@ public class Preloader_GT_OreDict { } } - } catch (Throwable e) { + } catch (final Throwable e) { FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "A mod tried to register an invalid item with the OreDictonary."); if (bannedItem != null){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Please report this issue to the authors of "+ItemUtils.getModId(bannedItem)); @@ -144,7 +144,7 @@ public class Preloader_GT_OreDict { } // Simplification of Life. - private static boolean isInstanceOf(Class clazz, Object obj) { + private static boolean isInstanceOf(final Class clazz, final Object obj) { return clazz.isInstance(obj); } diff --git a/src/Java/gtPlusPlus/xmod/mekanism/HANDLER_Mekanism.java b/src/Java/gtPlusPlus/xmod/mekanism/HANDLER_Mekanism.java index 401bd19e83..ce4ec38a09 100644 --- a/src/Java/gtPlusPlus/xmod/mekanism/HANDLER_Mekanism.java +++ b/src/Java/gtPlusPlus/xmod/mekanism/HANDLER_Mekanism.java @@ -27,180 +27,180 @@ public class HANDLER_Mekanism { } public static void postInit(){ - if (LoadedMods.Mekanism){ - + if (LoadedMods.Mekanism && !LoadedMods.RedTech){ + Utils.LOG_INFO("Performing GT recipe balance for Mek. now that it's Osmium is useless."); - + //Steel Casing - ItemStack tSteelCasing = ItemUtils.simpleMetaStack("Mekanism:BasicBlock:8", 8, 1); + final ItemStack tSteelCasing = ItemUtils.simpleMetaStack("Mekanism:BasicBlock:8", 8, 1); addNewRecipe( - "plateSteel", "blockGlass", "plateSteel", - "blockGlass", "plateStainlessSteel", "blockGlass", + "plateSteel", "blockGlass", "plateSteel", + "blockGlass", "plateStainlessSteel", "blockGlass", "plateSteel", "blockGlass", "plateSteel", tSteelCasing); //Energy Storage - ItemStack tAdvancedEnergyCube = ItemUtils.simpleMetaStack("Mekanism:EnergyCube", 0, 1).copy(); + final ItemStack tAdvancedEnergyCube = ItemUtils.simpleMetaStack("Mekanism:EnergyCube", 0, 1).copy(); NBTUtils.setString(tAdvancedEnergyCube, "tier", "Advanced"); - ItemStack tBasicEnergyCube = ItemUtils.simpleMetaStack("Mekanism:EnergyCube", 0, 1).copy(); + final ItemStack tBasicEnergyCube = ItemUtils.simpleMetaStack("Mekanism:EnergyCube", 0, 1).copy(); NBTUtils.setString(tBasicEnergyCube, "tier", "Basic"); //Gas tanks - ItemStack tBasicGasTank = ItemUtils.simpleMetaStack("Mekanism:GasTank", 0, 1).copy(); + final ItemStack tBasicGasTank = ItemUtils.simpleMetaStack("Mekanism:GasTank", 0, 1).copy(); NBTUtils.setInteger(tBasicGasTank, "tier", 0); - ItemStack tAdvancedGasTank = ItemUtils.simpleMetaStack("Mekanism:GasTank", 0, 1).copy(); + final ItemStack tAdvancedGasTank = ItemUtils.simpleMetaStack("Mekanism:GasTank", 0, 1).copy(); NBTUtils.setInteger(tAdvancedGasTank, "tier", 1); - ItemStack tEliteGasTank = ItemUtils.simpleMetaStack("Mekanism:GasTank", 0, 1).copy(); + final ItemStack tEliteGasTank = ItemUtils.simpleMetaStack("Mekanism:GasTank", 0, 1).copy(); NBTUtils.setInteger(tEliteGasTank, "tier", 2); - ItemStack tMasterGasTank = ItemUtils.simpleMetaStack("Mekanism:GasTank", 0, 1).copy(); + final ItemStack tMasterGasTank = ItemUtils.simpleMetaStack("Mekanism:GasTank", 0, 1).copy(); NBTUtils.setInteger(tMasterGasTank, "tier", 3); //Machines that use Osmium - ItemStack tMachineBlock_Basic = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:5", 5, 1); - ItemStack tMachineBlock = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:6", 6, 1); + final ItemStack tMachineBlock_Basic = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:5", 5, 1); + final ItemStack tMachineBlock = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:6", 6, 1); //Smelting - ItemStack tMachineBlock_0_Basic = tMachineBlock_Basic.copy(); + final ItemStack tMachineBlock_0_Basic = tMachineBlock_Basic.copy(); NBTUtils.setInteger(tMachineBlock_0_Basic, "recipeType", 0); - ItemStack tMachineBlock_0 = tMachineBlock.copy(); + final ItemStack tMachineBlock_0 = tMachineBlock.copy(); NBTUtils.setInteger(tMachineBlock_0, "recipeType", 0); //Enriching - ItemStack tMachineBlock_1_Basic = tMachineBlock_Basic.copy(); + final ItemStack tMachineBlock_1_Basic = tMachineBlock_Basic.copy(); NBTUtils.setInteger(tMachineBlock_1_Basic, "recipeType", 1); - ItemStack tMachineBlock_1 = tMachineBlock.copy(); + final ItemStack tMachineBlock_1 = tMachineBlock.copy(); NBTUtils.setInteger(tMachineBlock_1, "recipeType", 1); //Crushing - ItemStack tMachineBlock_2_Basic = tMachineBlock_Basic.copy(); + final ItemStack tMachineBlock_2_Basic = tMachineBlock_Basic.copy(); NBTUtils.setInteger(tMachineBlock_2_Basic, "recipeType", 2); - ItemStack tMachineBlock_2 = tMachineBlock.copy(); + final ItemStack tMachineBlock_2 = tMachineBlock.copy(); NBTUtils.setInteger(tMachineBlock_2, "recipeType", 2); //Compressing - ItemStack tMachineBlock_3_Basic = tMachineBlock_Basic.copy(); + final ItemStack tMachineBlock_3_Basic = tMachineBlock_Basic.copy(); NBTUtils.setInteger(tMachineBlock_3_Basic, "recipeType", 3); - ItemStack tMachineBlock_3 = tMachineBlock.copy(); + final ItemStack tMachineBlock_3 = tMachineBlock.copy(); NBTUtils.setInteger(tMachineBlock_3, "recipeType", 3); //Combining - ItemStack tMachineBlock_4_Basic = tMachineBlock_Basic.copy(); + final ItemStack tMachineBlock_4_Basic = tMachineBlock_Basic.copy(); NBTUtils.setInteger(tMachineBlock_4_Basic, "recipeType", 4); - ItemStack tMachineBlock_4 = tMachineBlock.copy(); + final ItemStack tMachineBlock_4 = tMachineBlock.copy(); NBTUtils.setInteger(tMachineBlock_4, "recipeType", 4); //Purifying - ItemStack tMachineBlock_5_Basic = tMachineBlock_Basic.copy(); + final ItemStack tMachineBlock_5_Basic = tMachineBlock_Basic.copy(); NBTUtils.setInteger(tMachineBlock_5_Basic, "recipeType", 5); - ItemStack tMachineBlock_5 = tMachineBlock.copy(); + final ItemStack tMachineBlock_5 = tMachineBlock.copy(); NBTUtils.setInteger(tMachineBlock_5, "recipeType", 5); //Injecting - ItemStack tMachineBlock_6_Basic = tMachineBlock_Basic.copy(); + final ItemStack tMachineBlock_6_Basic = tMachineBlock_Basic.copy(); NBTUtils.setInteger(tMachineBlock_6_Basic, "recipeType", 6); - ItemStack tMachineBlock_6 = tMachineBlock.copy(); + final ItemStack tMachineBlock_6 = tMachineBlock.copy(); NBTUtils.setInteger(tMachineBlock_6, "recipeType", 6); //Infusing - ItemStack tMachineBlock_7_Basic = tMachineBlock_Basic.copy(); + final ItemStack tMachineBlock_7_Basic = tMachineBlock_Basic.copy(); NBTUtils.setInteger(tMachineBlock_7_Basic, "recipeType", 7); - ItemStack tMachineBlock_7 = tMachineBlock.copy(); + final ItemStack tMachineBlock_7 = tMachineBlock.copy(); NBTUtils.setInteger(tMachineBlock_7, "recipeType", 7); //Infuser - ItemStack tMachineBlock_8 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:8", 8, 1); + final ItemStack tMachineBlock_8 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:8", 8, 1); //Purification - ItemStack tMachineBlock_9 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:9", 9, 1); + final ItemStack tMachineBlock_9 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:9", 9, 1); //Pump - ItemStack tMachineBlock_12 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:12", 12, 1); + final ItemStack tMachineBlock_12 = ItemUtils.simpleMetaStack("Mekanism:MachineBlock:12", 12, 1); // - ItemStack tItem_1 = ItemUtils.simpleMetaStack("Mekanism:ElectrolyticCore", 0, 1); + final ItemStack tItem_1 = ItemUtils.simpleMetaStack("Mekanism:ElectrolyticCore", 0, 1); // - ItemStack tItem_2 = ItemUtils.simpleMetaStack("Mekanism:FactoryInstaller:1", 1, 1); + final ItemStack tItem_2 = ItemUtils.simpleMetaStack("Mekanism:FactoryInstaller:1", 1, 1); // - ItemStack tItem_3 = ItemUtils.simpleMetaStack("Mekanism:SpeedUpgrade", 0, 1); + final ItemStack tItem_3 = ItemUtils.simpleMetaStack("Mekanism:SpeedUpgrade", 0, 1); //MiscItems - String tAdvancedAlloy = "alloyAdvanced"; - String tCircuitAdvanced = "circuitAdvanced"; - ItemStack tMekBatterySimple = ItemUtils.simpleMetaStack("Mekanism:EnergyTablet", 0, 1); + final String tAdvancedAlloy = "alloyAdvanced"; + final String tCircuitAdvanced = "circuitAdvanced"; + final ItemStack tMekBatterySimple = ItemUtils.simpleMetaStack("Mekanism:EnergyTablet", 0, 1); //Items addNewRecipe( - tAdvancedAlloy, "plateTitanium", tAdvancedAlloy, - "dustIron", tAdvancedAlloy, "dustGold", - tAdvancedAlloy, "plateTitanium", tAdvancedAlloy, + tAdvancedAlloy, "plateTitanium", tAdvancedAlloy, + "dustIron", tAdvancedAlloy, "dustGold", + tAdvancedAlloy, "plateTitanium", tAdvancedAlloy, tItem_1); addNewRecipe( - tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, - "plateStainlessSteel", "plankWood", "plateStainlessSteel", - tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, + tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, + "plateStainlessSteel", "plankWood", "plateStainlessSteel", + tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, tItem_2); addNewRecipe( - null, "blockGlass", null, - tAdvancedAlloy, "plateTungsten", tAdvancedAlloy, - null, "blockGlass", null, + null, "blockGlass", null, + tAdvancedAlloy, "plateTungsten", tAdvancedAlloy, + null, "blockGlass", null, tItem_3); //Power Storage addNewRecipe( - tAdvancedAlloy, tMekBatterySimple, tAdvancedAlloy, - "plateAluminium", tBasicEnergyCube, "plateAluminium", - tAdvancedAlloy, tMekBatterySimple, tAdvancedAlloy, + tAdvancedAlloy, tMekBatterySimple, tAdvancedAlloy, + "plateAluminium", tBasicEnergyCube, "plateAluminium", + tAdvancedAlloy, tMekBatterySimple, tAdvancedAlloy, tAdvancedEnergyCube); //Blocks addNewRecipe( - "plateSteel", "craftingFurnace", "plateSteel", - "plateRedstone", "platePlatinum", "plateRedstone", - "plateSteel", "craftingFurnace", "plateSteel", + "plateSteel", "craftingFurnace", "plateSteel", + "plateRedstone", "platePlatinum", "plateRedstone", + "plateSteel", "craftingFurnace", "plateSteel", tMachineBlock_8); addNewRecipe( - tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, - "plateTitanium", ItemUtils.simpleMetaStack("Mekanism:MachineBlock", 0, 1), "plateTitanium", - tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, + tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, + "plateTitanium", ItemUtils.simpleMetaStack("Mekanism:MachineBlock", 0, 1), "plateTitanium", + tAdvancedAlloy, "circuitAdvanced", tAdvancedAlloy, tMachineBlock_9); addNewRecipe( - null, ItemUtils.getSimpleStack(Items.bucket), null, - tAdvancedAlloy, tSteelCasing, tAdvancedAlloy, - "plateStainlessSteel", "plateStainlessSteel", "plateStainlessSteel", + null, ItemUtils.getSimpleStack(Items.bucket), null, + tAdvancedAlloy, tSteelCasing, tAdvancedAlloy, + "plateStainlessSteel", "plateStainlessSteel", "plateStainlessSteel", tMachineBlock_12); //Machines addNewRecipe( - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - "plateStainlessSteel", tMachineBlock_0_Basic, "plateStainlessSteel", - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_0_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, tMachineBlock_0); addNewRecipe( - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - "plateStainlessSteel", tMachineBlock_1_Basic, "plateStainlessSteel", - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_1_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, tMachineBlock_1); addNewRecipe( - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - "plateStainlessSteel", tMachineBlock_2_Basic, "plateStainlessSteel", - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_2_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, tMachineBlock_2); addNewRecipe( - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - "plateStainlessSteel", tMachineBlock_3_Basic, "plateStainlessSteel", - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_3_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, tMachineBlock_3); addNewRecipe( - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - "plateStainlessSteel", tMachineBlock_4_Basic, "plateStainlessSteel", - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_4_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, tMachineBlock_4); addNewRecipe( - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - "plateStainlessSteel", tMachineBlock_5_Basic, "plateStainlessSteel", - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_5_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, tMachineBlock_5); addNewRecipe( - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - "plateStainlessSteel", tMachineBlock_6_Basic, "plateStainlessSteel", - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_6_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, tMachineBlock_6); addNewRecipe( - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - "plateStainlessSteel", tMachineBlock_7_Basic, "plateStainlessSteel", - tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, - tMachineBlock_7); + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + "plateStainlessSteel", tMachineBlock_7_Basic, "plateStainlessSteel", + tAdvancedAlloy, tCircuitAdvanced, tAdvancedAlloy, + tMachineBlock_7); //Gas Tanks addNewRecipe( @@ -222,7 +222,7 @@ public class HANDLER_Mekanism { "alloyUltimate", "plateTungsten", "alloyUltimate", "plateTungsten", tEliteGasTank, "plateTungsten", "alloyUltimate", "plateTungsten", "alloyUltimate", - tMasterGasTank); + tMasterGasTank); } } @@ -234,34 +234,34 @@ public class HANDLER_Mekanism { /*if (removeRecipe(OutputItem)){ return RecipeUtils.recipeBuilder( - InputItem1, InputItem2, InputItem3, - InputItem4, InputItem5, InputItem6, - InputItem7, InputItem8, InputItem9, + InputItem1, InputItem2, InputItem3, + InputItem4, InputItem5, InputItem6, + InputItem7, InputItem8, InputItem9, OutputItem); }*/ removeRecipe(OutputItem); return RecipeUtils.recipeBuilder( - InputItem1, InputItem2, InputItem3, - InputItem4, InputItem5, InputItem6, - InputItem7, InputItem8, InputItem9, + InputItem1, InputItem2, InputItem3, + InputItem4, InputItem5, InputItem6, + InputItem7, InputItem8, InputItem9, OutputItem); } - private static boolean removeRecipe(ItemStack item){ + private static boolean removeRecipe(final ItemStack item){ Class mekUtils; boolean removed = false; try { mekUtils = Class.forName("mekanism.common.util.RecipeUtils"); if (mekUtils != null){ - Method mRemoveRecipe = mekUtils.getDeclaredMethod("removeRecipes", ItemStack.class); + final Method mRemoveRecipe = mekUtils.getDeclaredMethod("removeRecipes", ItemStack.class); if (mRemoveRecipe != null){ removed = (boolean) mRemoveRecipe.invoke(null, item); if (!removed) { removed = (boolean) mRemoveRecipe.invoke(mekUtils, item); } } - } + } } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { Utils.LOG_INFO("[Mek] Failed to use the built-in recipe remover from Mekanism."); } -- cgit From 0d18c5ebd32acf0fc58643d40229947eee547e49 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 27 Nov 2017 00:59:09 +1000 Subject: ^ Version Bump. --- build.gradle | 2 +- src/Java/gtPlusPlus/core/lib/CORE.java | 11 ++++++++--- src/resources/mcmod.info | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/build.gradle b/build.gradle index c6bafd9207..c009405e03 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ sourceCompatibility = 1.7 targetCompatibility = 1.7 archivesBaseName = "GT-PlusPlus" -version = "1.6.94-release" +version = "1.6.97-release" minecraft.version = "1.7.10-10.13.4.1448-1.7.10" diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 1099679f5e..76a65ca4fe 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -1,6 +1,11 @@ package gtPlusPlus.core.lib; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import com.mojang.authlib.GameProfile; @@ -35,7 +40,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.6.94-release"; + public static final String VERSION = "1.6.97-release"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); @@ -77,7 +82,7 @@ public class CORE { //Book List public static final Map sBookList = new ConcurrentHashMap(); - + /** * File Paths and Resource Paths */ diff --git a/src/resources/mcmod.info b/src/resources/mcmod.info index 7140a5b320..9f12b3fae0 100644 --- a/src/resources/mcmod.info +++ b/src/resources/mcmod.info @@ -5,7 +5,7 @@ "description": "Adds a few various Multiblocks, Machines, etc to Gregtech and a plethora of other mods (Nearly 30!)", "credits": "", "logoFile": "", - "version": "1.6.94-release", + "version": "1.6.97-release", "mcversion": "1.7.10", "url": "https://github.com/draknyte1/GTplusplus/wiki", "updateUrl": "https://github.com/draknyte1/GTplusplus/releases/latest", -- cgit From 77ae1498e2276df9046ce4e28fe2138877c63bea Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 27 Nov 2017 01:02:35 +1000 Subject: $ Fixed Sugarcane to Plant Fiber recipe. --- src/Java/gtPlusPlus/core/recipe/RECIPES_General.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 180294c597..4304fdaff5 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -171,7 +171,7 @@ public class RECIPES_General { RecipeUtils.addShapelessGregtechRecipe( new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDictNoBroken(CI.craftingToolKnife, 1), ItemUtils.getSimpleStack(Blocks.reeds)}, + ItemUtils.getItemStackOfAmountFromOreDictNoBroken(CI.craftingToolKnife, 1), ItemUtils.getSimpleStack(Items.reeds)}, ItemUtils.getSimpleStack(ModItems.itemFiber, 16) ); -- cgit From 066bd6475ce142f405d521975b1d4105ccaddf0d Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 27 Nov 2017 12:54:10 +1000 Subject: $ Tried to implement a much nicer gui for the Grindle. --- .../gtPlusPlus/core/gui/item/GuiScreenGrindle.java | 488 +++++++++++++++++++++ src/Java/gtPlusPlus/core/handler/GuiHandler.java | 4 +- 2 files changed, 490 insertions(+), 2 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java new file mode 100644 index 0000000000..991937ff03 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java @@ -0,0 +1,488 @@ +package gtPlusPlus.core.gui.item; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.nbt.NBTUtils; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.util.ChatAllowedCharacters; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class GuiScreenGrindle extends GuiContainer { + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png"); + /** The player editing the book */ + private final EntityPlayer editingPlayer; + private final ItemStack bookObj; + /** Whether the book is signed or can still be edited */ + private final boolean bookIsUnsigned; + private boolean field_146481_r; + private boolean field_146480_s; + /** Update ticks since the gui was opened */ + private int updateCount; + private final int bookImageWidth = 192; + private final int bookImageHeight = 192; + private int bookTotalPages = 1; + private int currPage; + private NBTTagList bookPages; + private String bookTitle = ""; + private GuiScreenGrindle.NextPageButton buttonNextPage; + private GuiScreenGrindle.NextPageButton buttonPreviousPage; + private GuiButton buttonDone; + /** The GuiButton to sign this book. */ + private GuiButton buttonSign; + private GuiButton buttonFinalize; + private GuiButton buttonCancel; + + // Texture + private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, + "textures/gui/itemGrindle.png"); + + /** The inventory to render on screen */ + private final BaseInventoryGrindle inventory; + + public GuiScreenGrindle(final Container_Grindle containerItem, final EntityPlayer player) { + super(containerItem); + this.inventory = containerItem.inventory; + this.editingPlayer = player; + this.bookObj = this.inventory.getStackInSlot(0); + this.bookIsUnsigned = (this.bookObj == null ? true : false); + + if (this.bookObj != null) { + if (this.bookObj.hasTagCompound()) { + final NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); + this.bookPages = nbttagcompound.getTagList("pages", 8); + + if (this.bookPages != null) { + this.bookPages = (NBTTagList) this.bookPages.copy(); + this.bookTotalPages = this.bookPages.tagCount(); + + if (this.bookTotalPages < 1) { + this.bookTotalPages = 1; + } + } + } + + + if ((this.bookPages == null) && this.bookIsUnsigned) { this.bookPages = + new NBTTagList(); this.bookPages.appendTag(new NBTTagString("")); + this.bookTotalPages = 1; } + + } + } + + /** + * Called from the main game loop to update the screen. + */ + @Override + public void updateScreen() { + super.updateScreen(); + ++this.updateCount; + } + + /** + * Adds the buttons (and other controls) to the screen in question. + */ + @Override + @SuppressWarnings("unchecked") + public void initGui() { + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + + if (this.bookIsUnsigned) { + this.buttonList.add(this.buttonSign = new GuiButton(3, (this.width / 2) - 100, 4 + this.bookImageHeight, 98, + 20, I18n.format("book.signButton", new Object[0]))); + this.buttonList.add(this.buttonDone = new GuiButton(0, (this.width / 2) + 2, this.bookImageHeight-4, 98, + 20, I18n.format("gui.close", new Object[0]))); + this.buttonList.add(this.buttonFinalize = new GuiButton(5, (this.width / 2) - 100, 4 + this.bookImageHeight, + 98, 20, I18n.format("book.finalizeButton", new Object[0]))); + this.buttonList.add(this.buttonCancel = new GuiButton(4, (this.width / 2) + 2, 4 + this.bookImageHeight, 98, + 20, I18n.format("gui.cancel", new Object[0]))); + } + else { + this.buttonList.add(this.buttonDone = new GuiButton(0, (this.width / 2) - 100, this.bookImageHeight+100, + 200, 20, I18n.format("gui.done", new Object[0]))); + } + + final int i = (this.width - this.bookImageWidth) / 2; + final byte b0 = 2; + this.buttonList.add(this.buttonNextPage = new GuiScreenGrindle.NextPageButton(1, i + 120, b0 + 154, true)); + this.buttonList.add(this.buttonPreviousPage = new GuiScreenGrindle.NextPageButton(2, i + 38, b0 + 154, false)); + this.updateButtons(); + } + + /** + * Called when the screen is unloaded. Used to disable keyboard repeat + * events + */ + @Override + public void onGuiClosed() { + Keyboard.enableRepeatEvents(false); + } + + private void updateButtons() { + this.buttonNextPage.visible = !this.field_146480_s + && ((this.currPage < (this.bookTotalPages - 1)) || this.bookIsUnsigned); + this.buttonPreviousPage.visible = !this.field_146480_s && (this.currPage > 0); + this.buttonDone.visible = !this.bookIsUnsigned || !this.field_146480_s; + + if (this.bookIsUnsigned) { + this.buttonSign.visible = !this.field_146480_s; + this.buttonCancel.visible = this.field_146480_s; + this.buttonFinalize.visible = this.field_146480_s; + this.buttonFinalize.enabled = this.bookTitle.trim().length() > 0; + } + } + + private void sendBookToServer(final boolean p_146462_1_) { + if (this.bookIsUnsigned && this.field_146481_r) { + if (this.bookPages != null) { + String s; + + while (this.bookPages.tagCount() > 1) { + s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1); + + if (s.length() != 0) { + break; + } + + this.bookPages.removeTag(this.bookPages.tagCount() - 1); + } + + if (this.bookObj.hasTagCompound()) { + final NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); + nbttagcompound.setTag("pages", this.bookPages); + } + else { + this.bookObj.setTagInfo("pages", this.bookPages); + } + + s = "MC|BEdit"; + + if (p_146462_1_) { + s = "MC|BSign"; + this.bookObj.setTagInfo("author", new NBTTagString(this.editingPlayer.getCommandSenderName())); + this.bookObj.setTagInfo("title", new NBTTagString(this.bookTitle.trim())); + this.bookObj.func_150996_a(ModItems.itemGrindleTablet); + } + + final ByteBuf bytebuf = Unpooled.buffer(); + + try { + (new PacketBuffer(bytebuf)).writeItemStackToBuffer(this.bookObj); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload(s, bytebuf)); + } + catch (final Exception exception) { + logger.error("Couldn\'t send book info", exception); + } + finally { + bytebuf.release(); + } + } + } + } + + @Override + protected void actionPerformed(final GuiButton button) { + if (button.enabled) { + if (button.id == 0) { + this.mc.displayGuiScreen((GuiScreen) null); + this.sendBookToServer(false); + } + else if ((button.id == 3) && this.bookIsUnsigned) { + this.field_146480_s = true; + } + else if (button.id == 1) { + if (this.currPage < (this.bookTotalPages - 1)) { + ++this.currPage; + } + else if (this.bookIsUnsigned) { + this.addNewPage(); + + if (this.currPage < (this.bookTotalPages - 1)) { + ++this.currPage; + } + } + } + else if (button.id == 2) { + if (this.currPage > 0) { + --this.currPage; + } + } + else if ((button.id == 5) && this.field_146480_s) { + this.sendBookToServer(true); + this.mc.displayGuiScreen((GuiScreen) null); + } + else if ((button.id == 4) && this.field_146480_s) { + this.field_146480_s = false; + } + + this.updateButtons(); + } + } + + private void addNewPage() { + if ((this.bookPages != null) && (this.bookPages.tagCount() < 50)) { + this.bookPages.appendTag(new NBTTagString("")); + ++this.bookTotalPages; + this.field_146481_r = true; + } + } + + /** + * Fired when a key is typed. This is the equivalent of + * KeyListener.keyTyped(KeyEvent e). + */ + @Override + protected void keyTyped(final char p_73869_1_, final int p_73869_2_) { + super.keyTyped(p_73869_1_, p_73869_2_); + + if (this.bookIsUnsigned) { + if (this.field_146480_s) { + this.func_146460_c(p_73869_1_, p_73869_2_); + } + else { + this.keyTypedInBook(p_73869_1_, p_73869_2_); + } + } + } + + /** + * Processes keystrokes when editing the text of a book + */ + private void keyTypedInBook(final char p_146463_1_, final int p_146463_2_) { + switch (p_146463_1_) { + case 22: + this.func_146459_b(GuiScreen.getClipboardString()); + return; + default: + switch (p_146463_2_) { + case 14: + final String s = this.func_146456_p(); + + if (s.length() > 0) { + this.func_146457_a(s.substring(0, s.length() - 1)); + } + + return; + case 28: + case 156: + this.func_146459_b("\n"); + return; + default: + if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_)) { + this.func_146459_b(Character.toString(p_146463_1_)); + } + } + } + } + + private void func_146460_c(final char p_146460_1_, final int p_146460_2_) { + switch (p_146460_2_) { + case 14: + if (!this.bookTitle.isEmpty()) { + this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1); + this.updateButtons(); + } + + return; + case 28: + case 156: + if (!this.bookTitle.isEmpty()) { + this.sendBookToServer(true); + this.mc.displayGuiScreen((GuiScreen) null); + } + + return; + default: + if ((this.bookTitle.length() < 16) && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) { + this.bookTitle = this.bookTitle + Character.toString(p_146460_1_); + this.updateButtons(); + this.field_146481_r = true; + } + } + } + + private String func_146456_p() { + return (this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount()) + ? this.bookPages.getStringTagAt(this.currPage) : ""; + } + + private void func_146457_a(final String p_146457_1_) { + if ((this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount())) { + this.bookPages.func_150304_a(this.currPage, new NBTTagString(p_146457_1_)); + this.field_146481_r = true; + } + } + + private void func_146459_b(final String p_146459_1_) { + final String s1 = this.func_146456_p(); + final String s2 = s1 + p_146459_1_; + final int i = this.fontRendererObj.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); + + if ((i <= 118) && (s2.length() < 256)) { + this.func_146457_a(s2); + } + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(final int p_73863_1_, final int p_73863_2_, final float p_73863_3_) { + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l2 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l2, 0, 0, this.xSize, this.ySize); + + //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + //this.mc.getTextureManager().bindTexture(iconLocation); + //final int k = (this.width - this.bookImageWidth) / 2; + //this.drawTexturedModalRect(k, b0, 0, 0, this.bookImageWidth, + // this.bookImageHeight); + + String s; + String s1; + int l; + final byte b0 = 2; + + if (this.inventory.getStackInSlot(0) != null) { + this.fontRendererObj.drawString( + I18n.format("" + NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), 10, 8, + Utils.rgbtoHexValue(125, 255, 125)); + } + + if (this.field_146480_s) { + s = this.bookTitle; + + if (this.bookIsUnsigned) { + if (((this.updateCount / 6) % 2) == 0) { + s = s + "" + EnumChatFormatting.BLACK + "_"; + } + else { + s = s + "" + EnumChatFormatting.GRAY + "_"; + } + } + + s1 = I18n.format("book.editTitle", new Object[0]); + l = this.fontRendererObj.getStringWidth(s1); + this.fontRendererObj.drawString(s1, k + 36 + ((116 - l) / 2), b0 + 16 + 16, 0); + final int i1 = this.fontRendererObj.getStringWidth(s); + this.fontRendererObj.drawString(s, k + 36 + ((116 - i1) / 2), b0 + 48, 0); + final String s2 = I18n.format("book.byAuthor", new Object[] { this.editingPlayer.getCommandSenderName() }); + final int j1 = this.fontRendererObj.getStringWidth(s2); + this.fontRendererObj.drawString(EnumChatFormatting.DARK_GRAY + s2, k + 36 + ((116 - j1) / 2), b0 + 48 + 10, + 0); + final String s3 = I18n.format("book.finalizeWarning", new Object[0]); + this.fontRendererObj.drawSplitString(s3, k + 36, b0 + 80, 116, 0); + } + else { + s = I18n.format("book.pageIndicator", + new Object[] { Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages) }); + s1 = ""; + + if ((this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount())) { + s1 = this.bookPages.getStringTagAt(this.currPage); + } + + if (this.bookIsUnsigned) { + if (this.fontRendererObj.getBidiFlag()) { + s1 = s1 + "_"; + } + else if (((this.updateCount / 6) % 2) == 0) { + s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; + } + else { + s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; + } + } + + l = this.fontRendererObj.getStringWidth(s); + this.fontRendererObj.drawString(s, ((k - l) + this.bookImageWidth) - 44, b0 + 16, 0); + //this.fontRendererObj.drawString(s, k+36, b0 + 16, 0); + this.fontRendererObj.drawSplitString(s1, k + 36, b0 + 16 + 16, 116, 0); + //this.fontRendererObj.drawSplitString(s1, k, b0 + 16 + 16, 116, 0); + } + + super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); + } + + @SideOnly(Side.CLIENT) + static class NextPageButton extends GuiButton { + private final boolean field_146151_o; + + public NextPageButton(final int p_i1079_1_, final int p_i1079_2_, final int p_i1079_3_, + final boolean p_i1079_4_) { + super(p_i1079_1_, p_i1079_2_, p_i1079_3_, 23, 13, ""); + this.field_146151_o = p_i1079_4_; + } + + /** + * Draws this button to the screen. + */ + @Override + public void drawButton(final Minecraft p_146112_1_, final int p_146112_2_, final int p_146112_3_) { + if (this.visible) { + final boolean flag = (p_146112_2_ >= this.xPosition) && (p_146112_3_ >= this.yPosition) + && (p_146112_2_ < (this.xPosition + this.width)) + && (p_146112_3_ < (this.yPosition + this.height)); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + p_146112_1_.getTextureManager().bindTexture(GuiScreenGrindle.bookGuiTextures); + int k = 0; + int l = 192; + + if (flag) { + k += 23; + } + + if (!this.field_146151_o) { + l += 13; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13); + } + } + } + + /** + * Draw the background layer for the GuiContainer (everything behind the + * items) + */ + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int i1; + // drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) + // - 50 - this.ySize_lo, this.mc.thePlayer); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index cf7c90eca5..4b7e58cf70 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -14,7 +14,7 @@ import gtPlusPlus.core.container.Container_WorkbenchAdvanced; import gtPlusPlus.core.gui.beta.Gui_ID_Registry; import gtPlusPlus.core.gui.beta.MU_GuiId; import gtPlusPlus.core.gui.item.GuiBaseBackpack; -import gtPlusPlus.core.gui.item.GuiBaseGrindle; +import gtPlusPlus.core.gui.item.GuiScreenGrindle; import gtPlusPlus.core.gui.machine.GUI_FishTrap; import gtPlusPlus.core.gui.machine.GUI_ModularityTable; import gtPlusPlus.core.gui.machine.GUI_ProjectTable; @@ -155,7 +155,7 @@ public class GuiHandler implements IGuiHandler { } if (ID == GUI9){ - return new GuiBaseGrindle(new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem()))); + return new GuiScreenGrindle(new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())), player); } return null; -- cgit