From 2b7ae2001ed8f49d2de8f88ef306426af60c279b Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 4 May 2020 01:32:46 +0100 Subject: $ Fixed handling of Giant Eggs. $ Fixed obscure crash caused by Dingos. $ Fixed handling of Spawn Eggs and entities registered to the global list. $ Potentially fixed NEI not working correctly for GT++ recipe maps. --- .../general/TileEntityDecayablesChest.java | 4 +- .../tileentities/general/TileEntityEggBox.java | 359 +++++++++++++++++++++ 2 files changed, 361 insertions(+), 2 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java index c184b47d25..db93e9c4fc 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityDecayablesChest.java @@ -90,14 +90,14 @@ public class TileEntityDecayablesChest extends TileEntity implements ISidedInven boolean a1, a2; int u = 0; - a1 = b.getIsActive(world, iStack); + a1 = b.isTicking(world, iStack); a2 = false; int SECONDS_TO_PROCESS = 1; while (u < (20 * SECONDS_TO_PROCESS)) { if (!a1) { break; } - a1 = b.getIsActive(world, iStack); + a1 = b.isTicking(world, iStack); a2 = b.tickItemTag(world, iStack); u++; } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java new file mode 100644 index 0000000000..0c428537cb --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityEggBox.java @@ -0,0 +1,359 @@ +package gtPlusPlus.core.tileentities.general; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.inventories.Inventory_EggBox; +import gtPlusPlus.core.item.general.ItemGiantEgg; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class TileEntityEggBox extends TileEntity implements ISidedInventory { + + private final Inventory_EggBox inventoryContents; + + /** Determines if the check for adjacent chests has taken place. */ + public boolean adjacentChestChecked; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestZNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestXPos; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestXNeg; + /** Contains the chest tile located adjacent to this one (if any) */ + public TileEntityEggBox adjacentChestZPos; + /** The current angle of the lid (between 0 and 1) */ + public float lidAngle; + /** The angle of the lid last tick */ + public float prevLidAngle; + /** The number of players currently using this chest */ + public int numPlayersUsing; + + private String customName; + + private int cachedChestType; + private int tickCount = 0; + + public TileEntityEggBox() { + this.inventoryContents = new Inventory_EggBox(); + } + + public Inventory_EggBox getInventory() { + return this.inventoryContents; + } + + @Override + public void updateEntity() { + + // Try do chesty stuff + try { + this.updateEntityChest(); + } catch (Throwable t) { + + } + + try { + if (!this.worldObj.isRemote) { + this.tickCount++; + if ((this.tickCount % 10) == 0) { + cachedChestType = 1; + } + + if ((this.tickCount % 20) == 0) { + for (ItemStack inv : this.getInventory().getInventory()) { + if (inv == null) { + continue; + } + if (inv.getItem() instanceof ItemGiantEgg) { + ItemGiantEgg D = (ItemGiantEgg) inv.getItem(); + tryUpdateDecayable(D, inv, this.worldObj); + } + } + + } + updateSlots(); + } + } catch (final Throwable t) { + } + } + + public void tryUpdateDecayable(final ItemGiantEgg d, ItemStack iStack, final World world) { + if (world == null || iStack == null) { + return; + } + if (world.isRemote) { + return; + } + + boolean a1, a2; + int u = 0; + a1 = d.isTicking(world, iStack); + a2 = false; + int SECONDS_TO_PROCESS = 1; + while (u < (20 * SECONDS_TO_PROCESS)) { + if (!a1) { + break; + } + a1 = d.isTicking(world, iStack); + a2 = d.tickItemTag(world, iStack); + u++; + } + Logger.MACHINE_INFO("| "+d.getUnlocalizedName()+" | "+a1+"/"+a2); + + if (!a1 && !a2) { + ItemStack replacement = ItemUtils.getSimpleStack(d.getHatchResult(), 1); + replacement.stackSize = 1; + //iStack = replacement.copy(); + for (int fff = 0; fff < this.inventoryContents.getSizeInventory(); fff++) { + if (this.inventoryContents.getStackInSlot(fff) == iStack) { + this.inventoryContents.setInventorySlotContents(fff, replacement.copy()); + } + } + + updateSlots(); + this.inventoryContents. + markDirty(); + } + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + if (this.numPlayersUsing < 0) { + this.numPlayersUsing = 0; + } + if (!this.worldObj.isRemote) { + this.numPlayersUsing++; + cachedChestType = 1; + } + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + 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(); + } + + @Override + public void closeInventory() { + if (!this.worldObj.isRemote) { + this.numPlayersUsing--; + cachedChestType = 1; + } + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + 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(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r = 0; r < this.getInventory().getSizeInventory(); r++) { + accessibleSides[r] = r; + } + return accessibleSides; + + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return this.getInventory().isItemValidForSlot(0, p_102007_2_); + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return this.getInventory().isItemValidForSlot(0, p_102008_2_); + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.EggBox"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + /** + * Causes the TileEntity to reset all it's cached values for it's container + * Block, metadata and in the case of chests, the adjacent chest check + */ + public void updateContainingBlockInfo() { + super.updateContainingBlockInfo(); + this.adjacentChestChecked = false; + } + + /** + * Performs the check for adjacent chests to determine if this chest is double + * or not. + */ + public void checkForAdjacentChests() { + if (!this.adjacentChestChecked) { + this.adjacentChestChecked = true; + this.adjacentChestZNeg = null; + this.adjacentChestXPos = null; + this.adjacentChestXNeg = null; + this.adjacentChestZPos = null; + } + } + + public void updateEntityChest() { + float f; + this.prevLidAngle = this.lidAngle; + f = 0.04F; + double d2; + if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null + && this.adjacentChestXNeg == null) { + double d1 = (double) this.xCoord + 0.5D; + d2 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect(d1, (double) this.yCoord + 0.5D, d2, "random.chestopen", 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { + float f1 = this.lidAngle; + if (this.numPlayersUsing > 0) { + //this.lidAngle += f; + this.lidAngle += (float) (f * (1 + 0.10 * 0.01)); + } else { + //this.lidAngle -= f; + this.lidAngle -= (float) (f * (1 + 0.10 * 0.01)); + } + if (this.lidAngle > 1.0F) { + this.lidAngle = 1.0F; + } + float f2 = 0.5F; + if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { + d2 = (double) this.xCoord + 0.5D; + double d0 = (double) this.zCoord + 0.5D; + this.worldObj.playSoundEffect(d2, (double) this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F, + this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.lidAngle < 0.0F) { + this.lidAngle = 0.0F; + } + } + } + + /** + * Called when a client event is received with the event number and argument, + * see World.sendClientEvent + */ + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + if (p_145842_1_ == 1) + { + this.numPlayersUsing = p_145842_2_; + return true; + } + else + { + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + } + + /** + * invalidates a tile entity + */ + public final void invalidate() { + super.invalidate(); + cachedChestType = 1; + this.updateContainingBlockInfo(); + this.checkForAdjacentChests(); + } + + private final int updateSlots() { + //Have slots changed? + if (cachedChestType == 0) { + return 0; + } + ItemUtils.organiseInventory(getInventory()); + cachedChestType = 0; + return cachedChestType; + + } + +} -- cgit From 6fb4b8a333e69bd591d49d9c5f251797de333c7b Mon Sep 17 00:00:00 2001 From: Alkalus Date: Mon, 25 May 2020 02:55:32 +0100 Subject: + Added the Volumetric Flask Configurator. + Added a recipe for the Egg Box. + Added a Book for the Chemical Plant. % Changed the Tooltip for the Egg Box. $ Fixed Robinators not returning the correct block when mined. $ Fixed Electric tool recipes not consuming the original tool. $ Redid handling of all shaped crafting recipes. $ Fixed recipe handling for the last few multiblocks. $ Potentially forgot some other minor fixes. --- build.gradle | 3 +- src/Java/gtPlusPlus/GTplusplus.java | 2 + src/Java/gtPlusPlus/core/block/ModBlocks.java | 9 +- .../core/block/base/BasicTileBlockWithTooltip.java | 13 + src/Java/gtPlusPlus/core/block/machine/EggBox.java | 2 +- .../core/block/machine/VolumetricFlaskSetter.java | 169 ++++++++++ src/Java/gtPlusPlus/core/common/CommonProxy.java | 38 ++- .../core/common/compat/COMPAT_ExtraUtils.java | 2 +- .../container/Container_VolumetricFlaskSetter.java | 162 ++++++++++ .../gui/machine/GUI_VolumetricFlaskSetter.java | 149 +++++++++ src/Java/gtPlusPlus/core/handler/BookHandler.java | 16 + src/Java/gtPlusPlus/core/handler/GuiHandler.java | 7 +- .../gtPlusPlus/core/handler/PacketHandler.java | 118 ++++--- .../Inventory_VolumetricFlaskSetter.java | 173 ++++++++++ .../item/base/itemblock/ItemBlockBasicTile.java | 7 +- .../base/itemblock/ItemBlockRoundRobinator.java | 5 + .../handler/AbstractClientMessageHandler.java | 13 + .../network/handler/AbstractMessageHandler.java | 37 +++ .../handler/AbstractServerMessageHandler.java | 13 + .../core/network/packet/AbstractPacket.java | 9 + .../network/packet/Packet_VolumetricFlaskGui.java | 128 ++++++++ .../network/packet/Packet_VolumetricFlaskGui2.java | 127 ++++++++ src/Java/gtPlusPlus/core/proxy/ClientProxy.java | 32 +- .../gtPlusPlus/core/recipe/RECIPES_General.java | 34 +- .../core/recipe/RECIPES_MachineComponents.java | 12 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 79 +++-- src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java | 12 +- .../gtPlusPlus/core/slots/SlotVolumetricFlask.java | 30 ++ .../core/tileentities/ModTileEntities.java | 5 + .../general/TileEntityVolumetricFlaskSetter.java | 348 +++++++++++++++++++++ src/Java/gtPlusPlus/core/util/data/ArrayUtils.java | 7 + .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 8 +- .../core/util/minecraft/RecipeUtils.java | 195 ++++++++++-- .../forestry/bees/recipe/FR_Gregtech_Recipes.java | 8 +- .../xmod/gregtech/common/Meta_GT_Proxy.java | 26 +- .../common/helpers/VolumetricFlaskHelper.java | 81 +++++ .../gregtech/loaders/ProcessingAngleGrinder.java | 6 +- .../loaders/ProcessingElectricButcherKnife.java | 33 +- .../loaders/ProcessingElectricLighter.java | 26 +- .../gregtech/loaders/ProcessingElectricSnips.java | 29 +- .../loaders/ProcessingToolHeadChoocher.java | 2 +- .../gregtech/loaders/RecipeGen_DustGeneration.java | 8 +- .../xmod/gregtech/loaders/RecipeGen_Ore.java | 14 +- .../gregtech/loaders/RecipeGen_ShapedCrafting.java | 20 +- .../xmod/gregtech/recipes/GregtechRecipeAdder.java | 124 ++++++-- .../registration/gregtech/GregtechConduits.java | 10 +- .../gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java | 32 +- src/resources/assets/miscutils/lang/en_US.lang | 5 +- .../textures/gui/VolumetricFlaskSetter.png | Bin 0 -> 2482 bytes 49 files changed, 2079 insertions(+), 309 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java create mode 100644 src/Java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java create mode 100644 src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java create mode 100644 src/Java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java create mode 100644 src/Java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java create mode 100644 src/Java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java create mode 100644 src/Java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java create mode 100644 src/Java/gtPlusPlus/core/network/packet/AbstractPacket.java create mode 100644 src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java create mode 100644 src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java create mode 100644 src/Java/gtPlusPlus/core/slots/SlotVolumetricFlask.java create mode 100644 src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java create mode 100644 src/resources/assets/miscutils/textures/gui/VolumetricFlaskSetter.png (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/build.gradle b/build.gradle index fb19efaab6..960cf9481e 100644 --- a/build.gradle +++ b/build.gradle @@ -145,7 +145,8 @@ dependencies { //compile files('libs/gregtech-5.08.33-dev.jar') - compile files('libs/gregtech-5.09.31-dev.jar') + //compile files('libs/gregtech-5.09.31-dev.jar') + compile files('libs/gregtech-5.09.33-dev.jar') provided "net.industrial-craft:industrialcraft-2:${config.ic2.version}:dev" //compile "ic2:IC2Classic:1.2.1.8:dev" - Does not mirror internal class structure or visibility of IC2, won't ever compile. diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index f138d5f95d..4e4088a367 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -28,6 +28,7 @@ import gtPlusPlus.core.commands.CommandMath; import gtPlusPlus.core.common.CommonProxy; import gtPlusPlus.core.config.ConfigHandler; import gtPlusPlus.core.handler.BookHandler; +import gtPlusPlus.core.handler.PacketHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.handler.events.LoginEventHandler; @@ -134,6 +135,7 @@ public class GTplusplus implements ActionListener { Logger.INFO("Loading " + CORE.name + " "+CORE.VERSION+" on Gregtech "+Utils.getGregtechVersionAsString()); //Load all class objects within the plugin package. Core_Manager.veryEarlyInit(); + PacketHandler.init(); if(!Utils.isServer()){ enableCustomCapes = true; diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index d5bf2da25d..de207335f2 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -17,6 +17,8 @@ import gtPlusPlus.core.block.machine.*; import gtPlusPlus.core.block.machine.bedrock.Mining_Head_Fake; import gtPlusPlus.core.block.machine.bedrock.Mining_Pipe_Fake; import gtPlusPlus.core.fluids.FluidRegistryHandler; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraftforge.fluids.Fluid; @@ -25,6 +27,7 @@ public final class ModBlocks { public static Block blockRoundRobinator; public static Block blockCircuitProgrammer; + public static Block blockVolumetricFlaskSetter; public static Block blockFakeMiningPipe; public static Block blockFakeMiningHead; @@ -144,7 +147,11 @@ public final class ModBlocks { blockPestKiller = new Machine_PestKiller(); blockRoundRobinator = new Machine_RoundRobinator(); - + + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + blockVolumetricFlaskSetter = new VolumetricFlaskSetter(); + } + new BlockGenericRedstoneDetector(); new BlockGenericRedstoneTest(); diff --git a/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java b/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java index 6166835f31..2bfd09d848 100644 --- a/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java +++ b/src/Java/gtPlusPlus/core/block/base/BasicTileBlockWithTooltip.java @@ -1,6 +1,8 @@ package gtPlusPlus.core.block.base; +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; @@ -22,6 +24,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -312,4 +315,14 @@ public abstract class BasicTileBlockWithTooltip extends BlockContainer implement return l; } + + public Item getItemDropped(int meta, Random rand, int p_149650_3_){ + return ItemUtils.getSimpleStack(this, 1).getItem(); + } + + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune){ + ArrayList drops = new ArrayList(); + drops.add(ItemUtils.simpleMetaStack(this, metadata, 1)); + return drops; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/EggBox.java b/src/Java/gtPlusPlus/core/block/machine/EggBox.java index f36dc83704..630c4b5bc2 100644 --- a/src/Java/gtPlusPlus/core/block/machine/EggBox.java +++ b/src/Java/gtPlusPlus/core/block/machine/EggBox.java @@ -37,7 +37,7 @@ public class EggBox extends BlockContainer implements ITileTooltip /** * Determines which tooltip is displayed within the itemblock. */ - private final int mTooltipID = 5; + private final int mTooltipID = 7; public final int field_149956_a = 0; @Override diff --git a/src/Java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java new file mode 100644 index 0000000000..4f86de49d3 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java @@ -0,0 +1,169 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.minecraft.CubicObject; +import gtPlusPlus.core.block.base.BasicTileBlockWithTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui2; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class VolumetricFlaskSetter extends BasicTileBlockWithTooltip { + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 8; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @Override + public Class getItemBlockClass() { + return ItemBlockBasicTile.class; + } + + @SuppressWarnings("deprecation") + public VolumetricFlaskSetter(){ + super(Material.iron); + LanguageRegistry.addName(this, "Volumetric Flask Configurator"); + } + + /** + * 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 { + + boolean mDidScrewDriver = false; + // 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)))) { + final TileEntityVolumetricFlaskSetter tile = (TileEntityVolumetricFlaskSetter) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + } + } + catch (final Throwable t) {} + + if (!mDidScrewDriver) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityVolumetricFlaskSetter)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI18, world, x, y, z); + TileEntityVolumetricFlaskSetter aTile = (TileEntityVolumetricFlaskSetter) te; + new Packet_VolumetricFlaskGui2(aTile, aTile.getCustomValue()); + return true; + } + } + else { + return true; + } + + } + return false; + } + + @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 TileEntityVolumetricFlaskSetter(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityVolumetricFlaskSetter) 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 int getMetaCount() { + return 0; + } + + @Override + public String getUnlocalBlockName() { + return "blockVolumetricFlaskSetter"; + } + + @Override + protected float initBlockHardness() { + return 5f; + } + + @Override + protected float initBlockResistance() { + return 1f; + } + + @Override + protected CreativeTabs initCreativeTab() { + return AddToCreativeTab.tabMachines; + } + + @Override + protected String getTileEntityName() { + return "Volumetric Flask Configurator"; + } + + @Override + public CubicObject[] getCustomTextureDirectoryObject() { + String[] aTexData = new String[] { + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_A", + CORE.MODID + ":" + "metro/" + "TEXTURE_TECH_PANEL_C", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H", + CORE.MODID + ":" + "metro/" + "TEXTURE_METAL_PANEL_H" + }; + CubicObject[] aTextureData = new CubicObject[] {new CubicObject(aTexData)}; + return aTextureData; + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 4dad732e25..9565d242c4 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.common; import cpw.mods.fml.common.event.*; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; @@ -42,8 +43,10 @@ import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; import net.minecraftforge.client.IItemRenderer; public class CommonProxy { @@ -138,7 +141,7 @@ public class CommonProxy { Utils.registerEvent(new HandlerTooltip_EIO()); // Handles Custom Tooltips for GC Utils.registerEvent(new HandlerTooltip_GC()); - + if (CORE.DEVENV) { Utils.registerEvent(new StopAnnoyingFuckingAchievements()); } @@ -231,13 +234,13 @@ public class CommonProxy { Utils.createNewMobSpawner(1, EntitySickBlaze.class); Utils.createNewMobSpawner(2, EntityStaballoyConstruct.class); } - + public void registerCustomItemsForMaterials() { Material.registerComponentForMaterial(GenericChem.CARBYNE, OrePrefixes.plate, GregtechItemList.Carbyne_Sheet_Finished.get(1)); } - + public void registerCustomMobDrops() { - + //Zombie EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemRope), 3, 100); EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemFiber), 5, 250); @@ -245,14 +248,14 @@ public class CommonProxy { EntityUtils.registerDropsForMob(EntityZombie.class, ItemUtils.getSimpleStack(ModItems.itemBomb), 2, 10); EntityUtils.registerDropsForMob(EntityZombie.class, ALLOY.TUMBAGA.getTinyDust(1), 1, 10); EntityUtils.registerDropsForMob(EntityZombie.class, ALLOY.POTIN.getTinyDust(1), 1, 10); - + //Blazes if (ItemUtils.doesOreDictHaveEntryFor("dustPyrotheum")) { EntityUtils.registerDropsForMob(EntityBlaze.class, ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), 1, 10); EntityUtils.registerDropsForMob(EntityBlaze.class, ItemUtils.getItemStackOfAmountFromOreDict("dustPyrotheum", 1), 1, 10); } - - + + //Special mobs Support if (ReflectionUtils.doesClassExist("toast.specialMobs.entity.zombie.EntityBrutishZombie")) { Class aBrutishZombie = ReflectionUtils.getClass("toast.specialMobs.entity.zombie.EntityBrutishZombie"); @@ -264,7 +267,7 @@ public class CommonProxy { EntityUtils.registerDropsForMob(aBrutishZombie, aFortune3, 1, 1); EntityUtils.registerDropsForMob(aBrutishZombie, ItemUtils.getItemStackOfAmountFromOreDict("ingotRedAlloy", 1), 3, 200); } - + //GalaxySpace Support if (ReflectionUtils.doesClassExist("galaxyspace.SolarSystem.moons.europa.entities.EntityEvolvedColdBlaze")) { Class aColdBlaze = ReflectionUtils.getClass("galaxyspace.SolarSystem.moons.europa.entities.EntityEvolvedColdBlaze"); @@ -287,16 +290,16 @@ public class CommonProxy { EntityUtils.registerDropsForMob(aColdBlaze, aTinyCryo, 2, 100); } } - + } - + protected final AutoMap> mItemRenderMappings = new AutoMap>(); - + public static void registerItemRendererGlobal(Item aItem, IItemRenderer aRenderer) { GTplusplus.proxy.registerItemRenderer(aItem, aRenderer); } - + public void registerItemRenderer(Item aItem, IItemRenderer aRenderer) { if (Utils.isServer()) { return; @@ -306,4 +309,15 @@ public class CommonProxy { } } + public World getClientWorld() { + return null; + } + + /** + * Returns a side-appropriate EntityPlayer for use during message handling + */ + public EntityPlayer getPlayerEntity(MessageContext ctx) { + return ctx.getServerHandler().playerEntity; + } + } diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java index 4d736e1362..d5ee51f61a 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java @@ -21,7 +21,7 @@ public class COMPAT_ExtraUtils { if (ConfigSwitches.enableAlternativeDivisionSigilRecipe){ //Division Sigil - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "plateNetherStar", "gemIridium", "plateNetherStar", "plateIridium", RECIPES_Tools.craftingToolHardHammer, "plateIridium", "plateNetherStar", "gemIridium", "plateNetherStar", diff --git a/src/Java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java new file mode 100644 index 0000000000..5c776b7a57 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java @@ -0,0 +1,162 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.inventories.Inventory_VolumetricFlaskSetter; +import gtPlusPlus.core.slots.SlotNoInput; +import gtPlusPlus.core.slots.SlotVolumetricFlask; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +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; +import net.minecraft.world.World; + +public class Container_VolumetricFlaskSetter extends Container { + + protected TileEntityVolumetricFlaskSetter tile_entity; + public final Inventory_VolumetricFlaskSetter inventoryChest; + + private final World worldObj; + private final int posX; + private final int posY; + private final int posZ; + + public static final int SLOT_OUTPUT = 8; + + public static int StorageSlotNumber = 8; // Number of slots in storage area + public static int InventorySlotNumber = 36; // Inventory Slots (Inventory + // and Hotbar) + public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All + // slots + + public Container_VolumetricFlaskSetter(final InventoryPlayer inventory, final TileEntityVolumetricFlaskSetter te) { + this.tile_entity = te; + this.inventoryChest = te.getInventory(); + + int var6; + int var7; + this.worldObj = te.getWorldObj(); + this.posX = te.xCoord; + this.posY = te.yCoord; + this.posZ = te.zCoord; + + int o = 0; + + // Storage Side + /*for (var6 = 0; var6 < 3; var6++) { + for (var7 = 0; var7 < 5; var7++) { + this.addSlotToContainer(new SlotIntegratedCircuit(o, this.inventoryChest, o, 44 + (var7 * 18), 15 + (var6 * 18))); + o++; + } + }*/ + + + int xStart = 26; + int yStart = 12; + + try { + //0 + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart+18)); + + //Add Output + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_OUTPUT, 8+(8*18), 59)); + o++; + + + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } + } + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + } + catch (Throwable t) {} + + } + + @Override + public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, + final EntityPlayer aPlayer) { + + if (!aPlayer.worldObj.isRemote) { + if ((aSlotIndex == 999) || (aSlotIndex == -999)) { + // Utils.LOG_WARNING("??? - "+aSlotIndex); + } + } + return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); + } + + @Override + public void onContainerClosed(final EntityPlayer par1EntityPlayer) { + super.onContainerClosed(par1EntityPlayer); + } + + @Override + public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { + if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockVolumetricFlaskSetter) { + return false; + } + + return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; + } + + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) { + ItemStack var3 = null; + final Slot var4 = (Slot) this.inventorySlots.get(par2); + + if ((var4 != null) && var4.getHasStack()) { + final ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + /* + * if (par2 == 0) { if (!this.mergeItemStack(var5, + * InOutputSlotNumber, FullSlotNumber, true)) { return null; } + * + * var4.onSlotChange(var5, var3); } else if (par2 >= + * InOutputSlotNumber && par2 < InventoryOutSlotNumber) { if + * (!this.mergeItemStack(var5, InventoryOutSlotNumber, + * FullSlotNumber, false)) { return null; } } else if (par2 >= + * InventoryOutSlotNumber && par2 < FullSlotNumber) { if + * (!this.mergeItemStack(var5, InOutputSlotNumber, + * InventoryOutSlotNumber, false)) { return null; } } else if + * (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, + * false)) { return null; } + */ + + if (var5.stackSize == 0) { + var4.putStack((ItemStack) null); + } else { + var4.onSlotChanged(); + } + + if (var5.stackSize == var3.stackSize) { + return null; + } + + var4.onPickupFromSlot(par1EntityPlayer, var5); + } + + return var3; + } + + // Can merge Slot + @Override + public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { + return super.func_94530_a(p_94530_1_, p_94530_2_); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java new file mode 100644 index 0000000000..6bdf8f2ef5 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java @@ -0,0 +1,149 @@ +package gtPlusPlus.core.gui.machine; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.container.Container_VolumetricFlaskSetter; +import gtPlusPlus.core.handler.PacketHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class GUI_VolumetricFlaskSetter extends GuiContainer { + + private GuiTextField text; + private TileEntityVolumetricFlaskSetter aTile; + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/VolumetricFlaskSetter.png"); + + public GUI_VolumetricFlaskSetter(final InventoryPlayer player_inventory, final TileEntityVolumetricFlaskSetter te){ + super(new Container_VolumetricFlaskSetter(player_inventory, te)); + aTile = te; + Logger.INFO("Tile Value: "+te.getCustomValue()); + } + + public void initGui(){ + super.initGui(); + this.text = new GuiTextField(this.fontRendererObj, this.width / 2 - 62, this.height/2-52, 106, 14); + text.setMaxStringLength(5); + if (aTile != null) { + Logger.INFO("Using Value from Tile: "+aTile.getCustomValue()); + text.setText(""+aTile.getCustomValue()); + } + else { + Logger.INFO("Using default Value: 1000"); + text.setText("1000"); + } + this.text.setFocused(true); + } + + protected void keyTyped(char par1, int par2){ + if (!isNumber(par1) && par2 != Keyboard.KEY_BACK && par2 != Keyboard.KEY_RETURN) { + text.setFocused(false); + super.keyTyped(par1, par2); + } + else { + if (par2 == Keyboard.KEY_RETURN) { + if (text.isFocused()) { + Logger.INFO("Removing Focus."); + text.setFocused(false); + } + } + else if (par2 == Keyboard.KEY_BACK) { + String aCurrentText = getText(); + if (aCurrentText.length() > 0) { + this.text.setText(aCurrentText.substring(0, aCurrentText.length() - 1)); + if (getText().length() <= 0) { + this.text.setText("0"); + } + } + } + else { + if (this.text.getText().equals("0")) { + this.text.setText(""+par1); + } + else { + this.text.textboxKeyTyped(par1, par2); + } + } + sendUpdateToServer(); + } + } + + public void updateScreen(){ + super.updateScreen(); + this.text.updateCursorCounter(); + } + + public void drawScreen(int par1, int par2, float par3){ + this.drawDefaultBackground(); + super.drawScreen(par1, par2, par3); + this.text.drawTextBox(); + } + + protected void mouseClicked(int x, int y, int btn) { + super.mouseClicked(x, y, btn); + this.text.mouseClicked(x, y, btn); + } + + + + + + + + + @Override + protected void drawGuiContainerForegroundLayer(final int i, final int j){ + super.drawGuiContainerForegroundLayer(i, j); + this.fontRendererObj.drawString(I18n.format("container.VolumetricFlaskSetter", new Object[0]), 4, 3, 4210752); + int aYVal = 49; + this.fontRendererObj.drawString(I18n.format("0 = 16l", new Object[0]), 8, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("4 = 576l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("1 = 36l", new Object[0]), 8, aYVal+=8, 4210752); + this.fontRendererObj.drawString(I18n.format("5 = 720l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("2 = 144l", new Object[0]), 8, aYVal+=8, 4210752); + this.fontRendererObj.drawString(I18n.format("6 = 864l", new Object[0]), 64, aYVal, 4210752); + this.fontRendererObj.drawString(I18n.format("3 = 432l", new Object[0]), 8, aYVal+=8, 4210752); + this.fontRendererObj.drawString(I18n.format("-> = Custom", new Object[0]), 59, aYVal, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + final int x = (this.width - this.xSize) / 2; + final int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + + public boolean isNumber(char c) { + return ((c >= 48 && c <= 57) || c == 45); + } + + protected String getText() { + return this.text.getText(); + } + + protected void sendUpdateToServer() { + Logger.INFO("Trying to send packet to server from GUI."); + int aCustomValue = 0; + if (getText().length() > 0) + try { + aCustomValue = Integer.parseInt(getText()); + Logger.INFO("Got Value: "+aCustomValue); + PacketHandler.sendToServer(new Packet_VolumetricFlaskGui(aTile, aCustomValue)); + } catch (NumberFormatException ex) { + + } + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/BookHandler.java b/src/Java/gtPlusPlus/core/handler/BookHandler.java index d9d3efe680..57d371905f 100644 --- a/src/Java/gtPlusPlus/core/handler/BookHandler.java +++ b/src/Java/gtPlusPlus/core/handler/BookHandler.java @@ -22,6 +22,7 @@ public class BookHandler { public static BookTemplate book_ModularBauble; public static BookTemplate book_MultiMachineManual; public static BookTemplate book_NuclearManual; + public static BookTemplate book_MultiChemicalPlant; public static void run(){ @@ -179,6 +180,18 @@ public class BookHandler { "This structure is used to produce the Molten Salts required to run a Liquid Fluorine Thorium Reactor [LFTR]." }); + + book_MultiChemicalPlant = writeBookTemplate( + "book_Multi_ChemicalPlant", "Chemical Plant Manual", "Alkalus", + new String[] { + "This Multiblock, depending upon the mode used, can function as a variety of different machines. The idea behind this, was that most of these machines are rather niche compared to any others, as such, not used often.", + "To build, you need to construct a hollow 3x3x3 structure made from Multi-Use casings, With a minimum of 6. Any Casing position can be substituted out with an Input Hatch/Bus, an Output Hatch/Bus, Muffler, Maint. Hatch or Energy Injector Hatch.", + "The Mode can be set by using a Screwdriver on the controller block. Each mode allows the use of Numbered Circuits, to allow a different machine 'type' for each input bus.", + "[Metal Work] Mode A - Allows the multiblock to function as a Compressor, a Lathe or an Electro-Magnet. To allow a hatch to run in Compressor mode, insert a No. 20 circuit. For Lathe, use No. 21 and for Electro-Magnet use No. 22.", + "[Fluid Work] Mode B - Allows the multiblock to function as a Fermenter, a Fluid Extractor or an Extractor. To allow a hatch to run in Fermenter mode, insert a No. 20 circuit. For Fluid Extractor, use No. 21 and for Extractor use No. 22.", + "[Misc. Work] Mode C - Allows the multiblock to function as a Laser Engraver, an Autoclave or a Fluid Solidifier. To allow a hatch to run in Laser Engraver mode, insert a No. 20 circuit. For Autoclave, use No. 21 and for Solidifier use No. 22.", + }); + } @@ -189,6 +202,7 @@ public class BookHandler { public static ItemStack ItemBookWritten_ModularBaubles; public static ItemStack ItemBookWritten_MultiPowerStorage; public static ItemStack ItemBookWritten_MultiMachineManual; + public static ItemStack ItemBookWritten_MultiChemicalPlant; public static void runLater(){ ItemBookWritten_ThermalBoiler = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 0, 1); @@ -196,12 +210,14 @@ public class BookHandler { ItemBookWritten_ModularBaubles = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 2, 1); ItemBookWritten_MultiMachineManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 3, 1); ItemBookWritten_NuclearManual = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 4, 1); + ItemBookWritten_MultiChemicalPlant = ItemUtils.simpleMetaStack(ModItems.itemCustomBook, 5, 1); //Multiblock Manuals RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getSimpleStack(Items.lava_bucket)}, ItemBookWritten_ThermalBoiler); RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict(CI.craftingToolWrench, 1)}, ItemBookWritten_MultiMachineManual); RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Tin", 1)}, ItemBookWritten_MultiPowerStorage); RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("dustUranium", 1)}, ItemBookWritten_NuclearManual); + RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{ItemUtils.getSimpleStack(Items.writable_book), ItemUtils.getItemStackOfAmountFromOreDict("wireGt01Copper", 1)}, ItemBookWritten_MultiChemicalPlant); } private static BookTemplate writeBookTemplate(String aMapping, String aTitle, String aAuthor, String[] aPages){ diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 542403bbcb..827b7d5b8f 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -56,6 +56,7 @@ public class GuiHandler implements IGuiHandler { public static final int GUI15 = 14; // Pest Killer public static final int GUI16 = 15; // Round-Robinator public static final int GUI17 = 16; // Egg Box + public static final int GUI18 = 17; // Volumetric Flask Setter public static void init() { @@ -108,6 +109,8 @@ public class GuiHandler implements IGuiHandler { return new Container_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); } else if (ID == GUI17) { return new Container_EggBox(player.inventory, (TileEntityEggBox) te); + } else if (ID == GUI18) { + return new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te); } } @@ -172,7 +175,9 @@ public class GuiHandler implements IGuiHandler { return new GUI_RoundRobinator(player.inventory, (TileEntityRoundRobinator) te); } else if (ID == GUI17) { return new GUI_EggBox(player.inventory, (TileEntityEggBox) te); - } + } else if (ID == GUI18) { + return new GUI_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te); + } } if (ID == GUI9) { diff --git a/src/Java/gtPlusPlus/core/handler/PacketHandler.java b/src/Java/gtPlusPlus/core/handler/PacketHandler.java index 2b9d424b32..382b82df29 100644 --- a/src/Java/gtPlusPlus/core/handler/PacketHandler.java +++ b/src/Java/gtPlusPlus/core/handler/PacketHandler.java @@ -1,69 +1,91 @@ package gtPlusPlus.core.handler; -import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.simpleimpl.*; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; - +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.network.handler.AbstractClientMessageHandler; +import gtPlusPlus.core.network.packet.AbstractPacket; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui; +import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui2; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import io.netty.buffer.ByteBuf; - public class PacketHandler { - - public static SimpleNetworkWrapper packetLightning; - public PacketHandler(){ - packetLightning = NetworkRegistry.INSTANCE.newSimpleChannel("gtpp_Lightning"); - packetLightning.registerMessage(Packet_Lightning_Handler.class, Packet_Lightning.class, 0, Side.SERVER); + private static byte packetId = 0; + + private static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(CORE.MODID); + + public static final void init() { + registerMessage(Packet_VolumetricFlaskGui.class, Packet_VolumetricFlaskGui.class); + registerMessage(Packet_VolumetricFlaskGui2.class, Packet_VolumetricFlaskGui2.class); } - - - /** - * Internal Packet Handlers - * @author Alkalus - * + * Registers a message and message handler */ + private static final void registerMessage(Class handlerClass, Class messageClass) { + Side side = AbstractClientMessageHandler.class.isAssignableFrom(handlerClass) ? Side.CLIENT : Side.SERVER; + registerMessage(handlerClass, messageClass, side); + } - private class Packet_Lightning implements IMessage{ - - public void sendTo(IMessage msg, EntityPlayerMP player){ - packetLightning.sendTo(msg, player); + private static final void registerMessage(Class handlerClass, Class messageClass, Side side) { + INSTANCE.registerMessage(handlerClass, messageClass, packetId++, side); + if (AbstractPacket.class.isInstance(messageClass.getClass())) { + AbstractPacket aPacket = ReflectionUtils.createNewInstanceFromConstructor(ReflectionUtils.getConstructor(messageClass, new Class[] {}), new Object[] {}); + if (aPacket != null) { + Logger.INFO("Registered Packet: "+aPacket.getPacketName()); + } } - - public void sendToServer(String string){ - packetLightning.sendToServer(new Packet_Lightning(string)); - } - - private String text; + } + + /** + * Send this message to the specified player. + * See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} + */ + public static final void sendTo(IMessage message, EntityPlayerMP player) { + INSTANCE.sendTo(message, player); + } + + /** + * Send this message to everyone within a certain range of a point. + * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, NetworkRegistry.TargetPoint)} + */ + public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { + INSTANCE.sendToAllAround(message, point); + } - public Packet_Lightning(String text) { - this.text = text; - } + /** + * Sends a message to everyone within a certain range of the coordinates in the same dimension. + */ + public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { + sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); + } - @Override - public void fromBytes(ByteBuf buf) { - text = ByteBufUtils.readUTF8String(buf); // this class is very useful in general for writing more complex objects - } + /** + * Sends a message to everyone within a certain range of the player provided. + */ + public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { + sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); + } - @Override - public void toBytes(ByteBuf buf) { - ByteBufUtils.writeUTF8String(buf, text); - } - + /** + * Send this message to everyone within the supplied dimension. + * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)} + */ + public static final void sendToDimension(IMessage message, int dimensionId) { + INSTANCE.sendToDimension(message, dimensionId); } - - private class Packet_Lightning_Handler implements IMessageHandler{ - @Override - public IMessage onMessage(Packet_Lightning message, MessageContext ctx) { - System.out.println(String.format("Received %s from %s", message.text, ctx.getServerHandler().playerEntity.getDisplayName())); - return null; // no response in this case - } - + /** + * Send this message to the server. + * See {@link SimpleNetworkWrapper#sendToServer(IMessage)} + */ + public static final void sendToServer(IMessage message) { + INSTANCE.sendToServer(message); } - - } diff --git a/src/Java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java new file mode 100644 index 0000000000..9bc9d3aa59 --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java @@ -0,0 +1,173 @@ +package gtPlusPlus.core.inventories; + +import gtPlusPlus.core.slots.SlotIntegratedCircuit; +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; + +public class Inventory_VolumetricFlaskSetter implements IInventory{ + + private final String name = "Circuit Programmer"; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 26; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private ItemStack[] inventory = new ItemStack[INV_SIZE]; + + public void readFromNBT(final NBTTagCompound nbt){ + final NBTTagList list = nbt.getTagList("Items", 10); + this.inventory = new ItemStack[INV_SIZE]; + for(int i = 0;i= 0) && (slot < INV_SIZE)){ + //Utils.LOG_INFO("Trying to read NBT data from inventory."); + this.inventory[slot] = ItemStack.loadItemStackFromNBT(data); + } + } + } + + public void writeToNBT(final NBTTagCompound nbt){ + final NBTTagList list = new NBTTagList(); + for(int i = 0;i 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 64; + } + + /** + * 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) + { + final ItemStack temp = this.getStackInSlot(i); + if (temp != null){ + //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize); + } + + if ((temp != null) && (temp.stackSize == 0)) { + this.inventory[i] = null; + } + } + } + + @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) { + return SlotIntegratedCircuit.isItemValidForSlot(itemstack); + } + +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java index 15782c20aa..f9f271ee39 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBasicTile.java @@ -53,12 +53,9 @@ public class ItemBlockBasicTile extends ItemBlock { } else if (this.mID == 7) { // Egg Box list.add("A box for holding big eggs"); - list.add("Items which decay will tick while inside"); - list.add("Place with right click"); - } - else if (this.mID == 8){ - + else if (this.mID == 8){ // Volumetric Flask Setter + list.add("Easy Flask Configuration"); } else if (this.mID == 9){ diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java index 2d0fd00dd9..7a4222ed0f 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockRoundRobinator.java @@ -107,4 +107,9 @@ public class ItemBlockRoundRobinator extends ItemBlockWithMetadata public int getItemEnchantability(ItemStack stack) { return 0; } + + @Override + public boolean getHasSubtypes() { + return true; + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java b/src/Java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java new file mode 100644 index 0000000000..b7ced2f7e9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/network/handler/AbstractClientMessageHandler.java @@ -0,0 +1,13 @@ +package gtPlusPlus.core.network.handler; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import net.minecraft.entity.player.EntityPlayer; + +public abstract class AbstractClientMessageHandler extends AbstractMessageHandler { + + public final IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx) { + return null; + } + +} diff --git a/src/Java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java b/src/Java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java new file mode 100644 index 0000000000..ca350f220f --- /dev/null +++ b/src/Java/gtPlusPlus/core/network/handler/AbstractMessageHandler.java @@ -0,0 +1,37 @@ +package gtPlusPlus.core.network.handler; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.GTplusplus; +import net.minecraft.entity.player.EntityPlayer; + +public abstract class AbstractMessageHandler implements IMessageHandler +{ + /** + * Handle a message received on the client side + * @return a message to send back to the Server, or null if no reply is necessary + */ + @SideOnly(Side.CLIENT) + public abstract IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx); + + /** + * Handle a message received on the server side + * @return a message to send back to the Client, or null if no reply is necessary + */ + public abstract IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx); + + @Override + public IMessage onMessage(T message, MessageContext ctx) { + if (ctx.side.isClient()) { + return handleClientMessage(GTplusplus.proxy.getPlayerEntity(ctx), message, ctx); + } else { + // server side proxy will return the server side EntityPlayer + return handleServerMessage(GTplusplus.proxy.getPlayerEntity(ctx), message, ctx); + } + } + + +} diff --git a/src/Java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java b/src/Java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java new file mode 100644 index 0000000000..d49e6cf350 --- /dev/null +++ b/src/Java/gtPlusPlus/core/network/handler/AbstractServerMessageHandler.java @@ -0,0 +1,13 @@ +package gtPlusPlus.core.network.handler; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import net.minecraft.entity.player.EntityPlayer; + +public abstract class AbstractServerMessageHandler extends AbstractMessageHandler { + + public final IMessage handleClientMessage(EntityPlayer player, T message, MessageContext ctx) { + return null; + } + +} diff --git a/src/Java/gtPlusPlus/core/network/packet/AbstractPacket.java b/src/Java/gtPlusPlus/core/network/packet/AbstractPacket.java new file mode 100644 index 0000000000..d6368e3d9e --- /dev/null +++ b/src/Java/gtPlusPlus/core/network/packet/AbstractPacket.java @@ -0,0 +1,9 @@ +package gtPlusPlus.core.network.packet; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; + +public interface AbstractPacket extends IMessage { + + public abstract String getPacketName(); + +} diff --git a/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java b/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java new file mode 100644 index 0000000000..7f13976d87 --- /dev/null +++ b/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java @@ -0,0 +1,128 @@ +package gtPlusPlus.core.network.packet; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.network.handler.AbstractServerMessageHandler; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Packet_VolumetricFlaskGui extends AbstractServerMessageHandler implements AbstractPacket { + + private int x; + private int y; + private int z; + private int flaskValue; + + public Packet_VolumetricFlaskGui() { + + } + + public Packet_VolumetricFlaskGui(TileEntityVolumetricFlaskSetter tile, int aCustomValue) { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + flaskValue = aCustomValue; + Logger.INFO("Created Packet with values ("+x+", "+y+", "+z+" | "+flaskValue+")"); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + buf.writeInt(flaskValue); + Logger.INFO("Writing to byte buffer."); + } + + @Override + public void fromBytes(ByteBuf buf) { + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + flaskValue = buf.readInt(); + Logger.INFO("Reading from byte buffer."); + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getZ() { + return z; + } + + public void setZ(int z) { + this.z = z; + } + + public int getCustomValue() { + return flaskValue; + } + + public void setCustomValue(int aVal) { + this.flaskValue = aVal; + } + + protected TileEntityVolumetricFlaskSetter getTileEntity(Packet_VolumetricFlaskGui message, MessageContext ctx) { + Logger.INFO("Trying to get tile."); + World worldObj = getWorld(ctx); + if(worldObj == null) { + Logger.INFO("Bad world object."); + return null; + } + TileEntity te = worldObj.getTileEntity(message.getX(), message.getY(), message.getZ()); + if(te == null) { + Logger.INFO("Bad Tile."); + return null; + } + if(te instanceof TileEntityVolumetricFlaskSetter) { + Logger.INFO("Found Tile."); + return (TileEntityVolumetricFlaskSetter) te; + } + Logger.INFO("Error."); + return null; + } + + protected World getWorld(MessageContext ctx) { + if(ctx.side == Side.SERVER) { + return ctx.getServerHandler().playerEntity.worldObj; + } else { + return GTplusplus.proxy.getClientWorld(); + } + } + + @Override + public IMessage handleServerMessage(EntityPlayer player, Packet_VolumetricFlaskGui message, MessageContext ctx) { + TileEntityVolumetricFlaskSetter te = getTileEntity(message, ctx); + if(te != null) { + Logger.INFO("Setting value on tile. "+message.getCustomValue()); + te.setCustomValue(message.getCustomValue()); + return new Packet_VolumetricFlaskGui2(te, message.getCustomValue()); + } + return null; + } + + @Override + public String getPacketName() { + return "Packet_VoluemtricFlaskSetter_ToServer"; + } + +} diff --git a/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java b/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java new file mode 100644 index 0000000000..bc6e6149d8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui2.java @@ -0,0 +1,127 @@ +package gtPlusPlus.core.network.packet; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.network.handler.AbstractClientMessageHandler; +import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Packet_VolumetricFlaskGui2 extends AbstractClientMessageHandler implements AbstractPacket { + + private int x; + private int y; + private int z; + private int flaskValue; + + public Packet_VolumetricFlaskGui2() { + + } + + public Packet_VolumetricFlaskGui2(TileEntityVolumetricFlaskSetter tile, int aCustomValue) { + x = tile.xCoord; + y = tile.yCoord; + z = tile.zCoord; + flaskValue = aCustomValue; + Logger.INFO("Created Packet with values ("+x+", "+y+", "+z+" | "+flaskValue+")"); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + buf.writeInt(flaskValue); + Logger.INFO("Writing to byte buffer."); + } + + @Override + public void fromBytes(ByteBuf buf) { + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + flaskValue = buf.readInt(); + Logger.INFO("Reading from byte buffer."); + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getZ() { + return z; + } + + public void setZ(int z) { + this.z = z; + } + + public int getCustomValue() { + return flaskValue; + } + + public void setCustomValue(int aVal) { + this.flaskValue = aVal; + } + + protected TileEntityVolumetricFlaskSetter getTileEntity(Packet_VolumetricFlaskGui2 message, MessageContext ctx) { + Logger.INFO("Trying to get tile."); + World worldObj = getWorld(ctx); + if(worldObj == null) { + Logger.INFO("Bad world object."); + return null; + } + TileEntity te = worldObj.getTileEntity(message.getX(), message.getY(), message.getZ()); + if(te == null) { + Logger.INFO("Bad Tile."); + return null; + } + if(te instanceof TileEntityVolumetricFlaskSetter) { + Logger.INFO("Found Tile."); + return (TileEntityVolumetricFlaskSetter) te; + } + Logger.INFO("Error."); + return null; + } + + protected World getWorld(MessageContext ctx) { + if(ctx.side == Side.SERVER) { + return ctx.getServerHandler().playerEntity.worldObj; + } else { + return GTplusplus.proxy.getClientWorld(); + } + } + + @Override + public String getPacketName() { + return "Packet_VoluemtricFlaskSetter_ToClient"; + } + + @Override + public IMessage handleClientMessage(EntityPlayer player, Packet_VolumetricFlaskGui2 message, MessageContext ctx) { + TileEntityVolumetricFlaskSetter te = getTileEntity(message, ctx); + if(te != null) { + Logger.INFO("Setting value on tile. "+message.getCustomValue()); + te.setCustomValue(message.getCustomValue()); + } + return null; + } + +} diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java index 5344a46407..1cef8a789a 100644 --- a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -1,10 +1,12 @@ package gtPlusPlus.core.proxy; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.GTplusplus; @@ -15,7 +17,6 @@ import gtPlusPlus.australia.entity.model.ModelDingo; import gtPlusPlus.australia.entity.model.ModelOctopus; import gtPlusPlus.australia.entity.render.*; import gtPlusPlus.australia.entity.type.*; -import gtPlusPlus.core.client.model.ModelEggBox; import gtPlusPlus.core.client.model.ModelGiantChicken; import gtPlusPlus.core.client.renderer.*; import gtPlusPlus.core.common.CommonProxy; @@ -29,7 +30,6 @@ import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE.ConfigSwitches; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; -import gtPlusPlus.core.tileentities.general.TileEntityEggBox; import gtPlusPlus.core.tileentities.general.TileEntityFirepit; import gtPlusPlus.core.util.minecraft.particles.EntityParticleFXMysterious; import gtPlusPlus.xmod.gregtech.common.render.GTPP_CapeRenderer; @@ -39,7 +39,9 @@ import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.entity.RenderFireball; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.world.World; import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; @@ -143,20 +145,20 @@ public class ClientProxy extends CommonProxy implements Runnable{ RenderingRegistry.registerEntityRenderingHandler(EntityBoar.class, new RenderBoar(new ModelBoar(), new ModelBoar(0.5F), 0.7F)); RenderingRegistry.registerEntityRenderingHandler(EntityDingo.class, new RenderDingo(new ModelDingo(), new ModelDingo(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityOctopus.class, new RenderOctopus(new ModelOctopus(), 0.7F)); - - - - - - - + + + + + + + /** * Items */ for (Pair sItemRenderMappings : mItemRenderMappings) { MinecraftForgeClient.registerItemRenderer(sItemRenderMappings.getKey(), sItemRenderMappings.getValue()); } - + } @Override @@ -250,4 +252,14 @@ public class ClientProxy extends CommonProxy implements Runnable{ super.onLoadComplete(event); } + @Override + public World getClientWorld() { + return FMLClientHandler.instance().getClient().theWorld; + } + + @Override + public EntityPlayer getPlayerEntity(MessageContext ctx) { + return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); + } + } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 5048c5f2a5..ce2d7bb105 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -63,14 +63,14 @@ public class RECIPES_General { private static void run() { //Workbench Blueprint - /*RecipeUtils.recipeBuilder( + /*RecipeUtils.addShapedRecipe( RECIPE_Paper, RECIPE_LapisDust, NULL, RECIPE_Paper, RECIPE_LapisDust, NULL, RECIPE_LapisDust, RECIPE_LapisDust, NULL, OUTPUT_Blueprint);*/ //Bronze Workbench - /*RecipeUtils.recipeBuilder( + /*RecipeUtils.addShapedRecipe( RECIPE_BronzePlate, RECIPE_CraftingTable, RECIPE_BronzePlate, RECIPE_BronzePlate, RECIPE_BasicCasingIC2, RECIPE_BronzePlate, RECIPE_BronzePlate, RECIPE_BronzePlate, RECIPE_BronzePlate, @@ -79,25 +79,25 @@ public class RECIPES_General { //Generates recipes for the Dull shard when TC is not installed. if (!LoadedMods.Thaumcraft) { //Dull Shard to Aer - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( RECIPE_HydrogenDust, RECIPE_HydrogenDust, RECIPE_HydrogenDust, RECIPE_HydrogenDust, ItemUtils.getSimpleStack(ModItems.shardDull), RECIPE_HydrogenDust, RECIPE_HydrogenDust, RECIPE_HydrogenDust, RECIPE_HydrogenDust, ItemUtils.getSimpleStack(ModItems.shardAer)); //Dull Shard to Ignis - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( RECIPE_Obsidian, RECIPE_Obsidian, RECIPE_Obsidian, RECIPE_Obsidian, ItemUtils.getSimpleStack(ModItems.shardDull), RECIPE_Obsidian, RECIPE_Obsidian, RECIPE_Obsidian, RECIPE_Obsidian, ItemUtils.getSimpleStack(ModItems.shardIgnis)); //Dull Shard to Terra - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( RECIPE_Dirt, RECIPE_Dirt, RECIPE_Dirt, RECIPE_Dirt, ItemUtils.getSimpleStack(ModItems.shardDull), RECIPE_Dirt, RECIPE_Dirt, RECIPE_Dirt, RECIPE_Dirt, ItemUtils.getSimpleStack(ModItems.shardTerra)); //Dull Shard to Aqua - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( RECIPE_LapisDust, RECIPE_LapisDust, RECIPE_LapisDust, RECIPE_LapisDust, ItemUtils.getSimpleStack(ModItems.shardDull), RECIPE_LapisDust, RECIPE_LapisDust, RECIPE_LapisDust, RECIPE_LapisDust, @@ -111,7 +111,7 @@ public class RECIPES_General { } //Rainforest oak Sapling - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "stickWood", "stickWood", "stickWood", "stickWood", "treeSapling", "stickWood", "stickWood", "dustBone", "stickWood", @@ -128,7 +128,7 @@ public class RECIPES_General { } //Fish Trap - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( ironBars, ironBars, ironBars, ironBars, "frameGtWroughtIron", ironBars, ironBars, ironBars, ironBars, @@ -145,7 +145,7 @@ public class RECIPES_General { for (int y=0;y aValidSlots = new AutoMap(); + int aSlotCount = 0; + for (ItemStack i : aInputs) { + if (i != null) { + aValidSlots.put(aSlotCount); + } + aSlotCount++; + } + for (int e : aValidSlots) { + boolean doAdd = false; + ItemStack g = this.getStackInSlot(e); + int aSize = 0; + ItemStack aInputStack = null; + int aTypeInSlot = 0; + if (aTypeInSlot >= 0 && g != null) { + // No Existing Output + if (!hasOutput) { + aSize = g.stackSize; + doAdd = true; + } + // Existing Output + else { + ItemStack f = this.getStackInSlot(8); + int aTypeInCheckedSlot = 0; + // Check that the Circuit in the Output slot is not null and the same type as the circuit input. + if (aTypeInCheckedSlot >= 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { + if (g.getItem() == f.getItem() && f.getItemDamage() == e) { + aSize = f.stackSize + g.stackSize; + if (aSize > 64) { + aInputStack = g.copy(); + aInputStack.stackSize = (aSize-64); + } + doAdd = true; + } + } + } + if (doAdd) { + // Check Circuit Type + ItemStack aOutput; + if (aTypeInSlot == 0) { + aOutput = VolumetricFlaskHelper.getVolumetricFlask(1); + } + else { + aOutput = null; + } + if (aOutput != null) { + aOutput.stackSize = aSize; + switch (e) { + case 0: //16 + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 16); + break; + case 1: //36 + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 36); + break; + case 2: //144 + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 144); + break; + case 3: //432 + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 432); + break; + case 4: //576 + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 576); + break; + case 5: //720 + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 720); + break; + case 6: //864 + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 864); + break; + case 7: //Custom + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, getCustomValue()); + break; + } + + this.setInventorySlotContents(e, aInputStack); + this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput); + return true; + } + } + } + continue; + } + return false; + } + + @Override + public void updateEntity() { + try{ + if (!this.worldObj.isRemote) { + if (tickCount % 10 == 0) { + if (hasFlask()) { + this.addOutput(); + this.markDirty(); + } + } + this.tickCount++; + } + } + catch (final Throwable t){} + } + + public boolean anyPlayerInRange() { + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) { + if (!nbt.hasKey(tag)) { + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound nbt) { + super.writeToNBT(nbt); + // Utils.LOG_WARNING("Trying to write NBT data to TE."); + final NBTTagCompound chestData = new NBTTagCompound(); + this.inventoryContents.writeToNBT(chestData); + nbt.setTag("ContentsChest", chestData); + nbt.setInteger("aCustomValue", aCustomValue); + if (this.hasCustomInventoryName()) { + nbt.setString("CustomName", this.getCustomName()); + } + nbt.setInteger("aCurrentMode", aCurrentMode); + } + + @Override + public void readFromNBT(final NBTTagCompound nbt) { + super.readFromNBT(nbt); + // Utils.LOG_WARNING("Trying to read NBT data from TE."); + this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest")); + this.aCustomValue = nbt.getInteger("aCustomValue"); + if (nbt.hasKey("CustomName", 8)) { + this.setCustomName(nbt.getString("CustomName")); + } + aCurrentMode = nbt.getInteger("aCurrentMode"); + } + + @Override + public int getSizeInventory() { + return this.getInventory().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(final int slot) { + return this.getInventory().getStackInSlot(slot); + } + + @Override + public ItemStack decrStackSize(final int slot, final int count) { + return this.getInventory().decrStackSize(slot, count); + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) { + return this.getInventory().getStackInSlotOnClosing(slot); + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) { + this.getInventory().setInventorySlotContents(slot, stack); + } + + @Override + public int getInventoryStackLimit() { + return this.getInventory().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { + return this.getInventory().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + 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(); + } + + @Override + public void closeInventory() { + 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(); + } + + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { + return this.getInventory().isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; + for (int r=0; r= 0 && p_102007_1_ <= 24; + } + + @Override + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { + return p_102008_1_ == 25; + } + + public String getCustomName() { + return this.customName; + } + + public void setCustomName(final String customName) { + this.customName = customName; + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.VolumetricFlaskSetter"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && !this.customName.equals(""); + } + + @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); + } + + public boolean onScrewdriverRightClick(byte side, EntityPlayer player, int x, int y, int z) { + + if (player.isSneaking()) { + PlayerUtils.messagePlayer(player, "Value: "+this.getCustomValue()); + } + + try { + if (aCurrentMode == 7) { + aCurrentMode = 0; + } + else { + aCurrentMode++; + } + PlayerUtils.messagePlayer(player, "Slot "+aCurrentMode+" is now default."); + return true; + } + catch (Throwable t) { + return false; + } + } + +} diff --git a/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java b/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java index 6f5bb5b453..c9c8d26744 100644 --- a/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/ArrayUtils.java @@ -31,6 +31,13 @@ public class ArrayUtils { return r.get(); }*/ + + public static Object[] removeNulls(final Object[] v) { + List list = new ArrayList(Arrays.asList(v)); + list.removeAll(Collections.singleton((Object)null)); + return list.toArray(new Object[list.size()]); + } + public static ItemStack[] removeNulls(final ItemStack[] v) { List list = new ArrayList(Arrays.asList(v)); list.removeAll(Collections.singleton((ItemStack)null)); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 70b635583d..3f939e6b4e 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -453,7 +453,7 @@ public class ItemUtils { if (ItemUtils.checkForInvalidItems(tinyDust) && ItemUtils.checkForInvalidItems(normalDust)) { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, @@ -464,7 +464,7 @@ public class ItemUtils { Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+materialName+" - Failed"); } - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( normalDust, null, null, null, null, null, null, null, null, @@ -477,7 +477,7 @@ public class ItemUtils { } if (ItemUtils.checkForInvalidItems(smallDust) && ItemUtils.checkForInvalidItems(normalDust)) { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( smallDust, smallDust, null, smallDust, smallDust, null, null, null, null, @@ -487,7 +487,7 @@ public class ItemUtils { else { Logger.WARNING("4 Small dust to 1 Dust Recipe: "+materialName+" - Failed"); } - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( null, normalDust, null, null, null, null, null, null, null, diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index 56772f0dc7..9c3ea3ab86 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -6,11 +6,8 @@ import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.Materials; -import gregtech.api.interfaces.internal.IGT_CraftingRecipe; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.RunnableWithInfo; @@ -20,9 +17,11 @@ import gtPlusPlus.api.objects.minecraft.ShapedRecipe; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; -import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.data.ArrayUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; @@ -38,15 +37,15 @@ public static int mInvalidID = 1; //Old Debug Code, useful for finding recipes loading too early. /*if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { - Logger.INFO(ReflectionUtils.getMethodName(1)); - Logger.INFO(ReflectionUtils.getMethodName(2)); - Logger.INFO(ReflectionUtils.getMethodName(3)); - Logger.INFO(ReflectionUtils.getMethodName(4)); - Logger.INFO(ReflectionUtils.getMethodName(5)); - Logger.INFO(ReflectionUtils.getMethodName(6)); - Logger.INFO(ReflectionUtils.getMethodName(7)); - Logger.INFO(ReflectionUtils.getMethodName(8)); - Logger.INFO(ReflectionUtils.getMethodName(9)); + Logger.RECIPE(ReflectionUtils.getMethodName(1)); + Logger.RECIPE(ReflectionUtils.getMethodName(2)); + Logger.RECIPE(ReflectionUtils.getMethodName(3)); + Logger.RECIPE(ReflectionUtils.getMethodName(4)); + Logger.RECIPE(ReflectionUtils.getMethodName(5)); + Logger.RECIPE(ReflectionUtils.getMethodName(6)); + Logger.RECIPE(ReflectionUtils.getMethodName(7)); + Logger.RECIPE(ReflectionUtils.getMethodName(8)); + Logger.RECIPE(ReflectionUtils.getMethodName(9)); System.exit(1); }*/ @@ -348,15 +347,15 @@ public static int mInvalidID = 1; if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { - Logger.INFO(ReflectionUtils.getMethodName(1)); - Logger.INFO(ReflectionUtils.getMethodName(2)); - Logger.INFO(ReflectionUtils.getMethodName(3)); - Logger.INFO(ReflectionUtils.getMethodName(4)); - Logger.INFO(ReflectionUtils.getMethodName(5)); - Logger.INFO(ReflectionUtils.getMethodName(6)); - Logger.INFO(ReflectionUtils.getMethodName(7)); - Logger.INFO(ReflectionUtils.getMethodName(8)); - Logger.INFO(ReflectionUtils.getMethodName(9)); + Logger.RECIPE(ReflectionUtils.getMethodName(1)); + Logger.RECIPE(ReflectionUtils.getMethodName(2)); + Logger.RECIPE(ReflectionUtils.getMethodName(3)); + Logger.RECIPE(ReflectionUtils.getMethodName(4)); + Logger.RECIPE(ReflectionUtils.getMethodName(5)); + Logger.RECIPE(ReflectionUtils.getMethodName(6)); + Logger.RECIPE(ReflectionUtils.getMethodName(7)); + Logger.RECIPE(ReflectionUtils.getMethodName(8)); + Logger.RECIPE(ReflectionUtils.getMethodName(9)); System.exit(1); } @@ -517,6 +516,9 @@ public static int mInvalidID = 1; else if (o instanceof Item) { aFiltered[aValid++] = ItemUtils.getSimpleStack((Item) o); } + else if (o instanceof Block) { + aFiltered[aValid++] = ItemUtils.getSimpleStack((Block) o); + } else if (o instanceof String) { aFiltered[aValid++] = o; } @@ -536,6 +538,9 @@ public static int mInvalidID = 1; else if (p instanceof Item) { validCounter++; } + else if (p instanceof Block) { + validCounter++; + } else if (p instanceof String) { validCounter++; } @@ -643,6 +648,148 @@ public static int mInvalidID = 1; } + public static boolean addShapedRecipe( + Object Input_1, Object Input_2, Object Input_3, + Object Input_4, Object Input_5, Object Input_6, + Object Input_7, Object Input_8, Object Input_9, + ItemStack aOutputStack) { + return addShapedRecipe(new Object[] {Input_1, Input_2, Input_3, Input_4, Input_5, Input_6, Input_7, Input_8, Input_9}, aOutputStack); + } + + private static boolean addShapedRecipe(Object[] Inputs, ItemStack aOutputStack) { + Object[] Slots = new Object[9]; + + String aFullString = ""; + String aFullStringExpanded = "abcdefghi"; + + for (int i=0; i<9; i++) { + Object o = Inputs[i]; + + if (o instanceof ItemStack) { + Slots[i] = ItemUtils.getSimpleStack((ItemStack) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } + else if (o instanceof Item) { + Slots[i] = ItemUtils.getSimpleStack((Item) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } + else if (o instanceof Block) { + Slots[i] = ItemUtils.getSimpleStack((Block) o, 1); + aFullString += aFullStringExpanded.charAt(i); + } + else if (o instanceof String) { + Slots[i] = o; + aFullString += aFullStringExpanded.charAt(i); + } + else if (o instanceof ItemData) { + ItemData aData = (ItemData) o; + ItemStack aStackFromGT = ItemUtils.getOrePrefixStack(aData.mPrefix, aData.mMaterial.mMaterial, 1); + Slots[i] = aStackFromGT; + aFullString += aFullStringExpanded.charAt(i); + } + else if (o == null) { + Slots[i] = null; + aFullString += " "; + } + else { + Slots[i] = null; + Logger.RECIPE("Cleaned a "+o.getClass().getSimpleName()+" from recipe input."); + Logger.RECIPE("ERROR"); + CORE.crash("Bad Shaped Recipe."); + } + } + Logger.RECIPE("Using String: "+aFullString); + + String aRow1 = aFullString.substring(0, 3); + String aRow2 = aFullString.substring(3, 6); + String aRow3 = aFullString.substring(6, 9); + Logger.RECIPE(""+aRow1); + Logger.RECIPE(""+aRow2); + Logger.RECIPE(""+aRow3); + + String[] aStringData = new String[] {aRow1, aRow2, aRow3}; + Object[] aDataObject = new Object[19]; + aDataObject[0] = aStringData; + int aIndex = 0; + for (int u=1;u<20;u+=2) { + if (aIndex == 9) { + break; + } + if (aFullString.charAt(aIndex) != (' ')) { + aDataObject[u] = aFullString.charAt(aIndex); + aDataObject[u+1] = Slots[aIndex]; + Logger.RECIPE("("+aIndex+") "+aFullString.charAt(aIndex)+" | "+ (Slots[aIndex] instanceof ItemStack ? ItemUtils.getItemName((ItemStack) Slots[aIndex]) : Slots[aIndex] instanceof String ? (String) Slots[aIndex] : "Unknown")); + aIndex++; + } + } + + Logger.RECIPE("Data Size: "+aDataObject.length); + aDataObject = ArrayUtils.removeNulls(aDataObject); + Logger.RECIPE("Clean Size: "+aDataObject.length); + + ShapedOreRecipe aRecipe = new ShapedOreRecipe(aOutputStack, aDataObject); + + /*ShapedOreRecipe aRecipe = new ShapedOreRecipe(aOutputStack, + aStringData, + 'a', Slots[0], + 'b', Slots[1], + 'c', Slots[2], + 'd', Slots[3], + 'e', Slots[4], + 'f', Slots[5], + 'g', Slots[6], + 'h', Slots[7], + 'i', Slots[8]);*/ + + int size = COMPAT_HANDLER.mRecipesToGenerate.size(); + COMPAT_HANDLER.mRecipesToGenerate.put(new InternalRecipeObject2(aRecipe)); + if (COMPAT_HANDLER.mRecipesToGenerate.size() > size) { + if (!COMPAT_HANDLER.areInitItemsLoaded){ + RegistrationHandler.recipesSuccess++; + } + else { + LateRegistrationHandler.recipesSuccess++; + } + return true; + } + return false; + } + public static class InternalRecipeObject2 implements RunnableWithInfo { + + final ItemStack mOutput; + final ShapedOreRecipe mRecipe; + final boolean isValid; + + public InternalRecipeObject2(ShapedOreRecipe aRecipe) { + mRecipe = aRecipe; + mOutput = aRecipe.getRecipeOutput(); + if (mOutput != null) { + this.isValid = true; + } + else { + this.isValid = false; + } + } + + @Override + public void run() { + if (this.isValid) { + GameRegistry.addRecipe(mRecipe); + } + else { + Logger.RECIPE("[Fix] Invalid shapped recipe outputting "+mOutput != null ? mOutput.getDisplayName() : "Bad Output Item"); + } + } + + @Override + public String getInfoData() { + if (mOutput != null && mOutput instanceof ItemStack) { + return ((ItemStack) mOutput).getDisplayName(); + } + return ""; + } + + } } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java index 7e011a808e..ddc401f752 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java @@ -75,25 +75,25 @@ public class FR_Gregtech_Recipes { if (!LoadedMods.ExtraBees){ //Extra Bee Like Frames - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( null, itemCocoaBeans, null, itemCocoaBeans, hiveFrameImpregnated, itemCocoaBeans, null, itemCocoaBeans, null, hiveFrameCocoa); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( hiveFrameImpregnated, blockIronBars, null, null, null, null, null, null, null, hiveFrameCaged); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( hiveFrameImpregnated, blockSoulSand, null, null, null, null, null, null, null, hiveFrameSoul); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( null, itemClayDust, null, itemClayDust, hiveFrameImpregnated, itemClayDust, null, itemClayDust, null, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 88c1fc8c15..2286d95d3a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -3,10 +3,7 @@ package gtPlusPlus.xmod.gregtech.common; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import org.apache.commons.lang3.ArrayUtils; @@ -15,29 +12,19 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.TAE; +import gregtech.api.enums.*; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.*; import gregtech.common.GT_Proxy; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; import gtPlusPlus.core.handler.AchievementHandler; -import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.LangUtils; -import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.*; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; @@ -62,6 +49,7 @@ public class Meta_GT_Proxy { static { Logger.INFO("GT_PROXY - initialized."); + sDoesVolumetricFlaskExist = ReflectionUtils.doesClassExist("gregtech.common.items.GT_VolumetricFlask"); } public static List GT_BlockIconload = new ArrayList<>(); @@ -76,6 +64,10 @@ public class Meta_GT_Proxy { public static final Map mCustomGregtechMetaTooltips = new LinkedHashMap(); + /** + * Does this feature exist within GT? Saves loading useless content if not. + */ + public static final boolean sDoesVolumetricFlaskExist; @SideOnly(Side.CLIENT) public static IIconRegister sBlockIcons, sItemIcons; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java new file mode 100644 index 0000000000..76bb378377 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -0,0 +1,81 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.lang.reflect.Method; + +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class VolumetricFlaskHelper { + + private static final Class sClassVolumetricFlask; + private static final Method sMethodGetFlaskMaxCapacity; + private static Item mFlask; + + static { + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + sClassVolumetricFlask = ReflectionUtils.getClass("gregtech.common.items.GT_VolumetricFlask"); + sMethodGetFlaskMaxCapacity = ReflectionUtils.getMethod(sClassVolumetricFlask, "getMaxCapacity", new Class[] {}); + } + else { + sClassVolumetricFlask = null; + sMethodGetFlaskMaxCapacity = null; + } + } + + public static ItemStack getVolumetricFlask(int aAmount) { + ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", aAmount, (ItemStack) null); + return aFlask; + } + + public static boolean isVolumetricFlask(ItemStack aStack) { + if (mFlask == null) { + ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null); + if (aFlask != null) { + mFlask = aFlask.getItem(); + } + } + if (aStack.getItem() == mFlask) { + return true; + } + return false; + } + + public static int getMaxFlaskCapacity(ItemStack aStack) { + if (aStack != null && sMethodGetFlaskMaxCapacity != null) { + Item aItem = aStack.getItem(); + if (sClassVolumetricFlask.isInstance(aItem)) { + int aMaxCapacity = (int) ReflectionUtils.invokeNonBool(aItem, sMethodGetFlaskMaxCapacity, new Object[] {}); + return aMaxCapacity; + } + } + return 0; + } + + public static int getFlaskCapacity(ItemStack aStack) { + int capacity = 1000; + if (aStack.hasTagCompound()) { + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt.hasKey("Capacity", 3)) + capacity = nbt.getInteger("Capacity"); + } + return Math.min(getMaxFlaskCapacity(aStack), capacity); + } + + public static boolean setNewFlaskCapacity(ItemStack aStack, int aCapacity) { + if (aStack == null || aCapacity <= 0) { + return false; + } + aCapacity = Math.min(aCapacity, getMaxFlaskCapacity(aStack)); + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt == null) { + aStack.setTagCompound(nbt = new NBTTagCompound()); + } + nbt.setInteger("Capacity", aCapacity); + return true; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java index bf4e9b1390..51316f024a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingAngleGrinder.java @@ -31,11 +31,7 @@ public class ProcessingAngleGrinder implements Interface_OreRecipeRegistrator, R if (aMaterial != Materials.Rubber) { if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) && (!aMaterial.contains(SubTag.NO_SMASHING))) { - GT_ModHandler.addCraftingRecipe( - MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(16, 1, aMaterial, aMaterial, null), - GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { "IhI", "III", " I ", Character.valueOf('I'), - OrePrefixes.ingot.get(aMaterial) }); + } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricButcherKnife.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricButcherKnife.java index e8f9f5129c..9fe9ad7816 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricButcherKnife.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricButcherKnife.java @@ -14,6 +14,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; @@ -32,11 +33,7 @@ public class ProcessingElectricButcherKnife implements Interface_OreRecipeRegist if (aMaterial != Materials.Rubber) { if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) && (!aMaterial.contains(SubTag.NO_SMASHING))) { - GT_ModHandler.addCraftingRecipe( - MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(16, 1, aMaterial, aMaterial, null), - GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { "IhI", "III", " I ", Character.valueOf('I'), - OrePrefixes.ingot.get(aMaterial) }); + } } } @@ -68,8 +65,9 @@ public class ProcessingElectricButcherKnife implements Interface_OreRecipeRegist final ItemStack plate = GT_OreDictUnificator.get(OrePrefixes.plate, aMaterial, 1L); + final ItemStack screw = GT_OreDictUnificator.get(OrePrefixes.screw, aMaterial, 1L); - if ((null != plate)) { + if ((null != plate) && screw != null) { addRecipe(aMaterial, 1600000L, 3, ItemList.Battery_RE_HV_Lithium.get(1)); addRecipe(aMaterial, 1200000L, 3, ItemList.Battery_RE_HV_Cadmium.get(1)); addRecipe(aMaterial, 800000L, 3, ItemList.Battery_RE_HV_Sodium.get(1)); @@ -97,7 +95,7 @@ public class ProcessingElectricButcherKnife implements Interface_OreRecipeRegist @Override public void run() { - Logger.INFO("Generating Electric Butcher Knifes for all valid GT Materials."); + Logger.INFO("Generating Electric Butcher Knives for all valid GT Materials."); this.materialsLoops(); } @@ -123,20 +121,13 @@ public class ProcessingElectricButcherKnife implements Interface_OreRecipeRegist return false; } - return GT_ModHandler.addCraftingRecipe( - aOutputStack, - RecipeBits.DISMANTLEABLE | RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | RecipeBits.BUFFERED, - new Object[]{ - "SXS", - "GMG", - "PBP", - 'X', aInputCutter, - 'M', CI.getElectricMotor(aVoltageTier, 1), - 'S', OrePrefixes.wireFine.get(Materials.Electrum), - 'P', OrePrefixes.plate.get(aMaterial), - 'G', ELEMENT.STANDALONE.WHITE_METAL.getGear(1), - 'B', aBattery - }); + + + return RecipeUtils.addShapedRecipe( + OrePrefixes.wireFine.get(Materials.Electrum), aInputCutter, OrePrefixes.wireFine.get(Materials.Electrum), + OrePrefixes.plate.get(aMaterial), CI.getElectricMotor(aVoltageTier, 1), OrePrefixes.plate.get(aMaterial), + OrePrefixes.screw.get(aMaterial), aBattery, OrePrefixes.screw.get(aMaterial), + aOutputStack); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricLighter.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricLighter.java index f3dc546191..5f6c5a0427 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricLighter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricLighter.java @@ -14,6 +14,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; @@ -32,11 +33,7 @@ public class ProcessingElectricLighter implements Interface_OreRecipeRegistrator if (aMaterial != Materials.Rubber) { if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) && (!aMaterial.contains(SubTag.NO_SMASHING))) { - GT_ModHandler.addCraftingRecipe( - MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(16, 1, aMaterial, aMaterial, null), - GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { "IhI", "III", " I ", Character.valueOf('I'), - OrePrefixes.ingot.get(aMaterial) }); + } } } @@ -123,20 +120,11 @@ public class ProcessingElectricLighter implements Interface_OreRecipeRegistrator return false; } - return GT_ModHandler.addCraftingRecipe( - aOutputStack, - RecipeBits.DISMANTLEABLE | RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | RecipeBits.BUFFERED, - new Object[]{ - "SXS", - "GMG", - "PBP", - 'X', aInputCutter, - 'M', CI.getSensor(aVoltageTier, 1), - 'S', OrePrefixes.wireGt04.get(Materials.Gold), - 'P', OrePrefixes.plate.get(aMaterial), - 'G', ELEMENT.STANDALONE.RUNITE.getPlate(1), - 'B', aBattery - }); + return RecipeUtils.addShapedRecipe( + OrePrefixes.wireGt04.get(Materials.Gold), aInputCutter, OrePrefixes.wireGt04.get(Materials.Gold), + ELEMENT.STANDALONE.RUNITE.getPlate(1), CI.getSensor(aVoltageTier, 1), ELEMENT.STANDALONE.RUNITE.getPlate(1), + OrePrefixes.plate.get(aMaterial), aBattery, OrePrefixes.plate.get(aMaterial), + aOutputStack); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricSnips.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricSnips.java index 9285dbc63d..dfcb7de4f8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricSnips.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingElectricSnips.java @@ -14,6 +14,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_OreRecipeRegistrator; @@ -32,11 +33,7 @@ public class ProcessingElectricSnips implements Interface_OreRecipeRegistrator, if (aMaterial != Materials.Rubber) { if ((!aMaterial.contains(SubTag.WOOD)) && (!aMaterial.contains(SubTag.BOUNCY)) && (!aMaterial.contains(SubTag.NO_SMASHING))) { - GT_ModHandler.addCraftingRecipe( - MetaGeneratedGregtechTools.INSTANCE.getToolWithStats(16, 1, aMaterial, aMaterial, null), - GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { "IhI", "III", " I ", Character.valueOf('I'), - OrePrefixes.ingot.get(aMaterial) }); + } } } @@ -97,7 +94,7 @@ public class ProcessingElectricSnips implements Interface_OreRecipeRegistrator, @Override public void run() { - Logger.INFO("Generating Electric Snipss for all valid GT Materials."); + Logger.INFO("Generating Electric Snips for all valid GT Materials."); this.materialsLoops(); } @@ -122,21 +119,11 @@ public class ProcessingElectricSnips implements Interface_OreRecipeRegistrator, Logger.MATERIALS("Unable to generate Electric Snips from "+MaterialUtils.getMaterialName(aMaterial)+", Durability: "+aDura); return false; } - - return GT_ModHandler.addCraftingRecipe( - aOutputStack, - RecipeBits.DISMANTLEABLE | RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | RecipeBits.BUFFERED, - new Object[]{ - "SXS", - "GMG", - "PBP", - 'X', aInputCutter, - 'M', CI.getElectricMotor(aVoltageTier, 1), - 'S', OrePrefixes.wireFine.get(Materials.Electrum), - 'P', OrePrefixes.plate.get(aMaterial), - 'G', ELEMENT.STANDALONE.WHITE_METAL.getGear(1), - 'B', aBattery - }); + return RecipeUtils.addShapedRecipe( + OrePrefixes.wireFine.get(Materials.Electrum), aInputCutter, OrePrefixes.wireFine.get(Materials.Electrum), + ELEMENT.STANDALONE.WHITE_METAL.getGear(1), CI.getElectricMotor(aVoltageTier, 1), ELEMENT.STANDALONE.WHITE_METAL.getGear(1), + OrePrefixes.plate.get(aMaterial), aBattery, OrePrefixes.plate.get(aMaterial), + aOutputStack); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingToolHeadChoocher.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingToolHeadChoocher.java index 9131975b21..e4858f8cd1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingToolHeadChoocher.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/ProcessingToolHeadChoocher.java @@ -56,7 +56,7 @@ public class ProcessingToolHeadChoocher implements Interface_OreRecipeRegistrato final ItemStack hammerhead = GT_OreDictUnificator.get(OrePrefixes.toolHeadHammer, aMaterial, 1L); if ((null != plate) && (null != ingot) && (null != hammerhead) && (null != longrod) && (null != screw)){ - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( hammerhead, ToolDictNames.craftingToolScrewdriver.name(), plate, ingot, plate, plate, longrod, screw, null, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java index da93fe212c..a346464eeb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -58,7 +58,7 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { if (ItemUtils.checkForInvalidItems(tinyDust) && ItemUtils.checkForInvalidItems(normalDust)) { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, @@ -69,7 +69,7 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); } - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( normalDust, null, null, null, null, null, null, null, null, @@ -82,7 +82,7 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { } if (ItemUtils.checkForInvalidItems(smallDust) && ItemUtils.checkForInvalidItems(normalDust)) { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( smallDust, smallDust, null, smallDust, smallDust, null, null, null, null, @@ -92,7 +92,7 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { else { Logger.WARNING("4 Small dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); } - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( null, normalDust, null, null, null, null, null, null, null, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index 9b7e1d708d..b7043b5983 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -462,19 +462,19 @@ public class RecipeGen_Ore extends RecipeGen_Base { /** * Shaped Crafting */ - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( CI.craftingToolHammer_Hard, null, null, material.getCrushedPurified(1), null, null, null, null, null, material.getDustPurified(1)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( CI.craftingToolHammer_Hard, null, null, material.getCrushed(1), null, null, null, null, null, material.getDustImpure(1)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( CI.craftingToolHammer_Hard, null, null, material.getCrushedCentrifuged(1), null, null, null, null, null, @@ -486,7 +486,7 @@ public class RecipeGen_Ore extends RecipeGen_Base { final ItemStack smallDust = material.getSmallDust(1); final ItemStack tinyDust = material.getTinyDust(1); - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, tinyDust, @@ -497,7 +497,7 @@ public class RecipeGen_Ore extends RecipeGen_Base { Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+material.getLocalizedName()+" - Failed"); } - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( normalDust, null, null, null, null, null, null, null, null, @@ -509,7 +509,7 @@ public class RecipeGen_Ore extends RecipeGen_Base { } - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( smallDust, smallDust, null, smallDust, smallDust, null, null, null, null, @@ -521,7 +521,7 @@ public class RecipeGen_Ore extends RecipeGen_Base { } - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( null, normalDust, null, null, null, null, null, null, null, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java index 3249e0101d..ea129a2b0e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java @@ -93,7 +93,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Ring Recipe if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getRing(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) { if (CORE.GTNH){ - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "craftingToolHardHammer", null, null, "craftingToolFile", material.getRod(1), null, null, null, null, @@ -105,7 +105,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { } } else { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "craftingToolHardHammer", null, null, null, material.getRod(1), null, null, null, null, @@ -122,7 +122,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Framebox Recipe if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getFrameBox(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) { final ItemStack stackStick = material.getRod(1); - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( stackStick, stackStick, stackStick, stackStick, "craftingToolWrench", stackStick, stackStick, stackStick, stackStick, @@ -166,7 +166,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Shaped Recipe - Bolts if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getBolt(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "craftingToolSaw", null, null, null, material.getRod(1), null, null, null, null, @@ -181,7 +181,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Shaped Recipe - Ingot to Rod if (ItemUtils.checkForInvalidItems(material.getRod(1)) && ItemUtils.checkForInvalidItems(material.getIngot(1))) - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "craftingToolFile", null, null, null, material.getIngot(1), null, null, null, null, @@ -195,7 +195,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Shaped Recipe - Long Rod to two smalls if (ItemUtils.checkForInvalidItems(material.getRod(1)) && ItemUtils.checkForInvalidItems(material.getLongRod(1))) - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "craftingToolSaw", null, null, material.getLongRod(1), null, null, null, null, null, @@ -208,7 +208,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Two small to long rod if (ItemUtils.checkForInvalidItems(material.getLongRod(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( material.getRod(1), "craftingToolHardHammer", material.getRod(1), null, null, null, null, null, null, @@ -221,7 +221,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Rotor Recipe if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getRotor(1)) && ItemUtils.checkForInvalidItems(material.getRing(1)) && !material.isRadioactive && ItemUtils.checkForInvalidItems(material.getPlate(1)) && ItemUtils.checkForInvalidItems(material.getScrew(1))) { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( material.getPlate(1), "craftingToolHardHammer", material.getPlate(1), material.getScrew(1), material.getRing(1), "craftingToolFile", material.getPlate(1), "craftingToolScrewdriver", material.getPlate(1), @@ -235,7 +235,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Gear Recipe if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getGear(1)) && ItemUtils.checkForInvalidItems(material.getPlate(1)) && ItemUtils.checkForInvalidItems(material.getRod(1))) { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( material.getRod(1), material.getPlate(1), material.getRod(1), material.getPlate(1), "craftingToolWrench", material.getPlate(1), material.getRod(1), material.getPlate(1), material.getRod(1), @@ -249,7 +249,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { //Screws if (!material.isRadioactive && ItemUtils.checkForInvalidItems(material.getScrew(1)) && ItemUtils.checkForInvalidItems(material.getBolt(1))) { - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "craftingToolFile", material.getBolt(1), null, material.getBolt(1), null, null, null, null, null, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index dae26bb25a..dfd4bd2144 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -97,9 +97,28 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { e.getStackTrace(); } try { + + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + new ItemStack[] { aInput1, aInput2 }, + new ItemStack[] { aOutput }, + null, + new int[] {}, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + 0); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.mRecipeList.size(); + + // RECIPEHANDLER_CokeOven.debug4(aInput1, aInput2, aFluidInput, // aFluidOutput, aOutput, aDuration, aEUt); - if (aFluidInput == null && aInput2 != null) { + /*if (aFluidInput == null && aInput2 != null) { GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, new ItemStack[] { aOutput }, null, null, null, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); @@ -113,11 +132,11 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { GTPP_Recipe.GTPP_Recipe_Map.sCokeOvenRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2 }, new ItemStack[] { aOutput }, null, null, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - } + }*/ // RECIPEHANDLER_CokeOven.debug5(aInput1, aInput2, aFluidInput, // aFluidOutput, aOutput, aDuration, aEUt); - return true; + return aSize > aSize2; } catch (final NullPointerException e) { @@ -380,23 +399,39 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (aFluidOutput != null) { Logger.WARNING("Recipe will output: " + aFluidOutput.getFluid().getName()); } + + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + aInput, + aOutputItems, + null, + aChances, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + 0); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.mRecipeList.size(); - if (aInput.length == 1) { + /*if (aInput.length == 1) { Logger.WARNING("Dehydrator recipe only has a single input item."); GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - + } else { Logger.WARNING("Dehydrator recipe has two input items."); GTPP_Recipe.GTPP_Recipe_Map.sChemicalDehydratorRecipes.addRecipe(true, aInput, aOutputItems, null, aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); + }*/ - } - - return true; + return aSize > aSize2; } catch (final NullPointerException e) { Logger.WARNING("FAILED TO LOAD RECIPES - NULL POINTER SOMEWHERE"); @@ -458,13 +493,29 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (aInput.length <= 1) { return false; } + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + aInput, + aOutputStack, + null, + aChance, + new FluidStack[] { aInputFluid }, + new FluidStack[] { aOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + aSpecialValue); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.mRecipeList.size(); - - GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.addRecipe(true, aInput, aOutputStack, null, + /*GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.addRecipe(true, aInput, aOutputStack, null, aChance, new FluidStack[] { aInputFluid }, new FluidStack[] { aOutput }, aDuration, aEUt, - aSpecialValue); - return true; + aSpecialValue);*/ + + return aSize > aSize2; } @Override @@ -518,14 +569,33 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { public boolean addCyclotronRecipe(ItemStack[] aInputs, FluidStack aFluidInput, ItemStack[] aOutput, FluidStack aFluidOutput, int[] aChances, int aDuration, int aEUt, int aSpecialValue) { if (aOutput == null || aOutput.length < 1 || !ItemUtils.checkForInvalidItems(aOutput)) { + Logger.INFO("Bad output for Cyclotron Recipe."); return false; } - if (GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.addRecipe(true, aInputs, aOutput, - null, aChances, new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, - Math.max(1, aDuration), Math.max(1, aEUt), aSpecialValue) != null) { + + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + aInputs, + aOutput, + null, + aChances, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + aSpecialValue); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.mRecipeList.size(); + + if (aSize > aSize2) { + Logger.INFO("Added Cyclotron Recipe."); return true; } + Logger.INFO("Failed to add Cyclotron Recipe. Output: "+ItemUtils.getArrayStackNames(aOutput)); return false; } @@ -544,11 +614,29 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { aFluidOutput.getFluid().getName(), aDuration)) <= 0)) { return false; } - GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.addRecipe(true, + GTPP_Recipe aSpecialRecipe = new GTPP_Recipe( + true, + new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, + new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, + null, + new int[] {}, + new FluidStack[] { aFluidInput }, + new FluidStack[] { aFluidOutput }, + Math.max(1, aDuration), + Math.max(1, aEUt), + 0); + + int aSize = GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size(); + int aSize2 = aSize; + GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.add(aSpecialRecipe); + aSize = GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.mRecipeList.size(); + + /*GTPP_Recipe.GTPP_Recipe_Map.sAdvancedMixerRecipes.addRecipe(true, new ItemStack[] { aInput1, aInput2, aInput3, aInput4 }, new ItemStack[] { aOutput1, aOutput2, aOutput3, aOutput4 }, null, null, - new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0); - return true; + new FluidStack[] { aFluidInput }, new FluidStack[] { aFluidOutput }, aDuration, aEUt, 0);*/ + + return aSize > aSize2; } // Machine Component Assembler diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java index abc5558444..e709d207ed 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechConduits.java @@ -363,19 +363,19 @@ public class GregtechConduits { //Add the Three Shaped Recipes First - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( pipePlate, "craftingToolWrench", pipePlate, pipePlate, null, pipePlate, pipePlate, "craftingToolHardHammer", pipePlate, ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Small"+output, 6)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( pipePlate, pipePlate, pipePlate, "craftingToolWrench", null, "craftingToolHardHammer", pipePlate, pipePlate, pipePlate, ItemUtils.getItemStackOfAmountFromOreDict("pipe"+"Medium"+output, 2)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( pipePlate, "craftingToolHardHammer", pipePlate, pipePlate, null, pipePlate, pipePlate, "craftingToolWrench", pipePlate, @@ -418,7 +418,7 @@ public class GregtechConduits { try { final ItemStack pipePlateDouble = ItemUtils.getItemStackOfAmountFromOreDict("plateDouble"+output, 1).copy(); if (pipePlateDouble != null) { - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( pipePlateDouble, "craftingToolHardHammer", pipePlateDouble, pipePlateDouble, null, pipePlateDouble, pipePlateDouble, "craftingToolWrench", pipePlateDouble, @@ -456,7 +456,7 @@ public class GregtechConduits { public static boolean generateWireRecipes(Material aMaterial){ //Adds manual crafting recipe - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( Utils.sanitizeString("plate"+aMaterial.getLocalizedName()), CI.craftingToolWireCutter, null, null, null, null, null, null, null, diff --git a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java index 1f5f9abe1d..e22a609814 100644 --- a/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java +++ b/src/Java/gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java @@ -95,25 +95,25 @@ public class RECIPE_IC2 { if (!CORE.GTNH) { //Rotor Blade Recipes - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate_T1, ingot_T1, plate_T1, plate_T1, ingot_T1, plate_T1, plate_T1, ingot_T1, plate_T1, rotor_blade_T1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate_T2, ingot_T2, plate_T2, plate_T2, ingot_T2, plate_T2, plate_T2, ingot_T2, plate_T2, rotor_blade_T2); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate_T3, ingot_T3, plate_T3, plate_T3, ingot_T3, plate_T3, plate_T3, ingot_T3, plate_T3, rotor_blade_T3); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate_T4, ingot_T4, plate_T4, plate_T4, ingot_T4, plate_T4, plate_T4, ingot_T4, plate_T4, @@ -121,25 +121,25 @@ public class RECIPE_IC2 { } if (CORE.GTNH) { - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate_T1, plate_T1, plate_T1, plate_T1, ring_T1, plate_T1, plate_T1, plate_T1, plate_T1, rotor_blade_T1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate_T2, plate_T2, plate_T2, plate_T2, ring_T2, plate_T2, plate_T2, plate_T2, plate_T2, rotor_blade_T2); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate_T3, plate_T3, plate_T3, plate_T3, ring_T3, plate_T3, plate_T3, plate_T3, plate_T3, rotor_blade_T3); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate_T4, plate_T4, plate_T4, plate_T4, ring_T4, plate_T4, plate_T4, plate_T4, plate_T4, @@ -190,25 +190,25 @@ public class RECIPE_IC2 { if (!CORE.GTNH) { //Rotor Recipes - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( null, rotor_blade_T1, null, rotor_blade_T1, shaft_T1, rotor_blade_T1, null, rotor_blade_T1, null, rotor_T1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( null, rotor_blade_T2, null, rotor_blade_T2, shaft_T2, rotor_blade_T2, null, rotor_blade_T2, null, rotor_T2); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( null, rotor_blade_T3, null, rotor_blade_T3, shaft_T3, rotor_blade_T3, null, rotor_blade_T3, null, rotor_T3); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( null, rotor_blade_T4, null, rotor_blade_T4, shaft_T4, rotor_blade_T4, null, rotor_blade_T4, null, @@ -216,25 +216,25 @@ public class RECIPE_IC2 { } if (CORE.GTNH) { - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( shaft_T1, rotor_blade_T1, craftingToolHardHammer, rotor_blade_T1, ring_T1, rotor_blade_T1, craftingToolWrench, rotor_blade_T1, shaft_T1, rotor_T1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( shaft_T2, rotor_blade_T2, craftingToolHardHammer, rotor_blade_T2, ring_T2, rotor_blade_T2, craftingToolWrench, rotor_blade_T2, shaft_T2, rotor_T2); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( shaft_T3, rotor_blade_T3, craftingToolHardHammer, rotor_blade_T3, ring_T3, rotor_blade_T3, craftingToolWrench, rotor_blade_T3, shaft_T3, rotor_T3); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( shaft_T4, rotor_blade_T4, craftingToolHardHammer, rotor_blade_T4, ring_T4, rotor_blade_T4, craftingToolWrench, rotor_blade_T4, shaft_T4, diff --git a/src/resources/assets/miscutils/lang/en_US.lang b/src/resources/assets/miscutils/lang/en_US.lang index a7746a06f8..1eb21aec5f 100644 --- a/src/resources/assets/miscutils/lang/en_US.lang +++ b/src/resources/assets/miscutils/lang/en_US.lang @@ -3188,4 +3188,7 @@ entity.miscutils.AusDingo.name=Dingo entity.miscutils.AusBoar.name=Wild Boar entity.miscutils.AusSpider.name=Forest Spider entity.miscutils.AusOctopus.name=Octopus -container.EggBox=Egg Hatching Box \ No newline at end of file +container.EggBox=Egg Hatching Box + +//Added24/05/20 +container.VolumetricFlaskSetter=Volumetric Flask Configurator \ No newline at end of file diff --git a/src/resources/assets/miscutils/textures/gui/VolumetricFlaskSetter.png b/src/resources/assets/miscutils/textures/gui/VolumetricFlaskSetter.png new file mode 100644 index 0000000000..08f9761233 Binary files /dev/null and b/src/resources/assets/miscutils/textures/gui/VolumetricFlaskSetter.png differ -- cgit From 8eb236fd8cc8189ccd0783aa4a6d2fbc48c319e2 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 26 May 2020 15:14:52 +0100 Subject: $ Fixed shaped recipe creation. $ Minor adjustments to the Volumetric Flask GUI. --- .../core/block/machine/VolumetricFlaskSetter.java | 2 +- .../container/Container_VolumetricFlaskSetter.java | 125 ++++++++++++--------- .../gui/machine/GUI_VolumetricFlaskSetter.java | 106 ++++++++--------- .../gtPlusPlus/core/gui/widget/GuiValueField.java | 86 ++++++++++++++ src/Java/gtPlusPlus/core/handler/GuiHandler.java | 2 +- .../Inventory_VolumetricFlaskSetter.java | 10 +- .../network/packet/Packet_VolumetricFlaskGui.java | 2 +- .../general/TileEntityVolumetricFlaskSetter.java | 13 ++- .../core/util/minecraft/RecipeUtils.java | 25 +++-- 9 files changed, 245 insertions(+), 126 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/gui/widget/GuiValueField.java (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/src/Java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java index 4f86de49d3..36ea2af7cc 100644 --- a/src/Java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/block/machine/VolumetricFlaskSetter.java @@ -78,7 +78,7 @@ public class VolumetricFlaskSetter extends BasicTileBlockWithTooltip { if ((te != null) && (te instanceof TileEntityVolumetricFlaskSetter)){ player.openGui(GTplusplus.instance, GuiHandler.GUI18, world, x, y, z); TileEntityVolumetricFlaskSetter aTile = (TileEntityVolumetricFlaskSetter) te; - new Packet_VolumetricFlaskGui2(aTile, aTile.getCustomValue()); + //new Packet_VolumetricFlaskGui2(aTile, aTile.getCustomValue()); return true; } } diff --git a/src/Java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java index 5c776b7a57..de3106c957 100644 --- a/src/Java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/container/Container_VolumetricFlaskSetter.java @@ -1,22 +1,34 @@ package gtPlusPlus.core.container; +import java.util.Iterator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.inventories.Inventory_VolumetricFlaskSetter; import gtPlusPlus.core.slots.SlotNoInput; import gtPlusPlus.core.slots.SlotVolumetricFlask; import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; +import gtPlusPlus.core.util.Utils; 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 net.minecraft.world.World; public class Container_VolumetricFlaskSetter extends Container { - protected TileEntityVolumetricFlaskSetter tile_entity; + public TileEntityVolumetricFlaskSetter mTileEntity; public final Inventory_VolumetricFlaskSetter inventoryChest; + + public short mCustomValue; + private short oCustomValue; + private int mTimer; + + private final World worldObj; private final int posX; private final int posY; @@ -26,12 +38,12 @@ public class Container_VolumetricFlaskSetter extends Container { public static int StorageSlotNumber = 8; // Number of slots in storage area public static int InventorySlotNumber = 36; // Inventory Slots (Inventory - // and Hotbar) + // and Hotbar) public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; // All - // slots + // slots public Container_VolumetricFlaskSetter(final InventoryPlayer inventory, final TileEntityVolumetricFlaskSetter te) { - this.tile_entity = te; + this.mTileEntity = te; this.inventoryChest = te.getInventory(); int var6; @@ -40,6 +52,7 @@ public class Container_VolumetricFlaskSetter extends Container { this.posX = te.xCoord; this.posY = te.yCoord; this.posZ = te.zCoord; + //mCustomValue = te.getCustomValue(); int o = 0; @@ -50,66 +63,50 @@ public class Container_VolumetricFlaskSetter extends Container { o++; } }*/ - - + + int xStart = 26; int yStart = 12; try { - //0 - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); - this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart+18)); - - //Add Output - this.addSlotToContainer(new SlotNoInput(this.inventoryChest, SLOT_OUTPUT, 8+(8*18), 59)); - o++; - - - - // Player Inventory - for (var6 = 0; var6 < 3; ++var6) { - for (var7 = 0; var7 < 9; ++var7) { - this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + //0 + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart+=18, yStart)); + this.addSlotToContainer(new SlotVolumetricFlask(this.inventoryChest, o++, xStart, yStart+18)); + + //Add Output + this.addSlotToContainer(new SlotNoInput(this.inventoryChest, o++, 8+(8*18), 59)); + o++; + + + + // Player Inventory + for (var6 = 0; var6 < 3; ++var6) { + for (var7 = 0; var7 < 9; ++var7) { + this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18))); + } } - } - // Player Hotbar - for (var6 = 0; var6 < 9; ++var6) { - this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); - } + // Player Hotbar + for (var6 = 0; var6 < 9; ++var6) { + this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142)); + } + detectAndSendChanges(); } catch (Throwable t) {} } - @Override - public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, - final EntityPlayer aPlayer) { - - if (!aPlayer.worldObj.isRemote) { - if ((aSlotIndex == 999) || (aSlotIndex == -999)) { - // Utils.LOG_WARNING("??? - "+aSlotIndex); - } - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void onContainerClosed(final EntityPlayer par1EntityPlayer) { - super.onContainerClosed(par1EntityPlayer); - } @Override public boolean canInteractWith(final EntityPlayer par1EntityPlayer) { if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockVolumetricFlaskSetter) { return false; } - return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D; } @@ -153,10 +150,36 @@ public class Container_VolumetricFlaskSetter extends Container { return var3; } - // Can merge Slot @Override - public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) { - return super.func_94530_a(p_94530_1_, p_94530_2_); + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if ((Utils.isClient()) || (this.mTileEntity == null)) { + return; + } + + mCustomValue = mTileEntity.getCustomValue(); + mTimer++; + + Iterator var2 = this.crafters.iterator(); + while (var2.hasNext()) { + ICrafting var1 = (ICrafting) var2.next(); + if (mTimer % 20 == 10 || oCustomValue != mCustomValue) { + var1.sendProgressBarUpdate(this, 0, mCustomValue); + } + } + + oCustomValue = mCustomValue; + } + + @SideOnly(Side.CLIENT) + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 0: + mCustomValue = (short) par2; + break; + } } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java index 6bdf8f2ef5..8df6a8a18e 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java @@ -5,8 +5,8 @@ import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.container.Container_VolumetricFlaskSetter; +import gtPlusPlus.core.gui.widget.GuiValueField; import gtPlusPlus.core.handler.PacketHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.network.packet.Packet_VolumetricFlaskGui; @@ -14,64 +14,56 @@ import gtPlusPlus.core.tileentities.general.TileEntityVolumetricFlaskSetter; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; @SideOnly(Side.CLIENT) public class GUI_VolumetricFlaskSetter extends GuiContainer { - private GuiTextField text; - private TileEntityVolumetricFlaskSetter aTile; - private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/VolumetricFlaskSetter.png"); + private GuiTextField mText; + private TileEntityVolumetricFlaskSetter mTile; + private Container_VolumetricFlaskSetter mContainer; + private static final ResourceLocation mGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/VolumetricFlaskSetter.png"); - public GUI_VolumetricFlaskSetter(final InventoryPlayer player_inventory, final TileEntityVolumetricFlaskSetter te){ - super(new Container_VolumetricFlaskSetter(player_inventory, te)); - aTile = te; - Logger.INFO("Tile Value: "+te.getCustomValue()); + public GUI_VolumetricFlaskSetter(Container_VolumetricFlaskSetter aContainer){ + super(aContainer); + mContainer = aContainer; + mTile = mContainer.mTileEntity; } public void initGui(){ super.initGui(); - this.text = new GuiTextField(this.fontRendererObj, this.width / 2 - 62, this.height/2-52, 106, 14); - text.setMaxStringLength(5); - if (aTile != null) { - Logger.INFO("Using Value from Tile: "+aTile.getCustomValue()); - text.setText(""+aTile.getCustomValue()); - } - else { - Logger.INFO("Using default Value: 1000"); - text.setText("1000"); - } - this.text.setFocused(true); + this.mText = new GuiValueField(this.fontRendererObj, 26, 31, this.width / 2 - 62, this.height/2-52, 106, 14); + mText.setMaxStringLength(5); + mText.setText("0"); + mText.setFocused(true); } protected void keyTyped(char par1, int par2){ if (!isNumber(par1) && par2 != Keyboard.KEY_BACK && par2 != Keyboard.KEY_RETURN) { - text.setFocused(false); + mText.setFocused(false); super.keyTyped(par1, par2); } else { if (par2 == Keyboard.KEY_RETURN) { - if (text.isFocused()) { - Logger.INFO("Removing Focus."); - text.setFocused(false); + if (mText.isFocused()) { + mText.setFocused(false); } } else if (par2 == Keyboard.KEY_BACK) { String aCurrentText = getText(); if (aCurrentText.length() > 0) { - this.text.setText(aCurrentText.substring(0, aCurrentText.length() - 1)); + this.mText.setText(aCurrentText.substring(0, aCurrentText.length() - 1)); if (getText().length() <= 0) { - this.text.setText("0"); + this.mText.setText("0"); } } } else { - if (this.text.getText().equals("0")) { - this.text.setText(""+par1); + if (this.mText.getText().equals("0")) { + this.mText.setText(""+par1); } else { - this.text.textboxKeyTyped(par1, par2); + this.mText.textboxKeyTyped(par1, par2); } } sendUpdateToServer(); @@ -80,30 +72,28 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { public void updateScreen(){ super.updateScreen(); - this.text.updateCursorCounter(); + this.mText.updateCursorCounter(); } public void drawScreen(int par1, int par2, float par3){ this.drawDefaultBackground(); super.drawScreen(par1, par2, par3); - this.text.drawTextBox(); + + } protected void mouseClicked(int x, int y, int btn) { super.mouseClicked(x, y, btn); - this.text.mouseClicked(x, y, btn); + this.mText.mouseClicked(x, y, btn); } - - - - @Override protected void drawGuiContainerForegroundLayer(final int i, final int j){ super.drawGuiContainerForegroundLayer(i, j); + this.mText.drawTextBox(); this.fontRendererObj.drawString(I18n.format("container.VolumetricFlaskSetter", new Object[0]), 4, 3, 4210752); int aYVal = 49; this.fontRendererObj.drawString(I18n.format("0 = 16l", new Object[0]), 8, aYVal, 4210752); @@ -114,12 +104,29 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { this.fontRendererObj.drawString(I18n.format("6 = 864l", new Object[0]), 64, aYVal, 4210752); this.fontRendererObj.drawString(I18n.format("3 = 432l", new Object[0]), 8, aYVal+=8, 4210752); this.fontRendererObj.drawString(I18n.format("-> = Custom", new Object[0]), 59, aYVal, 4210752); + + + // Check TextBox Value is correct + short aCustomValue = 0; + if (getText().length() > 0) { + try { + aCustomValue = Short.parseShort(getText()); + short aTileValue = ((Container_VolumetricFlaskSetter) mContainer).mCustomValue; + if (mContainer != null) { + if (aTileValue != aCustomValue){ + this.mText.setText(""+aTileValue); + } + } + } catch (NumberFormatException ex) { + + } + } } @Override protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){ GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(craftingTableGuiTextures); + this.mc.renderEngine.bindTexture(mGuiTextures); final int x = (this.width - this.xSize) / 2; final int y = (this.height - this.ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); @@ -130,20 +137,19 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { } protected String getText() { - return this.text.getText(); + return this.mText.getText(); } - protected void sendUpdateToServer() { - Logger.INFO("Trying to send packet to server from GUI."); - int aCustomValue = 0; - if (getText().length() > 0) - try { - aCustomValue = Integer.parseInt(getText()); - Logger.INFO("Got Value: "+aCustomValue); - PacketHandler.sendToServer(new Packet_VolumetricFlaskGui(aTile, aCustomValue)); - } catch (NumberFormatException ex) { - - } - } + protected void sendUpdateToServer() { + short aCustomValue = 0; + if (getText().length() > 0) { + try { + aCustomValue = Short.parseShort(getText()); + PacketHandler.sendToServer(new Packet_VolumetricFlaskGui(mTile, aCustomValue)); + } catch (NumberFormatException ex) { + + } + } + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/gui/widget/GuiValueField.java b/src/Java/gtPlusPlus/core/gui/widget/GuiValueField.java new file mode 100644 index 0000000000..ac4c1a8aee --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/widget/GuiValueField.java @@ -0,0 +1,86 @@ +package gtPlusPlus.core.gui.widget; + +import java.lang.reflect.Field; + +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiTextField; + +public class GuiValueField extends GuiTextField { + + private final FontRenderer mFontRenderer; + private final int mScreenLocationX; + private final int mScreenLocationY; + + public GuiValueField(FontRenderer aFontRenderer, int aX, int aY, int aScreenLocationX, int aScreenLocationY, int aWidth, int aHeight) { + super(aFontRenderer, aX, aY, aWidth, aHeight); + mFontRenderer = aFontRenderer; + mScreenLocationX = aScreenLocationX; + mScreenLocationY = aScreenLocationY; + } + + public boolean canLoseFocus() { + Field canLoseFocus = ReflectionUtils.getField(GuiTextField.class, "canLoseFocus"); + if (canLoseFocus != null) { + return (boolean) ReflectionUtils.getFieldValue(canLoseFocus, this); + } + return true; + } + + public boolean isFocused() { + Field isFocused = ReflectionUtils.getField(GuiTextField.class, "isFocused"); + if (isFocused != null) { + return (boolean) ReflectionUtils.getFieldValue(isFocused, this); + } + return false; + } + + public boolean isBackgroundDrawingEnabled() { + Field enableBackgroundDrawing = ReflectionUtils.getField(GuiTextField.class, "enableBackgroundDrawing"); + if (enableBackgroundDrawing != null) { + return (boolean) ReflectionUtils.getFieldValue(enableBackgroundDrawing, this); + } + return true; + } + public int getLineScrollOffset() { + Field lineScrollOffset = ReflectionUtils.getField(GuiTextField.class, "lineScrollOffset"); + if (lineScrollOffset != null) { + return (int) ReflectionUtils.getFieldValue(lineScrollOffset, this); + } + return 0; + } + + /** + * Args: x, y, buttonClicked + */ + public void mouseClicked(int aX, int aY, int aButton){ + + boolean flag = aX >= this.mScreenLocationX && aX < this.mScreenLocationX + this.width && aY >= this.mScreenLocationY && aY < this.mScreenLocationY + this.height; + + //Logger.INFO("Clicked X:"+aX); + //Logger.INFO("Clicked Y:"+aY); + //Logger.INFO("ScreenPos X:"+mScreenLocationX); + //Logger.INFO("ScreenPos Y:"+mScreenLocationY); + //Logger.INFO("Render X:"+xPosition); + //Logger.INFO("Render Y:"+yPosition); + + if (canLoseFocus()) + { + this.setFocused(flag); + } + + if (isFocused() && aButton == 0) + { + int l = aX - this.mScreenLocationX; + + if (isBackgroundDrawingEnabled()) + { + l -= 4; + } + + String s = this.mFontRenderer.trimStringToWidth(this.getText().substring(getLineScrollOffset()), this.getWidth()); + this.setCursorPosition(this.mFontRenderer.trimStringToWidth(s, l).length() + getLineScrollOffset()); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 827b7d5b8f..0567d6c5dd 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -176,7 +176,7 @@ public class GuiHandler implements IGuiHandler { } else if (ID == GUI17) { return new GUI_EggBox(player.inventory, (TileEntityEggBox) te); } else if (ID == GUI18) { - return new GUI_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te); + return new GUI_VolumetricFlaskSetter(new Container_VolumetricFlaskSetter(player.inventory, (TileEntityVolumetricFlaskSetter) te)); } } diff --git a/src/Java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java index 9bc9d3aa59..e2dc91a413 100644 --- a/src/Java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/inventories/Inventory_VolumetricFlaskSetter.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.inventories; -import gtPlusPlus.core.slots.SlotIntegratedCircuit; +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -9,10 +9,10 @@ import net.minecraft.nbt.NBTTagList; public class Inventory_VolumetricFlaskSetter implements IInventory{ - private final String name = "Circuit Programmer"; + private final String name = "Volumetric Flask Setter"; /** Defining your inventory size this way is handy */ - public static final int INV_SIZE = 26; + public static final int INV_SIZE = 9; /** Inventory's size must be same as number of slots you add to the Container class */ private ItemStack[] inventory = new ItemStack[INV_SIZE]; @@ -121,7 +121,7 @@ public class Inventory_VolumetricFlaskSetter implements IInventory{ @Override public int getInventoryStackLimit() { - return 64; + return 16; } /** @@ -167,7 +167,7 @@ public class Inventory_VolumetricFlaskSetter implements IInventory{ */ @Override public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { - return SlotIntegratedCircuit.isItemValidForSlot(itemstack); + return VolumetricFlaskHelper.isVolumetricFlask(itemstack); } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java b/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java index 7f13976d87..609ea729b7 100644 --- a/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java +++ b/src/Java/gtPlusPlus/core/network/packet/Packet_VolumetricFlaskGui.java @@ -115,7 +115,7 @@ public class Packet_VolumetricFlaskGui extends AbstractServerMessageHandler Date: Tue, 26 May 2020 22:42:43 +0100 Subject: + Added custom Flask Renderer. + Added ability for the Volumetric Flask Configurator to handle the new Flasks. % Made 64k Flask have a capacity of 32k instead. (Technical limitation involving Short data types) --- src/Java/gtPlusPlus/core/item/ModItems.java | 4 +- src/Java/gtPlusPlus/core/proxy/ClientProxy.java | 6 ++ .../general/TileEntityVolumetricFlaskSetter.java | 81 ++++++++++-------- .../xmod/gregtech/api/enums/GregtechItemList.java | 2 +- .../common/helpers/VolumetricFlaskHelper.java | 23 ++++- .../gregtech/common/render/GTPP_FlaskRenderer.java | 94 +++++++++++++++++++++ .../textures/items/gt.Volumetric_Flask_32k.png | Bin 0 -> 1013 bytes .../items/gt.Volumetric_Flask_32k.window.png | Bin 0 -> 399 bytes .../textures/items/gt.Volumetric_Flask_64k.png | Bin 1013 -> 0 bytes .../items/gt.Volumetric_Flask_64k.window.png | Bin 399 -> 0 bytes 10 files changed, 173 insertions(+), 37 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java create mode 100644 src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_32k.png create mode 100644 src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_32k.window.png delete mode 100644 src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.png delete mode 100644 src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.window.png (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index bc9cb4bc5e..963d6203cc 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -983,9 +983,9 @@ public final class ModItems { if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { Item a8kFlask = VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_8k", "Large Volumetric Flask", 8000); - Item a64kFlask = VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_64k", "Gigantic Volumetric Flask", 64000); + Item a64kFlask = VolumetricFlaskHelper.generateNewFlask("Volumetric_Flask_32k", "Gigantic Volumetric Flask", 32000); GregtechItemList.VOLUMETRIC_FLASK_8k.set(a8kFlask); - GregtechItemList.VOLUMETRIC_FLASK_64k.set(a64kFlask); + GregtechItemList.VOLUMETRIC_FLASK_32k.set(a64kFlask); } itemBoilerChassis = new ItemBoilerChassis(); diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java index 1cef8a789a..5a0c0f4ea3 100644 --- a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -32,7 +32,9 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; import gtPlusPlus.core.tileentities.general.TileEntityFirepit; import gtPlusPlus.core.util.minecraft.particles.EntityParticleFXMysterious; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.render.GTPP_CapeRenderer; +import gtPlusPlus.xmod.gregtech.common.render.GTPP_FlaskRenderer; import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; @@ -94,6 +96,10 @@ public class ClientProxy extends CommonProxy implements Runnable{ new CustomItemBlockRenderer(); new GTPP_Render_MachineBlock(); + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + new GTPP_FlaskRenderer(); + } + super.init(e); } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index 1aede47096..fb2a7843aa 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -72,6 +72,41 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide public Inventory_VolumetricFlaskSetter getInventory() { return this.inventoryContents; } + + private int getFlaskType(ItemStack aStack) { + if (VolumetricFlaskHelper.isNormalVolumetricFlask(aStack)) { + return 1; + } + else if (VolumetricFlaskHelper.isLargeVolumetricFlask(aStack)) { + return 2; + } + else if (VolumetricFlaskHelper.isGiganticVolumetricFlask(aStack)) { + return 3; + } + return 0; + } + + private int getCapacityForSlot(int aSlot) { + switch (aSlot) { + case 0: //16 + return 16; + case 1: //36 + return 36; + case 2: //144 + return 144; + case 3: //432 + return 432; + case 4: //576 + return 576; + case 5: //720 + return 720; + case 6: //864 + return 864; + case 7: //Custom + return getCustomValue(); + } + return 0; + } public boolean addOutput() { ItemStack[] aInputs = this.getInventory().getInventory().clone(); @@ -93,8 +128,8 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide ItemStack g = this.getStackInSlot(e); int aSize = 0; ItemStack aInputStack = null; - int aTypeInSlot = 0; - if (aTypeInSlot >= 0 && g != null) { + int aTypeInSlot = getFlaskType(g); + if (aTypeInSlot > 0 && g != null) { // No Existing Output if (!hasOutput) { aSize = g.stackSize; @@ -103,10 +138,10 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide // Existing Output else { ItemStack f = this.getStackInSlot(8); - int aTypeInCheckedSlot = 0; + int aTypeInCheckedSlot = getFlaskType(f); // Check that the Circuit in the Output slot is not null and the same type as the circuit input. - if (aTypeInCheckedSlot >= 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { - if (g.getItem() == f.getItem() && f.getItemDamage() == e) { + if (aTypeInCheckedSlot > 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { + if (g.getItem() == f.getItem() && VolumetricFlaskHelper.getFlaskCapacity(f) == getCapacityForSlot(e)) { aSize = f.stackSize + g.stackSize; if (aSize > 64) { aInputStack = g.copy(); @@ -119,41 +154,21 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide if (doAdd) { // Check Circuit Type ItemStack aOutput; - if (aTypeInSlot == 0) { + if (aTypeInSlot == 1) { aOutput = VolumetricFlaskHelper.getVolumetricFlask(1); } + else if (aTypeInSlot == 2) { + aOutput = VolumetricFlaskHelper.getLargeVolumetricFlask(1); + } + else if (aTypeInSlot == 3) { + aOutput = VolumetricFlaskHelper.getGiganticVolumetricFlask(1); + } else { aOutput = null; } if (aOutput != null) { aOutput.stackSize = aSize; - switch (e) { - case 0: //16 - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 16); - break; - case 1: //36 - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 36); - break; - case 2: //144 - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 144); - break; - case 3: //432 - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 432); - break; - case 4: //576 - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 576); - break; - case 5: //720 - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 720); - break; - case 6: //864 - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, 864); - break; - case 7: //Custom - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, getCustomValue()); - break; - } - + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, getCapacityForSlot(e)); this.setInventorySlotContents(e, aInputStack); this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput); return true; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 7d3476d48b..7d76082aee 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -97,7 +97,7 @@ public enum GregtechItemList implements GregtechItemContainer { // Larger Volumetric Flasks VOLUMETRIC_FLASK_8k, - VOLUMETRIC_FLASK_64k, + VOLUMETRIC_FLASK_32k, //RTG Fuels Pellet_RTG_PU238, Pellet_RTG_SR90, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java index a169419fea..61d0797ccf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -39,11 +39,18 @@ public class VolumetricFlaskHelper { } public static ItemStack getGiganticVolumetricFlask(int aAmount) { - ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_64k.get(aAmount); + ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_32k.get(aAmount); return aFlask; } public static boolean isVolumetricFlask(ItemStack aStack) { + if (isNormalVolumetricFlask(aStack) || isLargeVolumetricFlask(aStack) || isGiganticVolumetricFlask(aStack)) { + return true; + } + return false; + } + + public static boolean isNormalVolumetricFlask(ItemStack aStack) { if (mFlask == null) { ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null); if (aFlask != null) { @@ -56,6 +63,20 @@ public class VolumetricFlaskHelper { return false; } + public static boolean isLargeVolumetricFlask(ItemStack aStack) { + if (GregtechItemList.VOLUMETRIC_FLASK_8k.getItem() == aStack.getItem()) { + return true; + } + return false; + } + + public static boolean isGiganticVolumetricFlask(ItemStack aStack) { + if (GregtechItemList.VOLUMETRIC_FLASK_32k.getItem() == aStack.getItem()) { + return true; + } + return false; + } + public static int getMaxFlaskCapacity(ItemStack aStack) { if (aStack != null && sMethodGetFlaskMaxCapacity != null) { Item aItem = aStack.getItem(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java new file mode 100644 index 0000000000..1561ba9f73 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java @@ -0,0 +1,94 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.ItemList; +import gregtech.common.items.GT_VolumetricFlask; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import ic2.core.util.DrawUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.opengl.GL11; + +@SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) +public final class GTPP_FlaskRenderer implements net.minecraftforge.client.IItemRenderer { + + public GTPP_FlaskRenderer() { + MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_8k.getItem(), this); + MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_32k.getItem(), this); + } + + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.FIRST_PERSON_MAP; + } + + + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { + return type == ItemRenderType.ENTITY; + } + + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GT_VolumetricFlask cell = (GT_VolumetricFlask) item.getItem(); + + int aType = cell.getMaxCapacity() == 8000 ? 0 : 1; + IIcon icon = item.getIconIndex(); + GL11.glEnable(3042); + GL11.glEnable(3008); + if (type.equals(ItemRenderType.ENTITY)) { + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D); + GL11.glTranslated(-0.5D, -0.6D, 0.0D); + } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { + GL11.glTranslated(1.0D, 1.0D, 0.0D); + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + } else if (type.equals(ItemRenderType.EQUIPPED)) { + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + GL11.glTranslated(-1.0D, -1.0D, 0.0D); + } + + FluidStack fs = cell.getFluid(item); + if (fs != null) { + IIcon iconWindow = cell.iconWindow; + IIcon fluidicon = fs.getFluid().getIcon(fs); + int fluidColor = fs.getFluid().getColor(fs); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(0, 1); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(iconWindow, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); + } else { + DrawUtil.renderIcon(iconWindow, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); + DrawUtil.renderIcon(iconWindow, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glBlendFunc(770, 771); + GL11.glDepthFunc(514); + GL11.glColor3ub((byte) (fluidColor >> 16), (byte) (fluidColor >> 8), (byte) fluidColor); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(fluidicon, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); + } else { + DrawUtil.renderIcon(fluidicon, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); + DrawUtil.renderIcon(fluidicon, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); + } + + GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); + GL11.glDepthFunc(515); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + } + GL11.glDisable(3008); + GL11.glDisable(3042); + } +} \ No newline at end of file diff --git a/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_32k.png b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_32k.png new file mode 100644 index 0000000000..13b37c999d Binary files /dev/null and b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_32k.png differ diff --git a/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_32k.window.png b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_32k.window.png new file mode 100644 index 0000000000..3fd5382926 Binary files /dev/null and b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_32k.window.png differ diff --git a/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.png b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.png deleted file mode 100644 index 13b37c999d..0000000000 Binary files a/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.png and /dev/null differ diff --git a/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.window.png b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.window.png deleted file mode 100644 index 3fd5382926..0000000000 Binary files a/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.window.png and /dev/null differ -- cgit From 527f3c0e675ed99b82f36108b29884711b3e1a55 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 26 May 2020 23:30:18 +0100 Subject: $ VFS now handles fluids. $ Fixed crash due to multiple key listeners running. (codechicken.nei.guihook.GuiContainerManager.lastKeyTyped(GuiContainerManager.java:306)) --- .../gui/machine/GUI_VolumetricFlaskSetter.java | 127 ++++++++++++--------- .../general/TileEntityVolumetricFlaskSetter.java | 46 ++++++-- .../common/helpers/VolumetricFlaskHelper.java | 78 +++++++++---- .../GregtechMetaAtmosphericReconditioner.java | 1 + 4 files changed, 167 insertions(+), 85 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java index 8df6a8a18e..b0c1e8b6ff 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_VolumetricFlaskSetter.java @@ -20,6 +20,7 @@ import net.minecraft.util.ResourceLocation; public class GUI_VolumetricFlaskSetter extends GuiContainer { private GuiTextField mText; + private boolean mIsOpen = false; private TileEntityVolumetricFlaskSetter mTile; private Container_VolumetricFlaskSetter mContainer; private static final ResourceLocation mGuiTextures = new ResourceLocation(CORE.MODID, "textures/gui/VolumetricFlaskSetter.png"); @@ -32,6 +33,7 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { public void initGui(){ super.initGui(); + mIsOpen = true; this.mText = new GuiValueField(this.fontRendererObj, 26, 31, this.width / 2 - 62, this.height/2-52, 106, 14); mText.setMaxStringLength(5); mText.setText("0"); @@ -39,47 +41,82 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { } protected void keyTyped(char par1, int par2){ - if (!isNumber(par1) && par2 != Keyboard.KEY_BACK && par2 != Keyboard.KEY_RETURN) { - mText.setFocused(false); - super.keyTyped(par1, par2); - } - else { - if (par2 == Keyboard.KEY_RETURN) { - if (mText.isFocused()) { - mText.setFocused(false); + if (mIsOpen) { + if (mText.isFocused()) { + if (par2 == Keyboard.KEY_RETURN) { + if (mText.isFocused()) { + mText.setFocused(false); + } } - } - else if (par2 == Keyboard.KEY_BACK) { - String aCurrentText = getText(); - if (aCurrentText.length() > 0) { - this.mText.setText(aCurrentText.substring(0, aCurrentText.length() - 1)); - if (getText().length() <= 0) { - this.mText.setText("0"); + else if (par2 == Keyboard.KEY_BACK) { + String aCurrentText = getText(); + if (aCurrentText.length() > 0) { + this.mText.setText(aCurrentText.substring(0, aCurrentText.length() - 1)); + if (getText().length() <= 0) { + this.mText.setText("0"); + } + sendUpdateToServer(); } } + else { + if (isNumber(par1)) { + if (this.mText.getText().equals("0")) { + this.mText.setText(""+par1); + sendUpdateToServer(); + } + else { + this.mText.textboxKeyTyped(par1, par2); + sendUpdateToServer(); + } + } + else { + super.keyTyped(par1, par2); + } + } } else { - if (this.mText.getText().equals("0")) { - this.mText.setText(""+par1); - } - else { - this.mText.textboxKeyTyped(par1, par2); - } - } - sendUpdateToServer(); + super.keyTyped(par1, par2); + } } } + @Override + public void onGuiClosed() { + mIsOpen = false; + super.onGuiClosed(); + } + public void updateScreen(){ super.updateScreen(); + // Update Textbox to 0 if Empty + if (getText().length() <= 0) { + this.mText.setText("0"); + sendUpdateToServer(); + } this.mText.updateCursorCounter(); + + // Check TextBox Value is correct + short aCustomValue = 0; + if (getText().length() > 0) { + try { + aCustomValue = Short.parseShort(getText()); + short aTileValue = ((Container_VolumetricFlaskSetter) mContainer).mCustomValue; + if (mContainer != null) { + if (aTileValue != aCustomValue){ + this.mText.setText(""+aTileValue); + } + } + } catch (NumberFormatException ex) { + + } + } } public void drawScreen(int par1, int par2, float par3){ this.drawDefaultBackground(); super.drawScreen(par1, par2, par3); - - + + } protected void mouseClicked(int x, int y, int btn) { @@ -104,23 +141,7 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { this.fontRendererObj.drawString(I18n.format("6 = 864l", new Object[0]), 64, aYVal, 4210752); this.fontRendererObj.drawString(I18n.format("3 = 432l", new Object[0]), 8, aYVal+=8, 4210752); this.fontRendererObj.drawString(I18n.format("-> = Custom", new Object[0]), 59, aYVal, 4210752); - - - // Check TextBox Value is correct - short aCustomValue = 0; - if (getText().length() > 0) { - try { - aCustomValue = Short.parseShort(getText()); - short aTileValue = ((Container_VolumetricFlaskSetter) mContainer).mCustomValue; - if (mContainer != null) { - if (aTileValue != aCustomValue){ - this.mText.setText(""+aTileValue); - } - } - } catch (NumberFormatException ex) { - - } - } + } @Override @@ -140,16 +161,16 @@ public class GUI_VolumetricFlaskSetter extends GuiContainer { return this.mText.getText(); } - protected void sendUpdateToServer() { - short aCustomValue = 0; - if (getText().length() > 0) { - try { - aCustomValue = Short.parseShort(getText()); - PacketHandler.sendToServer(new Packet_VolumetricFlaskGui(mTile, aCustomValue)); - } catch (NumberFormatException ex) { - - } - } - } + protected void sendUpdateToServer() { + short aCustomValue = 0; + if (getText().length() > 0) { + try { + aCustomValue = Short.parseShort(getText()); + PacketHandler.sendToServer(new Packet_VolumetricFlaskGui(mTile, aCustomValue)); + } catch (NumberFormatException ex) { + + } + } + } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index fb2a7843aa..6ced7ac7f7 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -15,6 +15,7 @@ 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.fluids.FluidStack; public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISidedInventory { @@ -39,7 +40,7 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide public void setCustomValue(int aVal) { Logger.INFO("Old Value: "+this.aCustomValue); - this.aCustomValue = (short) MathUtils.balance(aVal, 1, Short.MAX_VALUE); + this.aCustomValue = (short) MathUtils.balance(aVal, 0, Short.MAX_VALUE); Logger.INFO("New Value: "+this.aCustomValue); markDirty(); } @@ -58,14 +59,14 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide //Rename to hasCircuitToConfigure public final boolean hasFlask() { - for (ItemStack i : this.getInventory().getInventory()) { - if (i == null) { + for (int i=0;i 0 + if (e == 7 && getCustomValue() <= 0) { + Logger.INFO("Skipping Custom slot as value <= 0"); + continue; + } + boolean doAdd = false; ItemStack g = this.getStackInSlot(e); + FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g); int aSize = 0; ItemStack aInputStack = null; int aTypeInSlot = getFlaskType(g); @@ -138,10 +154,11 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide // Existing Output else { ItemStack f = this.getStackInSlot(8); + FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f); int aTypeInCheckedSlot = getFlaskType(f); // Check that the Circuit in the Output slot is not null and the same type as the circuit input. if (aTypeInCheckedSlot > 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { - if (g.getItem() == f.getItem() && VolumetricFlaskHelper.getFlaskCapacity(f) == getCapacityForSlot(e)) { + if (g.getItem() == f.getItem() && VolumetricFlaskHelper.getFlaskCapacity(f) == getCapacityForSlot(e) && ((aInputFluidStack == null && aFluidInCheckedSlot == null) || aInputFluidStack.isFluidEqual(aFluidInCheckedSlot))) { aSize = f.stackSize + g.stackSize; if (aSize > 64) { aInputStack = g.copy(); @@ -154,6 +171,10 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide if (doAdd) { // Check Circuit Type ItemStack aOutput; + FluidStack aOutputFluid = null; + if (!VolumetricFlaskHelper.isFlaskEmpty(g)) { + aOutputFluid = aInputFluidStack.copy(); + } if (aTypeInSlot == 1) { aOutput = VolumetricFlaskHelper.getVolumetricFlask(1); } @@ -168,7 +189,14 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide } if (aOutput != null) { aOutput.stackSize = aSize; - VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, getCapacityForSlot(e)); + int aCapacity = getCapacityForSlot(e); + VolumetricFlaskHelper.setNewFlaskCapacity(aOutput, aCapacity); + if (aOutputFluid != null) { + if (aOutputFluid.amount > aCapacity) { + aOutputFluid.amount = aCapacity; + } + VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid); + } this.setInventorySlotContents(e, aInputStack); this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput); return true; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java index 61d0797ccf..e85a78b8aa 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -10,9 +10,10 @@ import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; public class VolumetricFlaskHelper { - + private static final Class sClassVolumetricFlask; private static final Method sMethodGetFlaskMaxCapacity; private static Item mFlask; @@ -32,24 +33,24 @@ public class VolumetricFlaskHelper { ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", aAmount, (ItemStack) null); return aFlask; } - + public static ItemStack getLargeVolumetricFlask(int aAmount) { ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_8k.get(aAmount); return aFlask; } - + public static ItemStack getGiganticVolumetricFlask(int aAmount) { ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_32k.get(aAmount); return aFlask; } - + public static boolean isVolumetricFlask(ItemStack aStack) { if (isNormalVolumetricFlask(aStack) || isLargeVolumetricFlask(aStack) || isGiganticVolumetricFlask(aStack)) { return true; } return false; } - + public static boolean isNormalVolumetricFlask(ItemStack aStack) { if (mFlask == null) { ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null); @@ -62,21 +63,21 @@ public class VolumetricFlaskHelper { } return false; } - + public static boolean isLargeVolumetricFlask(ItemStack aStack) { if (GregtechItemList.VOLUMETRIC_FLASK_8k.getItem() == aStack.getItem()) { return true; } return false; } - + public static boolean isGiganticVolumetricFlask(ItemStack aStack) { if (GregtechItemList.VOLUMETRIC_FLASK_32k.getItem() == aStack.getItem()) { return true; } return false; } - + public static int getMaxFlaskCapacity(ItemStack aStack) { if (aStack != null && sMethodGetFlaskMaxCapacity != null) { Item aItem = aStack.getItem(); @@ -87,28 +88,59 @@ public class VolumetricFlaskHelper { } return 0; } + + public static boolean isFlaskEmpty(ItemStack aStack) { + return getFlaskFluid(aStack) == null; + } + + public static FluidStack getFlaskFluid(ItemStack aStack) { + if (aStack.hasTagCompound()) { + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt.hasKey("Fluid", 10)) + return FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("Fluid")); + } + return null; + } - public static int getFlaskCapacity(ItemStack aStack) { - int capacity = 1000; - if (aStack.hasTagCompound()) { - NBTTagCompound nbt = aStack.getTagCompound(); - if (nbt.hasKey("Capacity", 3)) - capacity = nbt.getInteger("Capacity"); + public static void setFluid(ItemStack stack, FluidStack fluidStack) { + boolean removeFluid = (fluidStack == null) || (fluidStack.amount <= 0); + NBTTagCompound nbt = stack.getTagCompound(); + if (nbt == null) { + if (removeFluid) + return; + stack.setTagCompound(nbt = new NBTTagCompound()); + } + if (removeFluid) { + nbt.removeTag("Fluid"); + if (nbt.hasNoTags()) { + stack.setTagCompound(null); + } + } else { + nbt.setTag("Fluid", fluidStack.writeToNBT(new NBTTagCompound())); } - return Math.min(getMaxFlaskCapacity(aStack), capacity); + } + + public static int getFlaskCapacity(ItemStack aStack) { + int capacity = 1000; + if (aStack.hasTagCompound()) { + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt.hasKey("Capacity", 3)) + capacity = nbt.getInteger("Capacity"); + } + return Math.min(getMaxFlaskCapacity(aStack), capacity); } - + public static boolean setNewFlaskCapacity(ItemStack aStack, int aCapacity) { if (aStack == null || aCapacity <= 0) { return false; } aCapacity = Math.min(aCapacity, getMaxFlaskCapacity(aStack)); - NBTTagCompound nbt = aStack.getTagCompound(); - if (nbt == null) { - aStack.setTagCompound(nbt = new NBTTagCompound()); - } - nbt.setInteger("Capacity", aCapacity); - return true; + NBTTagCompound nbt = aStack.getTagCompound(); + if (nbt == null) { + aStack.setTagCompound(nbt = new NBTTagCompound()); + } + nbt.setInteger("Capacity", aCapacity); + return true; } public static Item generateNewFlask(String unlocalized, String english, int maxCapacity) { @@ -122,5 +154,5 @@ public class VolumetricFlaskHelper { } return null; } - + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index 33c6bacbd4..04d37e8c1e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -268,6 +268,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi //We are good to clean if (toRemove > 0){ if (damageTurbineRotor() && damageAirFilter()){ + Logger.INFO("Removing "+toRemove+" pollution"); removePollution(mSaveRotor ? (toRemove/2) : toRemove); Logger.WARNING("mNewPollution[4]:"+getCurrentChunkPollution()); } -- cgit From cf125cd1dff982663ec687cd0e2c06662df355a5 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sun, 31 May 2020 20:10:14 +0100 Subject: + Added recipes for Laurenium and Botmium casings. - Removed VFCs ability to handle flasks with fluid in them. - Disabled Thaumic Tinkerer Hazmat additions. - Disabled Item Overflow Covers. % Made Green Rocket Fuel more expensive. % Made Purple Rocket Fuel use less copper, give more output. $ Fixed unloacl name of GT++ Super Chests, to prevent GT's Language Manager re-using the Localised String. $ Fixed handling of large recipes in GT_NEI_multiCentriElectroFreezer. $ Fixed Automation of Pollution Scrubbers. --- .../core/item/chemistry/RocketFuels.java | 10 +- .../gtPlusPlus/core/recipe/RECIPES_GREGTECH.java | 48 ++++++ .../general/TileEntityVolumetricFlaskSetter.java | 26 +++- .../core/util/minecraft/HazmatUtils.java | 25 +-- .../nei/GT_NEI_multiCentriElectroFreezer.java | 68 ++++++++- .../common/items/MetaGeneratedGregtechItems.java | 5 +- .../GregtechMetaAtmosphericReconditioner.java | 170 ++++++++++----------- .../registration/gregtech/GregtechSuperChests.java | 10 +- 8 files changed, 242 insertions(+), 120 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index c91efd4ec8..86088fe8c6 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -100,7 +100,7 @@ public class RocketFuels extends ItemPackage { CORE.RA.addChemicalPlantRecipe( new ItemStack[]{ - ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 16), + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 12), ItemUtils.getSimpleStack(GenericChem.mOrangeCatalyst, 0), }, new FluidStack[] { @@ -397,14 +397,14 @@ public class RocketFuels extends ItemPackage { CI.getNumberedCircuit(3), }, new FluidStack[] { - FluidUtils.getFluidStack(Monomethylhydrazine, 1000), + FluidUtils.getFluidStack(Monomethylhydrazine, 2000), FluidUtils.getFluidStack("nitricacid", 1000), }, new ItemStack[] { }, new FluidStack[] { - FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 3000), + FluidUtils.getFluidStack(Monomethylhydrazine_Plus_Nitric_Acid, 2000), }, 20 * 45, @@ -425,12 +425,12 @@ public class RocketFuels extends ItemPackage { }, new FluidStack[] { - FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 4000), + FluidUtils.getFluidStack(Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 5000), }, 20 * 60, 480, - 5); + 6); } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 817683cb1e..af694fa07d 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -338,6 +338,54 @@ public class RECIPES_GREGTECH { 2); } + int aLaureniumTier = ALLOY.LAURENIUM.vTier; + // Adding Recipes for Casings + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(12), + CI.getTieredMachineCasing(aLaureniumTier), + CI.getPlate(aLaureniumTier-1, 8), + CI.getGear(aLaureniumTier, 2), + CI.getBolt(aLaureniumTier-3, 16) + }, + new FluidStack[] { + CI.getTieredFluid(aLaureniumTier, 2 * 144), + CI.getAlternativeTieredFluid(aLaureniumTier-1, 4 * 144) + }, + new ItemStack[] { + GregtechItemList.Casing_Machine_Custom_3.get(1) + }, + new FluidStack[] { + + }, + 20 * 20, + MaterialUtils.getVoltageForTier(aLaureniumTier-2), + 5); + + int aBotmiumTier = ALLOY.BOTMIUM.vTier; + // Adding Recipes for Casings + CORE.RA.addChemicalPlantRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(12), + CI.getTieredMachineCasing(aBotmiumTier), + CI.getPlate(aBotmiumTier-1, 8), + CI.getGear(aBotmiumTier, 2), + CI.getBolt(aBotmiumTier-3, 16) + }, + new FluidStack[] { + CI.getTieredFluid(aBotmiumTier, 2 * 144), + CI.getAlternativeTieredFluid(aBotmiumTier-1, 4 * 144) + }, + new ItemStack[] { + GregtechItemList.Casing_Machine_Custom_4.get(1) + }, + new FluidStack[] { + + }, + 20 * 20, + MaterialUtils.getVoltageForTier(aBotmiumTier-2), + 6); + } private static void fluidheaterRecipes() { diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index 6ced7ac7f7..e20a538ea7 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -117,7 +117,21 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide return false; } + boolean aAllowFluid = false; + boolean aHasFluid = false; + ItemStack[] aInputs = this.getInventory().getInventory().clone(); + + for (ItemStack aStack : aInputs) { + if (VolumetricFlaskHelper.getFlaskFluid(aStack) != null) { + aHasFluid = true; + } + } + + if (aHasFluid && !aAllowFluid) { + return false; + } + //Check if there is output in slot. Boolean hasOutput = false; if (aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT] != null) { @@ -141,7 +155,8 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide boolean doAdd = false; ItemStack g = this.getStackInSlot(e); - FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g); + //FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g); + FluidStack aInputFluidStack = null; int aSize = 0; ItemStack aInputStack = null; int aTypeInSlot = getFlaskType(g); @@ -154,7 +169,8 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide // Existing Output else { ItemStack f = this.getStackInSlot(8); - FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f); + //FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f); + FluidStack aFluidInCheckedSlot = null; int aTypeInCheckedSlot = getFlaskType(f); // Check that the Circuit in the Output slot is not null and the same type as the circuit input. if (aTypeInCheckedSlot > 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { @@ -172,9 +188,9 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide // Check Circuit Type ItemStack aOutput; FluidStack aOutputFluid = null; - if (!VolumetricFlaskHelper.isFlaskEmpty(g)) { + /*if (!VolumetricFlaskHelper.isFlaskEmpty(g)) { aOutputFluid = aInputFluidStack.copy(); - } + }*/ if (aTypeInSlot == 1) { aOutput = VolumetricFlaskHelper.getVolumetricFlask(1); } @@ -195,7 +211,7 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide if (aOutputFluid.amount > aCapacity) { aOutputFluid.amount = aCapacity; } - VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid); + //VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid); } this.setInventorySlotContents(e, aInputStack); this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput); diff --git a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java index 137b05d85a..287820404a 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java @@ -208,6 +208,7 @@ public class HazmatUtils { } if (LoadedMods.isModLoaded("ThaumicTinkerer")) { + /* AutoMap aItems = new AutoMap(); Class aMainTT = ReflectionUtils.getClass("thaumic.tinkerer.common.ThaumicTinkerer"); Class aItemRegistryTT = ReflectionUtils.getClass("thaumic.tinkerer.common.registry.TTRegistry"); @@ -225,21 +226,23 @@ public class HazmatUtils { AutoMap aItemMap = new AutoMap(); int aIndex = 0; for (Item aItem : aItems) { - Item aItemObject = null; - if (aItem != null) { - aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); - } - else { - Logger.INFO("[Hazmat] Could not get item "+aIndex+" from "+aItemRegistryTT.getName()); - } - aIndex++; + Item aItemObject = null; + if (aItem != null) { + aItemMap.add(ItemUtils.getSimpleStack(aItemObject)); + } + else { + Logger.INFO("[Hazmat] Could not get item "+aIndex+" from "+aItemRegistryTT.getName()); + } + aIndex++; } Logger.INFO("[Hazmat] Registering "+aItemMap.size()+" Thaumic Tinkerer Items as hazmat gear."); for (ItemStack aItem : aItemMap) { - addProtection(aItem); + addProtection(aItem); } Logger.INFO("[Hazmat] Registered Thaumic Tinkerer Items as hazmat gear."); - } + */ + Logger.INFO("[Hazmat] Did not register Thaumic Tinkerer Items as hazmat gear."); + } if (LoadedMods.isModLoaded("GraviSuite")) { AutoMap aItemFields = new AutoMap(); @@ -426,7 +429,7 @@ public class HazmatUtils { Logger.INFO("=========================================================="); return false; } - Logger.INFO("[Hazmat] Registering " + aVanStack.getDisplayName() + " for full Hazmat protection."); + Logger.INFO("[Hazmat] Registering " + ItemUtils.getItemName(aVanStack) + " for full Hazmat protection."); GT_ItemStack aStack = getGtStackFromVanilla(aVanStack); AutoMap aAdded = new AutoMap(); aAdded.put(addProtection_Frost(aStack)); diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_multiCentriElectroFreezer.java b/src/Java/gtPlusPlus/nei/GT_NEI_multiCentriElectroFreezer.java index 5850df8647..a8c77094cd 100644 --- a/src/Java/gtPlusPlus/nei/GT_NEI_multiCentriElectroFreezer.java +++ b/src/Java/gtPlusPlus/nei/GT_NEI_multiCentriElectroFreezer.java @@ -19,10 +19,9 @@ import gregtech.api.gui.GT_GUIContainer_BasicMachine; import gregtech.api.objects.ItemData; import gregtech.api.util.*; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map_Internal; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.nei.GTPP_NEI_DefaultHandler.CachedDefaultRecipe; -import gtPlusPlus.nei.GTPP_NEI_DefaultHandler.FixedPositionedStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.init.Blocks; @@ -51,6 +50,33 @@ extends TemplateRecipeHandler { GuiUsageRecipe.usagehandlers.add(this); } } + + public static void logRecipeError(GT_Recipe aRecipe) { + if (aRecipe == null) { + Logger.INFO("Tried to handle null recipe. :("); + } + else { + ItemStack[] aInputs = aRecipe.mInputs; + ItemStack[] aOutputs = aRecipe.mOutputs; + FluidStack[] aFluidInputs = aRecipe.mFluidInputs; + FluidStack[] aFluidOutputs = aRecipe.mFluidOutputs; + int aEU = aRecipe.mEUt; + int aTime = aRecipe.mDuration; + int aSpecialValue = aRecipe.mSpecialValue; + String aInputitems = ItemUtils.getArrayStackNames(aInputs); + String aOutputitems = ItemUtils.getArrayStackNames(aOutputs); + String aInputFluids = ItemUtils.getArrayStackNames(aFluidInputs); + String aOutputFluids = ItemUtils.getArrayStackNames(aFluidOutputs); + Logger.INFO("Logging Broken Recipe Details:"); + Logger.INFO("Input Items - "+aInputitems); + Logger.INFO("Output Items - "+aOutputitems); + Logger.INFO("Input Fluids - "+aInputFluids); + Logger.INFO("Output Fluids - "+aOutputFluids); + Logger.INFO("EU/t - "+aEU); + Logger.INFO("Duration - "+aTime); + Logger.INFO("Special Value - "+aSpecialValue); + } + } public List getSortedRecipes() { List result = new ArrayList(this.mRecipeMap.mRecipeList); @@ -72,7 +98,11 @@ extends TemplateRecipeHandler { if (outputId.equals(getRecipeMapName())) { for (GTPP_Recipe tRecipe : getSortedRecipes()) { if (!tRecipe.mHidden) { - this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + CachedDefaultRecipe tNEIRecipe = getCachedRecipe(tRecipe); + if (tNEIRecipe == null) { + continue; + } + this.arecipes.add(tNEIRecipe); } } } else { @@ -103,7 +133,10 @@ extends TemplateRecipeHandler { } for (GTPP_Recipe tRecipe : getSortedRecipes()) { if (!tRecipe.mHidden) { - CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + CachedDefaultRecipe tNEIRecipe = getCachedRecipe(tRecipe); + if (tNEIRecipe == null) { + continue; + } for (ItemStack tStack : tResults) { if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { this.arecipes.add(tNEIRecipe); @@ -137,7 +170,10 @@ extends TemplateRecipeHandler { } for (GTPP_Recipe tRecipe : getSortedRecipes()) { if (!tRecipe.mHidden) { - CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + CachedDefaultRecipe tNEIRecipe = getCachedRecipe(tRecipe); + if (tNEIRecipe == null) { + continue; + } for (ItemStack tStack : tInputs) { if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { this.arecipes.add(tNEIRecipe); @@ -386,6 +422,8 @@ extends TemplateRecipeHandler { mInputSlotMap.put(7, new Pair(aSlotX_2, aSlotY_3)); mInputSlotMap.put(8, new Pair(aSlotX_3, aSlotY_3)); mInputSlotMap.put(9, new Pair(aSlotX_1, aSlotY_10)); + mInputSlotMap.put(10, new Pair(aSlotX_2, aSlotY_10)); + mInputSlotMap.put(11, new Pair(aSlotX_3, aSlotY_10)); aSlotX_1 = 102; aSlotX_2 = 120; aSlotX_3 = 138; @@ -399,6 +437,18 @@ extends TemplateRecipeHandler { mOutputSlotMap.put(7, new Pair(aSlotX_2, aSlotY_3)); mOutputSlotMap.put(8, new Pair(aSlotX_3, aSlotY_3)); mOutputSlotMap.put(9, new Pair(aSlotX_1, aSlotY_10)); + mOutputSlotMap.put(10, new Pair(aSlotX_2, aSlotY_10)); + mOutputSlotMap.put(11, new Pair(aSlotX_3, aSlotY_10)); + } + + private CachedDefaultRecipe getCachedRecipe(GT_Recipe aRecipe) { + try { + return new CachedDefaultRecipe(aRecipe); + } + catch(Throwable e) { + logRecipeError(aRecipe); + } + return null; } public class CachedDefaultRecipe @@ -431,6 +481,9 @@ extends TemplateRecipeHandler { // Upto 9 Inputs Slots if (aInputItemsCount > 0) { + if (aInputItemsCount > 9) { + aInputItemsCount = 9; + } for (int i=0;i 0) { + if (aOutputItemsCount > 0) { + if (aOutputItemsCount > 9) { + aOutputItemsCount = 9; + } for (int i=0;i= 7; - + String[] A = new String[]{ this.mDescription, highTier ? "Will attempt to remove 1/4 pollution from 8 surrounding chunks" : "", highTier ? "If these chunks are not loaded, they will be ignored" : "", - "Requires a turbine rotor and an Air Filter [T1/T2] to run.", - "The turbine rotor must be manually inserted/replaced", - "Can be configured with a soldering iron to change modes", - "Low Efficiency: Removes half pollution, Turbine takes 50% dmg", - "High Efficiency: Removes full pollution, Turbine takes 100% dmg", - "Turbine Rotor will not break in LE mode", - "Insert an equal tier Conveyor Module to enable automation" - }; + "Requires a turbine rotor and an Air Filter [T1/T2] to run.", + "The turbine rotor must be manually inserted/replaced", + "Can be configured with a soldering iron to change modes", + "Low Efficiency: Removes half pollution, Turbine takes 50% dmg", + "High Efficiency: Removes full pollution, Turbine takes 100% dmg", + "Turbine Rotor will not break in LE mode", + "Insert an equal tier Conveyor Module to enable automation" + }; if (!mPollutionEnabled) { String[] B = new String[] { "===============================================", @@ -178,10 +178,10 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi aBaseMetaTileEntity.setActive(false); this.sendSound((byte) -122); } - + //Only try once/sec. if (!isIdle && aTick % 20L == 0L){ - + //Check if machine can work. if ((aBaseMetaTileEntity.isAllowedToWork())){ @@ -197,13 +197,13 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi this.sendSound((byte) -122); } } - + //If Active. if (aBaseMetaTileEntity.isActive()){ //Do nothing if there is no pollution. if(this.mHasPollution && mCurrentPollution > 0){ - + //Only check every 30s. if (!isIdle && aTick % (20L * 30) == 0L){ mPollutionEnabled = PollutionUtils.mPollution(); @@ -212,9 +212,9 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi PollutionUtils.nullifyPollution(this.getBaseMetaTileEntity()); } } - - - + + + //Use a Turbine if(hasRotor(stackRotor) && hasAirFilter(stackFilter)){ @@ -240,7 +240,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi int mAirSides = getFreeSpaces(); int reduction = 0; - + //If no sides are free, how will you process the atmosphere? if (mAirSides > 0){ reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); //Was originally *100 @@ -253,7 +253,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi Logger.WARNING("reduction[3]:"+reduction); mPollutionReduction = reduction; - + //Set a temp to remove variable to aleviate duplicate code. int toRemove = 0; @@ -296,21 +296,21 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } } //End of 1/sec action block. else { - + if (hasRotor(stackRotor) && hasAirFilter(stackFilter) && this.mHasPollution && !isIdle && aBaseMetaTileEntity.isAllowedToWork()){ aBaseMetaTileEntity.setActive(true); } else if (isIdle || !this.mHasPollution || mCurrentPollution <= 0 || stackRotor == null || stackFilter == null || !hasRotor(stackRotor) || !hasAirFilter(stackFilter)){ aBaseMetaTileEntity.setActive(false); } - + } if (this.getBaseMetaTileEntity().isActive()) { if (MathUtils.randInt(0, 5) <= 2) { this.sendSound((byte) -120); } } - + } //End of is serverside block. } @@ -366,7 +366,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } return mCurrentChunkPollution; } - + public boolean hasRotor(ItemStack rotorStack){ if(rotorStack != null){ if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { @@ -381,7 +381,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi public boolean damageTurbineRotor(){ try{ - + boolean creativeRotor = false; ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; if (rotorStack == null) { @@ -396,7 +396,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } } } - + if (rotorStack.getItem() instanceof ItemBasicScrubberTurbine) { long currentUse = ItemBasicScrubberTurbine.getFilterDamage(rotorStack); //Remove broken Filter @@ -415,15 +415,15 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi return true; } } - + if(mInventory[SLOT_ROTOR].getItem() instanceof GT_MetaGenerated_Tool_01 && ((GT_MetaGenerated_Tool) mInventory[SLOT_ROTOR].getItem()).getToolStats(mInventory[SLOT_ROTOR]).getSpeedMultiplier()>0 && GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[SLOT_ROTOR]).mToolSpeed>0 ) { - + long damageValue = (long) Math.floor(Math.abs(MathUtils.randFloat(1, 2) - MathUtils.randFloat(1, 3)) * (1 + 3 - 1) + 1); double fDam = Math.floor(Math.abs(MathUtils.randFloat(1f, 2f) - MathUtils.randFloat(1f, 2f)) * (1f + 2f - 1f) + 1f); damageValue -= fDam; - + //Logger.WARNING("Trying to do "+damageValue+" damage to the rotor. ["+fDam+"]"); /*Materials M1 = GT_MetaGenerated_Tool.getPrimaryMaterial(this.mInventory[this.SLOT_ROTOR]); Materials M2 = GT_MetaGenerated_Tool.getSecondaryMaterial(this.mInventory[this.SLOT_ROTOR]); @@ -437,14 +437,27 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi long rotorDurability = (rotorDurabilityMax - rotorDamage); Logger.WARNING("Rotor Damage: "+rotorDamage + " | Max Durability: "+rotorDurabilityMax+" | "+" Remaining Durability: "+rotorDurability); if (rotorDurability >= damageValue){ - - - if (!mSaveRotor){ - Logger.WARNING("Damaging Rotor."); - - if (!creativeRotor) + + + if (!mSaveRotor){ + Logger.WARNING("Damaging Rotor."); + + if (!creativeRotor) GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue, 0, null); + long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); + if (tempDur < rotorDurabilityMax){ + return true; + } + else { + rotorDurability = 0; + } + } + else { + Logger.WARNING("Damaging Rotor."); + if (rotorDurability > 1000){ + if (!creativeRotor) + GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue/2, 0, null); long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); if (tempDur < rotorDurabilityMax){ return true; @@ -452,23 +465,10 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi else { rotorDurability = 0; } - } - else { - Logger.WARNING("Damaging Rotor."); - if (rotorDurability > 1000){ - if (!creativeRotor) - GT_ModHandler.damageOrDechargeItem(this.mInventory[this.SLOT_ROTOR], (int) damageValue/2, 0, null); - long tempDur = GT_MetaGenerated_Tool.getToolDamage(this.mInventory[this.SLOT_ROTOR]); - if (tempDur < rotorDurabilityMax){ - return true; - } - else { - rotorDurability = 0; - } - } - } - - + } + } + + } if (rotorDurability <= 0 && !mSaveRotor && !creativeRotor) { @@ -519,11 +519,11 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } public boolean removePollution(int toRemove){ - + if (this == null || this.getBaseMetaTileEntity() == null || this.getBaseMetaTileEntity().getWorld() == null) { return false; } - + if (this.mTier < 7) { int startPollution = getCurrentChunkPollution(); PollutionUtils.removePollution(this.getBaseMetaTileEntity(), toRemove); @@ -537,7 +537,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi Chunk aThisChunk = this.getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getZCoord()); int mainChunkX = aThisChunk.xPosition; int mainChunkZ = aThisChunk.zPosition; - + World aWorld = this.getBaseMetaTileEntity().getWorld(); int xPos = this.getBaseMetaTileEntity().getXCoord(); int zPos = this.getBaseMetaTileEntity().getZCoord(); @@ -561,21 +561,21 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi aSurrounding.put(c1); aSurrounding.put(c2); aSurrounding.put(c3); - + for (Chunk r : aSurrounding) { if (!r.isChunkLoaded) { continue; } - + int startPollution = getPollutionInChunk(r); if (startPollution == 0) { continue; } - + Logger.WARNING("Trying to remove pollution from chunk "+r.xPosition+", "+r.zPosition+" | "+startPollution); int after = 0; boolean isMainChunk = r.isAtLocation(mainChunkX, mainChunkZ); - + int removal = Math.max(0, !isMainChunk ? (toRemove/4) : toRemove); if (removePollution(r, removal)) { chunksWithRemoval++; @@ -592,7 +592,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi return totalRemoved > 0 && chunksWithRemoval > 0; } } - + public boolean removePollution(Chunk aChunk, int toRemove){ int before = getCurrentChunkPollution(); PollutionUtils.removePollution(aChunk, toRemove); @@ -616,7 +616,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi if (filter == null) { return false; } - + boolean creativeRotor = false; ItemStack rotorStack = this.mInventory[SLOT_ROTOR]; if (rotorStack != null) { @@ -628,11 +628,11 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } } } - + if (creativeRotor) { return true; } - + if (filter.getItem() instanceof ItemAirFilter){ @@ -670,22 +670,20 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - Logger.INFO("Trying to Insert into "+aIndex); if (aIndex == 5) { if (aStack.getItem() instanceof ItemAirFilter) { + Logger.INFO("Inserting Air Filter into "+aIndex); return true; } } - if (aIndex == 4 || aIndex == 6){ - if (aIndex == 4) { - if (this.mInventory[5] != null) { - Logger.INFO("Found conveyor, can automate turbines."); - if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { - return true; - } - if (aStack.getItem() instanceof GT_MetaGenerated_Tool && aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 179){ - return true; - } + if (aIndex == 4) { + if (this.mInventory[6] != null) { + Logger.INFO("Found conveyor, can automate turbines. Inserting into "+aIndex); + if (aStack.getItem() instanceof ItemBasicScrubberTurbine) { + return true; + } + if (aStack.getItem() instanceof GT_MetaGenerated_Tool && aStack.getItemDamage() >= 170 && aStack.getItemDamage() <= 179){ + return true; } } } @@ -737,29 +735,29 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi } int mAirSides = getFreeSpaces(); int reduction = 0; - + try { - long tVoltage = maxEUInput(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); - reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); - reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); - - aTooltipSuper.put("Maximum pollution removed per second: "+reduction); + long tVoltage = maxEUInput(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); + reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); + reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); + + aTooltipSuper.put("Maximum pollution removed per second: "+reduction); } catch (Throwable t) { aTooltipSuper.put("Maximum pollution removed per second: "+mPollutionReduction); } aTooltipSuper.put("Air Sides: "+mAirSides); - + String[] mBuiltOutput = new String[aTooltipSuper.size()]; int aIndex = 0; for (String i : aTooltipSuper) { mBuiltOutput[aIndex++] = i; } - - - + + + return mBuiltOutput; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java index dcf52a5008..5027e2d6e8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechSuperChests.java @@ -22,11 +22,11 @@ public class GregtechSuperChests { aSuffix = " [Disabled]"; } - GregtechItemList.Super_Chest_LV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.01", "Super Chest I"+aSuffix, 1)).getStackForm(1L)); - GregtechItemList.Super_Chest_MV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.02", "Super Chest II"+aSuffix, 2)).getStackForm(1L)); - GregtechItemList.Super_Chest_HV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.03", "Super Chest III"+aSuffix, 3)).getStackForm(1L)); - GregtechItemList.Super_Chest_EV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.04", "Super Chest IV"+aSuffix, 4)).getStackForm(1L)); - GregtechItemList.Super_Chest_IV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.tier.05", "Super Chest V"+aSuffix, 5)).getStackForm(1L)); + GregtechItemList.Super_Chest_LV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.01", "Super Chest I"+aSuffix, 1)).getStackForm(1L)); + GregtechItemList.Super_Chest_MV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.02", "Super Chest II"+aSuffix, 2)).getStackForm(1L)); + GregtechItemList.Super_Chest_HV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.03", "Super Chest III"+aSuffix, 3)).getStackForm(1L)); + GregtechItemList.Super_Chest_EV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.04", "Super Chest IV"+aSuffix, 4)).getStackForm(1L)); + GregtechItemList.Super_Chest_IV.set((new GT_MetaTileEntity_TieredChest(mId++, "super.chest.gtpp.tier.05", "Super Chest V"+aSuffix, 5)).getStackForm(1L)); // Do not add Recipes for GTNH, hide them from NEI instead. if (CORE.GTNH) { -- cgit From d1a813e829fa4393aeb625ce83c64f079e44cdb0 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 2 Jun 2020 14:33:02 +0100 Subject: $ Fixed VFC fluid handling. --- .../handler/StopAnnoyingFuckingAchievements.java | 30 +++++++++++++++--- .../general/TileEntityVolumetricFlaskSetter.java | 37 ++++++++++------------ 2 files changed, 42 insertions(+), 25 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java index 8853acd4b7..b3b720497e 100644 --- a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java +++ b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java @@ -1,8 +1,13 @@ package gtPlusPlus.core.handler; +import java.lang.reflect.Field; + import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.client.Minecraft; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.stats.AchievementList; import net.minecraftforge.event.entity.player.AchievementEvent; @@ -14,11 +19,28 @@ public class StopAnnoyingFuckingAchievements { */ @SubscribeEvent(priority=EventPriority.HIGHEST) public void FUCK_OFF(AchievementEvent event) { + if (Utils.isClient()) { + doClientStuff(); + } if (event.achievement.equals(AchievementList.openInventory)) { event.setCanceled(true); - if (Minecraft.getMinecraft() != null) { - if (Minecraft.getMinecraft().gameSettings != null) { - Minecraft.getMinecraft().gameSettings.showInventoryAchievementHint = false; + } + } + + @SideOnly(Side.CLIENT) + private final void doClientStuff() { + Class aMC = ReflectionUtils.getClass("net.minecraft.client.Minecraft"); + if (aMC != null) { + Field aInstanceMC = ReflectionUtils.getField(aMC, "theMinecraft"); + Object aMcObj = ReflectionUtils.getFieldValue(null, aInstanceMC); + Class aClazz2 = aMcObj.getClass(); + if (aClazz2 != null) { + Field aGameSettings = ReflectionUtils.getField(aClazz2, "gameSettings"); + Object aGameSettingsObj = ReflectionUtils.getFieldValue(aInstanceMC, aGameSettings); + Class aClazz3 = aGameSettingsObj.getClass(); + if (aClazz2 != null) { + Field ainvHint = ReflectionUtils.getField(aClazz3, "showInventoryAchievementHint"); + ReflectionUtils.setField(aGameSettingsObj, ainvHint, false); } } } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index e20a538ea7..febe646310 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -117,25 +117,17 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide return false; } - boolean aAllowFluid = false; - boolean aHasFluid = false; ItemStack[] aInputs = this.getInventory().getInventory().clone(); - for (ItemStack aStack : aInputs) { - if (VolumetricFlaskHelper.getFlaskFluid(aStack) != null) { - aHasFluid = true; - } - } - - if (aHasFluid && !aAllowFluid) { - return false; - } //Check if there is output in slot. Boolean hasOutput = false; if (aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT] != null) { hasOutput = true; + if (aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT].stackSize >= 16) { + return false; + } } AutoMap aValidSlots = new AutoMap(); int aSlotCount = 0; @@ -152,11 +144,13 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide Logger.INFO("Skipping Custom slot as value <= 0"); continue; } + if (e == Container_VolumetricFlaskSetter.SLOT_OUTPUT) { + continue; + } boolean doAdd = false; ItemStack g = this.getStackInSlot(e); - //FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g); - FluidStack aInputFluidStack = null; + FluidStack aInputFluidStack = VolumetricFlaskHelper.getFlaskFluid(g); int aSize = 0; ItemStack aInputStack = null; int aTypeInSlot = getFlaskType(g); @@ -168,17 +162,18 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide } // Existing Output else { - ItemStack f = this.getStackInSlot(8); - //FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f); - FluidStack aFluidInCheckedSlot = null; + ItemStack f = aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT]; + FluidStack aFluidInCheckedSlot = VolumetricFlaskHelper.getFlaskFluid(f); int aTypeInCheckedSlot = getFlaskType(f); // Check that the Circuit in the Output slot is not null and the same type as the circuit input. if (aTypeInCheckedSlot > 0 && (aTypeInSlot == aTypeInCheckedSlot) && f != null) { if (g.getItem() == f.getItem() && VolumetricFlaskHelper.getFlaskCapacity(f) == getCapacityForSlot(e) && ((aInputFluidStack == null && aFluidInCheckedSlot == null) || aInputFluidStack.isFluidEqual(aFluidInCheckedSlot))) { + Logger.INFO("Input Slot Flask Contains: "+(aInputFluidStack != null ? aInputFluidStack.getLocalizedName() : "Empty")); + Logger.INFO("Output Slot Flask Contains: "+(aFluidInCheckedSlot != null ? aFluidInCheckedSlot.getLocalizedName() : "Empty")); aSize = f.stackSize + g.stackSize; - if (aSize > 64) { + if (aSize > 16) { aInputStack = g.copy(); - aInputStack.stackSize = (aSize-64); + aInputStack.stackSize = (aSize-16); } doAdd = true; } @@ -188,9 +183,9 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide // Check Circuit Type ItemStack aOutput; FluidStack aOutputFluid = null; - /*if (!VolumetricFlaskHelper.isFlaskEmpty(g)) { + if (!VolumetricFlaskHelper.isFlaskEmpty(g)) { aOutputFluid = aInputFluidStack.copy(); - }*/ + } if (aTypeInSlot == 1) { aOutput = VolumetricFlaskHelper.getVolumetricFlask(1); } @@ -211,7 +206,7 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide if (aOutputFluid.amount > aCapacity) { aOutputFluid.amount = aCapacity; } - //VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid); + VolumetricFlaskHelper.setFluid(aOutput, aOutputFluid); } this.setInventorySlotContents(e, aInputStack); this.setInventorySlotContents(Container_VolumetricFlaskSetter.SLOT_OUTPUT, aOutput); -- cgit From 174d2abf005402d46b3ebd3cfbc8c84ccfe95928 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 2 Jun 2020 14:36:02 +0100 Subject: $ Fixed I/O of VFC. --- .../core/tileentities/general/TileEntityVolumetricFlaskSetter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index febe646310..316d271961 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -339,8 +339,8 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide } @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return p_102007_1_ >= 0 && p_102007_1_ <= 24; + public boolean canInsertItem(final int aSlot, final ItemStack p_102007_2_, final int p_102007_3_) { + return aSlot >= 0 && aSlot <= 24; } @Override -- cgit From 8ee7350f7e52b898126331aea6e673c70942e42a Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 18 Aug 2020 18:35:49 +0100 Subject: + Added Spice of Life support. + Added new Food Crate. $ Fixed bug in Fish Catcher, where side by side traps didn't count properly as water. $ Fixed bug in Air Intake Hatch. --- .../core/handler/COMPAT_IntermodStaging.java | 4 ++ src/Java/gtPlusPlus/core/lib/LoadedMods.java | 6 ++ .../tileentities/general/TileEntityFishTrap.java | 3 +- .../general/TileEntityVolumetricFlaskSetter.java | 6 +- .../GT_MetaTileEntity_Hatch_AirIntake.java | 41 +++++++++++++- .../gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java | 61 +++++++++++++++++++++ src/resources/assets/spiceoflife/lang/de_DE.lang | 2 + src/resources/assets/spiceoflife/lang/en_US.lang | 2 + src/resources/assets/spiceoflife/lang/es_ES.lang | 2 + src/resources/assets/spiceoflife/lang/fr_FR.lang | 2 + src/resources/assets/spiceoflife/lang/it_IT.lang | 2 + src/resources/assets/spiceoflife/lang/ko_KR.lang | 2 + src/resources/assets/spiceoflife/lang/ru_RU.lang | 2 + src/resources/assets/spiceoflife/lang/zh_CN.lang | 2 + .../spiceoflife/textures/items/foodcrate.png | Bin 0 -> 365 bytes .../textures/items/foodcrate_open_empty.png | Bin 0 -> 355 bytes .../textures/items/foodcrate_open_full.png | Bin 0 -> 509 bytes 17 files changed, 132 insertions(+), 5 deletions(-) create mode 100644 src/Java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java create mode 100644 src/resources/assets/spiceoflife/lang/de_DE.lang create mode 100644 src/resources/assets/spiceoflife/lang/en_US.lang create mode 100644 src/resources/assets/spiceoflife/lang/es_ES.lang create mode 100644 src/resources/assets/spiceoflife/lang/fr_FR.lang create mode 100644 src/resources/assets/spiceoflife/lang/it_IT.lang create mode 100644 src/resources/assets/spiceoflife/lang/ko_KR.lang create mode 100644 src/resources/assets/spiceoflife/lang/ru_RU.lang create mode 100644 src/resources/assets/spiceoflife/lang/zh_CN.lang create mode 100644 src/resources/assets/spiceoflife/textures/items/foodcrate.png create mode 100644 src/resources/assets/spiceoflife/textures/items/foodcrate_open_empty.png create mode 100644 src/resources/assets/spiceoflife/textures/items/foodcrate_open_full.png (limited to 'src/Java/gtPlusPlus/core/tileentities/general') diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index cd25fdb1c3..9a1b551d30 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -16,6 +16,7 @@ import gtPlusPlus.xmod.ob.HANDLER_OpenBlocks; import gtPlusPlus.xmod.railcraft.HANDLER_Railcraft; import gtPlusPlus.xmod.reliquary.HANDLER_Reliquary; import gtPlusPlus.xmod.sc2.HANDLER_SC2; +import gtPlusPlus.xmod.sol.HANDLER_SpiceOfLife; import gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; @@ -39,6 +40,7 @@ public class COMPAT_IntermodStaging { HANDLER_Railcraft.preInit(); HANDLER_Reliquary.preInit(); HANDLER_OpenBlocks.preInit(); + HANDLER_SpiceOfLife.preInit(); } public static void init(FMLInitializationEvent init){ @@ -58,6 +60,7 @@ public class COMPAT_IntermodStaging { HANDLER_Railcraft.init(); HANDLER_Reliquary.init(); HANDLER_OpenBlocks.init(); + HANDLER_SpiceOfLife.init(); } public static void postInit(FMLPostInitializationEvent postinit){ @@ -77,6 +80,7 @@ public class COMPAT_IntermodStaging { HANDLER_Railcraft.postInit(); HANDLER_Reliquary.postInit(); HANDLER_OpenBlocks.postInit(); + HANDLER_SpiceOfLife.postInit(); } public static void onLoadComplete(FMLLoadCompleteEvent event) { diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index 329cf634b6..1eb8351d65 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -59,6 +59,7 @@ public class LoadedMods { public static boolean Waila = false; public static boolean CropsPlusPlus = false; //Barts Crop Mod public static boolean Reliquary = false; + public static boolean SpiceOfLife = false; @@ -211,6 +212,11 @@ public class LoadedMods { Logger.INFO("Components enabled for: WAILA"); totalMods++; } + if (isModLoaded("SpiceOfLife")){ + SpiceOfLife = true; + Logger.INFO("Components enabled for: Spice Of Life"); + totalMods++; + } if (isModLoaded("Mekanism")){ Mekanism = true; Logger.INFO("Components enabled for: Mekanism - This feature is not configurable and balances Mekanism to suit GT."); diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java index e7c37f7994..beff269428 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -79,7 +79,8 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } } if ((waterCount >= 2) && (trapCount <= 4)) { - this.waterSides = waterCount; + int aCheck = trapCount + waterCount; + this.waterSides = MathUtils.balance(aCheck, 0, 6); Logger.MACHINE_INFO("Valid Trap. "+waterCount+" | "+(this.tickCount/20)+"/"+(this.baseTickRate/20)); return true; } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java index 316d271961..5b837397b1 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -340,12 +340,12 @@ public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISide @Override public boolean canInsertItem(final int aSlot, final ItemStack p_102007_2_, final int p_102007_3_) { - return aSlot >= 0 && aSlot <= 24; + return aSlot == aCurrentMode; } @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return p_102008_1_ == 25; + public boolean canExtractItem(final int aSlot, final ItemStack p_102008_2_, final int p_102008_3_) { + return aSlot == Container_VolumetricFlaskSetter.SLOT_OUTPUT; } public String getCustomName() { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java index 4e6e2bc35b..3a0c101375 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java @@ -1,6 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; import net.minecraft.world.World; import net.minecraft.item.ItemStack; @@ -196,6 +198,20 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_I public boolean canTankBeEmptied() { return true; } + + private static Fluid AIR; + + public boolean isAirInHatch() { + if (this.mFluid != null) { + if (AIR == null) { + AIR = FluidUtils.getAir(1).getFluid(); + } + if (AIR == this.mFluid.getFluid()) { + return true; + } + } + return false; + } public boolean addAirToHatch(long aTick) { if (!this.getBaseMetaTileEntity().getAirAtSide(this.getBaseMetaTileEntity().getFrontFacing())) { @@ -209,6 +225,9 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_I return false; } else { + if (!isAirInHatch()) { + return false; + } if (this.mFluid != null && a1) { this.mFluid.amount += 1000; return true; @@ -244,6 +263,26 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_I @Override public boolean doesFillContainers() { - return true; + return false; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return 0; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + return false; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return 0; + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + return 0; } } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java b/src/Java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java new file mode 100644 index 0000000000..11cc5da89c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/sol/HANDLER_SpiceOfLife.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.sol; + +import java.lang.reflect.Constructor; + +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.Item; + +public class HANDLER_SpiceOfLife { + + public static final void preInit() { + if (LoadedMods.SpiceOfLife) { + //Add a new Lunch Box with a reasonable amount of slots + tryRegisterNewLunchBox("foodcrate", 12); + } + } + + public static final void init() { + if (LoadedMods.SpiceOfLife) { + + } + } + + public static final void postInit() { + if (LoadedMods.SpiceOfLife) { + + } + } + + private static boolean tryRegisterNewLunchBox(String aItemName, int aSlots) { + Item aNewBox = getNewLunchBox(aItemName, aSlots); + if (aNewBox != null) { + GameRegistry.registerItem(aNewBox, aItemName); + Logger.INFO("[Spice of Life] Registered "+aItemName+" as a new food container."); + return true; + } + return false; + } + + private static Item getNewLunchBox(String aItemName, int aSlots) { + Class aItemFoodContainer = ReflectionUtils.getClass("squeek.spiceoflife.items.ItemFoodContainer"); + if (aItemFoodContainer != null) { + Constructor aItemFoodContainerConstructor = ReflectionUtils.getConstructor(aItemFoodContainer, new Class[] {String.class, int.class}); + if (aItemFoodContainerConstructor != null) { + Object aNewObject = ReflectionUtils.createNewInstanceFromConstructor(aItemFoodContainerConstructor, new Object[] {aItemName, aSlots}); + if (aNewObject instanceof Item) { + Item aNewInstance = (Item) aNewObject; + return aNewInstance; + } + } + } + return null; + } + + + + + +} diff --git a/src/resources/assets/spiceoflife/lang/de_DE.lang b/src/resources/assets/spiceoflife/lang/de_DE.lang new file mode 100644 index 0000000000..63ad1e2a98 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/de_DE.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Voedselkrat \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/en_US.lang b/src/resources/assets/spiceoflife/lang/en_US.lang new file mode 100644 index 0000000000..bf16f4dc93 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/en_US.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Food Crate \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/es_ES.lang b/src/resources/assets/spiceoflife/lang/es_ES.lang new file mode 100644 index 0000000000..02fe4c8806 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/es_ES.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Caja de comida \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/fr_FR.lang b/src/resources/assets/spiceoflife/lang/fr_FR.lang new file mode 100644 index 0000000000..418c2b7053 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/fr_FR.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Caisse alimentaire \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/it_IT.lang b/src/resources/assets/spiceoflife/lang/it_IT.lang new file mode 100644 index 0000000000..841b97c63f --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/it_IT.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Cassa Alimentare \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/ko_KR.lang b/src/resources/assets/spiceoflife/lang/ko_KR.lang new file mode 100644 index 0000000000..7e9973e936 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/ko_KR.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=음식 상자 \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/ru_RU.lang b/src/resources/assets/spiceoflife/lang/ru_RU.lang new file mode 100644 index 0000000000..e167a0ae03 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/ru_RU.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=Продовольственный ящик \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/lang/zh_CN.lang b/src/resources/assets/spiceoflife/lang/zh_CN.lang new file mode 100644 index 0000000000..bb211e7b57 --- /dev/null +++ b/src/resources/assets/spiceoflife/lang/zh_CN.lang @@ -0,0 +1,2 @@ +# Items +item.spiceoflife.foodcrate.name=食品箱 \ No newline at end of file diff --git a/src/resources/assets/spiceoflife/textures/items/foodcrate.png b/src/resources/assets/spiceoflife/textures/items/foodcrate.png new file mode 100644 index 0000000000..b717dd0318 Binary files /dev/null and b/src/resources/assets/spiceoflife/textures/items/foodcrate.png differ diff --git a/src/resources/assets/spiceoflife/textures/items/foodcrate_open_empty.png b/src/resources/assets/spiceoflife/textures/items/foodcrate_open_empty.png new file mode 100644 index 0000000000..4dbfd54ea7 Binary files /dev/null and b/src/resources/assets/spiceoflife/textures/items/foodcrate_open_empty.png differ diff --git a/src/resources/assets/spiceoflife/textures/items/foodcrate_open_full.png b/src/resources/assets/spiceoflife/textures/items/foodcrate_open_full.png new file mode 100644 index 0000000000..0284bd29ad Binary files /dev/null and b/src/resources/assets/spiceoflife/textures/items/foodcrate_open_full.png differ -- cgit