Lasers now have fancy sound effects!

This commit is contained in:
Aidan C. Brady 2015-02-27 01:57:54 -05:00
parent 48c872ec37
commit 84ab0ecb3f
17 changed files with 87 additions and 34 deletions

View file

@ -127,5 +127,4 @@ public class CTMData
return !valid; return !valid;
} }
} }

View file

@ -114,8 +114,6 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
CrystallizerRecipe recipe = getRecipe();
if(updateDelay > 0) if(updateDelay > 0)
{ {
updateDelay--; updateDelay--;
@ -133,6 +131,8 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
inputTank.receive(GasTransmission.removeGas(inventory[0], inputTank.getGasType(), inputTank.getNeeded()), true); inputTank.receive(GasTransmission.removeGas(inventory[0], inputTank.getGasType(), inputTank.getNeeded()), true);
} }
CrystallizerRecipe recipe = getRecipe();
if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyUsage) if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyUsage)
{ {
setActive(true); setActive(true);

View file

@ -95,8 +95,6 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
DissolutionRecipe recipe = getRecipe();
if(updateDelay > 0) if(updateDelay > 0)
{ {
updateDelay--; updateDelay--;
@ -121,6 +119,8 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
boolean changed = false; boolean changed = false;
DissolutionRecipe recipe = getRecipe();
if(canOperate(recipe) && getEnergy() >= energyUsage && injectTank.getStored() >= injectUsage && MekanismUtils.canFunction(this)) if(canOperate(recipe) && getEnergy() >= energyUsage && injectTank.getStored() >= injectUsage && MekanismUtils.canFunction(this))
{ {
setActive(true); setActive(true);

View file

@ -90,8 +90,6 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
ChemicalInfuserRecipe recipe = getRecipe();
if(updateDelay > 0) if(updateDelay > 0)
{ {
updateDelay--; updateDelay--;
@ -119,6 +117,8 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
centerTank.draw(GasTransmission.addGas(inventory[2], centerTank.getGas()), true); centerTank.draw(GasTransmission.addGas(inventory[2], centerTank.getGas()), true);
} }
ChemicalInfuserRecipe recipe = getRecipe();
if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this)) if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this))
{ {
setActive(true); setActive(true);

View file

@ -90,7 +90,6 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
OxidationRecipe recipe = getRecipe();
if(updateDelay > 0) if(updateDelay > 0)
{ {
updateDelay--; updateDelay--;
@ -108,6 +107,8 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
gasTank.draw(GasTransmission.addGas(inventory[2], gasTank.getGas()), true); gasTank.draw(GasTransmission.addGas(inventory[2], gasTank.getGas()), true);
} }
OxidationRecipe recipe = getRecipe();
if(canOperate(recipe) && getEnergy() >= energyUsage && MekanismUtils.canFunction(this)) if(canOperate(recipe) && getEnergy() >= energyUsage && MekanismUtils.canFunction(this))
{ {
setActive(true); setActive(true);

View file

@ -103,8 +103,6 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
WasherRecipe recipe = getRecipe();
if(updateDelay > 0) if(updateDelay > 0)
{ {
updateDelay--; updateDelay--;
@ -123,6 +121,8 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true); outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true);
} }
WasherRecipe recipe = getRecipe();
if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this)) if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this))
{ {
setActive(true); setActive(true);

View file

@ -97,8 +97,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
{ {
ChargeUtils.discharge(3, this); ChargeUtils.discharge(3, this);
SeparatorRecipe recipe = getRecipe();
if(inventory[0] != null) if(inventory[0] != null)
{ {
if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory[0])) if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory[0]))
@ -143,6 +141,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
MekanismUtils.saveChunk(this); MekanismUtils.saveChunk(this);
} }
SeparatorRecipe recipe = getRecipe();
if(canOperate(recipe) && getEnergy() >= recipe.extraEnergy) if(canOperate(recipe) && getEnergy() >= recipe.extraEnergy)
{ {
setActive(true); setActive(true);

View file

@ -1,33 +1,39 @@
package mekanism.common.tile; package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.general;
import mekanism.api.MekanismConfig.usage; import mekanism.api.MekanismConfig.usage;
import mekanism.api.Range4D;
import mekanism.api.lasers.ILaserReceptor; import mekanism.api.lasers.ILaserReceptor;
import mekanism.common.LaserManager; import mekanism.common.LaserManager;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import io.netty.buffer.ByteBuf; public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IActiveState
public class TileEntityLaser extends TileEntityElectricBlock
{ {
public boolean on;
public Coord4D digging; public Coord4D digging;
public double diggingProgress; public double diggingProgress;
public boolean isActive;
public boolean clientActive;
public TileEntityLaser() public TileEntityLaser()
{ {
super("Laser", 2* usage.laserUsage); super("machine.laser", "Laser", 2*usage.laserUsage);
inventory = new ItemStack[0]; inventory = new ItemStack[0];
} }
@ -38,7 +44,7 @@ public class TileEntityLaser extends TileEntityElectricBlock
if(worldObj.isRemote) if(worldObj.isRemote)
{ {
if(on) if(isActive)
{ {
LaserManager.fireLaserClient(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); LaserManager.fireLaserClient(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj);
} }
@ -46,11 +52,7 @@ public class TileEntityLaser extends TileEntityElectricBlock
else { else {
if(getEnergy() >= usage.laserUsage) if(getEnergy() >= usage.laserUsage)
{ {
if(!on) setActive(true);
{
on = true;
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D));
}
MovingObjectPosition mop = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); MovingObjectPosition mop = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj);
Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ); 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; diggingProgress += usage.laserUsage;
if(diggingProgress >= hardness * general.laserEnergyNeededPerHardness) if(diggingProgress >= hardness*general.laserEnergyNeededPerHardness)
{ {
LaserManager.breakBlock(hitCoord, true, worldObj); LaserManager.breakBlock(hitCoord, true, worldObj);
diggingProgress = 0; diggingProgress = 0;
@ -84,21 +86,49 @@ public class TileEntityLaser extends TileEntityElectricBlock
setEnergy(getEnergy() - usage.laserUsage); setEnergy(getEnergy() - usage.laserUsage);
} }
else if(on) else {
{ setActive(false);
on = false;
diggingProgress = 0; 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 @Override
public ArrayList getNetworkedData(ArrayList data) public ArrayList getNetworkedData(ArrayList data)
{ {
super.getNetworkedData(data); super.getNetworkedData(data);
data.add(on); data.add(isActive);
return data; return data;
} }
@ -108,6 +138,24 @@ public class TileEntityLaser extends TileEntityElectricBlock
{ {
super.handlePacketData(dataStream); 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);
} }
} }

View file

@ -70,8 +70,6 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
SolarNeutronRecipe recipe = getRecipe();
if(updateDelay > 0) if(updateDelay > 0)
{ {
updateDelay--; updateDelay--;
@ -84,6 +82,8 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
//Buckets //Buckets
SolarNeutronRecipe recipe = getRecipe();
if(canOperate(recipe) && MekanismUtils.canFunction(this)) if(canOperate(recipe) && MekanismUtils.canFunction(this))
{ {
setActive(true); setActive(true);
@ -143,6 +143,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
{ {
super.handlePacketData(dataStream); super.handlePacketData(dataStream);
isActive = dataStream.readBoolean();
controlType = RedstoneControl.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()];
if(dataStream.readBoolean()) if(dataStream.readBoolean())
@ -169,6 +170,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
{ {
super.getNetworkedData(data); super.getNetworkedData(data);
data.add(isActive);
data.add(controlType.ordinal()); data.add(controlType.ordinal());
if(inputTank.getGas() != null) if(inputTank.getGas() != null)
@ -199,6 +201,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
{ {
super.readFromNBT(nbtTags); super.readFromNBT(nbtTags);
isActive = nbtTags.getBoolean("isActive");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
inputTank.read(nbtTags.getCompoundTag("inputTank")); inputTank.read(nbtTags.getCompoundTag("inputTank"));
@ -210,6 +213,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
{ {
super.writeToNBT(nbtTags); super.writeToNBT(nbtTags);
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("controlType", controlType.ordinal()); nbtTags.setInteger("controlType", controlType.ordinal());
nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound())); nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound()));

View file

@ -35,6 +35,7 @@
"tile.machine.prc": {"category": "block", "sounds": [{"name": "PressurizedReactionChamber", "stream": false}]}, "tile.machine.prc": {"category": "block", "sounds": [{"name": "PressurizedReactionChamber", "stream": false}]},
"tile.machine.purification": {"category": "block", "sounds": [{"name": "PurificationChamber", "stream": false}]}, "tile.machine.purification": {"category": "block", "sounds": [{"name": "PurificationChamber", "stream": false}]},
"tile.machine.smelter": {"category": "block", "sounds": [{"name": "Smelter", "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.bio": {"category": "block", "sounds": [{"name": "BioGenerator", "stream": false}]},
"tile.gen.gas": {"category": "block", "sounds": [{"name": "GasGenerator", "stream": false}]}, "tile.gen.gas": {"category": "block", "sounds": [{"name": "GasGenerator", "stream": false}]},

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB