diff --git a/src/main/java/net/anvilcraft/thaummach/ClientProxy.java b/src/main/java/net/anvilcraft/thaummach/ClientProxy.java index e866951..d3961a0 100644 --- a/src/main/java/net/anvilcraft/thaummach/ClientProxy.java +++ b/src/main/java/net/anvilcraft/thaummach/ClientProxy.java @@ -7,20 +7,23 @@ import cpw.mods.fml.common.registry.GameRegistry; import net.anvilcraft.thaummach.entities.EntitySingularity; import net.anvilcraft.thaummach.gui.GuiArcaneFurnace; import net.anvilcraft.thaummach.gui.GuiBore; +import net.anvilcraft.thaummach.gui.GuiCondenser; import net.anvilcraft.thaummach.gui.GuiCrystallizer; import net.anvilcraft.thaummach.gui.GuiSoulBrazier; import net.anvilcraft.thaummach.gui.GuiVoidChest; import net.anvilcraft.thaummach.gui.GuiVoidInterface; import net.anvilcraft.thaummach.render.BlockApparatusRenderer; -import net.anvilcraft.thaummach.render.TileSealRenderer; import net.anvilcraft.thaummach.render.entity.EntitySingularityRenderer; import net.anvilcraft.thaummach.render.tile.TileBoreRenderer; +import net.anvilcraft.thaummach.render.tile.TileCondenserRenderer; import net.anvilcraft.thaummach.render.tile.TileConduitPumpRenderer; import net.anvilcraft.thaummach.render.tile.TileCrystallizerRenderer; +import net.anvilcraft.thaummach.render.tile.TileSealRenderer; import net.anvilcraft.thaummach.render.tile.TileVoidChestRenderer; import net.anvilcraft.thaummach.render.tile.TileVoidInterfaceRenderer; import net.anvilcraft.thaummach.tiles.TileArcaneFurnace; import net.anvilcraft.thaummach.tiles.TileBore; +import net.anvilcraft.thaummach.tiles.TileCondenser; import net.anvilcraft.thaummach.tiles.TileConduit; import net.anvilcraft.thaummach.tiles.TileConduitPump; import net.anvilcraft.thaummach.tiles.TileConduitTank; @@ -58,32 +61,25 @@ public class ClientProxy extends CommonProxy { @Override public void registerTileEntities() { + // clang-format off GameRegistry.registerTileEntity(TileArcaneFurnace.class, "arcane_furnace"); GameRegistry.registerTileEntity(TileConduit.class, "conduit"); GameRegistry.registerTileEntity(TileConduitTank.class, "conduit_tank"); GameRegistry.registerTileEntity(TileConduitValve.class, "conduit_valve"); - GameRegistry.registerTileEntity( - TileConduitValveAdvanced.class, "conduit_valve_advanced" - ); + GameRegistry.registerTileEntity(TileConduitValveAdvanced.class, "conduit_valve_advanced"); GameRegistry.registerTileEntity(TileCrucible.class, "crucible"); GameRegistry.registerTileEntity(TileFilter.class, "filter"); GameRegistry.registerTileEntity(TilePurifier.class, "purifier"); GameRegistry.registerTileEntity(TileSoulBrazier.class, "soulBrazier"); ClientRegistry.registerTileEntity(TileBore.class, "bore", new TileBoreRenderer()); - ClientRegistry.registerTileEntity( - TileConduitPump.class, "conduit_pump", new TileConduitPumpRenderer() - ); - ClientRegistry.registerTileEntity( - TileCrystallizer.class, "crystallizer", new TileCrystallizerRenderer() - ); + ClientRegistry.registerTileEntity(TileCondenser.class, "condenser", new TileCondenserRenderer()); + ClientRegistry.registerTileEntity(TileConduitPump.class, "conduit_pump", new TileConduitPumpRenderer()); + ClientRegistry.registerTileEntity(TileCrystallizer.class, "crystallizer", new TileCrystallizerRenderer()); ClientRegistry.registerTileEntity(TileSeal.class, "seal", new TileSealRenderer()); - ClientRegistry.registerTileEntity( - TileVoidChest.class, "voidChest", new TileVoidChestRenderer() - ); - ClientRegistry.registerTileEntity( - TileVoidInterface.class, "voidInterface", new TileVoidInterfaceRenderer() - ); + ClientRegistry.registerTileEntity(TileVoidChest.class, "voidChest", new TileVoidChestRenderer()); + ClientRegistry.registerTileEntity(TileVoidInterface.class, "voidInterface", new TileVoidInterfaceRenderer()); + // clang-format on } @Override @@ -97,6 +93,9 @@ public class ClientProxy extends CommonProxy { case BORE: return new GuiBore(player.inventory, (TileBore) te); + case CONDENSER: + return new GuiCondenser(player.inventory, (TileCondenser) te); + case CRYSTALLIZER: return new GuiCrystallizer(player.inventory, (TileCrystallizer) te); diff --git a/src/main/java/net/anvilcraft/thaummach/CommonProxy.java b/src/main/java/net/anvilcraft/thaummach/CommonProxy.java index a447e89..2e53a28 100644 --- a/src/main/java/net/anvilcraft/thaummach/CommonProxy.java +++ b/src/main/java/net/anvilcraft/thaummach/CommonProxy.java @@ -4,12 +4,14 @@ import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameRegistry; import net.anvilcraft.thaummach.container.ContainerArcaneFurnace; import net.anvilcraft.thaummach.container.ContainerBore; +import net.anvilcraft.thaummach.container.ContainerCondenser; import net.anvilcraft.thaummach.container.ContainerCrystallizer; import net.anvilcraft.thaummach.container.ContainerSoulBrazier; import net.anvilcraft.thaummach.container.ContainerVoidChest; import net.anvilcraft.thaummach.container.ContainerVoidInterface; import net.anvilcraft.thaummach.tiles.TileArcaneFurnace; import net.anvilcraft.thaummach.tiles.TileBore; +import net.anvilcraft.thaummach.tiles.TileCondenser; import net.anvilcraft.thaummach.tiles.TileConduit; import net.anvilcraft.thaummach.tiles.TileConduitPump; import net.anvilcraft.thaummach.tiles.TileConduitTank; @@ -33,23 +35,24 @@ public class CommonProxy implements IGuiHandler { public void init() {} public void registerTileEntities() { + // clang-format off GameRegistry.registerTileEntity(TileArcaneFurnace.class, "arcane_furnace"); GameRegistry.registerTileEntity(TileBore.class, "bore"); + GameRegistry.registerTileEntity(TileCondenser.class, "condenser"); GameRegistry.registerTileEntity(TileConduit.class, "conduit"); GameRegistry.registerTileEntity(TileConduitPump.class, "conduit_pump"); GameRegistry.registerTileEntity(TileConduitTank.class, "conduit_tank"); GameRegistry.registerTileEntity(TileConduitValve.class, "conduit_valve"); - GameRegistry.registerTileEntity( - TileConduitValveAdvanced.class, "conduit_valve_advanced" - ); + GameRegistry.registerTileEntity(TileConduitValveAdvanced.class, "conduit_valve_advanced"); GameRegistry.registerTileEntity(TileCrucible.class, "crucible"); GameRegistry.registerTileEntity(TileCrystallizer.class, "crystallizer"); GameRegistry.registerTileEntity(TileFilter.class, "filter"); GameRegistry.registerTileEntity(TilePurifier.class, "purifier"); GameRegistry.registerTileEntity(TileSeal.class, "seal"); + GameRegistry.registerTileEntity(TileSoulBrazier.class, "soulBrazier"); GameRegistry.registerTileEntity(TileVoidChest.class, "voidChest"); GameRegistry.registerTileEntity(TileVoidInterface.class, "voidInterface"); - GameRegistry.registerTileEntity(TileSoulBrazier.class, "soulBrazier"); + // clang-format on } @Override @@ -65,6 +68,9 @@ public class CommonProxy implements IGuiHandler { case BORE: return new ContainerBore(player.inventory, (TileBore) te); + case CONDENSER: + return new ContainerCondenser(player.inventory, (TileCondenser) te); + case CRYSTALLIZER: return new ContainerCrystallizer(player.inventory, (TileCrystallizer) te); diff --git a/src/main/java/net/anvilcraft/thaummach/GuiID.java b/src/main/java/net/anvilcraft/thaummach/GuiID.java index 9fdf87f..f670d37 100644 --- a/src/main/java/net/anvilcraft/thaummach/GuiID.java +++ b/src/main/java/net/anvilcraft/thaummach/GuiID.java @@ -3,6 +3,7 @@ package net.anvilcraft.thaummach; public enum GuiID { ARCANE_FURNACE, BORE, + CONDENSER, CRYSTALLIZER, SOUL_BRAZIER, VOID_CHEST, diff --git a/src/main/java/net/anvilcraft/thaummach/blocks/BlockApparatusWood.java b/src/main/java/net/anvilcraft/thaummach/blocks/BlockApparatusWood.java index f8bd90a..bf1e1f2 100644 --- a/src/main/java/net/anvilcraft/thaummach/blocks/BlockApparatusWood.java +++ b/src/main/java/net/anvilcraft/thaummach/blocks/BlockApparatusWood.java @@ -1,30 +1,55 @@ package net.anvilcraft.thaummach.blocks; -import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.function.Function; +import java.util.stream.IntStream; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.anvilcraft.thaummach.particles.FXWisp; import net.anvilcraft.thaummach.render.BlockApparatusRenderer; import net.anvilcraft.thaummach.render.apparatus.IApparatusRenderer; +import net.anvilcraft.thaummach.render.apparatus.apparati.wood.CondenserApparatusRenderer; +import net.anvilcraft.thaummach.tiles.TileCondenser; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockApparatusWood extends BlockApparatus { + public IIcon iconCondenserPart1; + public IIcon iconCondenserPart2; + public IIcon iconCondenserSide; + public IIcon iconCondenserSpeedUpgrade; + public IIcon iconCondenserTop; + + public IIcon iconDawnTotemBottom; + public IIcon[] iconsDawnTotemSide; + + public IIcon iconDuskTotemBottom; + public IIcon[] iconsDuskTotemSide; + + public IIcon iconDuplicatorBottom; + public IIcon iconDuplicatorInside; + public IIcon iconDuplicatorSide; + public IIcon iconDuplicatorTop; + + public IIcon iconRestorerBottom; + public IIcon iconRestorerSide; + public IIcon iconRestorerSidePipes; + public IIcon iconRestorerTop; + public BlockApparatusWood() { super(Material.wood); this.setHardness(2.0F); @@ -33,15 +58,50 @@ public class BlockApparatusWood extends BlockApparatus { this.setBlockName("tcbappwood"); } + @Override + public void registerBlockIcons(IIconRegister register) { + Function reg = (s) -> register.registerIcon("thaummach:" + s); + + this.iconCondenserPart1 = reg.apply("condenser_part_1"); + this.iconCondenserPart2 = reg.apply("condenser_part_2"); + this.iconCondenserSide = reg.apply("condenser_side"); + this.iconCondenserSpeedUpgrade = reg.apply("condenser_speed_upgrade"); + this.iconCondenserTop = reg.apply("condenser_top"); + + this.iconDawnTotemBottom = reg.apply("dawn_totem_bottom"); + this.iconsDawnTotemSide = IntStream.rangeClosed(1, 6) + .mapToObj((i) -> reg.apply("dawn_totem_side_" + i)) + .toArray(IIcon[] ::new); + + this.iconDuskTotemBottom = reg.apply("dusk_totem_bottom"); + this.iconsDuskTotemSide = IntStream.rangeClosed(1, 6) + .mapToObj((i) -> reg.apply("dusk_totem_side_" + i)) + .toArray(IIcon[] ::new); + + this.iconDuplicatorBottom = reg.apply("duplicator_bottom"); + this.iconDuplicatorSide = reg.apply("duplicator_side"); + this.iconDuplicatorInside = reg.apply("duplicator_inside"); + this.iconDuplicatorTop = reg.apply("duplicator_top"); + + this.iconRestorerBottom = reg.apply("restorer_bottom"); + this.iconRestorerSide = reg.apply("restorer_side"); + this.iconRestorerSidePipes = reg.apply("restorer_side_pipes"); + this.iconRestorerTop = reg.apply("restorer_top"); + } + @Override public IApparatusRenderer getApparatusRenderer(int meta) { switch (MetaVals.get(meta)) { + case CONDENSER: + return CondenserApparatusRenderer.INSTANCE; + default: return null; } } @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List itemList) { itemList.add(new ItemStack(this, 1, 0)); itemList.add(new ItemStack(this, 1, 1)); @@ -55,9 +115,9 @@ public class BlockApparatusWood extends BlockApparatus { MetaVals md = MetaVals.get(meta); switch (md) { - //case CONDENSER: - // return new TileCondenser(); - // + case CONDENSER: + return new TileCondenser(); + //case DUPLICATOR: // return new TileDuplicator(); // @@ -222,46 +282,49 @@ public class BlockApparatusWood extends BlockApparatus { // } //} - //@Override - //public int getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) { - // int md = iblockaccess.getBlockMetadata(i, j, k); - // if (md == 0) { - // return l <= 1 ? 113 : 112; - // } else if (md == 1) { - // if (l <= 1) { - // return 70; - // } else { - // TileEntity te = iblockaccess.getBlockTileEntity(i, j, k); - // if (te != null && te instanceof TileDuplicator) { - // if (((TileDuplicator) te).orientation == 0 && l == 2) { - // return 71; - // } + @Override + public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) { + MetaVals md = MetaVals.get(iblockaccess.getBlockMetadata(i, j, k)); + if (md == MetaVals.CONDENSER) { + return l <= 1 ? this.iconCondenserTop : this.iconCondenserSide; + } + //else if (md == 1) { + // if (l <= 1) { + // return 70; + // } else { + // TileEntity te = iblockaccess.getBlockTileEntity(i, j, k); + // if (te != null && te instanceof TileDuplicator) { + // if (((TileDuplicator) te).orientation == 0 && l == 2) { + // return 71; + // } - // if (((TileDuplicator) te).orientation == 1 && l == 5) { - // return 71; - // } + // if (((TileDuplicator) te).orientation == 1 && l == 5) { + // return 71; + // } - // if (((TileDuplicator) te).orientation == 2 && l == 3) { - // return 71; - // } + // if (((TileDuplicator) te).orientation == 2 && l == 3) { + // return 71; + // } - // if (((TileDuplicator) te).orientation == 3 && l == 4) { - // return 71; - // } - // } + // if (((TileDuplicator) te).orientation == 3 && l == 4) { + // return 71; + // } + // } - // return 72; - // } - // } else if (md == 2) { - // return l <= 1 ? 86 : 87; - // } else if (md == 3) { - // return l <= 1 ? 127 : 121 + Math.abs((i + j + k) % 6); - // } else if (md == 4) { - // return l <= 1 ? 143 : 137 + Math.abs((i + j + k) % 6); - // } else { - // return 15; - // } - //} + // return 72; + // } + //} else if (md == 2) { + // return l <= 1 ? 86 : 87; + //} else if (md == 3) { + // return l <= 1 ? 127 : 121 + Math.abs((i + j + k) % 6); + //} else if (md == 4) { + // return l <= 1 ? 143 : 137 + Math.abs((i + j + k) % 6); + //} else { + // return 15; + //} + + return null; + } @Override public int damageDropped(int i) { diff --git a/src/main/java/net/anvilcraft/thaummach/container/ContainerCondenser.java b/src/main/java/net/anvilcraft/thaummach/container/ContainerCondenser.java new file mode 100644 index 0000000..39ec78e --- /dev/null +++ b/src/main/java/net/anvilcraft/thaummach/container/ContainerCondenser.java @@ -0,0 +1,69 @@ +package net.anvilcraft.thaummach.container; + +import net.anvilcraft.thaummach.InventorySlot; +import net.anvilcraft.thaummach.OutputSlot; +import net.anvilcraft.thaummach.tiles.TileCondenser; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerCondenser extends Container { + private TileCondenser arcaneCondenser; + + public ContainerCondenser( + InventoryPlayer inventoryplayer, TileCondenser tileCondenser + ) { + this.arcaneCondenser = tileCondenser; + this.addSlotToContainer(new InventorySlot(tileCondenser, 0, 46, 32)); + this.addSlotToContainer(new OutputSlot(tileCondenser, 1, 114, 32)); + + int j; + for (j = 0; j < 3; ++j) { + for (int k = 0; k < 9; ++k) { + this.addSlotToContainer( + new Slot(inventoryplayer, k + j * 9 + 9, 8 + k * 18, 84 + j * 18) + ); + } + } + + for (j = 0; j < 9; ++j) { + this.addSlotToContainer(new Slot(inventoryplayer, j, 8 + j * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return this.arcaneCondenser.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) { + ItemStack itemstack = null; + Slot slot = (Slot) super.inventorySlots.get(i); + if (slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + if (i < 2) { + if (!this.mergeItemStack(itemstack1, 2, 38, true)) { + return null; + } + } else if (this.arcaneCondenser.isItemValidForSlot(0, itemstack1) && !this.mergeItemStack(itemstack1, 0, 1, false)) { + return null; + } + + if (itemstack1.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) { + return null; + } + } + + return itemstack; + } +} diff --git a/src/main/java/net/anvilcraft/thaummach/gui/GuiCondenser.java b/src/main/java/net/anvilcraft/thaummach/gui/GuiCondenser.java new file mode 100644 index 0000000..73424ff --- /dev/null +++ b/src/main/java/net/anvilcraft/thaummach/gui/GuiCondenser.java @@ -0,0 +1,54 @@ +package net.anvilcraft.thaummach.gui; + +import net.anvilcraft.thaummach.TMItems; +import net.anvilcraft.thaummach.container.ContainerCondenser; +import net.anvilcraft.thaummach.tiles.TileCondenser; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class GuiCondenser extends GuiContainer { + private TileCondenser arcaneCondenser; + + public GuiCondenser(InventoryPlayer inventoryplayer, TileCondenser tileCondenser) { + super(new ContainerCondenser(inventoryplayer, tileCondenser)); + this.arcaneCondenser = tileCondenser; + } + + @Override + protected void drawGuiContainerForegroundLayer(int alec1, int alec2) { + super.fontRendererObj.drawString("Vis Condenser", 54, 5, 0x404040); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int qq, int ww) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + super.mc.renderEngine.bindTexture( + new ResourceLocation("thaummach", "textures/guis/condenser.png") + ); + int l = (super.width - super.xSize) / 2; + int i1 = (super.height - super.ySize) / 2; + this.drawTexturedModalRect(l, i1, 0, 0, super.xSize, super.ySize); + int k1 = (int) (35.0F * this.arcaneCondenser.degredation / 4550.0F); + this.drawTexturedModalRect(l + 78, i1 + 23 + 35 - k1, 176, 35 - k1, 20, k1); + int moon = super.mc.theWorld.getMoonPhase(); + this.drawTexturedModalRect(l + 84, i1 + 68, 200, moon * 8, 8, 8); + + this.mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + + for (int upgIdx = 0; upgIdx <= 1; upgIdx++) { + int upgMeta = this.arcaneCondenser.getUpgrades()[upgIdx]; + if (upgMeta >= 0) { + this.drawTexturedModelRectFromIcon( + l + 56 + 48 * upgIdx, + i1 + 56, + TMItems.upgrade.getIconFromDamage(upgMeta), + 16, + 16 + ); + } + } + } +} diff --git a/src/main/java/net/anvilcraft/thaummach/items/ItemUpgrade.java b/src/main/java/net/anvilcraft/thaummach/items/ItemUpgrade.java index a7620ba..8ff54db 100644 --- a/src/main/java/net/anvilcraft/thaummach/items/ItemUpgrade.java +++ b/src/main/java/net/anvilcraft/thaummach/items/ItemUpgrade.java @@ -101,7 +101,6 @@ public class ItemUpgrade extends Item { float alec2, float alec3 ) { - System.out.println("ALEC"); TileEntity ent = world.getTileEntity(x, y, z); if (ent != null && ent instanceof IUpgradable) { IUpgradable ue = (IUpgradable) ent; diff --git a/src/main/java/net/anvilcraft/thaummach/render/apparatus/apparati/wood/CondenserApparatusRenderer.java b/src/main/java/net/anvilcraft/thaummach/render/apparatus/apparati/wood/CondenserApparatusRenderer.java new file mode 100644 index 0000000..8ae07f6 --- /dev/null +++ b/src/main/java/net/anvilcraft/thaummach/render/apparatus/apparati/wood/CondenserApparatusRenderer.java @@ -0,0 +1,120 @@ +package net.anvilcraft.thaummach.render.apparatus.apparati.wood; + +import net.anvilcraft.thaummach.blocks.BlockApparatusWood; +import net.anvilcraft.thaummach.render.apparatus.ApparatusRenderingHelper; +import net.anvilcraft.thaummach.render.apparatus.IApparatusRenderer; +import net.anvilcraft.thaummach.tiles.TileCondenser; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; + +public class CondenserApparatusRenderer implements IApparatusRenderer { + public static final CondenserApparatusRenderer INSTANCE + = new CondenserApparatusRenderer(); + + @Override + public void renderApparatus( + IBlockAccess w, + RenderBlocks rb, + int i, + int j, + int k, + Block block_, + int meta, + boolean inv + ) { + BlockApparatusWood block = (BlockApparatusWood) block_; + + float w4 = 0.25F; + float w3 = 0.1875F; + float w2 = 0.125F; + if (block.getRenderBlockPass() == 0 || inv) { + rb.setRenderBounds(w3, 1.0F - w4, w3, 1.0F - w3, 1.0F, 1.0F - w3); + if (inv) { + ApparatusRenderingHelper.drawFaces( + rb, + block, + block.iconCondenserTop, + block.iconCondenserTop, + block.iconCondenserSide, + block.iconCondenserSide, + block.iconCondenserSide, + block.iconCondenserSide, + false + ); + } else { + rb.renderStandardBlock(block, i, j, k); + } + + rb.setRenderBounds(w3, 0.0F, w3, 1.0F - w3, w4, 1.0F - w3); + if (inv) { + ApparatusRenderingHelper.drawFaces( + rb, + block, + block.iconCondenserTop, + block.iconCondenserTop, + block.iconCondenserSide, + block.iconCondenserSide, + block.iconCondenserSide, + block.iconCondenserSide, + false + ); + } else { + rb.renderStandardBlock(block, i, j, k); + } + + rb.overrideBlockTexture = block.iconCondenserPart1; + rb.setRenderBounds(0.5F - w2, w2, 0.0F, 0.5F + w2, 1.0F - w2, 1.0F); + if (inv) { + ApparatusRenderingHelper.drawFaces( + rb, block, block.iconCondenserPart1, false + ); + } else { + rb.renderStandardBlock(block, i, j, k); + } + + rb.setRenderBounds(0.0F, w2, 0.5F - w2, 1.0F, 1.0F - w2, 0.5F + w2); + if (inv) { + ApparatusRenderingHelper.drawFaces( + rb, block, block.iconCondenserPart1, false + ); + } else { + rb.renderStandardBlock(block, i, j, k); + } + + rb.setRenderBounds(0.5F - w2, w2, 0.0F, 0.5F + w2, 1.0F - w2, 1.0F); + if (inv) { + ApparatusRenderingHelper.drawFaces( + rb, block, block.iconCondenserPart1, false + ); + } else { + rb.renderStandardBlock(block, i, j, k); + } + + rb.setRenderBounds(0.0F, w2, 0.5F - w2, 1.0F, 1.0F - w2, 0.5F + w2); + if (inv) { + ApparatusRenderingHelper.drawFaces( + rb, block, block.iconCondenserPart1, false + ); + } else { + rb.renderStandardBlock(block, i, j, k); + } + + if (!inv) { + TileCondenser tc = (TileCondenser) w.getTileEntity(i, j, k); + if (tc != null && tc.hasUpgrade((byte) 0)) { + rb.overrideBlockTexture = null; + rb.setRenderBounds(w4, w4, w4, 1.0F - w4, 1.0F - w4, 1.0F - w4); + + rb.renderFaceXNeg(block, i, j, k, block.iconCondenserSpeedUpgrade); + rb.renderFaceXPos(block, i, j, k, block.iconCondenserSpeedUpgrade); + rb.renderFaceZNeg(block, i, j, k, block.iconCondenserSpeedUpgrade); + rb.renderFaceZPos(block, i, j, k, block.iconCondenserSpeedUpgrade); + } + } + } + + rb.overrideBlockTexture = null; + rb.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } +} diff --git a/src/main/java/net/anvilcraft/thaummach/render/tile/TileCondenserRenderer.java b/src/main/java/net/anvilcraft/thaummach/render/tile/TileCondenserRenderer.java new file mode 100644 index 0000000..c5fec16 --- /dev/null +++ b/src/main/java/net/anvilcraft/thaummach/render/tile/TileCondenserRenderer.java @@ -0,0 +1,105 @@ +package net.anvilcraft.thaummach.render.tile; + +import java.awt.Color; + +import dev.tilera.auracore.api.CrystalColors; +import net.anvilcraft.thaummach.tiles.TileCondenser; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import thaumcraft.client.renderers.models.ModelCrystal; + +public class TileCondenserRenderer extends TileEntitySpecialRenderer { + private ModelCrystal model = new ModelCrystal(); + private float bob = 0.0F; + + private void drawDisk(double x, double y, double z, float angle) { + Tessellator tessellator = Tessellator.instance; + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y, (float) z + 0.5F); + GL11.glPushMatrix(); + GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.3F, 0.0F, -0.3F); + GL11.glDepthMask(false); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 1); + Minecraft.getMinecraft().renderEngine.bindTexture( + new ResourceLocation("thaummach", "textures/misc/portal2.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + tessellator.startDrawingQuads(); + tessellator.setBrightness(200); + tessellator.setColorRGBA_F(1.0F, 0.5F, 1.0F, 1.0F); + tessellator.addVertexWithUV(0.0, 0.0, 0.6, 0.0, 1.0); + tessellator.addVertexWithUV(0.6, 0.0, 0.6, 1.0, 1.0); + tessellator.addVertexWithUV(0.6, 0.0, 0.0, 1.0, 0.0); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 1.0); + tessellator.addVertexWithUV(0.6, 0.0, 0.0, 1.0, 1.0); + tessellator.addVertexWithUV(0.6, 0.0, 0.6, 1.0, 0.0); + tessellator.addVertexWithUV(0.0, 0.0, 0.6, 0.0, 0.0); + tessellator.draw(); + GL11.glDisable(3042); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public void + renderEntityAt(TileCondenser condenser, double x, double y, double z, float fq) { + if (condenser.degredation > 0.0F) { + float tbob = this.bob; + if (condenser.hasUpgrade((byte) 1)) { + tbob = 0.0F; + } + + this.bindTexture( + new ResourceLocation("thaumcraft", "textures/models/crystal.png") + ); + + GL11.glEnable(2977); + GL11.glEnable(3042); + GL11.glPushMatrix(); + GL11.glEnable(32826); + GL11.glBlendFunc(770, 771); + Color c = new Color(CrystalColors.getColorForShard(condenser.currentType)); + GL11.glColor4f( + c.getRed() / 220.0f, c.getGreen() / 220.0f, c.getBlue() / 220.0f, 1.0F + ); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(220); + GL11.glTranslatef( + (float) x + 0.5F, (float) y + tbob + 0.95F, (float) z + 0.5F + ); + GL11.glRotatef(condenser.angle, 0.0F, 1.0F, 0.0F); + GL11.glPushMatrix(); + GL11.glScalef(0.15F, 0.45F, 0.15F); + this.model.render(); + GL11.glScalef(1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + GL11.glDisable(32826); + GL11.glPopMatrix(); + GL11.glDisable(3042); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + if (condenser.hasUpgrade((byte) 1)) { + this.drawDisk( + x, + y + 1.1749999523162842 + (double) (this.bob * 6.0F), + z, + 360.0F - condenser.angle + ); + } + } + } + + public void + renderTileEntityAt(TileEntity te, double d, double d1, double d2, float f) { + int count = Minecraft.getMinecraft().thePlayer.ticksExisted; + this.bob = MathHelper.sin((float) count / 10.0F) * 0.05F + 0.05F; + this.renderEntityAt((TileCondenser) te, d, d1, d2, f); + } +} diff --git a/src/main/java/net/anvilcraft/thaummach/render/TileSealRenderer.java b/src/main/java/net/anvilcraft/thaummach/render/tile/TileSealRenderer.java similarity index 99% rename from src/main/java/net/anvilcraft/thaummach/render/TileSealRenderer.java rename to src/main/java/net/anvilcraft/thaummach/render/tile/TileSealRenderer.java index 622eeef..602832c 100644 --- a/src/main/java/net/anvilcraft/thaummach/render/TileSealRenderer.java +++ b/src/main/java/net/anvilcraft/thaummach/render/tile/TileSealRenderer.java @@ -1,4 +1,4 @@ -package net.anvilcraft.thaummach.render; +package net.anvilcraft.thaummach.render.tile; import net.anvilcraft.thaummach.TMBlocks; import net.anvilcraft.thaummach.tiles.TileSeal; diff --git a/src/main/java/net/anvilcraft/thaummach/tiles/TileCondenser.java b/src/main/java/net/anvilcraft/thaummach/tiles/TileCondenser.java new file mode 100644 index 0000000..3c00f2a --- /dev/null +++ b/src/main/java/net/anvilcraft/thaummach/tiles/TileCondenser.java @@ -0,0 +1,621 @@ +package net.anvilcraft.thaummach.tiles; + +import java.util.ArrayList; + +import dev.tilera.auracore.api.AuraNode; +import dev.tilera.auracore.api.HelperLocation; +import dev.tilera.auracore.api.machine.IConnection; +import dev.tilera.auracore.api.machine.IUpgradable; +import dev.tilera.auracore.aura.AuraManager; +import net.anvilcraft.thaummach.GuiID; +import net.anvilcraft.thaummach.ITileGui; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.EnumSkyBlock; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.common.config.ConfigItems; + +public class TileCondenser + extends TileEntity implements ISidedInventory, IUpgradable, IConnection, ITileGui { + public float angle = 0.0F; + public float speed; + public long accTimer; + public float progress; + public float currentVis; + public float currentTaint; + public int currentType = -1; + public short maxVis = 10; + public float degredation; + private ItemStack[] condenserItemStacks = new ItemStack[2]; + private byte[] upgrades = new byte[] { -1, -1 }; + + @Override + public void updateEntity() { + if (!super.worldObj.isBlockIndirectlyGettingPowered( + super.xCoord, super.yCoord, super.zCoord + )) { + if (this.worldObj.isRemote) { + this.angle += this.speed * 5.0F; + if (this.angle > 360.0F) { + this.angle -= 360.0F; + } + + return; + } + + if (this.accTimer < System.currentTimeMillis()) { + this.equalizeWithNeighbours(); + if (this.speed < (this.hasUpgrade((byte) 0) ? 1.25F : 1.0F)) { + this.speed += this.hasUpgrade((byte) 0) ? 0.01F : 5.0E-4F; + if (this.speed > (this.hasUpgrade((byte) 0) ? 1.25F : 1.0F)) { + this.speed = this.hasUpgrade((byte) 0) ? 1.25F : 1.0F; + } + } + + if (this.speed > 0.0F && this.degredation == 0.0F) { + this.speed -= 0.005F; + if (this.speed < 0.0F) { + this.speed = 0.0F; + } + } + + if (!this.hasUpgrade((byte) 3) && this.currentType == 9) { + this.progress = 0.0F; + this.degredation = 0.0F; + } + + float moon + = (float) (3 + Math.abs(super.worldObj.getMoonPhase() - 4)) * 0.2F; + if (this.currentType >= 0) { + this.progress += this.speed * moon; + } + + if (this.progress >= (float) (this.hasUpgrade((byte) 1) ? 20 : 25) + && this.currentVis <= (float) (this.maxVis - 1) + && this.currentTaint <= (float) (this.maxVis - 1) + && this.currentType >= 0) { + int nodeID = AuraManager.getClosestAuraWithinRange( + this.worldObj, this.xCoord, this.yCoord, this.zCoord, 1024 + ); + if (nodeID >= 0) { + AuraNode node = AuraManager.getNode(nodeID); + if (this.currentType != 9) { + if (node.level > 0) { + AuraManager.queueNodeChanges( + nodeID, -1, 0, false, null, 0, 0, 0 + ); + this.progress = 0.0f; + ++this.currentVis; + } else if (this.hasUpgrade((byte) 3) && node.taint > 0) { + AuraManager.queueNodeChanges( + nodeID, 0, 0, -1, false, null, 0, 0, 0 + ); + this.progress = 0.0f; + ++this.currentTaint; + } + } + + this.worldObj.markBlockForUpdate( + this.xCoord, this.yCoord, this.zCoord + ); + super.worldObj.updateLightByType( + EnumSkyBlock.Block, super.xCoord, super.yCoord, super.zCoord + ); + } + } + + boolean flag = false; + if (this.progress < (float) (this.hasUpgrade((byte) 1) ? 20 : 25)) { + if (this.degredation > 0.0F) { + flag = true; + } + + this.degredation -= Math.max(0.25F, this.speed); + if (this.degredation < 0.0F) { + this.degredation = 0.0F; + } + + if (this.degredation > 0.0F && (int) (this.degredation % 3.0F) == 0) { + // TODO: FX + //FXWisp ef = new FXWisp( + // super.worldObj, + // (double + // ) ((float) super.xCoord + 0.5F + // + super.worldObj.rand.nextFloat() + // - super.worldObj.rand.nextFloat()), + // (double + // ) ((float) super.yCoord + 1.5F + // + super.worldObj.rand.nextFloat() + // - super.worldObj.rand.nextFloat()), + // (double + // ) ((float) super.zCoord + 0.5F + // + super.worldObj.rand.nextFloat() + // - super.worldObj.rand.nextFloat()), + // (double) ((float) super.xCoord + 0.5F), + // (double) ((float) super.yCoord + 1.5F), + // (double) ((float) super.zCoord + 0.5F), + // 0.1F, + // this.currentType + //); + //ef.tinkle = true; + //ModLoader.getMinecraftInstance().effectRenderer.addEffect(ef); + } + } + + if (this.degredation < 10.0F && flag) { + super.worldObj.spawnParticle( + "largesmoke", + (double) ((float) super.xCoord + 0.5F), + (double) ((float) super.yCoord + 1.3F), + (double) ((float) super.zCoord + 0.5F), + 0.0, + 0.0, + 0.0 + ); + } + + if (this.degredation <= 0.0F) { + this.worldObj.markBlockForUpdate( + this.xCoord, this.yCoord, this.zCoord + ); + if (flag && this.condenserItemStacks[1] != null + && this.condenserItemStacks[1].getItem() == ConfigItems.itemShard + && this.condenserItemStacks[1].getItemDamage() == 6) { + if (this.condenserItemStacks[1].stackSize < 64) { + ++this.condenserItemStacks[1].stackSize; + } else { + EntityItem entityitem = new EntityItem( + super.worldObj, + (double) ((float) super.xCoord + 0.5F), + (double) ((float) super.yCoord + 1.0F), + (double) ((float) super.zCoord + 0.5F), + new ItemStack(ConfigItems.itemShard, 1, 8) + ); + entityitem.motionY = 0.20000000298023224; + super.worldObj.spawnEntityInWorld(entityitem); + } + } + + if (flag && this.condenserItemStacks[1] == null) { + this.condenserItemStacks[1] + = new ItemStack(ConfigItems.itemShard, 1, 8); + } + + if (this.condenserItemStacks[0] == null + || this.condenserItemStacks[0].getItem() != ConfigItems.itemShard + || this.condenserItemStacks[0].getItemDamage() == 8 + || this.condenserItemStacks[0].stackSize <= 0 + && !this.hasUpgrade((byte) 3)) { + this.currentType = -1; + } else { + this.degredation = 4550.0F; + this.currentType = this.condenserItemStacks[0].getItemDamage(); + --this.condenserItemStacks[0].stackSize; + if (this.condenserItemStacks[0].stackSize == 0) { + this.condenserItemStacks[0] = null; + } + } + } + + this.accTimer = System.currentTimeMillis() + 100L; + } + } + } + + @Override + public GuiID getGuiID() { + return GuiID.CONDENSER; + } + + protected void equalizeWithNeighbours() { + ArrayList neighbours = new ArrayList<>(); + + for (int dir = 0; dir < 6; ++dir) { + // Don't connect on top + if (dir == 1) + continue; + + HelperLocation loc = new HelperLocation(this); + loc.facing = ForgeDirection.VALID_DIRECTIONS[dir]; + + TileEntity te = loc.getConnectableTile(super.worldObj); + if (te != null && te instanceof TileCondenser) { + IConnection ent = (IConnection) te; + neighbours.add(ent); + } + } + + if (neighbours.size() > 0) { + float pVis = this.getPureVis(); + float tVis = this.getTaintedVis(); + + int a; + for (a = 0; a < neighbours.size(); ++a) { + pVis += ((IConnection) neighbours.get(a)).getPureVis(); + } + + for (a = 0; a < neighbours.size(); ++a) { + tVis += ((IConnection) neighbours.get(a)).getTaintedVis(); + } + + pVis /= (float) (neighbours.size() + 1); + tVis /= (float) (neighbours.size() + 1); + + for (a = 0; a < neighbours.size(); ++a) { + ((IConnection) neighbours.get(a)).setPureVis(pVis); + ((IConnection) neighbours.get(a)).setTaintedVis(tVis); + } + + this.setPureVis(pVis); + this.setTaintedVis(tVis); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + NBTTagList nbttaglist = nbttagcompound.getTagList("Items", 10); + this.condenserItemStacks = new ItemStack[this.getSizeInventory()]; + + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound nbttagcompound1 + = (NBTTagCompound) nbttaglist.getCompoundTagAt(i); + byte byte0 = nbttagcompound1.getByte("Slot"); + if (byte0 >= 0 && byte0 < this.condenserItemStacks.length) { + this.condenserItemStacks[byte0] + = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + + this.speed = nbttagcompound.getFloat("speed"); + this.progress = nbttagcompound.getFloat("progress"); + this.currentVis = nbttagcompound.getFloat("currentVis"); + this.currentTaint = nbttagcompound.getFloat("currentTaint"); + this.currentType = nbttagcompound.getShort("currentType"); + this.degredation = nbttagcompound.getFloat("taint"); + this.upgrades = nbttagcompound.getByteArray("upgrades"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + nbttagcompound.setFloat("speed", this.speed); + nbttagcompound.setFloat("progress", this.progress); + nbttagcompound.setFloat("currentVis", this.currentVis); + nbttagcompound.setFloat("currentTaint", this.currentTaint); + nbttagcompound.setFloat("taint", this.degredation); + nbttagcompound.setShort("currentType", (short) this.currentType); + nbttagcompound.setByteArray("upgrades", this.upgrades); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.condenserItemStacks.length; ++i) { + if (this.condenserItemStacks[i] != null) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + this.condenserItemStacks[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + nbttagcompound.setTag("Items", nbttaglist); + } + + @Override + public boolean isVisSource() { + return true; + } + + @Override + public boolean isVisConduit() { + return false; + } + + @Override + public float getPureVis() { + return this.currentVis; + } + + @Override + public void setPureVis(float amount) { + this.currentVis = amount; + } + + @Override + public float getTaintedVis() { + return this.currentTaint; + } + + @Override + public float getMaxVis() { + return (float) this.maxVis; + } + + @Override + public void setTaintedVis(float amount) { + this.currentTaint = amount; + } + + @Override + public float[] subtractVis(float amount) { + float pureAmount = amount / 2.0F; + float taintAmount = amount / 2.0F; + float[] result = new float[] { 0.0F, 0.0F }; + if (amount < 0.001F) { + return result; + } else { + if (this.currentVis < pureAmount) { + pureAmount = this.currentVis; + } + + if (this.currentTaint < taintAmount) { + taintAmount = this.currentTaint; + } + + if (pureAmount < amount / 2.0F && taintAmount == amount / 2.0F) { + taintAmount = Math.min(amount - pureAmount, this.currentTaint); + } else if (taintAmount < amount / 2.0F && pureAmount == amount / 2.0F) { + pureAmount = Math.min(amount - taintAmount, this.currentVis); + } + + this.currentVis -= pureAmount; + this.currentTaint -= taintAmount; + result[0] = pureAmount; + result[1] = taintAmount; + return result; + } + } + + @Override + public ItemStack decrStackSize(int i, int j) { + if (this.condenserItemStacks[i] != null) { + ItemStack itemstack1; + if (this.condenserItemStacks[i].stackSize <= j) { + itemstack1 = this.condenserItemStacks[i]; + this.condenserItemStacks[i] = null; + return itemstack1; + } else { + itemstack1 = this.condenserItemStacks[i].splitStack(j); + if (this.condenserItemStacks[i].stackSize == 0) { + this.condenserItemStacks[i] = null; + } + + return itemstack1; + } + } else { + return null; + } + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + this.condenserItemStacks[i] = itemstack; + if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { + itemstack.stackSize = this.getInventoryStackLimit(); + } + } + + @Override + public String getInventoryName() { + return "Vis Condenser"; + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + if (super.worldObj.getTileEntity(super.xCoord, super.yCoord, super.zCoord) + != this) { + return false; + } else { + return entityplayer.getDistanceSq( + (double) super.xCoord + 0.5, + (double) super.yCoord + 0.5, + (double) super.zCoord + 0.5 + ) + <= 64.0; + } + } + + @Override + public int getSizeInventory() { + return this.condenserItemStacks.length; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + switch (side) { + // Bottom + case 0: + return new int[] { 1 }; + + default: + return new int[] { 0 }; + } + } + + @Override + public ItemStack getStackInSlot(int i) { + return this.condenserItemStacks[i]; + } + + @Override + public boolean canAcceptUpgrade(byte upgrade) { + if (upgrade != 0 && upgrade != 1 && upgrade != 3) { + return false; + } else { + return !this.hasUpgrade(upgrade); + } + } + + @Override + public int getUpgradeLimit() { + return 2; + } + + @Override + public byte[] getUpgrades() { + return this.upgrades; + } + + @Override + public boolean hasUpgrade(byte upgrade) { + if (this.upgrades.length < 1) { + return false; + } else { + for (int a = 0; a < this.getUpgradeLimit(); ++a) { + if (this.upgrades[a] == upgrade) { + return true; + } + } + + return false; + } + } + + @Override + public boolean setUpgrade(byte upgrade) { + for (int a = 0; a < this.getUpgradeLimit(); ++a) { + if (this.upgrades[a] < 0 && this.canAcceptUpgrade(upgrade)) { + this.upgrades[a] = upgrade; + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + return true; + } + } + + return false; + } + + @Override + public boolean clearUpgrade(int index) { + if (this.upgrades[index] >= 0) { + this.upgrades[index] = -1; + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + return true; + } else { + return false; + } + } + + @Override + public ItemStack getStackInSlotOnClosing(int var1) { + if (this.condenserItemStacks[var1] != null) { + ItemStack var2 = this.condenserItemStacks[var1]; + this.condenserItemStacks[var1] = null; + return var2; + } else { + return null; + } + } + + @Override + public int getVisSuction(HelperLocation loc) { + return 0; + } + + @Override + public void setVisSuction(int suction) {} + + @Override + public int getTaintSuction(HelperLocation loc) { + return 0; + } + + @Override + public void setTaintSuction(int suction) {} + + @Override + public void setSuction(int suction) {} + + @Override + public int getSuction(HelperLocation loc) { + return 0; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + // output slot + if (slot == 1) + return false; + + return stack.getItem() == ConfigItems.itemShard && stack.getItemDamage() != 8; + } + + @Override + public boolean getConnectable(ForgeDirection side) { + return side != ForgeDirection.UP; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) { + ItemStack curStack = this.condenserItemStacks[0]; + if (curStack != null + && (!curStack.isItemEqual(stack) + || curStack.stackSize + stack.stackSize > curStack.getMaxStackSize())) + return false; + + return this.isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) { + return slot == 1; + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbt = new NBTTagCompound(); + + nbt.setFloat("speed", this.speed); + nbt.setFloat("progress", this.progress); + nbt.setFloat("currentVis", this.currentVis); + nbt.setFloat("currentTaint", this.currentTaint); + nbt.setInteger("currentType", this.currentType); + nbt.setShort("maxVis", this.maxVis); + nbt.setFloat("degredation", this.degredation); + nbt.setByteArray("upgrades", this.upgrades); + + return new S35PacketUpdateTileEntity( + this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt + ); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound nbt = pkt.func_148857_g(); + + this.speed = nbt.getFloat("speed"); + this.progress = nbt.getFloat("progress"); + this.currentVis = nbt.getFloat("currentVis"); + this.currentTaint = nbt.getFloat("currentTaint"); + this.currentType = nbt.getInteger("currentType"); + this.maxVis = nbt.getShort("maxVis"); + this.degredation = nbt.getFloat("degredation"); + this.upgrades = nbt.getByteArray("upgrades"); + + this.worldObj.markBlockRangeForRenderUpdate( + this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord + ); + } +} diff --git a/src/main/resources/assets/thaummach/textures/blocks/condenser_speed_upgrade.png b/src/main/resources/assets/thaummach/textures/blocks/condenser_speed_upgrade.png new file mode 100644 index 0000000..77f6631 Binary files /dev/null and b/src/main/resources/assets/thaummach/textures/blocks/condenser_speed_upgrade.png differ diff --git a/src/main/resources/assets/thaummach/textures/blocks/condenser_speed_upgrade.png.mcmeta b/src/main/resources/assets/thaummach/textures/blocks/condenser_speed_upgrade.png.mcmeta new file mode 100644 index 0000000..6bc42e6 --- /dev/null +++ b/src/main/resources/assets/thaummach/textures/blocks/condenser_speed_upgrade.png.mcmeta @@ -0,0 +1,23 @@ +{ + "animation": { + "width": 1, + "height": 14, + "frametime": 1, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13 + ] + } +} diff --git a/src/main/resources/assets/thaummach/textures/guis/condenser.png b/src/main/resources/assets/thaummach/textures/guis/condenser.png new file mode 100644 index 0000000..2c8cfa3 Binary files /dev/null and b/src/main/resources/assets/thaummach/textures/guis/condenser.png differ