diff options
49 files changed, 2079 insertions, 309 deletions
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<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune){ + ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); + 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<? extends ItemBlock> 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<String>[] 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<String>[] aTextureData = new CubicObject[] {new CubicObject<String>(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<Pair<Item, IItemRenderer>> mItemRenderMappings = new AutoMap<Pair<Item, IItemRenderer>>(); - + 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<Packet_Lightning, IMessage>{ - @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<list.tagCount();i++){ + final NBTTagCompound data = list.getCompoundTagAt(i); + final int slot = data.getInteger("Slot"); + if((slot >= 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<INV_SIZE;i++){ + final ItemStack stack = this.inventory[i]; + if(stack != null){ + //Utils.LOG_INFO("Trying to write NBT data to inventory."); + final NBTTagCompound data = new NBTTagCompound(); + stack.writeToNBT(data); + data.setInteger("Slot", i); + list.appendTag(data); + } + } + nbt.setTag("Items", list); + } + + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + public ItemStack[] getInventory(){ + return this.inventory; + } + + @Override + public ItemStack getStackInSlot(final int slot) + { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) + { + ItemStack stack = this.getStackInSlot(slot); + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) + { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) + { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 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<T extends IMessage> extends AbstractMessageHandler<T> { + + 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 <T extends IMessage> implements IMessageHandler <T, IMessage> +{ + /** + * 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<T extends IMessage> extends AbstractMessageHandler<T> { + + 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<Packet_VolumetricFlaskGui> 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<Packet_VolumetricFlaskGui2> 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<Item, IItemRenderer> 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<ironTypes.length;y++) { //Iron bars String ironRecipe = "stick"+ironTypes[y]+"Iron"; - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( null, CI.craftingToolWrench, null, ironRecipe, ironRecipe, ironRecipe, ironRecipe, ironRecipe, ironRecipe, @@ -189,7 +189,7 @@ public class RECIPES_General { //Mining Explosive Logger.RECIPE("[Inspection] Explosives"); - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( CI.explosiveITNT, CI.explosiveTNT, CI.explosiveITNT, CI.explosiveTNT, "frameGtIron", CI.explosiveTNT, "dustSulfur", CI.explosiveTNT, "dustSulfur", @@ -198,7 +198,7 @@ public class RECIPES_General { } //Alkalus Coin - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "gemExquisiteRuby", "gemFlawlessDiamond", "gemExquisiteDiamond", "gemFlawlessRuby", ItemList.Credit_Greg_Osmium.get(1), "gemFlawlessSapphire", "gemExquisiteEmerald", "gemFlawlessEmerald", "gemExquisiteSapphire", @@ -222,7 +222,7 @@ public class RECIPES_General { }*/ Logger.RECIPE("[Inspection] Wither Cage"); - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", "plateTungstenSteel", getSimpleStack(Items.nether_star), "plateTungstenSteel", "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", @@ -231,7 +231,7 @@ public class RECIPES_General { } /*Logger.RECIPE("[Inspection] Xp Converter"); - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.nether_star), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), @@ -259,7 +259,7 @@ public class RECIPES_General { Logger.INFO("Added a recipe for Fiber."); } - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( null, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), null, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), CI.craftingToolKnife, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), null, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), null, @@ -268,7 +268,7 @@ public class RECIPES_General { } Logger.RECIPE("[Inspection] Net"); - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), null, null, null, @@ -307,7 +307,7 @@ public class RECIPES_General { private static boolean addCompressedObsidian(){ //Invert Obsidian - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( getSimpleStack(Items.redstone), getSimpleStack(Items.glowstone_dust), getSimpleStack(Items.redstone), getSimpleStack(Items.glowstone_dust), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 1, 1), getSimpleStack(Items.glowstone_dust), getSimpleStack(Items.redstone), getSimpleStack(Items.glowstone_dust), getSimpleStack(Items.redstone), @@ -327,7 +327,7 @@ public class RECIPES_General { final ItemStack input = mItems[r]; final ItemStack output = mItems[r+1]; - if (RecipeUtils.recipeBuilder( + if (RecipeUtils.addShapedRecipe( input, input, input, input, input, input, input, input, input, diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java index fd513809ed..71b4c4ef48 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_MachineComponents.java @@ -264,22 +264,22 @@ public class RECIPES_MachineComponents { CI.fieldGenerator_MAX); //Sensor Modules - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateTier7, null, circuitTier6, plateTier7, rodTier7c, null, circuitTier7, plateTier7, plateTier7, CI.sensor_LuV); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateTier8, null, circuitTier7, plateTier8, rodTier8c, null, circuitTier8, plateTier8, plateTier8, CI.sensor_ZPM); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateTier9, null, circuitTier8, plateTier9, rodTier9c, null, circuitTier9, plateTier9, plateTier9, CI.sensor_UV); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateTier10, null, circuitTier9, plateTier10, rodTier10c, null, circuitTier10, plateTier10, plateTier10, @@ -334,7 +334,7 @@ public class RECIPES_MachineComponents { wireTier0, circuitTier0, wireTier0, CI.fieldGenerator_ULV); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateTier0, null, circuitTier1, plateTier0, rodTier2, null, circuitTier0, plateTier0, plateTier0, @@ -377,7 +377,7 @@ public class RECIPES_MachineComponents { circuitTier10, circuitTier9, circuitTier10, wireTier10, circuitTier10, wireTier10, CI.fieldGenerator_MAX); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateTier10, null, circuitTier9, plateTier10, rodTier10c, null, circuitTier10, plateTier10, plateTier10, diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 387f7bef65..391073dcc2 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -28,7 +28,9 @@ import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.everglades.dimension.Dimension_Everglades; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.covers.CoverManager; +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import net.minecraft.block.Block; @@ -628,7 +630,7 @@ public class RECIPES_Machines { } - //Steam Condenser + //RF Convertor if (LoadedMods.CoFHCore && CORE.ConfigSwitches.enableMachine_RF_Convetor){ RecipeUtils.addShapedGregtechRecipe( CI.getPlate(4, 1), CI.getTieredCircuitOreDictName(5), CI.getPlate(4, 1), @@ -636,6 +638,37 @@ public class RECIPES_Machines { CI.getPlate(4, 1), plateEnergeticAlloy, CI.getPlate(4, 1), GregtechItemList.Energy_Buffer_RF_Convertor.get(1)); } + + // Egg Box + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(8), + CI.getTieredMachineHull(3), + ItemUtils.getSimpleStack(Items.egg, 64), + ItemUtils.getSimpleStack(ModItems.itemRope, 32), + CI.getPlate(4, GTNH ? 16 : 8) + }, + FluidUtils.getFluidStack("mobessence", 4096), + ItemUtils.getSimpleStack(ModBlocks.blockEggBox, 1), + 20 * 60, + 480); + + //Flask Configurator + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getNumberedAdvancedCircuit(8), + CI.getTieredMachineHull(2), + ItemUtils.getSimpleStack(ModBlocks.blockCircuitProgrammer), + VolumetricFlaskHelper.getVolumetricFlask(8), + CI.getTieredComponent(OrePrefixes.pipeSmall, 2, GTNH ? 4 : 2), + CI.getPlate(2, GTNH ? 8 : 4) + }, + CI.getAlternativeTieredFluid(1, 144 * 8), + ItemUtils.getSimpleStack(ModBlocks.blockVolumetricFlaskSetter, 1), + 20 * 60, + 120); + } if (CORE.ConfigSwitches.enableMultiblock_IronBlastFurnace){ @@ -1462,7 +1495,7 @@ public class RECIPES_Machines { if (CORE.ConfigSwitches.enableMultiblock_PowerSubstation){ - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "screwTitanium", "plateIncoloy020", "screwTitanium", "plateIncoloy020", "frameGtIncoloyMA956", "plateIncoloy020", "screwTitanium", "plateIncoloy020", "screwTitanium", @@ -1470,7 +1503,7 @@ public class RECIPES_Machines { ItemStack mBattery = ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "plateIncoloyMA956", mBattery, "plateIncoloyMA956", GregtechItemList.Casing_Power_SubStation.get(1), GregtechItemList.Casing_Vanadium_Redox.get(1), GregtechItemList.Casing_Power_SubStation.get(1), "plateIncoloy020", "plateIncoloyMA956", "plateIncoloy020", @@ -1478,13 +1511,13 @@ public class RECIPES_Machines { } if (CORE.ConfigSwitches.enableMultiblock_IndustrialThermalCentrifuge){ - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "plateRedSteel", CI.craftingToolHammer_Hard, "plateRedSteel", "plateRedSteel", "frameGtBlackSteel", "plateRedSteel", "plateRedSteel", CI.craftingToolWrench, "plateRedSteel", GregtechItemList.Casing_ThermalCentrifuge.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "plateRedSteel","circuitData","plateRedSteel", "stickTalonite",EV_MACHINE_ThermalCentrifuge,"stickTalonite", "plateRedSteel","gearGtTalonite","plateRedSteel", @@ -1492,13 +1525,13 @@ public class RECIPES_Machines { } if (CORE.ConfigSwitches.enableMultiblock_IndustrialWashPlant){ - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "plateGrisium", CI.craftingToolHammer_Hard, "plateGrisium", "plateTalonite", "frameGtGrisium", "plateTalonite", "plateGrisium", CI.craftingToolWrench, "plateGrisium", GregtechItemList.Casing_WashPlant.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "plateGrisium",CI.electricPump_MV,"plateGrisium", "plateTalonite",EV_MACHINE_OreWasher,"plateTalonite", "plateGrisium","circuitData","plateGrisium", @@ -1550,13 +1583,13 @@ public class RECIPES_Machines { if (CORE.ConfigSwitches.enableMultiblock_IndustrialCuttingMachine){ ItemStack plate = ALLOY.MARAGING300.getPlate(1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate, CI.craftingToolHammer_Hard, plate, "plateStellite", "frameGtTalonite", "plateStellite", plate, CI.craftingToolWrench, plate, GregtechItemList.Casing_CuttingFactoryFrame.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate,CI.getTieredCircuit(3),plate, "wireFinePlatinum", EV_MACHINE_Cutter, "wireFinePlatinum", plate,CI.getTieredCircuit(4),plate, @@ -1566,13 +1599,13 @@ public class RECIPES_Machines { //EV_MACHINE_Extruder if (CORE.ConfigSwitches.enableMultiblock_IndustrialExtrudingMachine){ ItemStack plate = ALLOY.INCONEL_690.getPlate(1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate, CI.craftingToolHammer_Hard, plate, "plateTalonite", "frameGtStaballoy", "plateTalonite", plate, CI.craftingToolWrench, plate, GregtechItemList.Casing_Extruder.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate,CI.getTieredCircuit(4),plate, CI.electricPiston_EV, EV_MACHINE_Extruder, CI.electricPiston_EV, plate,CI.getTieredCircuit(4),plate, @@ -1581,13 +1614,13 @@ public class RECIPES_Machines { if (CORE.ConfigSwitches.enableMultiblock_IndustrialFishingPort){ ItemStack plate = ALLOY.AQUATIC_STEEL.getPlate(1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate, CI.craftingToolHammer_Hard, plate, "plateEglinSteel", "frameGtEglinSteel", "plateEglinSteel", plate, CI.craftingToolWrench, plate, GregtechItemList.Casing_FishPond.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate,CI.getTieredCircuit(3),plate, "wireFineElectrum", ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), "wireFineElectrum", plate,CI.getTieredCircuit(2),plate, @@ -1602,12 +1635,12 @@ public class RECIPES_Machines { ItemStack cell1 = ItemList.Reactor_Coolant_He_6.get(1); ItemStack cell2 = ItemList.Reactor_Coolant_NaK_6.get(1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate, gear, plate, cell1, frame, cell2, plate, gear, plate, GregtechItemList.Casing_AdvancedVacuum.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( gear,CI.getTieredCircuit(6),gear, CI.electricPiston_IV, GregtechItemList.Casing_AdvancedVacuum.get(1), CI.electricPiston_IV, plate, GregtechItemList.Gregtech_Computer_Cube.get(1), plate, @@ -1621,12 +1654,12 @@ public class RECIPES_Machines { cell2 = ItemUtils.simpleMetaStack("IC2:reactorVentGold:1", 1, 1); ItemStack cell3 = ItemUtils.simpleMetaStack("IC2:reactorVentDiamond:1:1", 1, 1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate, cell1, plate, cell3, frame, cell2, plate, gear, plate, GregtechItemList.Casing_Adv_BlastFurnace.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( gear,CI.getTieredCircuit(6),gear, CI.robotArm_IV, GregtechItemList.Casing_Adv_BlastFurnace.get(1), CI.robotArm_IV, plate, GregtechItemList.Gregtech_Computer_Cube.get(1), plate, @@ -1639,7 +1672,7 @@ public class RECIPES_Machines { cell1 = ItemUtils.simpleMetaStack("IC2:reactorHeatSwitchDiamond:1", 1, 1); cell2 = ItemUtils.simpleMetaStack("IC2:reactorVentGold:1", 1, 1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( gear,CI.getTieredCircuit(6),gear, CI.fieldGenerator_IV, CI.machineHull_ZPM, CI.robotArm_IV, plate, GregtechItemList.Gregtech_Computer_Cube.get(1), plate, @@ -1657,12 +1690,12 @@ public class RECIPES_Machines { ItemStack aTieredUnboxinator = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? ItemUtils.getValueOfItemList("Machine_LuV_Unboxinator", 1, ItemList.Machine_IV_Unboxinator.get(1)) : ItemList.Machine_IV_Unboxinator.get(1); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate, ItemUtils.getItemStackOfAmountFromOreDict("cableGt12VanadiumGallium", 1), plate, cell1, frame, cell2, plate, gear, plate, GregtechItemList.Casing_AmazonWarehouse.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( casingAmazon, CI.getTieredCircuit(7), casingAmazon, CI.robotArm_LuV, aTieredUnboxinator, CI.robotArm_LuV, CI.conveyorModule_LuV, GregtechItemList.Gregtech_Computer_Cube.get(1), CI.conveyorModule_LuV, @@ -1670,7 +1703,7 @@ public class RECIPES_Machines { //Industrial Mixing Machine - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "plateStaballoy",CI.getTieredCircuit(5),"plateStaballoy", "plateZirconiumCarbide", EV_MACHINE_Mixer, "plateZirconiumCarbide", "plateStaballoy",CI.getTieredCircuit(5),"plateStaballoy", @@ -1704,13 +1737,13 @@ public class RECIPES_Machines { o_Distillery = ItemList.Machine_EV_FluidExtractor.get(1); o_Extractor = ItemList.Machine_EV_Extractor.get(1); } - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plate, CI.craftingToolHammer_Hard, plate, "plateStainlessSteel", "frameGtZirconiumCarbide", "plateStainlessSteel", plate, CI.craftingToolWrench, plate, GregtechItemList.Casing_Multi_Use.get(Casing_Amount)); - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( o_Compressor, o_Lathe, o_Electromagnet, plate, ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), plate, o_Fermenter, o_Distillery, o_Extractor, diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java index 2cc6d7b41a..42448e6b74 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Tools.java @@ -135,42 +135,42 @@ public class RECIPES_Tools { private static void run(){ //Staballoy Pickaxe - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateStaballoy, plateStaballoy, ingotStaballoy, craftingToolFile, stickTungsten, craftingToolHardHammer, craftingToolWrench, stickTungsten, craftingToolHardHammer, RECIPE_StaballoyPickaxe); //Staballoy Axe - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateStaballoy, ingotStaballoy, craftingToolHardHammer, plateStaballoy, stickTungsten, craftingToolHardHammer, craftingToolFile, stickTungsten, craftingToolWrench, RECIPE_StaballoyAxe); //Cobble to Sand - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( CobbleStone, CobbleStone, CobbleStone, CobbleStone, sandHammer, CobbleStone, CobbleStone, CobbleStone, CobbleStone, RECIPE_Sand); //Sand to Sandstone - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( Sand, Sand, Sand, Sand, sandHammer, Sand, Sand, Sand, Sand, RECIPE_SandStone); //Sandstone Hammer - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( plateElectrum, ingotElectrum, plateElectrum, craftingToolScrewdriver, stickBronze, craftingToolHardHammer, null, stickSteel, null, RECIPE_SandstoneHammer); //Basic Firemaker - RecipeUtils.recipeBuilder( + RecipeUtils.addShapedRecipe( "cropWheat", "cropWheat", "cropWheat", ItemUtils.getSimpleStack(Items.string), stickWood, ItemUtils.getSimpleStack(Items.string), "cropWheat", "cropWheat", "cropWheat", diff --git a/src/Java/gtPlusPlus/core/slots/SlotVolumetricFlask.java b/src/Java/gtPlusPlus/core/slots/SlotVolumetricFlask.java new file mode 100644 index 0000000000..b8955f6dc8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotVolumetricFlask.java @@ -0,0 +1,30 @@ +package gtPlusPlus.core.slots; + +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class SlotVolumetricFlask extends Slot { + + public static Item mFlask; + + public SlotVolumetricFlask(final IInventory inventory, final int slot, final int x, final int y) { + super(inventory, slot, x, y); + } + + @Override + public synchronized boolean isItemValid(final ItemStack itemstack) { + return isItemValidForSlot(itemstack); + } + + public static synchronized boolean isItemValidForSlot(final ItemStack itemstack) { + return VolumetricFlaskHelper.isVolumetricFlask(itemstack); + } + + @Override + public int getSlotStackLimit() { + return 16; + } +} diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index 246bacca19..62b545c5c8 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -43,6 +43,10 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityRoundRobinator.class, "TileEntityRoundRobinator"); GameRegistry.registerTileEntity(TileEntityEggBox.class, "TileEggBox"); + if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { + GameRegistry.registerTileEntity(TileEntityVolumetricFlaskSetter.class, "TileEntityVolumetricFlaskSetter"); + } + //Mod TEs if (LoadedMods.Thaumcraft){ @@ -53,6 +57,7 @@ public class ModTileEntities { private static void blacklistTilesFromAcceleration() { Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEntityFishTrap"); Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest"); + Meta_GT_Proxy.setTileEntityClassAsBlacklistedInWorldAccelerator("gtPlusPlus.core.tileentities.general.TileEggBox"); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java new file mode 100644 index 0000000000..9ca9730330 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityVolumetricFlaskSetter.java @@ -0,0 +1,348 @@ +package gtPlusPlus.core.tileentities.general; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.container.Container_VolumetricFlaskSetter; +import gtPlusPlus.core.inventories.Inventory_VolumetricFlaskSetter; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.xmod.gregtech.common.helpers.VolumetricFlaskHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityVolumetricFlaskSetter extends TileEntity implements ISidedInventory { + + private int tickCount = 0; + private final Inventory_VolumetricFlaskSetter inventoryContents; + private String customName; + public int locationX; + public int locationY; + public int locationZ; + private int aCurrentMode = 0; + private int aCustomValue = 1000; + + public TileEntityVolumetricFlaskSetter() { + this.inventoryContents = new Inventory_VolumetricFlaskSetter(); + this.setTileLocation(); + } + + public int getCustomValue() { + Logger.INFO("Value: "+this.aCustomValue); + return this.aCustomValue; + } + + public void setCustomValue(int aVal) { + Logger.INFO("Old Value: "+this.aCustomValue); + this.aCustomValue = aVal; + Logger.INFO("New Value: "+this.aCustomValue); + markDirty(); + } + + public boolean setTileLocation() { + if (this.hasWorldObj()) { + if (!this.getWorldObj().isRemote) { + this.locationX = this.xCoord; + this.locationY = this.yCoord; + this.locationZ = this.zCoord; + return true; + } + } + return false; + } + + //Rename to hasCircuitToConfigure + public final boolean hasFlask() { + for (ItemStack i : this.getInventory().getInventory()) { + if (i == null) { + continue; + } + else { + return true; + } + } + return false; + } + + public Inventory_VolumetricFlaskSetter getInventory() { + return this.inventoryContents; + } + + public boolean addOutput() { + ItemStack[] aInputs = this.getInventory().getInventory().clone(); + //Check if there is output in slot. + Boolean hasOutput = false; + if (aInputs[Container_VolumetricFlaskSetter.SLOT_OUTPUT] != null) { + hasOutput = true; + } + AutoMap<Integer> aValidSlots = new AutoMap<Integer>(); + 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<this.getInventory().getSizeInventory(); r++){ + accessibleSides[r]=r; + } + return accessibleSides; + + } + + @Override + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { + return p_102007_1_ >= 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<Object> list = new ArrayList<Object>(Arrays.asList(v)); + list.removeAll(Collections.singleton((Object)null)); + return list.toArray(new Object[list.size()]); + } + public static ItemStack[] removeNulls(final ItemStack[] v) { List<ItemStack> list = new ArrayList<ItemStack>(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<String> { + + 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<Runnable> GT_BlockIconload = new ArrayList<>(); @@ -76,6 +64,10 @@ public class Meta_GT_Proxy { public static final Map<String, FormattedTooltipString> mCustomGregtechMetaTooltips = new LinkedHashMap<String, FormattedTooltipString>(); + /** + * 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 Binary files differnew file mode 100644 index 0000000000..08f9761233 --- /dev/null +++ b/src/resources/assets/miscutils/textures/gui/VolumetricFlaskSetter.png |