From c9c4544429f1fdcd644b1b99ff14506902847a06 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Thu, 25 May 2023 20:45:13 +0200 Subject: [PATCH] feat: implement condenser --- .../net/anvilcraft/thaummach/ClientProxy.java | 31 +- .../net/anvilcraft/thaummach/CommonProxy.java | 14 +- .../java/net/anvilcraft/thaummach/GuiID.java | 1 + .../thaummach/blocks/BlockApparatusWood.java | 147 +++-- .../container/ContainerCondenser.java | 69 ++ .../thaummach/gui/GuiCondenser.java | 54 ++ .../thaummach/items/ItemUpgrade.java | 1 - .../wood/CondenserApparatusRenderer.java | 120 ++++ .../render/tile/TileCondenserRenderer.java | 105 +++ .../render/{ => tile}/TileSealRenderer.java | 2 +- .../thaummach/tiles/TileCondenser.java | 621 ++++++++++++++++++ .../blocks/condenser_speed_upgrade.png | Bin 0 -> 1248 bytes .../blocks/condenser_speed_upgrade.png.mcmeta | 23 + .../thaummach/textures/guis/condenser.png | Bin 0 -> 8001 bytes 14 files changed, 1124 insertions(+), 64 deletions(-) create mode 100644 src/main/java/net/anvilcraft/thaummach/container/ContainerCondenser.java create mode 100644 src/main/java/net/anvilcraft/thaummach/gui/GuiCondenser.java create mode 100644 src/main/java/net/anvilcraft/thaummach/render/apparatus/apparati/wood/CondenserApparatusRenderer.java create mode 100644 src/main/java/net/anvilcraft/thaummach/render/tile/TileCondenserRenderer.java rename src/main/java/net/anvilcraft/thaummach/render/{ => tile}/TileSealRenderer.java (99%) create mode 100644 src/main/java/net/anvilcraft/thaummach/tiles/TileCondenser.java create mode 100644 src/main/resources/assets/thaummach/textures/blocks/condenser_speed_upgrade.png create mode 100644 src/main/resources/assets/thaummach/textures/blocks/condenser_speed_upgrade.png.mcmeta create mode 100644 src/main/resources/assets/thaummach/textures/guis/condenser.png 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 0000000000000000000000000000000000000000..77f6631fcf63c358883cbed8fad09aed318bb7c6 GIT binary patch literal 1248 zcmV<61Rwi}P)WdKcYZXh!-AWC6wATls9G9WQDIx{&sFf<@5FfuSOITs_%00007bV*G` z2iyT34HG2>y?Jf`000SaNLh0L03N{r03N{s!)a7g00004XF*Lt006O%3;baP000Cx zNklYxN7{~vylhv${yiKH zqq(^mf*^q7IApU~BoYav(`k&4kN2^1Gc3ua4iq^Y4unD>jEya;nXDnq$#3xae2+KoUakd6S6eq?u{8)*0Ye8n)QtH0 z0%Gw6yx9M;U5GsW5o-x28XI@RV$P`cCy_g-msfSWpvcOn5D11ayD)?2QcAVAG-lD> z=`?oG-nNG|HHpQg81i|WYTxB{U~f;4u>?-+3b3gRl!p&Tar<^(N8=ey++ai<>JNb zvd1&PhVKd+eMKIuu0Fv0{2w@f{+ms8O8lK2U<8y7 zcMsxgDaM2NCLXl4JF%~qctF}FX?Sqy(ha%4{{Wj0l=5Io;la6cU+eM!9#2082V2-x z3$9(8Q|(UYem3DqYg(WIN-!8?V_;s17ySOxcwt2;13jQzxpJY(KpEKYg2{9cDN#WF zd2xcV!v=FR zZ~#L?t?a55SFaX%uybcWBA02%U@3=TDN0X5AyqekS65!d_i(|)6>CaG>A`yJ{$uY(QPQ!zV zyAwdk42480=oRFFn5$zfkQ5$BQn3Y+)XV}Ald*#|gUHRBeq}vzhy5+pURX~Q#f+hY zhF|Y}i*S^$7%#vGDB}~8RR)Ty)sC}YoMsT^5KGzBOx_a3Y$#wnL%~ZfM3HJjwa9~K ztkURcK;gmLO~sdMfd`V5HFmJ_*R6l{7rIOK7rg&!f1x1~o`Y}t=Zf(HjDYgf*mPN- zJc=YR^QSV!*;=6d?~N(~N==A(Ks+e-KOi2wnW{w|P`p6#0_nf$732Y}C(?Q%sY;^# zM%r&Akv2r}*HQF66MfHA)&cRL3i=!3-hi4(AvEd$0000< KMNUMnLSTX@C^-xO literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..2c8cfa3c7bec8a6eb401ee633ba363bd979d9e69 GIT binary patch literal 8001 zcmeHsWl)^Kw(ZB@5Q>#q_s3WLRoAN3Yp=bldUtn(hMN360vZAU0PZO&$i4;ujJsb9 z01xMGFmf(_cQ@d=Dyqui{>H>2q2pmEZC1LQ!go~AcL4z6j=vwqeGa97yGbl-DOD)| z_zoewF~bG`hEYXXDQ(aB{Y*kfqYbxSG~z(nKoM%GPqHv8{lkKG&s0pv&-5)$GEgA6 z4akg#ux7Fe+Vn?>*-!9ljmK)Fr527d3$F7$d0diuq{N|u7kfl7i?i@B>UaTaryu`# zZradbe{FH`w5*~UYH3q8Rpott>pxTln>slDGxY*}=mQs9Y6!Jk=#wYv>>I(HAcfQM zIr|b>Y;1lwsDUB4!j_IKywAVPHoJ9t`9gi8!Mox!dQc1g`$>@6{Svwo5f#Xow~1K7@BB`I`WfAsO4zkO4?r`-7pWLNgfny#h#wksCiO#BE~^-}T` zIEIs`%heBrYztSO|7185WOrPd2PF>ij{SL`i_9!`cJ~J(vqFXQQ*Mi}XD_l_!ohyV zbj1&+FA%8xm$DWb-2mhk0jczc>(V*Az@HH0^IzK;oi#~Pi7JSnk)SxO2WkgV`MU}rD&IoVpRX}ZU=4J$4reVX+8Otor+uz>76MCFF^K{JjSxm{(pe=!@o$A~y6add_U$K$CVM*?buwQuXR~4{DGZW^bL`_v1zT#Ob?wDk2o~ z18Kh{m#puBhwMsDY^DfYEzBZRBzF91rBW%Fn}4)Y;1VCo6ir1Mpv_gHf6-nn6_=&M zuq2^a>@<|XstqyXup`TaTefpoGbDoyWsyy6aYBpHj5=%D`j{FW6hulS56pi`Bdfk9 z&ByfXzXuZDu?6(QV1WBfqF$dNPv97SZX5 z+O>&b{=~`Gg&G*F=sX}9DaTCVcnW~-3dP1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