From 7d8ba25d2dd4fa35a9ec372193342e5e445443e7 Mon Sep 17 00:00:00 2001 From: brandon3055 Date: Thu, 6 Nov 2014 19:57:09 +1100 Subject: [PATCH] commit 06/11/2014 --- build.gradle | 2 +- .../client/interfaces/GUIDraconiumChest.java | 43 ++++++- .../interfaces/manual/CraftingInfoPage.java | 2 +- .../interfaces/manual/TutorialPage.java | 2 +- .../render/block/RenderDraconiumChest.java | 4 +- .../common/blocks/BlockDE.java | 66 ---------- .../common/blocks/DraconiumChest.java | 121 ++++++++++++++++-- .../common/blocks/DraconiumOre.java | 27 ++-- .../container/ContainerDraconiumChest.java | 3 +- .../common/core/network/ButtonPacket.java | 36 +++++- .../common/core/network/TeleporterPacket.java | 4 +- .../common/core/proxy/ClientProxy.java | 1 + .../common/core/proxy/CommonProxy.java | 11 +- .../common/items/Tclogo.java | 15 ++- .../common/items/tools/TeleporterMKII.java | 2 + .../common/lib/OreDoublingRegistry.java | 61 +++++++++ .../tileentities/TileDraconiumChest.java | 98 +++++++++----- .../assets/draconicevolution/lang/en_US.lang | 5 + 18 files changed, 364 insertions(+), 139 deletions(-) create mode 100644 src/main/java/com/brandon3055/draconicevolution/common/lib/OreDoublingRegistry.java diff --git a/build.gradle b/build.gradle index 345d456d..6574862c 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ repositories { apply plugin: 'forge' -version = "1.7.10-v0.9.6-Beta-pre3" +version = "1.7.10-v0.9.6-Beta-pre5" group= "com.brandon3055.draconicevolution" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "Draconic-Evolution" diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIDraconiumChest.java index d8674ff8..823e8b29 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIDraconiumChest.java @@ -37,7 +37,7 @@ public class GUIDraconiumChest extends GuiContainer implements INEIGuiHandler { private TileDraconiumChest tile; private static final ResourceLocation textureLeft = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/DraconicChestLeft.png"); private static final ResourceLocation textureRight = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/DraconicChestRight.png"); - private boolean lastAutoFeed; + private int lastAutoFeed = -1; public GUIDraconiumChest(InventoryPlayer invPlayer, TileDraconiumChest tile) { super(new ContainerDraconiumChest(invPlayer, tile)); @@ -75,10 +75,32 @@ public class GUIDraconiumChest extends GuiContainer implements INEIGuiHandler { @Override protected void drawGuiContainerForegroundLayer(int x, int y) { fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("tile.draconicevolution:draconiumChest.name"), 4, 4, 0x00FFFF); + //fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("button.de.chestAutoFeed.txt"), 4, 180, 0x00FFFF); ArrayList list = new ArrayList(); list.add(String.valueOf(tile.getEnergyStored(ForgeDirection.DOWN)) + "/" + String.valueOf(tile.getMaxEnergyStored(ForgeDirection.DOWN)) + "RF"); if (GuiHelper.isInRect(44, 235, 90, 16, x-guiLeft, y-guiTop))drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); + list.clear(); + String s = StatCollector.translateToLocal("button.de.chestAutoFeed0.txt"); + if (GuiHelper.isInRect(4, 180, 38, 12, x-guiLeft, y-guiTop)){ + list.add(s.substring(s.indexOf(".")+1)); + drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); + } + if (GuiHelper.isInRect(4, 193, 38, 12, x-guiLeft, y-guiTop)){ + s = StatCollector.translateToLocal("button.de.chestAutoFeed1.txt"); + list.add(s.substring(s.indexOf(".")+1)); + drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); + } + if (GuiHelper.isInRect(4, 206, 38, 12, x-guiLeft, y-guiTop)){ + s = StatCollector.translateToLocal("button.de.chestAutoFeed2.txt"); + list.add(s.substring(s.indexOf(".")+1)); + drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); + } + if (GuiHelper.isInRect(4, 219, 38, 12, x-guiLeft, y-guiTop)){ + s = StatCollector.translateToLocal("button.de.chestAutoFeed3.txt"); + list.add(s.substring(s.indexOf(".")+1)); + drawHoveringText(list, x-guiLeft, y-guiTop, fontRendererObj); + } RenderHelper.enableGUIStandardItemLighting(); } @@ -89,12 +111,22 @@ public class GUIDraconiumChest extends GuiContainer implements INEIGuiHandler { int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; buttonList.clear(); - buttonList.add(new GuiButtonAHeight(0, posX+47, posY+180, 85, 12, "AutoFeed "+(tile.smeltingAutoFeed ? "on" : "off"))); + String s = StatCollector.translateToLocal("button.de.chestAutoFeed0.txt"); + buttonList.add(new GuiButtonAHeight(0, posX+4, posY+180, 38, 12, s.substring(0, s.indexOf(".")))); + s = StatCollector.translateToLocal("button.de.chestAutoFeed1.txt"); + buttonList.add(new GuiButtonAHeight(1, posX+4, posY+193, 38, 12, s.substring(0, s.indexOf(".")))); + s = StatCollector.translateToLocal("button.de.chestAutoFeed2.txt"); + buttonList.add(new GuiButtonAHeight(2, posX+4, posY+206, 38, 12, s.substring(0, s.indexOf(".")))); + s = StatCollector.translateToLocal("button.de.chestAutoFeed3.txt"); + buttonList.add(new GuiButtonAHeight(3, posX+4, posY+219, 38, 12, s.substring(0, s.indexOf(".")))); } @Override protected void actionPerformed(GuiButton button) { - DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST, false)); + if (button.id == 0)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST0, false)); + else if (button.id == 1)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST1, false)); + else if (button.id == 2)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST2, false)); + else if (button.id == 3)DraconicEvolution.network.sendToServer(new ButtonPacket(ButtonPacket.ID_DRACONIUMCHEST3, false)); } @Override @@ -102,7 +134,10 @@ public class GUIDraconiumChest extends GuiContainer implements INEIGuiHandler { super.updateScreen(); if (lastAutoFeed != tile.smeltingAutoFeed){ lastAutoFeed = tile.smeltingAutoFeed; - ((GuiButton)buttonList.get(0)).displayString = "AutoFeed "+(tile.smeltingAutoFeed ? "on" : "off"); + ((GuiButton)buttonList.get(0)).enabled = lastAutoFeed != 0; + ((GuiButton)buttonList.get(1)).enabled = lastAutoFeed != 1; + ((GuiButton)buttonList.get(2)).enabled = lastAutoFeed != 2; + ((GuiButton)buttonList.get(3)).enabled = lastAutoFeed != 3; } } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/manual/CraftingInfoPage.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/manual/CraftingInfoPage.java index acd04525..e4ad8b85 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/manual/CraftingInfoPage.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/manual/CraftingInfoPage.java @@ -110,7 +110,7 @@ public class CraftingInfoPage extends TitledPage { int offset = 0; for (String s : getFormattedText(fontRendererObj)) { if (s == null) break; - fontRendererObj.drawString(s, 0, offset, 4210752); + fontRendererObj.drawString(s, 0, offset, 0x000000); offset += fontRendererObj.FONT_HEIGHT; } GL11.glPopMatrix(); diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/manual/TutorialPage.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/manual/TutorialPage.java index 66c7fb44..5e5e3536 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/manual/TutorialPage.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/manual/TutorialPage.java @@ -55,7 +55,7 @@ public class TutorialPage extends TitledPage { int offset = 0; for (String s : description) { if (s == null) break; - fontRendererObj.drawString(s, 0, offset, 4210752); + fontRendererObj.drawString(s, 0, offset, 0x000000); offset += fontRendererObj.FONT_HEIGHT; } GL11.glPopMatrix(); diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderDraconiumChest.java index 102e7942..300be7d2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/block/RenderDraconiumChest.java @@ -18,14 +18,14 @@ public class RenderDraconiumChest implements ISimpleBlockRenderingHandler { public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileDraconiumChest(), 0.0D, 0.0D, 0.0D, 0.0F); + TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileDraconiumChest(), 0.0D, 0.0D, 0.0D, 0.0F);//todo find a way to render the block the correct colour GL11.glPopMatrix(); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return false; - } + } @Override public boolean shouldRender3DInInventory(int modelId) { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockDE.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockDE.java index dc0ae2eb..99e90d27 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockDE.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockDE.java @@ -1,21 +1,11 @@ package com.brandon3055.draconicevolution.common.blocks; -import com.brandon3055.draconicevolution.common.core.utills.InventoryUtils; import com.brandon3055.draconicevolution.common.lib.References; -import com.google.common.collect.Lists; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import java.util.ArrayList; -import java.util.List; public class BlockDE extends Block { @@ -46,60 +36,4 @@ public class BlockDE extends Block { this.blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } - public boolean hasTileEntityDrops() { - return false; - } - - public boolean dropTileInventory() {return false;} - - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { - if (willHarvest && hasTileEntityDrops() && !player.capabilities.isCreativeMode) { - final TileEntity te = world.getTileEntity(x, y, z); - - boolean result = super.removedByPlayer(world, player, x, y, z, willHarvest); - - if (result) { - List teDrops = Lists.newArrayList(); - getTileEntityDrops(te, teDrops, 0); - for (ItemStack drop : teDrops) - dropBlockAsItem(world, x, y, z, drop); - } - - return result; - } - - return super.removedByPlayer(world, player, x, y, z, willHarvest); - } - - public void getTileEntityDrops(TileEntity te, List result, int fortune) { - if (te != null) { - getTileInventoryDrops(te, result); - } - } - - public static boolean getTileInventoryDrops(TileEntity tileEntity, List drops) { - if (tileEntity == null) return false; - - if (tileEntity instanceof IInventory) { - drops.addAll(InventoryUtils.getInventoryContents((IInventory)tileEntity)); - return true; - } - - return false; - } - - public boolean hasNormalDrops() {return true;} - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList result = Lists.newArrayList(); -// if (hasNormalDrops()) result.addAll(super.getDrops(world, x, y, z, metadata, fortune)); -// if (hasTileEntityDrops()) { -// final TileEntity te = world.getTileEntity(x, y, z); -// getTileEntityDrops(te, result, fortune); -// } - - return result; - } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumChest.java index cc8d55d6..7dddf706 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumChest.java @@ -3,9 +3,11 @@ package com.brandon3055.draconicevolution.common.blocks; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.client.interfaces.GuiHandler; import com.brandon3055.draconicevolution.common.blocks.itemblocks.DraconiumChestItemBlock; +import com.brandon3055.draconicevolution.common.core.utills.InventoryUtils; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.TileDraconiumChest; +import com.google.common.collect.Lists; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -231,18 +233,76 @@ public class DraconiumChest extends BlockContainerDE { blockIcon = par1IconRegister.registerIcon(References.RESOURCESPREFIX + "draconiumChest"); } - @Override - public boolean hasTileEntityDrops() { - return true; - } - @Override - public boolean hasNormalDrops() { + //TODO Tidy up the crazy mess!!!! and make a block class to handle this type of block also create an interface for tiles that keep their data when harvested similar to openblocks but simpler (two methods one to write to item one to read from item) +// public boolean hasTileEntityDrops() { +// return true; +// } +// +// public boolean hasNormalDrops() { +// return false; +// } +// +// public void getTileEntityDrops(TileEntity te, List result, int fortune) { +// ItemStack stack = new ItemStack(ModBlocks.draconiumChest); +// if (te instanceof TileDraconiumChest){ +// TileDraconiumChest chest = (TileDraconiumChest)te; +// NBTTagCompound tileTag = new NBTTagCompound(); +// NBTTagCompound itemTag = new NBTTagCompound(); +// chest.writeToItem(tileTag); +// itemTag.setTag("TileCompound", tileTag); +// stack.setTagCompound(itemTag); +// } +// result.add(stack); +// } +// +// @Override +// public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { +// LogHelper.info(willHarvest); +// if (willHarvest && hasTileEntityDrops() && !player.capabilities.isCreativeMode) { +// final TileEntity te = world.getTileEntity(x, y, z); +// +// boolean result = super.removedByPlayer(world, player, x, y, z, willHarvest); +// +// if (result) { +// List teDrops = Lists.newArrayList(); +// getTileEntityDrops(te, teDrops, 0); +// for (ItemStack drop : teDrops) +// dropBlockAsItem(world, x, y, z, drop); +// } +// +// return result; +// } +// +// return super.removedByPlayer(world, player, x, y, z, willHarvest); +// } +// + public static boolean getTileInventoryDrops(TileEntity tileEntity, List drops) { + if (tileEntity == null) return false; + + if (tileEntity instanceof IInventory) { + drops.addAll(InventoryUtils.getInventoryContents((IInventory) tileEntity)); + return true; + } + return false; } +// +// +// @Override +// public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { +// ArrayList result = Lists.newArrayList(); +// return result; +// } + private void getTileEntityDrops(TileEntity te, List result, int fortune) { + if (te != null) { + //getTileInventoryDrops(te, result); + //if (te instanceof ISpecialDrops) ((ISpecialDrops)te).addDrops(result, fortune); + getCustomTileEntityDrops(te, result, fortune); + } + } - @Override - public void getTileEntityDrops(TileEntity te, List result, int fortune) { + protected void getCustomTileEntityDrops(TileEntity te, List result, int fortune) { ItemStack stack = new ItemStack(ModBlocks.draconiumChest); if (te instanceof TileDraconiumChest){ TileDraconiumChest chest = (TileDraconiumChest)te; @@ -255,4 +315,49 @@ public class DraconiumChest extends BlockContainerDE { result.add(stack); } + protected boolean hasNormalDrops() { + return false; + } + + protected boolean hasTileEntityDrops() { + return true; + } + + @Override + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { + // This is last place we have TE, before it's removed, + // When removed by player, it will be already unavailable in + // getBlockDropped + // TODO: evaluate, if new behaviour can be used + if (willHarvest && hasTileEntityDrops() && !player.capabilities.isCreativeMode) { + final TileEntity te = world.getTileEntity(x, y, z); + + boolean result = super.removedByPlayer(world, player, x, y, z, willHarvest); + + if (result) { + List teDrops = Lists.newArrayList(); + getTileEntityDrops(te, teDrops, 0); + for (ItemStack drop : teDrops) + dropBlockAsItem(world, x, y, z, drop); + } + + return result; + } + + return super.removedByPlayer(world, player, x, y, z, willHarvest); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList result = Lists.newArrayList(); + if (hasNormalDrops()) result.addAll(super.getDrops(world, x, y, z, metadata, fortune)); + if (hasTileEntityDrops()) { + final TileEntity te = world.getTileEntity(x, y, z); + getTileEntityDrops(te, result, fortune); + } + + return result; + } + + } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java index 0379c1b1..27ef5ac2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java @@ -1,22 +1,21 @@ package com.brandon3055.draconicevolution.common.blocks; -import java.util.Random; - +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.items.ModItems; +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.lib.Strings; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.util.IIcon; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.items.ModItems; -import com.brandon3055.draconicevolution.common.lib.References; -import com.brandon3055.draconicevolution.common.lib.Strings; import net.minecraft.world.IBlockAccess; +import java.util.Random; + public class DraconiumOre extends BlockDE { public IIcon icon; public IIcon iconEnd; @@ -38,7 +37,7 @@ public class DraconiumOre extends BlockDE { @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(final IIconRegister iconRegister) + public void registerBlockIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore"); iconEnd = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore_end"); @@ -60,15 +59,15 @@ public class DraconiumOre extends BlockDE { } @Override - public int quantityDropped(final Random random) + public int quantityDropped(Random random) { return 1 + random.nextInt(2); } @Override - public int quantityDroppedWithBonus(final int number, final Random random) + public int quantityDroppedWithBonus(int fortune, Random random) { - return this.quantityDropped(random) + random.nextInt(number + 1); + return fortune == 0 ? this.quantityDropped(random) : this.quantityDropped(random) + fortune + random.nextInt(fortune * 2); } @Override @@ -78,7 +77,7 @@ public class DraconiumOre extends BlockDE { } @Override - public Item getItemDropped(final int p_149650_1_, final Random p_149650_2_, final int p_149650_3_) + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return ModItems.draconiumDust; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDraconiumChest.java index 12b8aab7..23b0bfdb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerDraconiumChest.java @@ -6,6 +6,7 @@ import com.brandon3055.draconicevolution.common.inventory.InventoryCraftingChest import com.brandon3055.draconicevolution.common.tileentities.TileDraconiumChest; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import invtweaks.api.container.ChestContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.*; @@ -15,7 +16,7 @@ import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -//@ChestContainer(isLargeChest = false, rowSize = 26)todo Re enable inv tweaks +@ChestContainer(isLargeChest = false, rowSize = 26) public class ContainerDraconiumChest extends Container { //todo Create and implement IExtendedCrafters /** The crafting matrix inventory (3x3). */ diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/network/ButtonPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/core/network/ButtonPacket.java index 4c660254..c7a6c895 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/network/ButtonPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/network/ButtonPacket.java @@ -16,7 +16,10 @@ public class ButtonPacket implements IMessage { public static final byte ID_WEATHERCONTROLLER = 0; public static final byte ID_DISSENCHANTER = 1; - public static final byte ID_DRACONIUMCHEST = 2; + public static final byte ID_DRACONIUMCHEST0 = 2; + public static final byte ID_DRACONIUMCHEST1 = 3; + public static final byte ID_DRACONIUMCHEST2 = 4; + public static final byte ID_DRACONIUMCHEST3 = 5; byte buttonId = 0; boolean state = false; @@ -62,12 +65,39 @@ public class ButtonPacket implements IMessage } break; } - case ID_DRACONIUMCHEST: + case ID_DRACONIUMCHEST0: { Container container = ctx.getServerHandler().playerEntity.openContainer; if (container != null && container instanceof ContainerDraconiumChest){ TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); - tile.setAutoFeed(!tile.smeltingAutoFeed); + tile.setAutoFeed(0); + } + break; + } + case ID_DRACONIUMCHEST1: + { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDraconiumChest){ + TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); + tile.setAutoFeed(1); + } + break; + } + case ID_DRACONIUMCHEST2: + { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDraconiumChest){ + TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); + tile.setAutoFeed(2); + } + break; + } + case ID_DRACONIUMCHEST3: + { + Container container = ctx.getServerHandler().playerEntity.openContainer; + if (container != null && container instanceof ContainerDraconiumChest){ + TileDraconiumChest tile = ((ContainerDraconiumChest) container).getTile(); + tile.setAutoFeed(3); } break; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterPacket.java index f4e62eaa..c67ecb6f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterPacket.java @@ -144,9 +144,11 @@ public class TeleporterPacket implements IMessage if (message.function == SCROLL){ int selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0); int selectionOffset = ItemNBTHelper.getIntager(teleporter, "SelectionOffset", 0); - int maxSelect = Math.min(list.tagCount(), 11); + int maxSelect = Math.min(list.tagCount()-1, 11); int maxOffset = Math.max(list.tagCount() - 12, 0); + LogHelper.info(message.data+" "+maxSelect+" "+selected); + if(message.data > 0 && selected < maxSelect) { ItemNBTHelper.setShort(teleporter, "Selection", (short) (selected + 1)); return null; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/ClientProxy.java b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/ClientProxy.java index e7e508c1..93707285 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/ClientProxy.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/ClientProxy.java @@ -101,4 +101,5 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerBlockHandler(new RenderTeleporterStand()); RenderingRegistry.registerBlockHandler(new RenderDraconiumChest()); } + } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java index 23c395f8..4c940f5b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java @@ -4,14 +4,12 @@ import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.client.creativetab.DETab; import com.brandon3055.draconicevolution.client.interfaces.GuiHandler; import com.brandon3055.draconicevolution.common.blocks.ModBlocks; -import com.brandon3055.draconicevolution.common.core.handler.ConfigHandler; -import com.brandon3055.draconicevolution.common.core.handler.CraftingHandler; -import com.brandon3055.draconicevolution.common.core.handler.FMLEventHandler; -import com.brandon3055.draconicevolution.common.core.handler.MinecraftForgeEventHandler; +import com.brandon3055.draconicevolution.common.core.handler.*; import com.brandon3055.draconicevolution.common.core.network.*; import com.brandon3055.draconicevolution.common.core.utills.Utills; import com.brandon3055.draconicevolution.common.entity.*; import com.brandon3055.draconicevolution.common.items.ModItems; +import com.brandon3055.draconicevolution.common.lib.OreDoublingRegistry; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.tileentities.*; import com.brandon3055.draconicevolution.common.tileentities.multiblocktiles.TileEnderResurrection; @@ -34,7 +32,7 @@ public class CommonProxy { public void preInit(FMLPreInitializationEvent event) { ConfigHandler.init(event.getSuggestedConfigurationFile()); - registerEventListeners(); + registerEventListeners(event.getSide()); ModBlocks.init(); ModItems.init(); GameRegistry.registerWorldGenerator(new DraconicWorldGenerator(), 1); @@ -51,6 +49,7 @@ public class CommonProxy { } public void postInit(FMLPostInitializationEvent event) { + OreDoublingRegistry.init(); } public void initializeNetwork(){ @@ -91,7 +90,7 @@ public class CommonProxy { } } - public void registerEventListeners() { + public void registerEventListeners(Side s) { MinecraftForge.EVENT_BUS.register(new MinecraftForgeEventHandler()); FMLCommonHandler.instance().bus().register(new FMLEventHandler()); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java b/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java index 829a3127..d1be8057 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java @@ -1,8 +1,11 @@ package com.brandon3055.draconicevolution.common.items; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; import com.brandon3055.draconicevolution.common.lib.Strings; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -70,15 +73,22 @@ public class Tclogo extends ItemDE { @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + //if (!world.isRemote)OreDoublingRegistry.getOreResult(GameRegistry.findItemStack("ThermalFoundation", "oreCopper", 1)); int xi = (int)player.posX; int yi = (int)player.posY; int zi = (int)player.posZ; - int rad = 100; + int rad = 1000; + Block block; for (int x = xi-rad; x < xi+rad; x++){ - for (int y = yi-5; y < yi+5; y++){ + for (int y = yi-10; y < yi+30; y++){ for (int z = zi-rad; z < zi+rad; z++){ + block = world.getBlock(x, y, z); + if (block.getMaterial().equals(Material.vine) || block.getMaterial().equals(Material.plants)){ + world.setBlockToAir(x, y, z); + } + //world.markBlockForUpdate(x, y, z); } } @@ -97,6 +107,7 @@ public class Tclogo extends ItemDE { @Override public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) { + LogHelper.info(player.worldObj.getBlock(X, Y, Z).getMaterial()); //player.worldObj.scheduleBlockUpdate(X, Y, Z, player.worldObj.getBlock(X, Y, Z), 10); return true; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java index feebb3fb..7b3ca895 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java @@ -119,6 +119,8 @@ public class TeleporterMKII extends ItemDE return teleporter; } + if (destination.getName().isEmpty()) return teleporter; + if (!player.capabilities.isCreativeMode && fuel <= 0 && !onStand) { if (world.isRemote) player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt")); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/OreDoublingRegistry.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/OreDoublingRegistry.java new file mode 100644 index 00000000..2a74b4c9 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/OreDoublingRegistry.java @@ -0,0 +1,61 @@ +package com.brandon3055.draconicevolution.common.lib; + +import com.brandon3055.draconicevolution.common.items.DraconiumBlend; +import com.brandon3055.draconicevolution.common.items.ModItems; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by Brandon on 2/11/2014. + */ +public class OreDoublingRegistry { + private static Map oreResults = new HashMap(); + private static String[] names = {"oreGold", "oreIron", "oreAluminum", "oreCopper", "oreLead", "oreSilver", "oreTin", "oreUranium", "orePlatinum", "oreNickel", "oreMithril", "oreCobalt", "oreArdite"}; + + public static void init(){ + + for (String oreName : names) { + String ingotName = "ingot" + oreName.substring(oreName.indexOf("ore")+3); + + ItemStack resultIngot = GameRegistry.findItemStack("ThermalFoundation", ingotName, 1); + + if (resultIngot == null && OreDictionary.getOres(ingotName).size() > 0) resultIngot = OreDictionary.getOres(ingotName).get(0); + + oreResults.put(oreName, resultIngot); + } + + } + + public static ItemStack getOreResult(ItemStack stack){ + if (stack.getItem() instanceof DraconiumBlend) return new ItemStack(ModItems.draconiumIngot, 4); + else if (stack.getItem() == Item.getItemFromBlock(Blocks.cobblestone)) return new ItemStack(Blocks.stone, 2); + else if (stack.getItem() == Item.getItemFromBlock(Blocks.sand)) return new ItemStack(Blocks.glass, 2); + else if (stack.getItem() == Item.getItemFromBlock(Blocks.cactus)) return new ItemStack(Items.dye, 2, 2); + else if (stack.getItem() == Items.clay_ball) return new ItemStack(Items.brick, 2); + + int[] ids = OreDictionary.getOreIDs(stack); + String name; + ItemStack resultStack = null; + + if (ids.length > 0){ + name = OreDictionary.getOreName(ids[0]); + resultStack = oreResults.get(name); + } + + if (resultStack != null) { + ItemStack doubledStack = resultStack.copy(); + doubledStack.stackSize = FurnaceRecipes.smelting().getSmeltingResult(stack).stackSize * 2; + return doubledStack; + } + + return null; + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDraconiumChest.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDraconiumChest.java index ff79cd4c..e8efa863 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDraconiumChest.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileDraconiumChest.java @@ -7,6 +7,7 @@ import com.brandon3055.draconicevolution.common.container.ContainerDraconiumChes import com.brandon3055.draconicevolution.common.core.utills.EnergyStorage; import com.brandon3055.draconicevolution.common.core.utills.InventoryUtils; import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.lib.OreDoublingRegistry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -48,7 +49,8 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg public int smeltingBurnSpeed; public final int smeltingMaxBurnSpeed = 50; public final int smeltingCompleateTime = 1600; - public boolean smeltingAutoFeed = false; + public int smeltingAutoFeed = 0; + public int tick; @Override public void updateEntity() { @@ -103,8 +105,16 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg updateEnergy(); } + public void updateEnergy() { + if (energy.getEnergyStored() < energy.getMaxEnergyStored() && getStackInSlot(239) != null && getStackInSlot(239).getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem item = (IEnergyContainerItem) getStackInSlot(239).getItem(); + item.extractEnergy(getStackInSlot(239), receiveEnergy(ForgeDirection.DOWN, item.extractEnergy(getStackInSlot(239), energy.getMaxReceive(), true), false), false); + } + } + public void updateFurnace() { if (worldObj.isRemote) return; + tick++; boolean canSmelt = false; boolean flag = true; for (int i = 0; i < 5; i++) { @@ -114,6 +124,7 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg else flag = false; } + if (!flag) canSmelt = false; if (canSmelt) {//Check if there is room for the output @@ -134,16 +145,31 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg } } + if (canSmelt && getLock()){ //Confirm that the firnace can still run when lock mode is enabled + flag = false; + for (int i = 0; i < 5; i++) { + + ItemStack recipe = getStackInSlot(234 + i); + + if (recipe == null || recipe.stackSize == 1) continue; + + flag = true; + } + canSmelt = flag; + } + + flag = false; if (canSmelt && smeltingProgressTime >= smeltingCompleateTime) { int itemsToProccess = 5; int proccessAttempts = 0; - flag = false; do { for (int i = 0; i < 5; i++) { - if (getStackInSlot(234 + i) == null) continue; + ItemStack recipe = getStackInSlot(234 + i); - ItemStack result = getResult(getStackInSlot(234 + i)).copy(); + if (recipe == null || (getLock() && recipe.stackSize == 1)) continue; + + ItemStack result = getResult(recipe).copy(); for (int j = 0; j < getSizeInventory(); j++) { if (getStackInSlot(j) == null) continue; @@ -153,8 +179,8 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg if (result.stackSize > 0) InventoryUtils.insertItemIntoInventory(this, result); if (result.stackSize == 0) { - getStackInSlot(234 + i).stackSize--; - if (getStackInSlot(234 + i).stackSize == 0) setInventorySlotContents(234 + i, null); + recipe.stackSize--; + if (recipe.stackSize == 0) setInventorySlotContents(234 + i, null); itemsToProccess--; flag = true; } @@ -165,11 +191,9 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg proccessAttempts++; } while (itemsToProccess > 0 && proccessAttempts < 5); - - if (flag && smeltingAutoFeed) feedNextItem(); - } + if ((flag && (getFill() || getLock() || getAll())) || (!canSmelt && (getLock() || getAll()) && tick % 60 == 0)) feedNextItem(); if (canSmelt) { smeltingBurnSpeed = Math.min(energy.getEnergyStored() / 1000, smeltingMaxBurnSpeed); @@ -182,13 +206,6 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg } - public void updateEnergy() { - if (energy.getEnergyStored() < energy.getMaxEnergyStored() && getStackInSlot(239) != null && getStackInSlot(239).getItem() instanceof IEnergyContainerItem) { - IEnergyContainerItem item = (IEnergyContainerItem) getStackInSlot(239).getItem(); - item.extractEnergy(getStackInSlot(239), receiveEnergy(ForgeDirection.DOWN, item.extractEnergy(getStackInSlot(239), energy.getMaxReceive(), true), false), false); - } - } - public void feedNextItem() { boolean[] stacksFull = new boolean[]{false,false,false,false,false}; @@ -198,34 +215,57 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg ItemStack candidate = getStackInSlot(i); for (int j = 0; j < 5; j++) { - if (getStackInSlot(234 + j) == null) continue; + if (getStackInSlot(234 + j) == null && getAll()) + { + + if (candidate == null) break; + boolean candidateSmeltable = FurnaceRecipes.smelting().getSmeltingResult(candidate) != null; + if (candidateSmeltable) { + LogHelper.info(candidate); + setInventorySlotContents(234 + j, candidate.copy()); + setInventorySlotContents(i, null); + candidate = null; + LogHelper.info(candidate); + } + } + + if (getStackInSlot(234 + j) == null || candidate == null) continue; ItemStack inputSlot = getStackInSlot(234 + j); - if (inputSlot.stackSize == inputSlot.getMaxStackSize()) { - stacksFull[j] = true; - continue; + InventoryUtils.tryMergeStacks(candidate, inputSlot); + + if (candidate != null && candidate.stackSize == 0) { + setInventorySlotContents(i, null); + candidate = null; } - InventoryUtils.tryMergeStacks(candidate, inputSlot); + if (inputSlot.stackSize == inputSlot.getMaxStackSize()) { + stacksFull[j] = true; + } } - if (candidate.stackSize == 0) setInventorySlotContents(i, null); + if (candidate != null && candidate.stackSize == 0) setInventorySlotContents(i, null); if (stacksFull[0] && stacksFull[1] && stacksFull[2] && stacksFull[3] && stacksFull[4]) break; } } + private boolean getFill() {return smeltingAutoFeed == 1;} + private boolean getLock() {return smeltingAutoFeed == 2;} + private boolean getAll() {return smeltingAutoFeed == 3;} + private boolean isSmeltable(ItemStack stack) { return FurnaceRecipes.smelting().getSmeltingResult(stack) != null; } private ItemStack getResult(ItemStack stack) { - return FurnaceRecipes.smelting().getSmeltingResult(stack); + ItemStack oreResult = OreDoublingRegistry.getOreResult(stack); + return oreResult != null ? oreResult : FurnaceRecipes.smelting().getSmeltingResult(stack); } - public void setAutoFeed(boolean b){ - smeltingAutoFeed = b; + public void setAutoFeed(int i){ + smeltingAutoFeed = i; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } @@ -390,7 +430,7 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg compound.setInteger("Green", green); compound.setInteger("Blue", blue); compound.setBoolean("Edit", editMode); - compound.setBoolean("AutoFeed", smeltingAutoFeed); + compound.setByte("AutoFeed", (byte) smeltingAutoFeed); energy.writeToNBT(compound); } @@ -414,7 +454,7 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg green = compound.getInteger("Green"); blue = compound.getInteger("Blue"); editMode = compound.getBoolean("Edit"); - smeltingAutoFeed = compound.getBoolean("AutoFeed"); + smeltingAutoFeed = compound.getByte("AutoFeed"); energy.readFromNBT(compound); } @@ -446,7 +486,7 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg compound.setInteger("Green", green); compound.setInteger("Blue", blue); compound.setBoolean("Edit", editMode); - compound.setBoolean("AutoFeed", smeltingAutoFeed); + compound.setByte("AutoFeed", (byte) smeltingAutoFeed); energy.writeToNBT(compound); } @@ -468,7 +508,7 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg green = compound.getInteger("Green"); blue = compound.getInteger("Blue"); editMode = compound.getBoolean("Edit"); - smeltingAutoFeed = compound.getBoolean("AutoFeed"); + smeltingAutoFeed = compound.getByte("AutoFeed"); energy.readFromNBT(compound); } diff --git a/src/main/resources/assets/draconicevolution/lang/en_US.lang b/src/main/resources/assets/draconicevolution/lang/en_US.lang index 15fb2c50..89435bc6 100644 --- a/src/main/resources/assets/draconicevolution/lang/en_US.lang +++ b/src/main/resources/assets/draconicevolution/lang/en_US.lang @@ -289,6 +289,11 @@ key.placeItem=Place Item in world death.attack.ChaosDragon=%1$s was torn apart by a Chaos Guardian +//###################################Buttons######################################// +button.de.chestAutoFeed0.txt=OFF.Auto Feed Disabled +button.de.chestAutoFeed1.txt=FILL.Keep the current stacks full +button.de.chestAutoFeed2.txt=LOCK.Only pull the currently smelting items from the inventory +button.de.chestAutoFeed3.txt=ALL.Pull any smeltable items from the inventory //###################################Manual Gui###################################//