From 733da7396fbb6951db5053347a0e7b7d55bc2108 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Mon, 21 Jul 2014 23:32:00 +0100 Subject: [PATCH 1/8] Add LiquidChlorine meta file --- .../mekanism/textures/blocks/LiquidChlorine.png.mcmeta | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/main/resources/assets/mekanism/textures/blocks/LiquidChlorine.png.mcmeta diff --git a/src/main/resources/assets/mekanism/textures/blocks/LiquidChlorine.png.mcmeta b/src/main/resources/assets/mekanism/textures/blocks/LiquidChlorine.png.mcmeta new file mode 100644 index 000000000..4b721e09a --- /dev/null +++ b/src/main/resources/assets/mekanism/textures/blocks/LiquidChlorine.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} From e35a673c8b4a4b7820d2d891c45513458cf45c37 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Tue, 22 Jul 2014 03:39:36 +0100 Subject: [PATCH 2/8] Get lasers rendering. I've yet to proxy it off, so THIS WILL CRASH DEDICATED SERVERS --- .../mekanism/api/lasers/LaserManager.java | 12 ++- .../mekanism/client/entity/EntityLaser.java | 91 ++++++++++++++++++ .../assets/mekanism/particles/laser.png | Bin 0 -> 156 bytes 3 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 src/main/java/mekanism/client/entity/EntityLaser.java create mode 100644 src/main/resources/assets/mekanism/particles/laser.png diff --git a/src/main/java/mekanism/api/lasers/LaserManager.java b/src/main/java/mekanism/api/lasers/LaserManager.java index 1bfd1d134..08cfd52d2 100644 --- a/src/main/java/mekanism/api/lasers/LaserManager.java +++ b/src/main/java/mekanism/api/lasers/LaserManager.java @@ -1,13 +1,17 @@ package mekanism.api.lasers; import mekanism.api.Coord4D; +import mekanism.client.entity.EntityLaser; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityNoteFX; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.client.FMLClientHandler; public class LaserManager { @@ -35,16 +39,16 @@ public class LaserManager } } - renderLaser(from, new Coord4D(mop.blockX, mop.blockY, mop.blockZ)); + renderLaser(world, from, new Coord4D(mop.blockX, mop.blockY, mop.blockZ), direction); } else { - renderLaser(from, to); + renderLaser(world, from, to, direction); } } - public static void renderLaser(Coord4D from, Coord4D to) + public static void renderLaser(World world, Coord4D from, Coord4D to, ForgeDirection direction) { - //TODO Particle effects + Minecraft.getMinecraft().effectRenderer.addEffect(new EntityLaser(world, from, to, direction)); } } diff --git a/src/main/java/mekanism/client/entity/EntityLaser.java b/src/main/java/mekanism/client/entity/EntityLaser.java new file mode 100644 index 000000000..61372dbce --- /dev/null +++ b/src/main/java/mekanism/client/entity/EntityLaser.java @@ -0,0 +1,91 @@ +package mekanism.client.entity; + +import mekanism.api.Coord4D; +import mekanism.api.Pos3D; +import mekanism.client.render.MekanismRenderer; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.client.FMLClientHandler; +import org.lwjgl.opengl.GL11; + +public class EntityLaser extends EntityFX +{ + double length; + ForgeDirection direction; + + public EntityLaser(World world, Coord4D start, Coord4D end, ForgeDirection direction) + { + super(world, (start.xCoord + end.xCoord)/2D + 0.5D, (start.yCoord + end.yCoord)/2D + 0.5D, (start.zCoord+end.zCoord)/2D + 0.5D); + particleMaxAge = 1; + particleRed = 1; + particleGreen = 0; + particleBlue = 0; + particleAlpha = 0.3F; + particleScale = 0.1F; + length = new Pos3D(end).distance(new Pos3D(start)); + this.direction = direction; + } + + @Override + public void renderParticle(Tessellator tessellator, float partialTick, float rotationX, float rotationXZ, float rotationZ, float rotationYZ, float rotationXY) + { + tessellator.draw(); + + GL11.glPushMatrix(); + Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("mekanism", "particles/laser.png")); + + float newX = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); + float newY = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY); + float newZ = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ); + + GL11.glTranslatef(newX, newY, newZ); + + switch(direction) + { + case UP: + case DOWN: + default: + break; + case WEST: + case EAST: + GL11.glRotated(90, 0, 0, 1); + break; + case NORTH: + case SOUTH: + GL11.glRotated(90, 1, 0, 0); + break; + } + GL11.glRotated(45, 0, 1, 0); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); + tessellator.addVertexWithUV(-particleScale, -length/2, 0, 0, 0); + tessellator.addVertexWithUV(-particleScale, length/2, 0, 0, 1); + tessellator.addVertexWithUV(particleScale, length/2, 0, 1, 1); + tessellator.addVertexWithUV(particleScale, -length/2, 0, 1, 0); + tessellator.draw(); + + GL11.glRotated(90, 0, 1, 0); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); + tessellator.addVertexWithUV(-particleScale, -length/2, 0, 0, 0); + tessellator.addVertexWithUV(-particleScale, length/2, 0, 0, 1); + tessellator.addVertexWithUV(particleScale, length/2, 0, 1, 1); + tessellator.addVertexWithUV(particleScale, -length/2, 0, 1, 0); + tessellator.draw(); + + GL11.glPopMatrix(); + + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + tessellator.startDrawingQuads(); + } + + public int getFXLayer() + { + return 1; + } +} diff --git a/src/main/resources/assets/mekanism/particles/laser.png b/src/main/resources/assets/mekanism/particles/laser.png new file mode 100644 index 0000000000000000000000000000000000000000..d2ddfa72116b7db2d1cdfb99e813d8bf9a681f6c GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#9=jNWndG^nR+2y=$r9Iy66gHf+|;}h2Ir#G#FEq$h4Rdj3> Date: Tue, 22 Jul 2014 17:41:34 +0100 Subject: [PATCH 3/8] Fix transmitter render pass to stop things occluding incorrectly, make lasers get stronger and weaker as they start and stop --- src/main/java/mekanism/client/entity/EntityLaser.java | 5 ++++- src/main/java/mekanism/common/multipart/PartSidedPipe.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/mekanism/client/entity/EntityLaser.java b/src/main/java/mekanism/client/entity/EntityLaser.java index 61372dbce..939fc6c75 100644 --- a/src/main/java/mekanism/client/entity/EntityLaser.java +++ b/src/main/java/mekanism/client/entity/EntityLaser.java @@ -11,8 +11,11 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; +@SideOnly(Side.CLIENT) public class EntityLaser extends EntityFX { double length; @@ -21,7 +24,7 @@ public class EntityLaser extends EntityFX public EntityLaser(World world, Coord4D start, Coord4D end, ForgeDirection direction) { super(world, (start.xCoord + end.xCoord)/2D + 0.5D, (start.yCoord + end.yCoord)/2D + 0.5D, (start.zCoord+end.zCoord)/2D + 0.5D); - particleMaxAge = 1; + particleMaxAge = 5; particleRed = 1; particleGreen = 0; particleBlue = 0; diff --git a/src/main/java/mekanism/common/multipart/PartSidedPipe.java b/src/main/java/mekanism/common/multipart/PartSidedPipe.java index 07f06d11a..a4227926e 100644 --- a/src/main/java/mekanism/common/multipart/PartSidedPipe.java +++ b/src/main/java/mekanism/common/multipart/PartSidedPipe.java @@ -312,7 +312,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, @SideOnly(Side.CLIENT) public boolean renderStatic(Vector3 pos, int pass) { - if(pass == 1) + if(pass == 0) { RenderPartTransmitter.getInstance().renderStatic(this); return true; From dd421f73083f13d77f1b1c2eb97e2bd1da14b748 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Tue, 22 Jul 2014 18:03:34 +0100 Subject: [PATCH 4/8] This should stop the servercrashing issue --- src/main/java/mekanism/api/lasers/LaserManager.java | 5 +++-- src/main/java/mekanism/client/ClientProxy.java | 8 ++++++++ src/main/java/mekanism/common/CommonProxy.java | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/mekanism/api/lasers/LaserManager.java b/src/main/java/mekanism/api/lasers/LaserManager.java index 08cfd52d2..6e92d91ba 100644 --- a/src/main/java/mekanism/api/lasers/LaserManager.java +++ b/src/main/java/mekanism/api/lasers/LaserManager.java @@ -2,6 +2,7 @@ package mekanism.api.lasers; import mekanism.api.Coord4D; import mekanism.client.entity.EntityLaser; +import mekanism.common.Mekanism; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityNoteFX; @@ -39,11 +40,11 @@ public class LaserManager } } - renderLaser(world, from, new Coord4D(mop.blockX, mop.blockY, mop.blockZ), direction); + Mekanism.proxy.renderLaser(world, from, new Coord4D(mop.blockX, mop.blockY, mop.blockZ), direction); } else { - renderLaser(world, from, to, direction); + Mekanism.proxy.renderLaser(world, from, to, direction); } } diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 38d0b44e6..79f20f899 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -4,6 +4,7 @@ import java.io.File; import java.util.HashMap; import mekanism.api.Coord4D; +import mekanism.client.entity.EntityLaser; import mekanism.client.gui.GuiChemicalCrystallizer; import mekanism.client.gui.GuiChemicalDissolutionChamber; import mekanism.client.gui.GuiChemicalInfuser; @@ -147,6 +148,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -583,4 +585,10 @@ public class ClientProxy extends CommonProxy return Minecraft.getMinecraft().thePlayer; } } + + @Override + public void renderLaser(World world, Coord4D from, Coord4D to, ForgeDirection direction) + { + Minecraft.getMinecraft().effectRenderer.addEffect(new EntityLaser(world, from, to, direction)); + } } diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index 68f701f58..e4dce9f06 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -2,6 +2,7 @@ package mekanism.common; import java.io.File; +import mekanism.api.Coord4D; import mekanism.api.MekanismAPI; import mekanism.common.EnergyDisplay.EnergyType; import mekanism.common.entity.EntityRobit; @@ -85,6 +86,7 @@ import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.registry.GameRegistry; @@ -471,4 +473,6 @@ public class CommonProxy { return context.getServerHandler().playerEntity; } + + public void renderLaser(World world, Coord4D from, Coord4D to, ForgeDirection direction) {} } From 327389a88c9228493ac5ccbcac8fd7a45a144855 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Tue, 22 Jul 2014 21:11:43 +0100 Subject: [PATCH 5/8] Get Lasers kind of working vs. dediservers --- .../mekanism/api/lasers/LaserManager.java | 10 --- .../java/mekanism/client/ClientProxy.java | 6 ++ .../java/mekanism/common/CommonProxy.java | 13 +++- .../java/mekanism/common/PacketHandler.java | 3 + .../common/network/PacketLaserFire.java | 71 +++++++++++++++++++ 5 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 src/main/java/mekanism/common/network/PacketLaserFire.java diff --git a/src/main/java/mekanism/api/lasers/LaserManager.java b/src/main/java/mekanism/api/lasers/LaserManager.java index 6e92d91ba..d69652cee 100644 --- a/src/main/java/mekanism/api/lasers/LaserManager.java +++ b/src/main/java/mekanism/api/lasers/LaserManager.java @@ -1,18 +1,13 @@ package mekanism.api.lasers; import mekanism.api.Coord4D; -import mekanism.client.entity.EntityLaser; import mekanism.common.Mekanism; -import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.EntityNoteFX; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; -import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.client.FMLClientHandler; public class LaserManager { @@ -47,9 +42,4 @@ public class LaserManager Mekanism.proxy.renderLaser(world, from, to, direction); } } - - public static void renderLaser(World world, Coord4D from, Coord4D to, ForgeDirection direction) - { - Minecraft.getMinecraft().effectRenderer.addEffect(new EntityLaser(world, from, to, direction)); - } } diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 79f20f899..ce61faf8e 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -591,4 +591,10 @@ public class ClientProxy extends CommonProxy { Minecraft.getMinecraft().effectRenderer.addEffect(new EntityLaser(world, from, to, direction)); } + + @Override + public boolean isClientSide() + { + return true; + } } diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index e4dce9f06..d5cb09961 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -38,6 +38,7 @@ import mekanism.common.inventory.container.ContainerSalinationController; import mekanism.common.inventory.container.ContainerSeismicVibrator; import mekanism.common.inventory.container.ContainerTeleporter; import mekanism.common.inventory.container.ContainerUpgradeManagement; +import mekanism.common.network.PacketLaserFire.LaserFireMessage; import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.tile.TileEntityAdvancedFactory; import mekanism.common.tile.TileEntityBin; @@ -145,7 +146,7 @@ public class CommonProxy /** * Registers a client-side sound, assigned to a TileEntity. - * @param tile - TileEntity who is registering the sound + * @param tileEntity - TileEntity who is registering the sound */ public void registerSound(TileEntity tileEntity) {} @@ -474,5 +475,13 @@ public class CommonProxy return context.getServerHandler().playerEntity; } - public void renderLaser(World world, Coord4D from, Coord4D to, ForgeDirection direction) {} + public void renderLaser(World world, Coord4D from, Coord4D to, ForgeDirection direction) + { + Mekanism.packetHandler.sendToAllAround(new LaserFireMessage(from, to, direction), from.getTargetPoint(50D)); + } + + public boolean isClientSide() + { + return false; + } } diff --git a/src/main/java/mekanism/common/PacketHandler.java b/src/main/java/mekanism/common/PacketHandler.java index b24281cff..d7d1ddb91 100644 --- a/src/main/java/mekanism/common/PacketHandler.java +++ b/src/main/java/mekanism/common/PacketHandler.java @@ -33,6 +33,8 @@ import mekanism.common.network.PacketJetpackData; import mekanism.common.network.PacketJetpackData.JetpackDataMessage; import mekanism.common.network.PacketKey; import mekanism.common.network.PacketKey.KeyMessage; +import mekanism.common.network.PacketLaserFire; +import mekanism.common.network.PacketLaserFire.LaserFireMessage; import mekanism.common.network.PacketLogisticalSorterGui; import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage; import mekanism.common.network.PacketNewFilter; @@ -118,6 +120,7 @@ public class PacketHandler netHandler.registerMessage(PacketPortableTankState.class, PortableTankStateMessage.class, 25, Side.SERVER); netHandler.registerMessage(PacketContainerEditMode.class, ContainerEditModeMessage.class, 26, Side.SERVER); netHandler.registerMessage(PacketFlamethrowerActive.class, FlamethrowerActiveMessage.class, 27, Side.SERVER); + netHandler.registerMessage(PacketLaserFire.class, LaserFireMessage.class, 28, Side.CLIENT); } /** diff --git a/src/main/java/mekanism/common/network/PacketLaserFire.java b/src/main/java/mekanism/common/network/PacketLaserFire.java new file mode 100644 index 000000000..ad0afeecb --- /dev/null +++ b/src/main/java/mekanism/common/network/PacketLaserFire.java @@ -0,0 +1,71 @@ +package mekanism.common.network; + +import mekanism.api.Coord4D; +import mekanism.common.IRedstoneControl.RedstoneControl; +import mekanism.common.Mekanism; +import mekanism.common.PacketHandler; +import mekanism.common.network.PacketLaserFire.LaserFireMessage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; + +import io.netty.buffer.ByteBuf; + +public class PacketLaserFire implements IMessageHandler +{ + @Override + public IMessage onMessage(LaserFireMessage message, MessageContext context) + { + EntityPlayer player = PacketHandler.getPlayer(context); + + if(Mekanism.proxy.isClientSide()) + { + Mekanism.proxy.renderLaser(player.worldObj, message.from, message.to, message.direction); + } + + return null; + } + + public static class LaserFireMessage implements IMessage + { + public Coord4D from; + public Coord4D to; + public ForgeDirection direction; + + public LaserFireMessage() {} + + public LaserFireMessage(Coord4D from, Coord4D to, ForgeDirection direction) + { + this.from = from; + this.to = to; + this.direction = direction; + } + + @Override + public void toBytes(ByteBuf dataStream) + { + dataStream.writeInt(from.xCoord); + dataStream.writeInt(from.yCoord); + dataStream.writeInt(from.zCoord); + dataStream.writeInt(from.dimensionId); + + dataStream.writeInt(to.xCoord); + dataStream.writeInt(to.yCoord); + dataStream.writeInt(to.zCoord); + dataStream.writeInt(to.dimensionId); + + dataStream.writeInt(direction.ordinal()); + } + + @Override + public void fromBytes(ByteBuf dataStream) + { + from = Coord4D.read(dataStream); + to = Coord4D.read(dataStream); + direction = ForgeDirection.getOrientation(dataStream.readInt()); + } + } +} From c66676dd55f4ffad8e3f221e64e1491390b398fd Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Tue, 22 Jul 2014 21:13:01 +0100 Subject: [PATCH 6/8] Fix some Server-side packets being sent by the client --- src/main/java/mekanism/common/tile/TileEntityBasicBlock.java | 2 +- src/main/java/mekanism/common/tile/TileEntityEnergyCube.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java b/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java index 7cd71e50a..882b84736 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java @@ -182,7 +182,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench facing = direction; } - if(facing != clientFacing) + if(!(facing == clientFacing || worldObj.isRemote)) { Mekanism.packetHandler.sendToDimension(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), worldObj.provider.dimensionId); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java index 86e921166..2fb1fd9b1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java @@ -65,7 +65,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe int newScale = getScaledEnergyLevel(20); - if(newScale != prevScale) + if(!(newScale == prevScale || worldObj.isRemote)) { Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); } From 775ba684822c44faaf889e57482967c8a8fde2d4 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Tue, 22 Jul 2014 22:34:19 +0100 Subject: [PATCH 7/8] Tweaking of lasers for packet-efficiency --- .../mekanism/api/lasers/LaserManager.java | 11 +++ .../java/mekanism/client/ClientProxy.java | 6 -- .../mekanism/client/entity/EntityLaser.java | 5 +- .../java/mekanism/common/CommonProxy.java | 11 +-- .../java/mekanism/common/ITileNetwork.java | 3 - .../java/mekanism/common/PacketHandler.java | 3 - .../common/network/PacketLaserFire.java | 71 ------------------- .../network/PacketTransmitterUpdate.java | 1 + .../mekanism/common/tile/TileEntityLaser.java | 52 +++++++++++++- 9 files changed, 66 insertions(+), 97 deletions(-) delete mode 100644 src/main/java/mekanism/common/network/PacketLaserFire.java diff --git a/src/main/java/mekanism/api/lasers/LaserManager.java b/src/main/java/mekanism/api/lasers/LaserManager.java index d69652cee..1c0f5eaf6 100644 --- a/src/main/java/mekanism/api/lasers/LaserManager.java +++ b/src/main/java/mekanism/api/lasers/LaserManager.java @@ -34,7 +34,17 @@ public class LaserManager ((ILaserReceptor)tile).receiveLaserEnergy(energy, ForgeDirection.getOrientation(mop.sideHit)); } } + } + } + public static void fireLaserClient(Coord4D from, ForgeDirection direction, World world) + { + Coord4D rangeFrom = from.getFromSide(direction, 1); + Coord4D to = from.getFromSide(direction, range); + MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord)); + + if(mop != null) + { Mekanism.proxy.renderLaser(world, from, new Coord4D(mop.blockX, mop.blockY, mop.blockZ), direction); } else @@ -42,4 +52,5 @@ public class LaserManager Mekanism.proxy.renderLaser(world, from, to, direction); } } + } diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index ce61faf8e..79f20f899 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -591,10 +591,4 @@ public class ClientProxy extends CommonProxy { Minecraft.getMinecraft().effectRenderer.addEffect(new EntityLaser(world, from, to, direction)); } - - @Override - public boolean isClientSide() - { - return true; - } } diff --git a/src/main/java/mekanism/client/entity/EntityLaser.java b/src/main/java/mekanism/client/entity/EntityLaser.java index 939fc6c75..5b1cd41b3 100644 --- a/src/main/java/mekanism/client/entity/EntityLaser.java +++ b/src/main/java/mekanism/client/entity/EntityLaser.java @@ -28,7 +28,7 @@ public class EntityLaser extends EntityFX particleRed = 1; particleGreen = 0; particleBlue = 0; - particleAlpha = 0.3F; + particleAlpha = 0.1F; particleScale = 0.1F; length = new Pos3D(end).distance(new Pos3D(start)); this.direction = direction; @@ -40,6 +40,8 @@ public class EntityLaser extends EntityFX tessellator.draw(); GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_POLYGON_BIT + GL11.GL_ENABLE_BIT); + GL11.glDisable(GL11.GL_CULL_FACE); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("mekanism", "particles/laser.png")); float newX = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); @@ -81,6 +83,7 @@ public class EntityLaser extends EntityFX tessellator.addVertexWithUV(particleScale, -length/2, 0, 1, 0); tessellator.draw(); + GL11.glPopAttrib(); GL11.glPopMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index d5cb09961..dd2ce8bc3 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -38,7 +38,6 @@ import mekanism.common.inventory.container.ContainerSalinationController; import mekanism.common.inventory.container.ContainerSeismicVibrator; import mekanism.common.inventory.container.ContainerTeleporter; import mekanism.common.inventory.container.ContainerUpgradeManagement; -import mekanism.common.network.PacketLaserFire.LaserFireMessage; import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.tile.TileEntityAdvancedFactory; import mekanism.common.tile.TileEntityBin; @@ -475,13 +474,5 @@ public class CommonProxy return context.getServerHandler().playerEntity; } - public void renderLaser(World world, Coord4D from, Coord4D to, ForgeDirection direction) - { - Mekanism.packetHandler.sendToAllAround(new LaserFireMessage(from, to, direction), from.getTargetPoint(50D)); - } - - public boolean isClientSide() - { - return false; - } + public void renderLaser(World world, Coord4D from, Coord4D to, ForgeDirection direction) {} } diff --git a/src/main/java/mekanism/common/ITileNetwork.java b/src/main/java/mekanism/common/ITileNetwork.java index 758c497f0..95679654e 100644 --- a/src/main/java/mekanism/common/ITileNetwork.java +++ b/src/main/java/mekanism/common/ITileNetwork.java @@ -13,9 +13,6 @@ public interface ITileNetwork { /** * Receive and manage a packet's data. - * @param network - * @param packet - * @param player * @param dataStream */ public void handlePacketData(ByteBuf dataStream) throws Exception; diff --git a/src/main/java/mekanism/common/PacketHandler.java b/src/main/java/mekanism/common/PacketHandler.java index d7d1ddb91..b24281cff 100644 --- a/src/main/java/mekanism/common/PacketHandler.java +++ b/src/main/java/mekanism/common/PacketHandler.java @@ -33,8 +33,6 @@ import mekanism.common.network.PacketJetpackData; import mekanism.common.network.PacketJetpackData.JetpackDataMessage; import mekanism.common.network.PacketKey; import mekanism.common.network.PacketKey.KeyMessage; -import mekanism.common.network.PacketLaserFire; -import mekanism.common.network.PacketLaserFire.LaserFireMessage; import mekanism.common.network.PacketLogisticalSorterGui; import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage; import mekanism.common.network.PacketNewFilter; @@ -120,7 +118,6 @@ public class PacketHandler netHandler.registerMessage(PacketPortableTankState.class, PortableTankStateMessage.class, 25, Side.SERVER); netHandler.registerMessage(PacketContainerEditMode.class, ContainerEditModeMessage.class, 26, Side.SERVER); netHandler.registerMessage(PacketFlamethrowerActive.class, FlamethrowerActiveMessage.class, 27, Side.SERVER); - netHandler.registerMessage(PacketLaserFire.class, LaserFireMessage.class, 28, Side.CLIENT); } /** diff --git a/src/main/java/mekanism/common/network/PacketLaserFire.java b/src/main/java/mekanism/common/network/PacketLaserFire.java deleted file mode 100644 index ad0afeecb..000000000 --- a/src/main/java/mekanism/common/network/PacketLaserFire.java +++ /dev/null @@ -1,71 +0,0 @@ -package mekanism.common.network; - -import mekanism.api.Coord4D; -import mekanism.common.IRedstoneControl.RedstoneControl; -import mekanism.common.Mekanism; -import mekanism.common.PacketHandler; -import mekanism.common.network.PacketLaserFire.LaserFireMessage; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; - -import io.netty.buffer.ByteBuf; - -public class PacketLaserFire implements IMessageHandler -{ - @Override - public IMessage onMessage(LaserFireMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(Mekanism.proxy.isClientSide()) - { - Mekanism.proxy.renderLaser(player.worldObj, message.from, message.to, message.direction); - } - - return null; - } - - public static class LaserFireMessage implements IMessage - { - public Coord4D from; - public Coord4D to; - public ForgeDirection direction; - - public LaserFireMessage() {} - - public LaserFireMessage(Coord4D from, Coord4D to, ForgeDirection direction) - { - this.from = from; - this.to = to; - this.direction = direction; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(from.xCoord); - dataStream.writeInt(from.yCoord); - dataStream.writeInt(from.zCoord); - dataStream.writeInt(from.dimensionId); - - dataStream.writeInt(to.xCoord); - dataStream.writeInt(to.yCoord); - dataStream.writeInt(to.zCoord); - dataStream.writeInt(to.dimensionId); - - dataStream.writeInt(direction.ordinal()); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - from = Coord4D.read(dataStream); - to = Coord4D.read(dataStream); - direction = ForgeDirection.getOrientation(dataStream.readInt()); - } - } -} diff --git a/src/main/java/mekanism/common/network/PacketTransmitterUpdate.java b/src/main/java/mekanism/common/network/PacketTransmitterUpdate.java index 3b01c90ed..8b3a1ce1f 100644 --- a/src/main/java/mekanism/common/network/PacketTransmitterUpdate.java +++ b/src/main/java/mekanism/common/network/PacketTransmitterUpdate.java @@ -9,6 +9,7 @@ import mekanism.api.gas.GasStack; import mekanism.api.transmitters.IGridTransmitter; import mekanism.common.EnergyNetwork; import mekanism.common.FluidNetwork; +import mekanism.common.Mekanism; import mekanism.common.PacketHandler; import mekanism.common.network.PacketTransmitterUpdate.TransmitterUpdateMessage; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index e4981dca2..b25e872c6 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -1,15 +1,23 @@ package mekanism.common.tile; +import java.util.ArrayList; + import mekanism.api.Coord4D; import mekanism.api.lasers.LaserManager; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketTileEntity.TileEntityMessage; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; +import io.netty.buffer.ByteBuf; + public class TileEntityLaser extends TileEntityElectricBlock { public static final double LASER_ENERGY = 50000; + public boolean on; + public TileEntityLaser() { super("Laser", 100000); @@ -21,10 +29,48 @@ public class TileEntityLaser extends TileEntityElectricBlock { super.onUpdate(); - if(getEnergy() >= LASER_ENERGY) + if(worldObj.isRemote) { - LaserManager.fireLaser(Coord4D.get(this), ForgeDirection.getOrientation(facing), LASER_ENERGY, worldObj); - setEnergy(getEnergy()-LASER_ENERGY); + if(on) + { + LaserManager.fireLaserClient(Coord4D.get(this), ForgeDirection.getOrientation(facing), worldObj); + } + } + else + { + if(getEnergy() >= LASER_ENERGY) + { + if(!on) + { + on = true; + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); + } + LaserManager.fireLaser(Coord4D.get(this), ForgeDirection.getOrientation(facing), LASER_ENERGY, worldObj); + setEnergy(getEnergy() - LASER_ENERGY); + } + else if(on) + { + on = false; + Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); + } } } + + @Override + public ArrayList getNetworkedData(ArrayList data) + { + super.getNetworkedData(data); + + data.add(on); + + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) + { + super.handlePacketData(dataStream); + + on = dataStream.readBoolean(); + } } From 84daf186ca61a836ee282f3cda80c74435baad80 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Wed, 23 Jul 2014 01:25:10 +0100 Subject: [PATCH 8/8] More Reactor GUI work --- .../mekanism/api/reactor/IFusionReactor.java | 2 + .../mekanism/client/gui/GuiNumberGauge.java | 48 ++++++++++ .../mekanism/common/tile/TileEntityLaser.java | 5 +- .../client/gui/GuiReactorController.java | 90 ++++++++++++++---- .../generators/common/FusionReactor.java | 22 ++++- .../container/ContainerReactorController.java | 8 -- .../generators/common/item/ItemHohlraum.java | 7 ++ .../reactor/TileEntityReactorController.java | 25 ++++- .../resources/assets/mekanism/gui/GuiTall.png | Bin 0 -> 1796 bytes .../resources/assets/mekanism/lang/en_US.lang | 3 + 10 files changed, 173 insertions(+), 37 deletions(-) create mode 100644 src/main/java/mekanism/client/gui/GuiNumberGauge.java create mode 100644 src/main/java/mekanism/generators/common/item/ItemHohlraum.java create mode 100644 src/main/resources/assets/mekanism/gui/GuiTall.png diff --git a/src/main/java/mekanism/api/reactor/IFusionReactor.java b/src/main/java/mekanism/api/reactor/IFusionReactor.java index 41f91ce07..9eb4383af 100644 --- a/src/main/java/mekanism/api/reactor/IFusionReactor.java +++ b/src/main/java/mekanism/api/reactor/IFusionReactor.java @@ -35,4 +35,6 @@ public interface IFusionReactor public double getBufferSize(); public void formMultiblock(); + + public boolean isFormed(); } diff --git a/src/main/java/mekanism/client/gui/GuiNumberGauge.java b/src/main/java/mekanism/client/gui/GuiNumberGauge.java new file mode 100644 index 000000000..42c8c82ee --- /dev/null +++ b/src/main/java/mekanism/client/gui/GuiNumberGauge.java @@ -0,0 +1,48 @@ +package mekanism.client.gui; + +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +import static java.lang.Math.min; + +public class GuiNumberGauge extends GuiGauge +{ + INumberInfoHandler infoHandler; + + public GuiNumberGauge(INumberInfoHandler handler, Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) + { + super(type, gui, def, x, y); + + infoHandler = handler; + } + + @Override + public int getScaledLevel() + { + return (int)((height-2) * min(infoHandler.getLevel() / infoHandler.getMaxLevel(), 1)); + } + + @Override + public IIcon getIcon() + { + return infoHandler.getIcon(); + } + + @Override + public String getTooltipText() + { + return infoHandler.getText(infoHandler.getLevel()); + } + + + public static interface INumberInfoHandler + { + public IIcon getIcon(); + + public double getLevel(); + + public double getMaxLevel(); + + public String getText(double level); + } +} diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index b25e872c6..42cf51da7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -14,13 +14,13 @@ import io.netty.buffer.ByteBuf; public class TileEntityLaser extends TileEntityElectricBlock { - public static final double LASER_ENERGY = 50000; + public static final double LASER_ENERGY = 1E10; public boolean on; public TileEntityLaser() { - super("Laser", 100000); + super("Laser", 2*LASER_ENERGY); inventory = new ItemStack[0]; } @@ -45,6 +45,7 @@ public class TileEntityLaser extends TileEntityElectricBlock on = true; Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); } + LaserManager.fireLaser(Coord4D.get(this), ForgeDirection.getOrientation(facing), LASER_ENERGY, worldObj); setEnergy(getEnergy() - LASER_ENERGY); } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java index 44444f695..4b1312306 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java @@ -12,20 +12,19 @@ import mekanism.client.gui.GuiGasGauge; import mekanism.client.gui.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.GuiGauge.Type; import mekanism.client.gui.GuiMekanism; +import mekanism.client.gui.GuiNumberGauge; +import mekanism.client.gui.GuiNumberGauge.INumberInfoHandler; import mekanism.client.gui.GuiPowerBar; -import mekanism.client.gui.GuiRedstoneControl; import mekanism.client.gui.GuiSlot; -import mekanism.client.gui.GuiSlot.SlotOverlay; import mekanism.client.gui.GuiSlot.SlotType; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; -import mekanism.generators.common.MekanismGenerators; import mekanism.generators.common.inventory.container.ContainerReactorController; -import mekanism.generators.common.inventory.container.ContainerSolarGenerator; -import mekanism.generators.common.tile.TileEntitySolarGenerator; import mekanism.generators.common.tile.reactor.TileEntityReactorController; +import net.minecraft.block.BlockStaticLiquid; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.IIcon; import net.minecraftforge.fluids.FluidTank; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -49,7 +48,7 @@ public class GuiReactorController extends GuiMekanism "Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), "Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); guiElements.add(new GuiGasGauge(new IGasInfoHandler() { @Override @@ -57,7 +56,7 @@ public class GuiReactorController extends GuiMekanism { return tentity.deuteriumTank; } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 124, 16)); + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 124, 6)); guiElements.add(new GuiGasGauge(new IGasInfoHandler() { @Override @@ -65,7 +64,7 @@ public class GuiReactorController extends GuiMekanism { return tentity.tritiumTank; } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 124, 46)); + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 124, 36)); guiElements.add(new GuiGasGauge(new IGasInfoHandler() { @Override @@ -73,7 +72,7 @@ public class GuiReactorController extends GuiMekanism { return tentity.fuelTank; } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 144, 16)); + }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 144, 6)); guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { @Override @@ -81,7 +80,7 @@ public class GuiReactorController extends GuiMekanism { return tentity.waterTank; } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 78, 46)); + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 78, 46)); guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { @Override @@ -89,9 +88,61 @@ public class GuiReactorController extends GuiMekanism { return tentity.steamTank; } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 98, 46)); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 98, 26)); + }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 98, 46)); + guiElements.add(new GuiNumberGauge(new INumberInfoHandler() + { + @Override + public IIcon getIcon() + { + return BlockStaticLiquid.getLiquidIcon("lava_still"); + } + + @Override + public double getLevel() + { + return tileEntity.getPlasmaTemp(); + } + + @Override + public double getMaxLevel() + { + return 5E8; + } + + @Override + public String getText(double level) + { + return "Plasma: " + (int)(level+23) + "C"; + } + }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall"), 124, 76)); + guiElements.add(new GuiNumberGauge(new INumberInfoHandler() + { + @Override + public IIcon getIcon() + { + return BlockStaticLiquid.getLiquidIcon("lava_still"); + } + + @Override + public double getLevel() + { + return tileEntity.getCaseTemp(); + } + + @Override + public double getMaxLevel() + { + return 5E8; + } + + @Override + public String getText(double level) + { + return "Case: " + (int)(level+23) + "C"; + } + }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 144, 76)); + guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 164, 15)); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 98, 26)); } @Override @@ -99,24 +150,21 @@ public class GuiReactorController extends GuiMekanism { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - fontRendererObj.drawString(tileEntity.getInventoryName(), 30, 6, 0x404040); - fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - if(tileEntity.getReactor() == null) + fontRendererObj.drawString(tileEntity.getInventoryName(), 6, 6, 0x404040); + if(tileEntity.getActive()) { - fontRendererObj.drawString(MekanismUtils.localize("container.reactor.notFormed"), 8, 16, 0x404040); + fontRendererObj.drawString(MekanismUtils.localize("container.reactor.formed"), 8, 16, 0x404040); } else { - fontRendererObj.drawString(MekanismUtils.localize("container.reactor.formed"), 8, 16, 0x404040); - fontRendererObj.drawString(MekanismUtils.localize("plasma") + ": " + (int)(tileEntity.getReactor().getPlasmaTemp()+23)+"C", 8, 26, 0x404040); - fontRendererObj.drawString(MekanismUtils.localize("casing") + ": " + (int)(tileEntity.getReactor().getCaseTemp()+23)+"C", 8, 36, 0x404040); + fontRendererObj.drawString(MekanismUtils.localize("container.reactor.notFormed"), 8, 16, 0x404040); } } @Override protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int guiWidth = (width - xSize) / 2; int guiHeight = (height - ySize) / 2; diff --git a/src/main/java/mekanism/generators/common/FusionReactor.java b/src/main/java/mekanism/generators/common/FusionReactor.java index d1ab0a00b..c2b6e6a12 100644 --- a/src/main/java/mekanism/generators/common/FusionReactor.java +++ b/src/main/java/mekanism/generators/common/FusionReactor.java @@ -15,9 +15,11 @@ import mekanism.api.reactor.IFusionReactor; import mekanism.api.reactor.INeutronCapture; import mekanism.api.reactor.IReactorBlock; import mekanism.common.Mekanism; +import mekanism.generators.common.item.ItemHohlraum; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.block.Block; +import net.minecraft.item.ItemCoal; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -61,7 +63,6 @@ public class FusionReactor implements IFusionReactor public static double caseAirConductivity = 0.1; public boolean burning = false; - public boolean hasHohlraum = false; public boolean activelyCooled = true; public boolean formed = false; @@ -77,6 +78,11 @@ public class FusionReactor implements IFusionReactor plasmaTemperature += energyAdded / plasmaHeatCapacity; } + public boolean hasHohlraum() + { + return controller != null && controller.inventory[0] != null && controller.inventory[0].getItem() instanceof ItemCoal; + } + @Override public void simulate() { @@ -90,7 +96,7 @@ public class FusionReactor implements IFusionReactor if(plasmaTemperature >= burnTemperature) { //If we're not burning yet we need a hohlraum to ignite - if(!burning && hasHohlraum) + if(!burning && hasHohlraum()) { vaporiseHohlraum(); } @@ -117,7 +123,11 @@ public class FusionReactor implements IFusionReactor public void vaporiseHohlraum() { getFuelTank().receive(new GasStack(GasRegistry.getGas("fusionFuelDT"), 10), true); - hasHohlraum = false; + controller.inventory[0].stackSize -= 1; + if(controller.inventory[0].stackSize == 0) + { + controller.inventory[0] = null; + } burning = true; } @@ -391,4 +401,10 @@ public class FusionReactor implements IFusionReactor return true; } + + public boolean isFormed() + { + return formed; + } + } diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java index 8600ee349..91808e4b8 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java @@ -21,14 +21,6 @@ public class ContainerReactorController extends Container addSlotToContainer(new Slot(tentity, 0, 99, 27)); int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } - for(slotX = 0; slotX < 9; ++slotX) { addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); diff --git a/src/main/java/mekanism/generators/common/item/ItemHohlraum.java b/src/main/java/mekanism/generators/common/item/ItemHohlraum.java new file mode 100644 index 000000000..b1670f990 --- /dev/null +++ b/src/main/java/mekanism/generators/common/item/ItemHohlraum.java @@ -0,0 +1,7 @@ +package mekanism.generators.common.item; + +import mekanism.common.item.ItemMekanism; + +public class ItemHohlraum extends ItemMekanism +{ +} diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java index 5d0760fe1..161cc1e8d 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java @@ -57,12 +57,30 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen getReactor().formMultiblock(); } + public double getPlasmaTemp() + { + if(getReactor() == null || !getReactor().isFormed()) + { + return 0; + } + return getReactor().getPlasmaTemp(); + } + + public double getCaseTemp() + { + if(getReactor() == null || !getReactor().isFormed()) + { + return 0; + } + return getReactor().getCaseTemp(); + } + @Override public void onUpdate() { super.onUpdate(); - if(getReactor() != null) + if(getReactor() != null && getReactor().isFormed()) { getReactor().simulate(); } @@ -73,7 +91,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen { super.getNetworkedData(data); - data.add(getReactor() != null); + data.add(getReactor() != null && getReactor().isFormed()); if(getReactor() != null) { data.add(getReactor().getPlasmaTemp()); @@ -100,6 +118,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen setReactor(new FusionReactor(this)); MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } + ((FusionReactor)getReactor()).formed = true; getReactor().setPlasmaTemp(dataStream.readDouble()); getReactor().setCaseTemp(dataStream.readDouble()); fuelTank.setGas(new GasStack(GasRegistry.getGas("fusionFuelDT"), dataStream.readInt())); @@ -118,7 +137,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen @Override public boolean getActive() { - return getReactor() != null; + return getReactor() != null && getReactor().isFormed(); } @Override diff --git a/src/main/resources/assets/mekanism/gui/GuiTall.png b/src/main/resources/assets/mekanism/gui/GuiTall.png new file mode 100644 index 0000000000000000000000000000000000000000..f1edcc4d357100ef755e88e0131f73fd9e1134dc GIT binary patch literal 1796 zcmd5+do|8CFOd(S=hJKrDQz2|)Ad=v}w%llw5FaQAd znP3eq0RXfEL4XK!XW9F|zypBLiU$T`VS>TPS@;w19$u~h5X?$U>meL+m1;#Zc-^l= zQNmWBga!&al6tAykqR{+GCHa)I`C{Kc18wwo;_AR@Nwzs$7KawzdqR)q{w)LPDb## zhCAY_OamcN1B@5e43)N~U?`y)GuUWG6n1YGtaS1so-GPCbrw^jIyu(k!~uBcy`18- z<>9ray!5vQG&ft!MbF}(3C{c93#|>=DlwQKkrz(~SfL zW&*WlK6V{eCT&Tg<6Hch8d$V?iP%p@Yb!4mWpWANIXQ=bcMW|g(z_=zdWfNdp3V#V zt(`huwP&9}vSL@dVi1Vk@;NrVbT+7q8H~Sm#%l8HSOhu~JPxhHjd~cD-HzyK(=9LQ<+5|C+`vNKoQ@g&VY@H9)-Spsl z@ddF3zfPsmlj*PNi&d|y2=t@nbRKIDSD5>ppU?N6DzO<)=Cf0AfyzrZnN>~dycuKO zo=QhOw>lTGyK9}R_}7|_K5BbsTKJ3;t0}c8vx(}$nhKj}*~Z36B?%+_!;;C<`?)0h z(;Af9YHPj23*wT=;3ZJ{$XX#W+@%28+tj}`mO^`bJbYN))Z>l)y@)Y zQ9M~PD;fUg5)50y=x={OVAj>^Gg$3cswWbF;rh{bZ*EK>IwpX@eMC#xUN0KFdcbUv zB^_SUMUDvY_RLnNB=9y z>;!i1QBH_nc$5dNqV%QajE=6G6jXZ^4ffp@>b8A!Vy=ef+&vJ$4}W8&3kJY|2p|VU z?)dp{@D~?GiyarrC^*$oky#g~IrD{PnlgL~Cvo)lgv8%AEeOtj585>-QlR&Bp!KxL zseHOOTSYZ2WBiN-3zcLOjr#&FBLOLSHzic>ErNmnsF<>A&<~lEaYadN-0lezBXh&j IOOE&d1jL}MssI20 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index 9b77b6c90..99dece49d 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -655,6 +655,9 @@ tile.Generator.BioGenerator.name=Bio-Generator tile.Generator.AdvancedSolarGenerator.name=Advanced Solar Generator tile.Generator.WindTurbine.name=Wind Turbine +//Reactor Blocks +tile.Reactor.ReactorController.name=Reactor Controller + //Gui text gui.heatGenerator.fuel=Fuel gui.solarGenerator.sun=Sun