From 86edf93e4bdf56ed4974d0c06eca5de309ca4f9a Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 14 Apr 2020 23:12:54 +0100 Subject: + Added a way to register blocks that will cause MachineUpdates when placed. (Useful for non-GT blocks used in Multis) $ Fixed Industrial Cutting Machine defaulting to slicing mode. $ Fixed reInit() on recipe maps causing absurd crashes. (Doesn't seem to break anything at the moment not doing it, so.. I won't) --- .../common/helpers/MachineUpdateHandler.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/helpers') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java new file mode 100644 index 0000000000..0b52560e0d --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/MachineUpdateHandler.java @@ -0,0 +1,42 @@ +package gtPlusPlus.xmod.gregtech.common.helpers; + +import java.util.HashMap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.GregTech_API; +import net.minecraft.block.Block; +import net.minecraftforge.event.world.BlockEvent; + +public class MachineUpdateHandler { + + private static final HashMap mBlockCache = new HashMap(); + + public static void registerBlockToCauseMachineUpdate(String aUnlocalName, Block aBlock) { + mBlockCache.put(aUnlocalName, aBlock); + } + + @SubscribeEvent + public void onBlockEvent(BlockEvent event) { + Block aBlock = event.block; + String aUnlocalName = aBlock != null ? aBlock.getUnlocalizedName() : "NULL"; + boolean aDoUpdate = false; + if (aBlock != null && aUnlocalName != null && !aUnlocalName.equals("NULL")) { + for (String aCachedName : mBlockCache.keySet()) { + if (aCachedName.equals(aUnlocalName)) { + aDoUpdate = true; + break; + } + else { + if (aBlock == mBlockCache.get(aCachedName)) { + aDoUpdate = true; + break; + } + } + } + if (aDoUpdate) { + GregTech_API.causeMachineUpdate(event.world, event.x, event.y, event.z); + } + } + } + +} -- 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/xmod/gregtech/common/helpers') 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 0b64ce224c2e3dc93d13d968a9094ebcb4903de6 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Tue, 26 May 2020 19:28:03 +0100 Subject: + Added new Volumetric Flasks. % Updated GT to reflect required change for additional Volumetric Flasks. --- src/Java/gtPlusPlus/core/item/ModItems.java | 13 +++++++++-- .../xmod/gregtech/api/enums/GregtechItemList.java | 4 ++++ .../common/helpers/VolumetricFlaskHelper.java | 26 ++++++++++++++++++++- .../chemplant/GregtechMTE_ChemicalPlant.java | 3 --- .../textures/items/gt.Volumetric_Flask_64k.png | Bin 0 -> 1013 bytes .../items/gt.Volumetric_Flask_64k.window.png | Bin 0 -> 399 bytes .../textures/items/gt.Volumetric_Flask_8k.png | Bin 0 -> 1010 bytes .../items/gt.Volumetric_Flask_8k.window.png | Bin 0 -> 398 bytes 8 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.png create mode 100644 src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.window.png create mode 100644 src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_8k.png create mode 100644 src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_8k.window.png (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/helpers') diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 1303ba2ab6..bc9cb4bc5e 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -4,8 +4,10 @@ import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; import static gtPlusPlus.core.lib.CORE.LOAD_ALL_CONTENT; import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.items.GT_VolumetricFlask; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.BlockBaseModular; @@ -100,6 +102,9 @@ import gtPlusPlus.everglades.GTplusplus_Everglades; import gtPlusPlus.preloader.CORE_Preloader; import gtPlusPlus.xmod.cofh.HANDLER_COFH; import gtPlusPlus.xmod.eio.material.MaterialEIO; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; @@ -976,8 +981,12 @@ public final class ModItems { itemIonParticleBase = new IonParticles(); itemStandarParticleBase = new StandardBaseParticles(); - - + 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); + GregtechItemList.VOLUMETRIC_FLASK_8k.set(a8kFlask); + GregtechItemList.VOLUMETRIC_FLASK_64k.set(a64kFlask); + } itemBoilerChassis = new ItemBoilerChassis(); itemDehydratorCoilWire = new ItemDehydratorCoilWire(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 9c22258e45..7d3476d48b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -94,6 +94,10 @@ public enum GregtechItemList implements GregtechItemContainer { //Debug TESTITEM, + + // Larger Volumetric Flasks + VOLUMETRIC_FLASK_8k, + VOLUMETRIC_FLASK_64k, //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 76bb378377..a169419fea 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -1,9 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.helpers; +import java.lang.reflect.Constructor; import java.lang.reflect.Method; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -25,12 +27,22 @@ public class VolumetricFlaskHelper { sMethodGetFlaskMaxCapacity = null; } } - + public static ItemStack getVolumetricFlask(int aAmount) { 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_64k.get(aAmount); + return aFlask; + } + public static boolean isVolumetricFlask(ItemStack aStack) { if (mFlask == null) { ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null); @@ -77,5 +89,17 @@ public class VolumetricFlaskHelper { nbt.setInteger("Capacity", aCapacity); return true; } + + public static Item generateNewFlask(String unlocalized, String english, int maxCapacity) { + Constructor aFlask = ReflectionUtils.getConstructor(sClassVolumetricFlask, new Class[] {String.class, String.class, int.class}); + if (aFlask != null) { + Object aInstance = ReflectionUtils.createNewInstanceFromConstructor(aFlask, new Object[] {unlocalized, english, maxCapacity}); + if (aInstance != null && aInstance instanceof Item) { + Item aNewFlaskItem = (Item) aInstance; + return aNewFlaskItem; + } + } + return null; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index 7fd89c481a..0883647c3d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -749,7 +749,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { markDirty(); } } - Logger.INFO("SolidCasingTier: "+mSolidCasingTier); super.onPostTick(aBaseMetaTileEntity, aTick); } @@ -1046,11 +1045,9 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase { for (int aTier : mTieredBlockRegistry.keySet()) { Triplet aData = mTieredBlockRegistry.get(aTier); if (aData.getValue_1() == aInitStructureCheck && aData.getValue_2() == aInitStructureCheckMeta) { - Logger.INFO("Found Tier information for "+aTier); return aTier; } } - Logger.INFO("Could not find tier info for "+aInitStructureCheck.getLocalizedName()+"|"+aInitStructureCheckMeta); return 0; } catch (Throwable t) { 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 new file mode 100644 index 0000000000..13b37c999d Binary files /dev/null and b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.png 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 new file mode 100644 index 0000000000..3fd5382926 Binary files /dev/null and b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_64k.window.png differ diff --git a/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_8k.png b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_8k.png new file mode 100644 index 0000000000..ffd9d4893b Binary files /dev/null and b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_8k.png differ diff --git a/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_8k.window.png b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_8k.window.png new file mode 100644 index 0000000000..a08018f561 Binary files /dev/null and b/src/resources/assets/gregtech/textures/items/gt.Volumetric_Flask_8k.window.png differ -- cgit From c5970457e812661b3b8cb6ffe0054df797197679 Mon Sep 17 00:00:00 2001 From: Alkalus 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/xmod/gregtech/common/helpers') 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/xmod/gregtech/common/helpers') 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 c66ed4cb8ba64a2fc6132cd7c039738922d0bb23 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Wed, 27 May 2020 13:45:04 +0100 Subject: $ Fixed TC dependency within the Fake Player checker. + Added basic TC transformer to try debug the StackOverflowError caused by TC/ExU/GT. --- .../core/handler/events/BlockEventHandler.java | 17 +-- .../core/handler/events/EntityDeathHandler.java | 4 - .../core/util/minecraft/PlayerUtils.java | 17 ++- .../preloader/asm/ClassesToTransform.java | 1 + .../preloader/asm/helpers/MethodHelper_TC.java | 121 +++++++++++++++++++ ...ssTransformer_TC_ThaumcraftCraftingManager.java | 131 +++++++++++++++++++++ .../Preloader_Transformer_Handler.java | 4 + .../common/helpers/VolumetricFlaskHelper.java | 48 +++++--- 8 files changed, 305 insertions(+), 38 deletions(-) create mode 100644 src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_TC.java create mode 100644 src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/helpers') diff --git a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java index 6da2dac38b..03bb99bb2a 100644 --- a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java @@ -1,18 +1,11 @@ package gtPlusPlus.core.handler.events; -import static gtPlusPlus.core.lib.CORE.ConfigSwitches.*; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.chanceToDropDrainedShard; +import static gtPlusPlus.core.lib.CORE.ConfigSwitches.chanceToDropFluoriteOre; import java.util.ArrayList; -import java.util.Map; -import java.util.WeakHashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChunkCoordinates; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.LoadedMods; @@ -20,12 +13,14 @@ import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import net.minecraftforge.common.util.FakePlayer; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.oredict.OreDictionary; -import thaumcraft.common.lib.FakeThaumcraftPlayer; public class BlockEventHandler { public static ArrayList oreLimestone; diff --git a/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java b/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java index 3492ee4788..391672e028 100644 --- a/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java @@ -11,14 +11,10 @@ import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.ChunkCoordinates; -import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.living.LivingDropsEvent; -import thaumcraft.common.lib.FakeThaumcraftPlayer; public class EntityDeathHandler { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java index 110b2baf25..24ffa295b7 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/PlayerUtils.java @@ -4,8 +4,8 @@ import java.util.*; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -16,11 +16,20 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; -import thaumcraft.common.lib.FakeThaumcraftPlayer; public class PlayerUtils { public static final Map mCachedFakePlayers = new WeakHashMap(); + private static final Class mThaumcraftFakePlayer; + + static { + if (ReflectionUtils.doesClassExist("thaumcraft.common.lib.FakeThaumcraftPlayer")) { + mThaumcraftFakePlayer = ReflectionUtils.getClass("thaumcraft.common.lib.FakeThaumcraftPlayer"); + } + else { + mThaumcraftFakePlayer = null; + } + } public static void messagePlayer(final EntityPlayer P, final String S){ gregtech.api.util.GT_Utility.sendChatToPlayer(P, S); @@ -203,7 +212,7 @@ public class PlayerUtils { public static void cacheFakePlayer(EntityPlayer aPlayer) { ChunkCoordinates aChunkLocation = aPlayer.getPlayerCoordinates(); // Cache Fake Player - if (aPlayer instanceof FakePlayer || aPlayer instanceof FakeThaumcraftPlayer + if (aPlayer instanceof FakePlayer || (mThaumcraftFakePlayer != null && mThaumcraftFakePlayer.isInstance(aPlayer)) || (aPlayer.getCommandSenderName() == null || aPlayer.getCommandSenderName().length() <= 0) || (aPlayer.isEntityInvulnerable() && !aPlayer.canCommandSenderUseCommand(0, "") @@ -225,7 +234,7 @@ public class PlayerUtils { cacheFakePlayer(p); return false; } - if (p instanceof FakeThaumcraftPlayer) { + if (mThaumcraftFakePlayer != null && mThaumcraftFakePlayer.isInstance(p) ) { cacheFakePlayer(p); return false; } diff --git a/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java b/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java index 3366f4aefe..a29cebfda1 100644 --- a/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java +++ b/src/Java/gtPlusPlus/preloader/asm/ClassesToTransform.java @@ -52,6 +52,7 @@ public class ClassesToTransform { public static final String THAUMCRAFT_ITEM_WISP_ESSENCE = "thaumcraft.common.items.ItemWispEssence"; + public static final String THAUMCRAFT_CRAFTING_MANAGER = "thaumcraft.common.lib.crafting.ThaumcraftCraftingManager"; public static final String THAUMICTINKERER_TILE_REPAIRER = "thaumic.tinkerer.common.block.tile.TileRepairer"; public static final String IC2_ITEM_ARMOUR_HAZMAT = "ic2.core.item.armor.ItemArmorHazmat"; diff --git a/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_TC.java b/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_TC.java new file mode 100644 index 0000000000..e7355c7d90 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/helpers/MethodHelper_TC.java @@ -0,0 +1,121 @@ +package gtPlusPlus.preloader.asm.helpers; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.Preloader_Logger; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager; + +public class MethodHelper_TC { + + private static Class mThaumcraftCraftingManager; + + public static AspectList generateTags(final Item item, final int meta, final ArrayList history) { + int tmeta = meta; + if (item == null) { + return null; + } + Preloader_Logger.INFO("Generating aspect tags for "+item.getUnlocalizedName()+":"+meta); + try { + tmeta = ((new ItemStack(item, 1, meta).getItem().isDamageable() || !new ItemStack(item, 1, meta).getItem().getHasSubtypes()) ? 32767 : meta); + } + catch (Exception ex) {} + Preloader_Logger.INFO("Set Meta to "+tmeta); + if (ThaumcraftApi.exists(item, tmeta)) { + return ThaumcraftCraftingManager.getObjectTags(new ItemStack(item, 1, tmeta)); + } + if (history.contains(Arrays.asList(item, tmeta))) { + return null; + } + history.add(Arrays.asList(item, tmeta)); + if (history.size() < 100) { + AspectList ret = generateTagsFromRecipes(item, (tmeta == 32767) ? 0 : meta, history); + ret = capAspects(ret, 64); + ThaumcraftApi.registerObjectTag(new ItemStack(item, 1, tmeta), ret); + return ret; + } + return null; + } + + private static AspectList capAspects(final AspectList sourcetags, final int amount) { + if (sourcetags == null) { + return sourcetags; + } + final AspectList out = new AspectList(); + for (final Aspect aspect : sourcetags.getAspects()) { + out.merge(aspect, Math.min(amount, sourcetags.getAmount(aspect))); + } + return out; + } + + private static AspectList generateTagsFromRecipes(final Item item, final int meta, final ArrayList history) { + AspectList ret = null; + ret = generateTagsFromCrucibleRecipes(item, meta, history); + if (ret != null) { + return ret; + } + ret = generateTagsFromArcaneRecipes(item, meta, history); + if (ret != null) { + return ret; + } + ret = generateTagsFromInfusionRecipes(item, meta, history); + if (ret != null) { + return ret; + } + ret = generateTagsFromCraftingRecipes(item, meta, history); + return ret; + } + + private static boolean isClassSet() { + if (mThaumcraftCraftingManager == null) { + mThaumcraftCraftingManager = ReflectionUtils.getClass("thaumcraft.common.lib.crafting.ThaumcraftCraftingManager"); + } + return true; + } + + private static Method mGetTagsFromCraftingRecipes; + private static Method mGetTagsFromInfusionRecipes; + private static Method mGetTagsFromArcaneRecipes; + private static Method mGetTagsFromCrucibleRecipes; + + private static AspectList generateTagsFromCraftingRecipes(Item item, int meta, ArrayList history) { + isClassSet(); + if (mGetTagsFromCraftingRecipes == null) { + mGetTagsFromCraftingRecipes = ReflectionUtils.getMethod(mThaumcraftCraftingManager, "generateTagsFromCraftingRecipes", new Class[] {Item.class, int.class, ArrayList.class}); + } + return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromCraftingRecipes, new Object[] {item, meta, history}); + } + + private static AspectList generateTagsFromInfusionRecipes(Item item, int meta, ArrayList history) { + isClassSet(); + if (mGetTagsFromInfusionRecipes == null) { + mGetTagsFromInfusionRecipes = ReflectionUtils.getMethod(mThaumcraftCraftingManager, "generateTagsFromInfusionRecipes", new Class[] {Item.class, int.class, ArrayList.class}); + } + return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromInfusionRecipes, new Object[] {item, meta, history}); + } + + private static AspectList generateTagsFromArcaneRecipes(Item item, int meta, ArrayList history) { + isClassSet(); + if (mGetTagsFromArcaneRecipes == null) { + mGetTagsFromArcaneRecipes = ReflectionUtils.getMethod(mThaumcraftCraftingManager, "generateTagsFromArcaneRecipes", new Class[] {Item.class, int.class, ArrayList.class}); + } + return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromArcaneRecipes, new Object[] {item, meta, history}); + } + + private static AspectList generateTagsFromCrucibleRecipes(Item item, int meta, ArrayList history) { + isClassSet(); + if (mGetTagsFromCrucibleRecipes == null) { + mGetTagsFromCrucibleRecipes = ReflectionUtils.getMethod(mThaumcraftCraftingManager, "generateTagsFromCrucibleRecipes", new Class[] {Item.class, int.class, ArrayList.class}); + } + return (AspectList) ReflectionUtils.invokeNonBool(null, mGetTagsFromCrucibleRecipes, new Object[] {item, meta, history}); + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java new file mode 100644 index 0000000000..d502af0fc8 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ThaumcraftCraftingManager.java @@ -0,0 +1,131 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.*; + +import gtPlusPlus.preloader.Preloader_Logger; + +public class ClassTransformer_TC_ThaumcraftCraftingManager { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + public ClassTransformer_TC_ThaumcraftCraftingManager(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + localClassVisitor aTempMethodRemover = new localClassVisitor(aTempWriter); + aTempReader.accept(aTempMethodRemover, 0); + boolean wasMethodObfuscated = aTempMethodRemover.getObfuscatedRemoval(); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } else { + isValid = false; + } + + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Valid patch? " + isValid + "."); + reader = aTempReader; + writer = aTempWriter; + + if (reader != null && writer != null) { + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Attempting Method Injection."); + injectMethod("generateTags", wasMethodObfuscated); + } + + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(String aMethodName, boolean wasMethodObfuscated) { + MethodVisitor mv; + boolean didInject = false; + ClassWriter cw = getWriter(); + String aitemClassName = wasMethodObfuscated ? "adb" : "net/minecraft/item/Item"; + String aClassName = "thaumcraft.common.lib.crafting.ThaumcraftCraftingManager"; + if (aMethodName.equals("generateTags")) { + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Injecting " + aMethodName + ", static replacement call to "+aClassName+"."); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "generateTags", "(L"+aitemClassName+";ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;", "(L"+aitemClassName+";ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;", null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(23, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ILOAD, 1); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/helpers/MethodHelper_TC", "generateTags", "(L"+aitemClassName+";ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitInsn(ARETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("item", "L"+aitemClassName+";", null, l0, l1, 0); + mv.visitLocalVariable("meta", "I", null, l0, l1, 1); + mv.visitLocalVariable("history", "Ljava/util/ArrayList;", "Ljava/util/ArrayList;", l0, l1, 2); + mv.visitMaxs(3, 3); + mv.visitEnd(); + didInject = true; + } + + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + public final class localClassVisitor extends ClassVisitor { + + boolean obfuscated = false; + + public localClassVisitor(ClassVisitor cv) { + super(ASM5, cv); + } + + public boolean getObfuscatedRemoval() { + return obfuscated; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + String aDeObfName = "net/minecraft/item/Item"; + String aObfName = "adb"; + String aDesc1 = "(L+aDeObfName+;ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;"; + String aDesc2 = "(L"+aObfName+";ILjava/util/ArrayList;)Lthaumcraft/api/aspects/AspectList;"; + + if (name.equals("generateTags") && (desc.equals(aDesc1) || desc.equals(aDesc2))) { + Preloader_Logger.INFO("Found method descriptor: "+desc); + if (desc.equals(aDesc1)) { + obfuscated = false; + methodVisitor = null; + } + else { + obfuscated = true; + methodVisitor = null; + } + } + else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + + if (methodVisitor == null) { + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Found method " + name + ", removing."); + Preloader_Logger.LOG("TC CraftingManager Patch", Level.INFO, "Descriptor: "+desc); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index cb9799fce7..d9496e2c0c 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -271,6 +271,10 @@ public class Preloader_Transformer_Handler implements IClassTransformer { Preloader_Logger.INFO("Thaumcraft WispEssence_Patch", "Transforming "+transformedName); return new ClassTransformer_TC_ItemWispEssence(basicClass, obfuscated).getWriter().toByteArray(); } + if (transformedName.equals(THAUMCRAFT_CRAFTING_MANAGER)) { + Preloader_Logger.INFO("Thaumcraft CraftingManager Patch", "Transforming "+transformedName); + return new ClassTransformer_TC_ThaumcraftCraftingManager(basicClass).getWriter().toByteArray(); + } //Fix Thaumic Tinkerer Shit if (transformedName.equals(THAUMICTINKERER_TILE_REPAIRER) && AsmConfig.enableThaumicTinkererRepairFix) { //Preloader_Logger.INFO("Thaumic Tinkerer RepairItem Patch", "Transforming "+transformedName); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java index e85a78b8aa..84bb52d064 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -3,6 +3,8 @@ package gtPlusPlus.xmod.gregtech.common.helpers; import java.lang.reflect.Constructor; import java.lang.reflect.Method; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -21,7 +23,15 @@ public class VolumetricFlaskHelper { static { if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { sClassVolumetricFlask = ReflectionUtils.getClass("gregtech.common.items.GT_VolumetricFlask"); - sMethodGetFlaskMaxCapacity = ReflectionUtils.getMethod(sClassVolumetricFlask, "getMaxCapacity", new Class[] {}); + Method aMaxCapacity = null; + try { + aMaxCapacity = sClassVolumetricFlask.getDeclaredMethod("getMaxCapacity", new Class[] {}); + } + catch (NoSuchMethodException e) { + e.printStackTrace(); + CORE.crash("Secondary Error Obtaining instance of 'getMaxCapacity' from 'GT_VolumetricFlask'. Crashing."); + } + sMethodGetFlaskMaxCapacity = aMaxCapacity; } else { sClassVolumetricFlask = null; @@ -101,24 +111,24 @@ public class VolumetricFlaskHelper { } return null; } - - 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())); - } - } + + 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())); + } + } public static int getFlaskCapacity(ItemStack aStack) { int capacity = 1000; -- cgit