diff --git a/src/main/java/mekanism/common/CTMData.java b/src/main/java/mekanism/common/CTMData.java index d3df03750..d2da42c73 100644 --- a/src/main/java/mekanism/common/CTMData.java +++ b/src/main/java/mekanism/common/CTMData.java @@ -127,5 +127,4 @@ public class CTMData return !valid; } - } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java index f4764651e..ca82743c9 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java @@ -114,8 +114,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock if(!worldObj.isRemote) { - CrystallizerRecipe recipe = getRecipe(); - if(updateDelay > 0) { updateDelay--; @@ -132,6 +130,8 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock { inputTank.receive(GasTransmission.removeGas(inventory[0], inputTank.getGasType(), inputTank.getNeeded()), true); } + + CrystallizerRecipe recipe = getRecipe(); if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyUsage) { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index b36248f25..cca8e0fb4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -95,8 +95,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri if(!worldObj.isRemote) { - DissolutionRecipe recipe = getRecipe(); - if(updateDelay > 0) { updateDelay--; @@ -120,6 +118,8 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri } boolean changed = false; + + DissolutionRecipe recipe = getRecipe(); if(canOperate(recipe) && getEnergy() >= energyUsage && injectTank.getStored() >= injectUsage && MekanismUtils.canFunction(this)) { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java index 479f99109..689a0977d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -90,8 +90,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl if(!worldObj.isRemote) { - ChemicalInfuserRecipe recipe = getRecipe(); - if(updateDelay > 0) { updateDelay--; @@ -118,6 +116,8 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl { centerTank.draw(GasTransmission.addGas(inventory[2], centerTank.getGas()), true); } + + ChemicalInfuserRecipe recipe = getRecipe(); if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this)) { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index 6593d82f3..9367d7844 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -90,7 +90,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp if(!worldObj.isRemote) { - OxidationRecipe recipe = getRecipe(); if(updateDelay > 0) { updateDelay--; @@ -107,6 +106,8 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp { gasTank.draw(GasTransmission.addGas(inventory[2], gasTank.getGas()), true); } + + OxidationRecipe recipe = getRecipe(); if(canOperate(recipe) && getEnergy() >= energyUsage && MekanismUtils.canFunction(this)) { diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index d70162e1a..a38c88e25 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -103,8 +103,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple if(!worldObj.isRemote) { - WasherRecipe recipe = getRecipe(); - if(updateDelay > 0) { updateDelay--; @@ -122,6 +120,8 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple { outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true); } + + WasherRecipe recipe = getRecipe(); if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this)) { diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index fdf883c7c..f792c9ee0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -96,9 +96,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(!worldObj.isRemote) { ChargeUtils.discharge(3, this); - - SeparatorRecipe recipe = getRecipe(); - + if(inventory[0] != null) { if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory[0])) @@ -142,6 +140,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp rightTank.draw(GasTransmission.addGas(inventory[2], rightTank.getGas()), true); MekanismUtils.saveChunk(this); } + + SeparatorRecipe recipe = getRecipe(); if(canOperate(recipe) && getEnergy() >= recipe.extraEnergy) { diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index 9d28f3b8a..c79bdcbf7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -1,33 +1,39 @@ package mekanism.common.tile; +import io.netty.buffer.ByteBuf; + import java.util.ArrayList; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.usage; +import mekanism.api.Range4D; import mekanism.api.lasers.ILaserReceptor; import mekanism.common.LaserManager; import mekanism.common.Mekanism; +import mekanism.common.base.IActiveState; import mekanism.common.network.PacketTileEntity.TileEntityMessage; - +import mekanism.common.util.MekanismUtils; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.common.util.ForgeDirection; -import io.netty.buffer.ByteBuf; - -public class TileEntityLaser extends TileEntityElectricBlock +public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IActiveState { - public boolean on; public Coord4D digging; public double diggingProgress; + + public boolean isActive; + + public boolean clientActive; public TileEntityLaser() { - super("Laser", 2* usage.laserUsage); + super("machine.laser", "Laser", 2*usage.laserUsage); inventory = new ItemStack[0]; } @@ -38,7 +44,7 @@ public class TileEntityLaser extends TileEntityElectricBlock if(worldObj.isRemote) { - if(on) + if(isActive) { LaserManager.fireLaserClient(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); } @@ -46,11 +52,7 @@ public class TileEntityLaser extends TileEntityElectricBlock else { if(getEnergy() >= usage.laserUsage) { - if(!on) - { - on = true; - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); - } + setActive(true); MovingObjectPosition mop = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ); @@ -71,7 +73,7 @@ public class TileEntityLaser extends TileEntityElectricBlock { diggingProgress += usage.laserUsage; - if(diggingProgress >= hardness * general.laserEnergyNeededPerHardness) + if(diggingProgress >= hardness*general.laserEnergyNeededPerHardness) { LaserManager.breakBlock(hitCoord, true, worldObj); diggingProgress = 0; @@ -84,21 +86,49 @@ public class TileEntityLaser extends TileEntityElectricBlock setEnergy(getEnergy() - usage.laserUsage); } - else if(on) - { - on = false; + else { + setActive(false); diggingProgress = 0; - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); } } } + + @Override + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active) + { + Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return false; + } + + @Override + public boolean lightUpdate() + { + return true; + } @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - data.add(on); + data.add(isActive); return data; } @@ -108,6 +138,24 @@ public class TileEntityLaser extends TileEntityElectricBlock { super.handlePacketData(dataStream); - on = dataStream.readBoolean(); + isActive = dataStream.readBoolean(); + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); } } diff --git a/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java b/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java index 3b8ca057f..57c2ab674 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java @@ -70,8 +70,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im if(!worldObj.isRemote) { - SolarNeutronRecipe recipe = getRecipe(); - if(updateDelay > 0) { updateDelay--; @@ -83,6 +81,8 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im } //Buckets + + SolarNeutronRecipe recipe = getRecipe(); if(canOperate(recipe) && MekanismUtils.canFunction(this)) { @@ -143,6 +143,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im { super.handlePacketData(dataStream); + isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; if(dataStream.readBoolean()) @@ -169,6 +170,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im { super.getNetworkedData(data); + data.add(isActive); data.add(controlType.ordinal()); if(inputTank.getGas() != null) @@ -199,6 +201,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im { super.readFromNBT(nbtTags); + isActive = nbtTags.getBoolean("isActive"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; inputTank.read(nbtTags.getCompoundTag("inputTank")); @@ -210,6 +213,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im { super.writeToNBT(nbtTags); + nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("controlType", controlType.ordinal()); nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound())); diff --git a/src/main/resources/assets/mekanism/sounds.json b/src/main/resources/assets/mekanism/sounds.json index c4e25c43e..6c59fbd96 100644 --- a/src/main/resources/assets/mekanism/sounds.json +++ b/src/main/resources/assets/mekanism/sounds.json @@ -35,6 +35,7 @@ "tile.machine.prc": {"category": "block", "sounds": [{"name": "PressurizedReactionChamber", "stream": false}]}, "tile.machine.purification": {"category": "block", "sounds": [{"name": "PurificationChamber", "stream": false}]}, "tile.machine.smelter": {"category": "block", "sounds": [{"name": "Smelter", "stream": false}]}, + "tile.machine.laser": {"category": "block", "sounds": [{"name": "Laser", "stream": false}]}, "tile.gen.bio": {"category": "block", "sounds": [{"name": "BioGenerator", "stream": false}]}, "tile.gen.gas": {"category": "block", "sounds": [{"name": "GasGenerator", "stream": false}]}, diff --git a/src/main/resources/assets/mekanism/sounds/Laser.ogg b/src/main/resources/assets/mekanism/sounds/Laser.ogg new file mode 100644 index 000000000..1b55c402e Binary files /dev/null and b/src/main/resources/assets/mekanism/sounds/Laser.ogg differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/SolarEvaporationController.png b/src/main/resources/assets/mekanism/textures/blocks/SolarEvaporationController.png index 1275a0a8b..fe0d60a55 100644 Binary files a/src/main/resources/assets/mekanism/textures/blocks/SolarEvaporationController.png and b/src/main/resources/assets/mekanism/textures/blocks/SolarEvaporationController.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/SolarEvaporationControllerOn.png b/src/main/resources/assets/mekanism/textures/blocks/SolarEvaporationControllerOn.png index 7769211be..c37aea836 100644 Binary files a/src/main/resources/assets/mekanism/textures/blocks/SolarEvaporationControllerOn.png and b/src/main/resources/assets/mekanism/textures/blocks/SolarEvaporationControllerOn.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationController-ctm.png b/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationController-ctm.png index bd2eeacec..656d7b08e 100644 Binary files a/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationController-ctm.png and b/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationController-ctm.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationController.png b/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationController.png index 1275a0a8b..fe0d60a55 100644 Binary files a/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationController.png and b/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationController.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationControllerOn-ctm.png b/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationControllerOn-ctm.png index 79df48105..dcac3a98a 100644 Binary files a/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationControllerOn-ctm.png and b/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationControllerOn-ctm.png differ diff --git a/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationControllerOn.png b/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationControllerOn.png index 7769211be..c37aea836 100644 Binary files a/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationControllerOn.png and b/src/main/resources/assets/mekanism/textures/blocks/ctm/SolarEvaporationControllerOn.png differ