diff --git a/mods/tinker/common/IMasterLogic.java b/mods/tinker/common/IMasterLogic.java new file mode 100644 index 00000000..9b484741 --- /dev/null +++ b/mods/tinker/common/IMasterLogic.java @@ -0,0 +1,6 @@ +package mods.tinker.common; + +public interface IMasterLogic +{ + public void notifyChange(int x, int y, int z); +} diff --git a/mods/tinker/common/IServantLogic.java b/mods/tinker/common/IServantLogic.java new file mode 100644 index 00000000..88369ba1 --- /dev/null +++ b/mods/tinker/common/IServantLogic.java @@ -0,0 +1,9 @@ +package mods.tinker.common; + +public interface IServantLogic +{ + public CoordTuple getMasterPosition (); + public void notifyMasterOfChange(); + public boolean verifyMaster(int x, int y, int z); + public boolean setMaster(int x, int y, int z); +} diff --git a/mods/tinker/tconstruct/TConstruct.java b/mods/tinker/tconstruct/TConstruct.java index 654f72a6..ef250b74 100644 --- a/mods/tinker/tconstruct/TConstruct.java +++ b/mods/tinker/tconstruct/TConstruct.java @@ -23,11 +23,12 @@ import cpw.mods.fml.common.registry.GameRegistry; * @author: mDiyo */ -@Mod(modid = "TConstruct", name = "TConstruct", version = "1.4.7_1.1.22", dependencies = "before:*") +@Mod(modid = "TConstruct", name = "TConstruct", version = "1.5.0_1.1.22", dependencies = "before:*") @NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = mods.tinker.tconstruct.TPacketHandler.class) public class TConstruct { - public static int ingotLiquidValue = 144; + public static final int ingotLiquidValue = 144; + public static final int liquidUpdateAmount = 6; /* Instance of this mod, used for grabbing prototype fields */ @Instance("TConstruct") diff --git a/mods/tinker/tconstruct/TConstructRegistry.java b/mods/tinker/tconstruct/TConstructRegistry.java index 8a96aa93..7cffbdf1 100644 --- a/mods/tinker/tconstruct/TConstructRegistry.java +++ b/mods/tinker/tconstruct/TConstructRegistry.java @@ -5,9 +5,6 @@ import java.util.HashMap; import mods.tinker.tconstruct.client.gui.ToolGuiElement; import mods.tinker.tconstruct.tools.ToolCore; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.Icon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; diff --git a/mods/tinker/tconstruct/TControls.java b/mods/tinker/tconstruct/TControls.java deleted file mode 100644 index d47e5918..00000000 --- a/mods/tinker/tconstruct/TControls.java +++ /dev/null @@ -1,120 +0,0 @@ -package mods.tinker.tconstruct; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.util.EnumSet; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraft.potion.Potion; -import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; -import cpw.mods.fml.common.TickType; -import cpw.mods.fml.common.network.PacketDispatcher; - -public class TControls extends KeyHandler -{ - static KeyBinding grabKey = new KeyBinding("key.grab", 29); - static KeyBinding jumpKey; - Minecraft mc; - EntityClientPlayerMP player; - boolean jumping; - boolean doubleJump = true; - boolean climbing = false; - boolean onGround = false; - - public TControls() - { - super(new KeyBinding[] { Minecraft.getMinecraft().gameSettings.keyBindJump, grabKey }, new boolean[] { false, false }); - mc = Minecraft.getMinecraft(); - jumpKey = mc.gameSettings.keyBindJump; - System.out.println("Controls registered"); - } - - //I will be wanting these later - /*@Override - public void tickStart(EnumSet type, Object... tickData) - { - super.tickStart(type, tickData); - } - - @Override - public void tickEnd(EnumSet type, Object... tickData) - { - super.tickEnd(type, tickData); - }*/ - - @Override - public String getLabel () - { - return null; - } - - @Override - public void keyDown (EnumSet types, KeyBinding kb, boolean tickEnd, boolean isRepeat) - { - if (kb == jumpKey && tickEnd) //Double jump - { - if (jumping && !doubleJump) - { - if (player == null) - player = mc.thePlayer; - - player.motionY = 0.42D; - player.fallDistance = 0; - - if (player.isPotionActive(Potion.jump)) - { - player.motionY += (double) ((float) (player.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); - } - - doubleJump = true; - updateServer(mc.thePlayer.username); - } - - if (!jumping) - jumping = mc.thePlayer.isAirBorne; - } - } - - @Override - public void keyUp (EnumSet types, KeyBinding kb, boolean tickEnd) - { - //landOnGround(); - } - - @Override - public EnumSet ticks () - { - return EnumSet.of(TickType.CLIENT); - } - - public void landOnGround () - { - doubleJump = false; - jumping = false; - } - - void updateServer (String name) - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(8); - DataOutputStream outputStream = new DataOutputStream(bos); - try - { - outputStream.writeByte(10); - outputStream.writeUTF(name); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - Packet250CustomPayload packet = new Packet250CustomPayload(); - packet.channel = "TConstruct"; - packet.data = bos.toByteArray(); - packet.length = bos.size(); - - PacketDispatcher.sendPacketToServer(packet); - } -} diff --git a/mods/tinker/tconstruct/TPacketHandler.java b/mods/tinker/tconstruct/TPacketHandler.java index 8ca60e5b..b6655161 100644 --- a/mods/tinker/tconstruct/TPacketHandler.java +++ b/mods/tinker/tconstruct/TPacketHandler.java @@ -121,6 +121,12 @@ public class TPacketHandler implements IPacketHandler EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user); player.fallDistance = 0; } + else if (packetID == 11) + { + String user = inputStream.readUTF(); + float size = inputStream.readFloat(); + TConstruct.playerTracker.updateSize(user, size); + } } catch (IOException e) { diff --git a/mods/tinker/tconstruct/blocks/LavaTankBlock.java b/mods/tinker/tconstruct/blocks/LavaTankBlock.java index d467be3c..a6461b46 100644 --- a/mods/tinker/tconstruct/blocks/LavaTankBlock.java +++ b/mods/tinker/tconstruct/blocks/LavaTankBlock.java @@ -2,6 +2,7 @@ package mods.tinker.tconstruct.blocks; import java.util.List; +import mods.tinker.common.IServantLogic; import mods.tinker.tconstruct.TConstruct; import mods.tinker.tconstruct.TContent; import mods.tinker.tconstruct.client.TankRender; @@ -83,9 +84,9 @@ public class LavaTankBlock extends BlockContainer @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { - LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z); - if (logic != null) - return logic.getBrightness(); + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic != null && logic instanceof LavaTankLogic) + return ((LavaTankLogic) logic).getBrightness(); return 0; } @@ -182,4 +183,14 @@ public class LavaTankBlock extends BlockContainer { return meta; } + + /* Updates */ + public void onNeighborBlockChange(World world, int x, int y, int z, int nBlockID) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic instanceof IServantLogic) + { + ((IServantLogic) logic).notifyMasterOfChange(); + } + } } diff --git a/mods/tinker/tconstruct/blocks/SmelteryBlock.java b/mods/tinker/tconstruct/blocks/SmelteryBlock.java index 2246917d..517aa3d9 100644 --- a/mods/tinker/tconstruct/blocks/SmelteryBlock.java +++ b/mods/tinker/tconstruct/blocks/SmelteryBlock.java @@ -4,6 +4,8 @@ import java.util.List; import java.util.Random; import mods.tinker.common.IFacingLogic; +import mods.tinker.common.IMasterLogic; +import mods.tinker.common.IServantLogic; import mods.tinker.common.InventoryBlock; import mods.tinker.tconstruct.TConstruct; import mods.tinker.tconstruct.TGuiHandler; @@ -243,4 +245,18 @@ public class SmelteryBlock extends InventoryBlock list.add(new ItemStack(id, 1, iter)); } } + + /* Updating */ + public void onNeighborBlockChange(World world, int x, int y, int z, int nBlockID) + { + TileEntity logic = world.getBlockTileEntity(x, y, z); + if (logic instanceof IServantLogic) + { + ((IServantLogic) logic).notifyMasterOfChange(); + } + else if (logic instanceof IMasterLogic) + { + ((IMasterLogic) logic).notifyChange(x, y, z); + } + } } diff --git a/mods/tinker/tconstruct/client/SearedRender.java b/mods/tinker/tconstruct/client/SearedRender.java index c4e95bde..d5175f51 100644 --- a/mods/tinker/tconstruct/client/SearedRender.java +++ b/mods/tinker/tconstruct/client/SearedRender.java @@ -97,17 +97,17 @@ public class SearedRender implements ISimpleBlockRenderingHandler renderer.setRenderBounds(0.6875, 0.0F, 0.6875, 1.0F, 0.625F, 1.0F); renderer.renderStandardBlock(block, x, y, z); - /*CastingTableLogic logic = (CastingTableLogic) world.getBlockTileEntity(x, y, z); + CastingTableLogic logic = (CastingTableLogic) world.getBlockTileEntity(x, y, z); if (logic.liquid != null) { - float height = logic.liquid.amount / (logic.getCapacity() * 1.03F) / 16F; + float height = logic.getLiquidAmount() / (logic.getCapacity() * 1.03F) / 16F; renderer.setRenderBounds(0.0625F, 0.9375F, 0.0625F, 0.9375F, 0.9375F + height, 0.9375F); if (logic.liquid.itemID < 4096) //Block { Block liquidBlock = Block.blocksList[logic.liquid.itemID]; if (liquidBlock != null) { - ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0); + //ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0); BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, logic.liquid.itemMeta, x, y, z, renderer, world); } } @@ -117,11 +117,11 @@ public class SearedRender implements ISimpleBlockRenderingHandler Item liquidItem = Item.itemsList[logic.liquid.itemID]; if (liquidItem != null) { - ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); + //ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(logic.liquid.itemMeta), logic.liquid.itemMeta, x, y, z, renderer, world); } } - }*/ + } } else if (metadata == 1) { @@ -137,7 +137,7 @@ public class SearedRender implements ISimpleBlockRenderingHandler renderer.setRenderBounds(0.625, 0.375, 0.625, 0.75, 0.625, 1); renderer.renderStandardBlock(block, x, y, z); renderer.setRenderBounds(0.375, 0.375, 0.625, 0.625, 0.625, 1); - xMax = 0.5F; + zMin = 0.5F; //zMin = 0.625F; break; case 3: @@ -167,8 +167,8 @@ public class SearedRender implements ISimpleBlockRenderingHandler renderer.renderStandardBlock(block, x, y, z); renderer.setRenderBounds(0, 0.375, 0.625, 0.375, 0.625, 0.75); renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(0, 0.375, 0.375, 0.325, 0.625, 0.625); - zMin = 0.5F; + renderer.setRenderBounds(0, 0.375, 0.375, 0.375, 0.625, 0.625); + xMax = 0.5F; break; } @@ -183,13 +183,13 @@ public class SearedRender implements ISimpleBlockRenderingHandler { yMin = -1F; } - /*if (logic.liquid != null) + if (logic.liquid != null) { ItemStack blockToRender = new ItemStack(logic.liquid.itemID, 1, logic.liquid.itemMeta); if (blockToRender.itemID < 4096) //Block { Block liquidBlock = Block.blocksList[blockToRender.itemID]; - ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0); + //ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0); BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, blockToRender.getItemDamage(), x, y, z, renderer, world); renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax); BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, blockToRender.getItemDamage(), x, y, z, renderer, world); @@ -198,14 +198,14 @@ public class SearedRender implements ISimpleBlockRenderingHandler //Item { Item liquidItem = Item.itemsList[blockToRender.itemID]; - ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); + //ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); int meta = blockToRender.getItemDamage(); BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(meta), meta, x, y, z, renderer, world); renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax); BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(meta), meta, x, y, z, renderer, world); } //renderer.renderStandardBlock(block, x, y, z); - }*/ + } } else diff --git a/mods/tinker/tconstruct/client/SmelteryRender.java b/mods/tinker/tconstruct/client/SmelteryRender.java index e76bba68..72030780 100644 --- a/mods/tinker/tconstruct/client/SmelteryRender.java +++ b/mods/tinker/tconstruct/client/SmelteryRender.java @@ -86,7 +86,6 @@ public class SmelteryRender implements ISimpleBlockRenderingHandler int liquidBase = 0; for (LiquidStack liquid : logic.moltenMetal) { - System.out.println("Liquid!"); int liquidSize = liquid.amount; while (liquidSize > 0) { diff --git a/mods/tinker/tconstruct/client/TConstructClientRegistry.java b/mods/tinker/tconstruct/client/TConstructClientRegistry.java index 635057b0..821c19c7 100644 --- a/mods/tinker/tconstruct/client/TConstructClientRegistry.java +++ b/mods/tinker/tconstruct/client/TConstructClientRegistry.java @@ -7,7 +7,7 @@ import net.minecraft.client.renderer.texture.TextureMap; public class TConstructClientRegistry { - public static TextureMap itemMap = Minecraft.getMinecraft().renderEngine.field_94155_m; + //public static TextureMap itemMap = Minecraft.getMinecraft().renderEngine.field_94155_m; public static void addMaterialRenderMapping (int materialID, String domain, String renderName, boolean useDefaultFolder) { diff --git a/mods/tinker/tconstruct/client/TControls.java b/mods/tinker/tconstruct/client/TControls.java new file mode 100644 index 00000000..b2fb540d --- /dev/null +++ b/mods/tinker/tconstruct/client/TControls.java @@ -0,0 +1,158 @@ +package mods.tinker.tconstruct.client; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.util.EnumSet; + +import mods.tinker.tconstruct.TConstruct; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.potion.Potion; +import cpw.mods.fml.common.TickType; +import cpw.mods.fml.common.network.PacketDispatcher; + +public class TControls extends TKeyHandler +{ + static KeyBinding grabKey = new KeyBinding("key.grab", 29); + //static KeyBinding stiltsKey = new KeyBinding("key.stilts", 46); + static KeyBinding jumpKey; + static Minecraft mc; + EntityClientPlayerMP player; + boolean jumping; + boolean doubleJump = true; + boolean climbing = false; + boolean onGround = false; + boolean onStilts = false; + //boolean onStilts = false; + + public TControls() + { + super(new KeyBinding[] { grabKey }, new boolean[] { false }, getVanillaKeyBindings(), new boolean[] { false }); + //System.out.println("Controls registered"); + } + + private static KeyBinding[] getVanillaKeyBindings () + { + mc = Minecraft.getMinecraft(); + jumpKey = mc.gameSettings.keyBindJump; + return new KeyBinding[] { jumpKey }; + } + + @Override + public String getLabel () + { + return null; + } + + @Override + public void keyDown (EnumSet types, KeyBinding kb, boolean tickEnd, boolean isRepeat) + { + if (tickEnd && mc.theWorld != null) + { + if (kb == jumpKey) //Double jump + { + if (jumping && !doubleJump) + { + if (player == null) + player = mc.thePlayer; + + player.motionY = 0.42D; + player.fallDistance = 0; + + if (player.isPotionActive(Potion.jump)) + { + player.motionY += (double) ((float) (player.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); + } + + doubleJump = true; + resetFallDamage(mc.thePlayer.username); + } + + if (!jumping) + jumping = mc.thePlayer.isAirBorne; + } + } + /*else if (kb == stiltsKey) //Stilts + { + float size = 1.8F; + if (!onStilts) + size = 0.8F; + TConstruct.playerTracker.updateSize(mc.thePlayer.username, size); + onStilts = !onStilts; + //updateServer(mc.thePlayer.username, (byte) 11); + if (onStilts) + { + onStilts = false; + } + else + { + onStilts = true; + } + }*/ + } + + @Override + public void keyUp (EnumSet types, KeyBinding kb, boolean tickEnd) + { + //landOnGround(); + } + + @Override + public EnumSet ticks () + { + return EnumSet.of(TickType.CLIENT); + } + + public void landOnGround () + { + doubleJump = false; + jumping = false; + } + + void resetFallDamage (String name) + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(10); + outputStream.writeUTF(name); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateServer(bos); + } + + void updateSize (String name, float size) + { + ByteArrayOutputStream bos = new ByteArrayOutputStream(8); + DataOutputStream outputStream = new DataOutputStream(bos); + try + { + outputStream.writeByte(11); + outputStream.writeUTF(name); + outputStream.writeFloat(size); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + updateServer(bos); + } + + void updateServer(ByteArrayOutputStream bos) + { + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "TConstruct"; + packet.data = bos.toByteArray(); + packet.length = bos.size(); + + PacketDispatcher.sendPacketToServer(packet); + } +} diff --git a/mods/tinker/tconstruct/client/TKeyHandler.java b/mods/tinker/tconstruct/client/TKeyHandler.java index 30f1fc58..d3fbf7a6 100644 --- a/mods/tinker/tconstruct/client/TKeyHandler.java +++ b/mods/tinker/tconstruct/client/TKeyHandler.java @@ -13,8 +13,10 @@ import cpw.mods.fml.common.TickType; public abstract class TKeyHandler implements ITickHandler { protected KeyBinding[] keyBindings; + protected KeyBinding[] vKeyBindings; protected boolean[] keyDown; protected boolean[] repeatings; + protected boolean[] vRepeatings; private boolean isDummy; /** @@ -23,12 +25,15 @@ public abstract class TKeyHandler implements ITickHandler * @param keyBindings * @param repeatings */ - public TKeyHandler(KeyBinding[] keyBindings, boolean[] repeatings) + public TKeyHandler(KeyBinding[] keyBindings, boolean[] repeatings, KeyBinding[] vanillaKeys, boolean[] vanillaRepeatings) { assert keyBindings.length == repeatings.length : "You need to pass two arrays of identical length"; + assert vanillaKeys.length == vanillaRepeatings.length : "You need to pass two arrays of identical length"; this.keyBindings = keyBindings; this.repeatings = repeatings; - this.keyDown = new boolean[keyBindings.length]; + this.vKeyBindings = vanillaKeys; + this.vRepeatings = vanillaRepeatings; + this.keyDown = new boolean[keyBindings.length + vanillaKeys.length]; } @@ -49,19 +54,25 @@ public abstract class TKeyHandler implements ITickHandler return this.keyBindings; } + /** + * Not to be overridden - KeyBindings are tickhandlers under the covers + */ @Override - public void tickStart(EnumSet type, Object... tickData) + public final void tickStart(EnumSet type, Object... tickData) { keyTick(type, false); } + /** + * Not to be overridden - KeyBindings are tickhandlers under the covers + */ @Override - public void tickEnd(EnumSet type, Object... tickData) + public final void tickEnd(EnumSet type, Object... tickData) { keyTick(type, true); } - private void keyTick(EnumSet type, boolean tickEnd) + public void keyTick(EnumSet type, boolean tickEnd) { for (int i = 0; i < keyBindings.length; i++) { @@ -83,7 +94,27 @@ public abstract class TKeyHandler implements ITickHandler keyDown[i] = state; } } - + } + for (int i = 0; i < vKeyBindings.length; i++) + { + KeyBinding keyBinding = vKeyBindings[i]; + int keyCode = keyBinding.keyCode; + boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode)); + if (state != keyDown[i+keyBindings.length] || (state && vRepeatings[i])) + { + if (state) + { + keyDown(type, keyBinding, tickEnd, state!=keyDown[i+keyBindings.length]); + } + else + { + keyUp(type, keyBinding, tickEnd); + } + if (tickEnd) + { + keyDown[i+keyBindings.length] = state; + } + } } } diff --git a/mods/tinker/tconstruct/client/TProxyClient.java b/mods/tinker/tconstruct/client/TProxyClient.java index 1ee0a4c2..85c7d51f 100644 --- a/mods/tinker/tconstruct/client/TProxyClient.java +++ b/mods/tinker/tconstruct/client/TProxyClient.java @@ -2,6 +2,7 @@ package mods.tinker.tconstruct.client; import java.io.File; import java.io.InputStream; +import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -11,7 +12,6 @@ import mods.tinker.common.fancyitem.FancyItemRender; import mods.tinker.tconstruct.TConstruct; import mods.tinker.tconstruct.TConstructRegistry; import mods.tinker.tconstruct.TContent; -import mods.tinker.tconstruct.TControls; import mods.tinker.tconstruct.TProxyCommon; import mods.tinker.tconstruct.client.entityrender.CartRender; import mods.tinker.tconstruct.client.entityrender.CrystalRender; @@ -22,15 +22,22 @@ import mods.tinker.tconstruct.entity.Crystal; import mods.tinker.tconstruct.entity.Skyla; import mods.tinker.tconstruct.logic.CastingTableLogic; import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import org.w3c.dom.Document; +import com.google.common.collect.Lists; + import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.common.registry.TickRegistry; +import cpw.mods.fml.relauncher.Side; public class TProxyClient extends TProxyCommon { @@ -48,45 +55,6 @@ public class TProxyClient extends TProxyCommon RenderingRegistry.registerBlockHandler(new TankRender()); RenderingRegistry.registerBlockHandler(new SearedRender()); RenderingRegistry.registerBlockHandler(new FluidRender()); - //RenderingRegistry.registerBlockHandler(new AxleRender()); - - /*RenderEngine renderEngine = FMLClientHandler.instance().getClient().renderEngine; - renderEngine.registerTextureFX(new LiquidIronFX()); - renderEngine.registerTextureFX(new LiquidIronFlowFX()); - renderEngine.registerTextureFX(new LiquidGoldFX()); - renderEngine.registerTextureFX(new LiquidGoldFlowFX()); - renderEngine.registerTextureFX(new LiquidCopperFX()); - renderEngine.registerTextureFX(new LiquidCopperFlowFX()); - renderEngine.registerTextureFX(new LiquidTinFX()); - renderEngine.registerTextureFX(new LiquidTinFlowFX()); - renderEngine.registerTextureFX(new LiquidAluminumFX()); - renderEngine.registerTextureFX(new LiquidAluminumFlowFX()); - renderEngine.registerTextureFX(new LiquidCobaltFX()); - renderEngine.registerTextureFX(new LiquidCobaltFlowFX()); - renderEngine.registerTextureFX(new LiquidArditeFX()); - renderEngine.registerTextureFX(new LiquidArditeFlowFX()); - renderEngine.registerTextureFX(new LiquidBronzeFX()); - renderEngine.registerTextureFX(new LiquidBronzeFlowFX()); - renderEngine.registerTextureFX(new LiquidAlBrassFX()); - renderEngine.registerTextureFX(new LiquidAlBrassFlowFX()); - renderEngine.registerTextureFX(new LiquidManyullynFX()); - renderEngine.registerTextureFX(new LiquidManyullynFlowFX()); - renderEngine.registerTextureFX(new LiquidAlumiteFX()); - renderEngine.registerTextureFX(new LiquidAlumiteFlowFX()); - renderEngine.registerTextureFX(new LiquidObsidianFX()); - renderEngine.registerTextureFX(new LiquidObsidianFlowFX()); - renderEngine.registerTextureFX(new LiquidSteelFX()); - renderEngine.registerTextureFX(new LiquidSteelFlowFX()); - - //Metallurgy - renderEngine.registerTextureFX(new LiquidManganeseFX()); - renderEngine.registerTextureFX(new LiquidManganeseFlowFX()); - renderEngine.registerTextureFX(new LiquidHeptazionFX()); - renderEngine.registerTextureFX(new LiquidHeptazionFlowFX()); - renderEngine.registerTextureFX(new LiquidDamascusSteelFX()); - renderEngine.registerTextureFX(new LiquidDamascusSteelFlowFX()); - renderEngine.registerTextureFX(new LiquidAngmallenFX()); - renderEngine.registerTextureFX(new LiquidAngmallenFlowFX());*/ //Tools //MinecraftForgeClient.preloadTexture(TContent.blockTexture); @@ -395,13 +363,30 @@ public class TProxyClient extends TProxyCommon tool.effectTextures.put(materialID, tool.getToolTextureFile() + partialLocation); } }*/ - + /* Keybindings */ public static TControls controlInstance; - - public void registerKeys() + + public void registerKeys () { controlInstance = new TControls(); - KeyBindingRegistry.registerKeyBinding(controlInstance); + TickRegistry.registerTickHandler(controlInstance, Side.CLIENT); + uploadKeyBindingsToGame(Minecraft.getMinecraft().gameSettings, controlInstance); + } + + public void uploadKeyBindingsToGame (GameSettings settings, TKeyHandler keyhandler) + { + ArrayList harvestedBindings = Lists.newArrayList(); + for (KeyBinding kb : keyhandler.keyBindings) + { + harvestedBindings.add(kb); + } + + KeyBinding[] modKeyBindings = harvestedBindings.toArray(new KeyBinding[harvestedBindings.size()]); + KeyBinding[] allKeys = new KeyBinding[settings.keyBindings.length + modKeyBindings.length]; + System.arraycopy(settings.keyBindings, 0, allKeys, 0, settings.keyBindings.length); + System.arraycopy(modKeyBindings, 0, allKeys, settings.keyBindings.length, modKeyBindings.length); + settings.keyBindings = allKeys; + settings.loadOptions(); } } diff --git a/mods/tinker/tconstruct/client/gui/SmelteryGui.java b/mods/tinker/tconstruct/client/gui/SmelteryGui.java index 0696eb21..373475e3 100644 --- a/mods/tinker/tconstruct/client/gui/SmelteryGui.java +++ b/mods/tinker/tconstruct/client/gui/SmelteryGui.java @@ -8,10 +8,13 @@ import mods.tinker.tconstruct.logic.SmelteryLogic; import net.minecraft.block.Block; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.util.Icon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.liquids.LiquidStack; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -129,7 +132,8 @@ public class SmelteryGui extends GuiContainer { //ForgeHooksClient.bindTexture(Block.lavaStill.getTextureFile(), 0); //int renderIndex = Block.lavaStill.getBlockTextureFromSideAndMetadata(0, 0); - Icon lavaInon = Block.lavaStill.getBlockTextureFromSideAndMetadata(0, 0); + this.mc.renderEngine.func_98187_b("/terrain.png"); + Icon lavaIcon = Block.lavaStill.getBlockTextureFromSideAndMetadata(0, 0); //int xTex = renderIndex % 16 * 16; //int yTex = renderIndex / 16 * 16; int fuel = logic.getScaledFuelGague(52); @@ -138,7 +142,7 @@ public class SmelteryGui extends GuiContainer { int size = fuel >= 16 ? 16 : fuel; fuel -= size; - func_94065_a(cornerX + 117, (cornerY + 68) - size - 16 * count, lavaInon, 12, size); + func_94065_a(cornerX + 117, (cornerY + 68) - size - 16 * count, lavaIcon, 12, size); //drawTexturedModalRect(cornerX + 117, (cornerY + 68) - size - 16 * count, 0, 16 - size, 12, size); count++; } @@ -146,25 +150,27 @@ public class SmelteryGui extends GuiContainer //Liquids - molten metal int base = 0; - /*for (LiquidStack liquid : logic.moltenMetal) + for (LiquidStack liquid : logic.moltenMetal) { - int renderIndex; + Icon renderIndex; if (liquid.itemID < 4096) //Block { Block liquidBlock = Block.blocksList[liquid.itemID]; - ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0); + //ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0); + this.mc.renderEngine.func_98187_b("/terrain.png"); renderIndex = liquidBlock.getBlockTextureFromSideAndMetadata(0, liquid.itemMeta); } else //Item { Item liquidItem = Item.itemsList[liquid.itemID]; - ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); + //ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0); + this.mc.renderEngine.func_98187_b("/gui/items.png"); renderIndex = liquidItem.getIconFromDamage(liquid.itemMeta); } - int xTex = renderIndex % 16 * 16; - int yTex = renderIndex / 16 * 16; + //int xTex = renderIndex % 16 * 16; + //int yTex = renderIndex / 16 * 16; if (logic.getCapacity() > 0) { int liquidSize = liquid.amount * 52 / logic.getCapacity(); @@ -172,16 +178,16 @@ public class SmelteryGui extends GuiContainer { int size = liquidSize >= 16 ? 16 : liquidSize; int basePos = 54; - drawTexturedModalRect(cornerX + basePos, (cornerY + 68) - size - base, xTex, yTex + 16 - size, 16, size); - drawTexturedModalRect(cornerX + basePos + 16, (cornerY + 68) - size - base, xTex, yTex + 16 - size, 16, size); - drawTexturedModalRect(cornerX + basePos + 32, (cornerY + 68) - size - base, xTex, yTex + 16 - size, 16, size); - drawTexturedModalRect(cornerX + basePos + 48, (cornerY + 68) - size - base, xTex, yTex + 16 - size, 4, size); + func_94065_a(cornerX + basePos, (cornerY + 68) - size - base, renderIndex, 16, size); + func_94065_a(cornerX + basePos + 16, (cornerY + 68) - size - base, renderIndex, 16, size); + func_94065_a(cornerX + basePos + 32, (cornerY + 68) - size - base, renderIndex, 16, size); + func_94065_a(cornerX + basePos + 48, (cornerY + 68) - size - base, renderIndex, 4, size); liquidSize -= size; base += size; } } //base = liquid.amount / 10000 * 52; - }*/ + } //Liquid gague GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -224,8 +230,8 @@ public class SmelteryGui extends GuiContainer } } - /*fontRenderer.drawString("Clicking: "+wasClicking, 140, 30, 0xFFFFFF); - fontRenderer.drawString("Scrolling: "+isScrolling, 140, 40, 0xFFFFFF); - fontRenderer.drawString("Scroll: "+currentScroll, 140, 50, 0xFFFFFF);*/ + fontRenderer.drawString("Time: "+logic.useTime, 140, 2, 0xFFFFFF); + /*fontRenderer.drawString("Scrolling: "+isScrolling, 140, 12, 0xFFFFFF); + fontRenderer.drawString("Scroll: "+currentScroll, 140, 22, 0xFFFFFF);*/ } } diff --git a/mods/tinker/tconstruct/logic/CastingTableLogic.java b/mods/tinker/tconstruct/logic/CastingTableLogic.java index 963dc38d..5db91a3b 100644 --- a/mods/tinker/tconstruct/logic/CastingTableLogic.java +++ b/mods/tinker/tconstruct/logic/CastingTableLogic.java @@ -17,12 +17,12 @@ import net.minecraftforge.liquids.ILiquidTank; import net.minecraftforge.liquids.ITankContainer; import net.minecraftforge.liquids.LiquidStack; -public class CastingTableLogic extends InventoryLogic - implements ILiquidTank, ITankContainer +public class CastingTableLogic extends InventoryLogic implements ILiquidTank, ITankContainer { public LiquidStack liquid; float materialRedux = 0; int castingDelay = 0; + int renderOffset = 0; public CastingTableLogic() { @@ -34,7 +34,6 @@ public class CastingTableLogic extends InventoryLogic { return null; } - @Override protected String getDefaultName () //Still not a gui block @@ -74,13 +73,12 @@ public class CastingTableLogic extends InventoryLogic if (liquid == null) { - System.out.println("Woo"); if (inventory[1] == null && LiquidCasting.instance.getCastingRecipe(resource, inventory[0]) != null) { - System.out.println("Cast exists"); liquid = resource.copy(); materialRedux = LiquidCasting.instance.getMaterialReduction(resource); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + renderOffset = liquid.amount; return liquid.amount; } else @@ -103,6 +101,7 @@ public class CastingTableLogic extends InventoryLogic castingDelay = LiquidCasting.instance.getCastingDelay(liquid, inventory[0]); } } + renderOffset = cap; return cap; } else @@ -127,9 +126,8 @@ public class CastingTableLogic extends InventoryLogic { return 0; } - + /* Tank Container */ - @Override public int fill (ForgeDirection from, LiquidStack resource, boolean doFill) @@ -168,6 +166,11 @@ public class CastingTableLogic extends InventoryLogic { return this; } + + public int getLiquidAmount() + { + return liquid.amount - renderOffset; + } /* Updating */ @Override @@ -179,6 +182,11 @@ public class CastingTableLogic extends InventoryLogic if (castingDelay == 0) castLiquid(); } + if (renderOffset > 0) + { + renderOffset -= 6; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } } public void castLiquid () @@ -191,22 +199,35 @@ public class CastingTableLogic extends InventoryLogic if (recipe.consumeCast) inventory[0] = null; liquid = null; - //System.out.println("Casting: " + inventory[1].getItemName()); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } /* NBT */ + + @Override public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) { if (tags.getBoolean("hasLiquid")) this.liquid = new LiquidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta")); else this.liquid = null; - super.readFromNBT(tags); } + @Override public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + public void writeCustomNBT (NBTTagCompound tags) { tags.setBoolean("hasLiquid", liquid != null); if (liquid != null) @@ -215,7 +236,6 @@ public class CastingTableLogic extends InventoryLogic tags.setInteger("amount", liquid.amount); tags.setInteger("itemMeta", liquid.itemMeta); } - super.writeToNBT(tags); } /* Packets */ diff --git a/mods/tinker/tconstruct/logic/FaucetLogic.java b/mods/tinker/tconstruct/logic/FaucetLogic.java index 0d229c7c..235bcdbd 100644 --- a/mods/tinker/tconstruct/logic/FaucetLogic.java +++ b/mods/tinker/tconstruct/logic/FaucetLogic.java @@ -2,6 +2,7 @@ package mods.tinker.tconstruct.logic; import mods.tinker.common.IActiveLogic; import mods.tinker.common.IFacingLogic; +import mods.tinker.tconstruct.TConstruct; import net.minecraft.entity.EntityLiving; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; @@ -18,13 +19,10 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi byte direction; boolean active; public LiquidStack liquid; - ITankContainer drain; - ITankContainer tank; - int drainAmount = 5; - public void activateFaucet () + public boolean activateFaucet () { - if (liquid == null) + if (liquid == null && active) { int x = xCoord, z = zCoord; switch (getRenderDirection()) @@ -45,57 +43,54 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi TileEntity drainte = worldObj.getBlockTileEntity(x, yCoord, z); TileEntity tankte = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord); + if (drainte != null && drainte instanceof ITankContainer && tankte != null && tankte instanceof ITankContainer) { - //System.out.println("Activating Faucet"); - liquid = ((ITankContainer) drainte).drain(getForgeDirection(), drainAmount, true); - drain = (ITankContainer) drainte; - tank = (ITankContainer) tankte; - active = true; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - //System.out.println("Drained"); - //return true; + liquid = ((ITankContainer) drainte).drain(getForgeDirection(), TConstruct.ingotLiquidValue, true); + if (liquid != null) + { + int drained = ((ITankContainer) tankte).fill(ForgeDirection.UP, liquid, true); + if (drained != liquid.amount) + { + liquid.amount -= drained; + ((ITankContainer) drainte).fill(getForgeDirection(), liquid, true); + } + if (drained > 0) + { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return true; + } + else + { + liquid = null; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return false; + } + } + else + { + ((ITankContainer) drainte).fill(getForgeDirection(), liquid, true); + } } } - //return true; - } - - public void deactivateFaucet () - { - //System.out.println("Deactivating Faucet"); - drain.fill(getForgeDirection(), liquid, true); - liquid = null; - drain = null; - tank = null; - active = false; - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return false; } + @Override public void updateEntity () { - if (active && liquid != null) + if (liquid != null) { - int drained = tank.fill(ForgeDirection.UP, liquid, true); - //System.out.println("Drained: "+drained); - if (drained < drainAmount) + liquid.amount -= TConstruct.liquidUpdateAmount; + if (liquid.amount <= 0) { - liquid.amount -= drained; - deactivateFaucet(); - } - else - { - liquid = drain.drain(getForgeDirection(), drainAmount, true); - } - /*TileEntity te = worldObj.getBlockTileEntity(xCoord, yCoord-1, zCoord); - if (te != null && te instanceof ILiquidTank) - { - int amount = ((ILiquidTank) te).fill(new LiquidStack(liquid.itemID, 2, liquid.itemMeta), true); - liquid.amount -= amount; - if (liquid.amount <= 0) + liquid = null; + if (!activateFaucet()) { - liquid = null; + active = false; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } - }*/ + } } } @@ -135,9 +130,15 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi } } + @Override public void readFromNBT (NBTTagCompound tags) { super.readFromNBT(tags); + readCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { direction = tags.getByte("Direction"); if (tags.getBoolean("hasLiquid")) this.liquid = new LiquidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta")); @@ -149,6 +150,11 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi public void writeToNBT (NBTTagCompound tags) { super.writeToNBT(tags); + writeCustomNBT(tags); + } + + public void writeCustomNBT (NBTTagCompound tags) + { tags.setByte("Direction", direction); tags.setBoolean("hasLiquid", liquid != null); if (liquid != null) @@ -164,14 +170,14 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi public Packet getDescriptionPacket () { NBTTagCompound tag = new NBTTagCompound(); - writeToNBT(tag); + writeCustomNBT(tag); return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); } @Override public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) { - readFromNBT(packet.customParam1); + readCustomNBT(packet.customParam1); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } @@ -184,13 +190,15 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi @Override public void setActive (boolean flag) { - //if (!worldObj.isRemote) - //{ - if (flag) - activateFaucet(); - else - deactivateFaucet(); - //} + if (!active) + { + active = true; + activateFaucet(); + } + else + { + active = false; + } } } diff --git a/mods/tinker/tconstruct/logic/FrypanLogic.java b/mods/tinker/tconstruct/logic/FrypanLogic.java index ae9e086d..9bc477f3 100644 --- a/mods/tinker/tconstruct/logic/FrypanLogic.java +++ b/mods/tinker/tconstruct/logic/FrypanLogic.java @@ -132,11 +132,9 @@ public class FrypanLogic extends EquipLogic public void cookItems () { - //System.out.println("Trying to cook"); if (!canCook()) return; - //System.out.println("Can cook"); for (int id = 2; id < 10; id++) //Check every slot { if (canCook()) diff --git a/mods/tinker/tconstruct/logic/LavaTankLogic.java b/mods/tinker/tconstruct/logic/LavaTankLogic.java index 84a90c49..b0e146fe 100644 --- a/mods/tinker/tconstruct/logic/LavaTankLogic.java +++ b/mods/tinker/tconstruct/logic/LavaTankLogic.java @@ -12,14 +12,17 @@ import net.minecraftforge.liquids.LiquidContainerRegistry; import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidTank; -public class LavaTankLogic extends MultiServantLogic - implements ITankContainer +public class LavaTankLogic extends MultiServantLogic implements ITankContainer { public LiquidTank tank; - + public int renderOffset; + //public LiquidStack renderLiquid; + //public int counter; + //public int updateAmount; + public LavaTankLogic() { - tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME*4); + tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * 4); } @Override @@ -31,9 +34,29 @@ public class LavaTankLogic extends MultiServantLogic @Override public int fill (int tankIndex, LiquidStack resource, boolean doFill) { + /*if (resource != null && resource.amount > 20 && counter == 0) + { + if (tank.getLiquid() == null) + { + renderLiquid = new LiquidStack(resource.itemID, 0, resource.itemMeta); + } + else + { + renderLiquid = tank.getLiquid(); + } + counter = 24; + updateAmount = resource.amount / 24; + System.out.println("renderLiquid: "+renderLiquid.amount); + }*/ + //renderLiquid = tank.getLiquid(); int amount = tank.fill(resource, doFill); if (amount > 0 && doFill) + { + renderOffset = resource.amount; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + + //System.out.println("tankLiquid: "+tank.getLiquid().amount); return amount; } @@ -46,9 +69,20 @@ public class LavaTankLogic extends MultiServantLogic @Override public LiquidStack drain (int tankIndex, int maxDrain, boolean doDrain) { + /*if (maxDrain > 20 && counter == 0) + { + renderLiquid = tank.getLiquid(); + counter = 24; + updateAmount = -(maxDrain / 24); + }*/ + + LiquidStack amount = tank.drain(maxDrain, doDrain); if (amount != null && doDrain) + { + renderOffset = -maxDrain; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } return amount; } @@ -63,18 +97,18 @@ public class LavaTankLogic extends MultiServantLogic { return tank; } - - public float getLiquidAmountScaled() + + public float getLiquidAmountScaled () { - return (float) (tank.getLiquid().amount) / (float) (tank.getCapacity() * 1.01F); + return (float) (tank.getLiquid().amount - renderOffset) / (float) (tank.getCapacity() * 1.01F); } - - public boolean containsLiquid() + + public boolean containsLiquid () { return tank.getLiquid() != null; } - - public int getBrightness() + + public int getBrightness () { if (containsLiquid()) { @@ -86,16 +120,32 @@ public class LavaTankLogic extends MultiServantLogic } return 0; } - - public void readFromNBT(NBTTagCompound tags) - { + + @Override + public void readFromNBT (NBTTagCompound tags) + { + super.readFromNBT(tags); + readCustomNBT(tags); + } + + @Override + public void writeToNBT (NBTTagCompound tags) + { + super.writeToNBT(tags); + writeCustomNBT(tags); + } + + public void readCustomNBT (NBTTagCompound tags) + { if (tags.getBoolean("hasLiquid")) tank.setLiquid(new LiquidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta"))); - super.readFromNBT(tags); - } - - public void writeToNBT(NBTTagCompound tags) - { + else + tank.setLiquid(null); + //renderLiquid = tank.getLiquid(); + } + + public void writeCustomNBT (NBTTagCompound tags) + { LiquidStack liquid = tank.getLiquid(); tags.setBoolean("hasLiquid", liquid != null); if (liquid != null) @@ -104,19 +154,37 @@ public class LavaTankLogic extends MultiServantLogic tags.setInteger("amount", liquid.amount); tags.setInteger("itemMeta", liquid.itemMeta); } - super.writeToNBT(tags); - } - + } + + /* Packets */ + @Override public Packet getDescriptionPacket () { NBTTagCompound tag = new NBTTagCompound(); - writeToNBT(tag); + writeCustomNBT(tag); return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); } + @Override public void onDataPacket (INetworkManager net, Packet132TileEntityData packet) { - worldObj.getBlockTileEntity(xCoord, yCoord, zCoord).readFromNBT(packet.customParam1); + readCustomNBT(packet.customParam1); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } + + /* Updating */ + public boolean canUpdate () + { + return true; + } + + @Override + public void updateEntity () + { + if (renderOffset > 0) + { + renderOffset -= 6; + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + } } diff --git a/mods/tinker/tconstruct/logic/MultiServantLogic.java b/mods/tinker/tconstruct/logic/MultiServantLogic.java index 5a411fbd..0c6475ff 100644 --- a/mods/tinker/tconstruct/logic/MultiServantLogic.java +++ b/mods/tinker/tconstruct/logic/MultiServantLogic.java @@ -1,10 +1,13 @@ package mods.tinker.tconstruct.logic; import mods.tinker.common.CoordTuple; +import mods.tinker.common.IMasterLogic; +import mods.tinker.common.IServantLogic; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class MultiServantLogic extends TileEntity + implements IServantLogic { boolean hasMaster; CoordTuple master; @@ -72,6 +75,15 @@ public class MultiServantLogic extends TileEntity return false; } } + + public void notifyMasterOfChange() + { + if (hasValidMaster()) + { + IMasterLogic logic = (IMasterLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z); + logic.notifyChange(xCoord, yCoord, zCoord); + } + } public void readFromNBT (NBTTagCompound tags) { diff --git a/mods/tinker/tconstruct/logic/PartCrafterLogic.java b/mods/tinker/tconstruct/logic/PartCrafterLogic.java index 5759bd7a..414305af 100644 --- a/mods/tinker/tconstruct/logic/PartCrafterLogic.java +++ b/mods/tinker/tconstruct/logic/PartCrafterLogic.java @@ -43,7 +43,6 @@ public class PartCrafterLogic extends InventoryLogic //return ((PatternHolderLogic) tile).getGuiContainer(player.inventory, world, x, y, z); } } - //System.out.println("Regular container"); return new PartCrafterContainer(inventoryplayer, this); } diff --git a/mods/tinker/tconstruct/logic/SmelteryLogic.java b/mods/tinker/tconstruct/logic/SmelteryLogic.java index db6d3830..a7d84e3d 100644 --- a/mods/tinker/tconstruct/logic/SmelteryLogic.java +++ b/mods/tinker/tconstruct/logic/SmelteryLogic.java @@ -5,10 +5,12 @@ import java.util.ArrayList; import mods.tinker.common.CoordTuple; import mods.tinker.common.IActiveLogic; import mods.tinker.common.IFacingLogic; +import mods.tinker.common.IMasterLogic; import mods.tinker.common.InventoryLogic; import mods.tinker.tconstruct.TContent; import mods.tinker.tconstruct.container.SmelteryContainer; import mods.tinker.tconstruct.crafting.Smeltery; +import net.minecraft.block.Block; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -23,19 +25,20 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.liquids.ILiquidTank; +import net.minecraftforge.liquids.ITankContainer; import net.minecraftforge.liquids.LiquidStack; /* Simple class for storing items in the block */ public class SmelteryLogic extends InventoryLogic - implements IActiveLogic, IFacingLogic, ILiquidTank + implements IActiveLogic, IFacingLogic, ILiquidTank, IMasterLogic { public boolean validStructure; byte direction; int internalTemp; int maxTemp; - int useTime; + public int useTime; public int fuelGague; ArrayList lavaTanks; @@ -172,14 +175,12 @@ public class SmelteryLogic extends InventoryLogic public int getMeltingPointForSlot (int slot) { - //System.out.println("Slot "+slot); return meltingTemps[slot]; } /* Updating */ public void updateEntity () { - //System.out.println("tick"); tick++; if (tick % 4 == 0) heatItems(); @@ -187,63 +188,55 @@ public class SmelteryLogic extends InventoryLogic if (tick == 20) { tick = 0; - checkValidPlacement(); - updateFuelGague(); + if (!validStructure) + checkValidPlacement(); if (useTime > 0) useTime--; - /*if (!worldObj.isRemote) - matchInventoryToWorld();*/ if (validStructure && useTime == 0) { - TileEntity tank = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); - if (tank instanceof ILiquidTank) - { - LiquidStack liquid = ((ILiquidTank) tank).drain(10, true); - if (liquid != null) - { - //System.out.println("Drained " + liquid.amount); - useTime += liquid.amount; - } - } + updateFuelGague(); } } } void heatItems () { - for (int i = 0; i < 9 * layers; i++) + if (useTime > 0) { - if (meltingTemps[i] > 20 && this.isStackInSlot(i)) + for (int i = 0; i < 9 * layers; i++) { - if (activeTemps[i] < internalTemp && activeTemps[i] < meltingTemps[i]) - activeTemps[i] += 5; - else if (meltingTemps[i] >= activeTemps[i]) + if (meltingTemps[i] > 20 && this.isStackInSlot(i)) { - if (!worldObj.isRemote) + if (activeTemps[i] < internalTemp && activeTemps[i] < meltingTemps[i]) + activeTemps[i] += 5; + else if (meltingTemps[i] >= activeTemps[i]) { - LiquidStack result = getResultFor(inventory[i]); - if (result != null) + if (!worldObj.isRemote) { - inventory[i] = null; - addMoltenMetal(result, false); - ArrayList alloys = Smeltery.mixMetals(moltenMetal); - for (int al = 0; al < alloys.size(); al++) + LiquidStack result = getResultFor(inventory[i]); + if (result != null) { - LiquidStack liquid = (LiquidStack) alloys.get(al); - addMoltenMetal(liquid, true); + inventory[i] = null; + addMoltenMetal(result, false); + ArrayList alloys = Smeltery.mixMetals(moltenMetal); + for (int al = 0; al < alloys.size(); al++) + { + LiquidStack liquid = (LiquidStack) alloys.get(al); + addMoltenMetal(liquid, true); + } + onInventoryChanged(); + //setWorldToInventory(); } - onInventoryChanged(); - //setWorldToInventory(); } } + } + else + activeTemps[i] = 20; } - - else - activeTemps[i] = 20; } } @@ -292,19 +285,23 @@ public class SmelteryLogic extends InventoryLogic if (activeLavaTank == null) return; - TileEntity tank = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); - if (tank == null) + TileEntity tankContainer = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); + if (tankContainer == null) { fuelGague = 0; } - if (tank instanceof ILiquidTank) + if (tankContainer instanceof ITankContainer) { - LiquidStack liquid = ((ILiquidTank) tank).getLiquid(); - int capacity = ((ILiquidTank) tank).getCapacity(); - if (liquid != null) + LiquidStack liquid = ((ITankContainer) tankContainer).drain(ForgeDirection.DOWN, 50, false); + if (liquid != null && liquid.itemID == Block.lavaStill.blockID) + { + liquid = ((ITankContainer) tankContainer).drain(ForgeDirection.DOWN, 50, true); + useTime += liquid.amount; + ILiquidTank tank = ((ITankContainer) tankContainer).getTank(ForgeDirection.DOWN, liquid); + liquid = tank.getLiquid(); + int capacity = tank.getCapacity(); fuelGague = liquid.amount * 52 / capacity; - else - fuelGague = 0; + } } } @@ -314,15 +311,14 @@ public class SmelteryLogic extends InventoryLogic } /* Inventory */ - public int getMaxStackStackSize(ItemStack stack) + public int getMaxStackStackSize (ItemStack stack) { LiquidStack liquid = getResultFor(stack); - System.out.println("Liquid: "+liquid); if (liquid == null) return 0; return liquid.amount; } - + public int getInventoryStackLimit () { return 1; @@ -332,7 +328,7 @@ public class SmelteryLogic extends InventoryLogic { updateTemperatures(); super.onInventoryChanged(); - worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } /* Multiblock */ @@ -394,7 +390,6 @@ public class SmelteryLogic extends InventoryLogic { int capacity = 0; validStructure = false; - //System.out.println("Yep"); if (checkSameLevel(x, y, z)) { capacity++; @@ -449,28 +444,10 @@ public class SmelteryLogic extends InventoryLogic hasLavaTank = true; } - //System.out.println("numBricks: "+numBricks); if (numBricks == 12 && hasLavaTank) return true; else return false; - - /*System.out.println("numBricks: "+numBricks); - - if (numBricks == 21 && hasLavaTank) - { - centerPos = new CoordTuple(x, y, z); - activeLavaTank = lavaTanks.get(0); - validStructure = true; - internalTemp = 800; - return true; - } - else - { - validStructure = false; - internalTemp = 20; - return false; - }*/ } public int recurseStructureUp (int x, int y, int z, int count) @@ -567,8 +544,6 @@ public class SmelteryLogic extends InventoryLogic boolean checkBricks (int x, int y, int z) { - //System.out.println("x: "+x+", z: "+z); - //System.out.println("Bricks: "+numBricks); int blockID = worldObj.getBlockId(x, y, z); if (blockID == TContent.smeltery.blockID || blockID == TContent.lavaTank.blockID) { @@ -593,7 +568,6 @@ public class SmelteryLogic extends InventoryLogic if (te instanceof LavaTankLogic) { - //System.out.println("Lava tank ho!"); lavaTanks.add(new CoordTuple(x, y, z)); return true; } @@ -642,8 +616,6 @@ public class SmelteryLogic extends InventoryLogic addMoltenMetal(resource, false); return amount; } - - @Override public LiquidStack getLiquid () @@ -725,4 +697,10 @@ public class SmelteryLogic extends InventoryLogic readFromNBT(packet.customParam1); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } + + @Override + public void notifyChange (int x, int y, int z) + { + checkValidPlacement(); + } } diff --git a/mods/tinker/tconstruct/player/TPlayerHandler.java b/mods/tinker/tconstruct/player/TPlayerHandler.java index 3f67b918..aadfad3c 100644 --- a/mods/tinker/tconstruct/player/TPlayerHandler.java +++ b/mods/tinker/tconstruct/player/TPlayerHandler.java @@ -6,6 +6,8 @@ import mods.tinker.tconstruct.AbilityHelper; import mods.tinker.tconstruct.PHConstruct; import mods.tinker.tconstruct.TContent; import mods.tinker.tconstruct.client.TProxyClient; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumEntitySize; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -76,44 +78,7 @@ public class TPlayerHandler implements IPlayerTracker NBTTagCompound tags = entityplayer.getEntityData().getCompoundTag("TConstruct"); tags.getCompoundTag("TConstruct").setBoolean("diary", stats.diary); } - - @ForgeSubscribe - public void playerDrops (PlayerDropsEvent evt) - { - TPlayerStats stats = getPlayerStats(evt.entityPlayer.username); - stats.level = evt.entityPlayer.experienceLevel / 2; - //stats.health = 20; - int hunger = evt.entityPlayer.getFoodStats().getFoodLevel(); - if (hunger < 6) - stats.hunger = 6; - else - stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel(); - } - - TPlayerStats getPlayerStats (String username) //Not sure if needed - { - TPlayerStats stats = playerStats.get(username); - if (stats == null) - { - stats = new TPlayerStats(); - playerStats.put(username, stats); - } - return stats; - } - - public EntityPlayer getEntityPlayer (String username) - { - TPlayerStats stats = playerStats.get(username); - if (stats == null) - { - return null; - } - else - { - return stats.player; - } - } - + @ForgeSubscribe public void livingFall (LivingFallEvent evt) //Only for negating fall damage { @@ -126,8 +91,8 @@ public class TPlayerHandler implements IPlayerTracker //System.out.println("Client side: "+evt.entityLiving.motionY); } - else - System.out.println("Server side"); + //else + //System.out.println("Server side"); evt.distance -= 1; //evt.distance = 0; @@ -158,4 +123,91 @@ public class TPlayerHandler implements IPlayerTracker } } }*/ + + @ForgeSubscribe + public void playerDrops (PlayerDropsEvent evt) + { + TPlayerStats stats = getPlayerStats(evt.entityPlayer.username); + stats.level = evt.entityPlayer.experienceLevel / 2; + //stats.health = 20; + int hunger = evt.entityPlayer.getFoodStats().getFoodLevel(); + if (hunger < 6) + stats.hunger = 6; + else + stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel(); + } + + /* Find the right player */ + TPlayerStats getPlayerStats (String username) + { + TPlayerStats stats = playerStats.get(username); + if (stats == null) + { + stats = new TPlayerStats(); + playerStats.put(username, stats); + } + return stats; + } + + public EntityPlayer getEntityPlayer (String username) + { + TPlayerStats stats = playerStats.get(username); + if (stats == null) + { + return null; + } + else + { + return stats.player; + } + } + + /* Modify Player */ + public void updateSize(String user, float offset) + { + /*EntityPlayer player = getEntityPlayer(user); + setEntitySize(0.6F, offset, player); + player.yOffset = offset - 0.18f;*/ + } + + public static void setEntitySize(float width, float height, Entity entity) + { + System.out.println("Size: "+height); + if (width != entity.width || height != entity.height) + { + entity.width = width; + entity.height = height; + entity.boundingBox.maxX = entity.boundingBox.minX + (double)entity.width; + entity.boundingBox.maxZ = entity.boundingBox.minZ + (double)entity.width; + entity.boundingBox.maxY = entity.boundingBox.minY + (double)entity.height; + } + + float que = width % 2.0F; + + if ((double)que < 0.375D) + { + entity.myEntitySize = EnumEntitySize.SIZE_1; + } + else if ((double)que < 0.75D) + { + entity.myEntitySize = EnumEntitySize.SIZE_2; + } + else if ((double)que < 1.0D) + { + entity.myEntitySize = EnumEntitySize.SIZE_3; + } + else if ((double)que < 1.375D) + { + entity.myEntitySize = EnumEntitySize.SIZE_4; + } + else if ((double)que < 1.75D) + { + entity.myEntitySize = EnumEntitySize.SIZE_5; + } + else + { + entity.myEntitySize = EnumEntitySize.SIZE_6; + } + //entity.yOffset = height; + } }