Move Laser range and usage to config

This commit is contained in:
Ben Spiers 2014-08-04 20:42:04 +01:00
parent 432eab1bcf
commit 12f9753ac5
4 changed files with 13 additions and 11 deletions

View file

@ -37,6 +37,7 @@ public class MekanismConfig
public static double FROM_IC2; public static double FROM_IC2;
public static double FROM_BC; public static double FROM_BC;
public static double FROM_TE; public static double FROM_TE;
public static int laserRange = 100;
} }
public static class usage public static class usage
@ -62,6 +63,7 @@ public class MekanismConfig
public static double seismicVibratorUsage; public static double seismicVibratorUsage;
public static double pressurizedReactionBaseUsage; public static double pressurizedReactionBaseUsage;
public static double fluidicPlenisherUsage; public static double fluidicPlenisherUsage;
public static double laserUsage;
} }
public static class generators public static class generators

View file

@ -251,6 +251,8 @@ public class CommonProxy
MekanismAPI.addBoxBlacklist(Blocks.mob_spawner, 0); MekanismAPI.addBoxBlacklist(Blocks.mob_spawner, 0);
} }
general.laserRange = Mekanism.configuration.get("general", "LaserRange", 100).getInt(100);
usage.enrichmentChamberUsage = Mekanism.configuration.get("usage", "EnrichmentChamberUsage", 50D).getDouble(50D); usage.enrichmentChamberUsage = Mekanism.configuration.get("usage", "EnrichmentChamberUsage", 50D).getDouble(50D);
usage.osmiumCompressorUsage = Mekanism.configuration.get("usage", "OsmiumCompressorUsage", 100D).getDouble(100D); usage.osmiumCompressorUsage = Mekanism.configuration.get("usage", "OsmiumCompressorUsage", 100D).getDouble(100D);
usage.combinerUsage = Mekanism.configuration.get("usage", "CombinerUsage", 50D).getDouble(50D); usage.combinerUsage = Mekanism.configuration.get("usage", "CombinerUsage", 50D).getDouble(50D);
@ -272,6 +274,7 @@ public class CommonProxy
usage.seismicVibratorUsage = Mekanism.configuration.get("usage", "SeismicVibratorUsage", 50D).getDouble(50D); usage.seismicVibratorUsage = Mekanism.configuration.get("usage", "SeismicVibratorUsage", 50D).getDouble(50D);
usage.pressurizedReactionBaseUsage = Mekanism.configuration.get("usage", "PressurizedReactionBaseUsage", 5D).getDouble(5D); usage.pressurizedReactionBaseUsage = Mekanism.configuration.get("usage", "PressurizedReactionBaseUsage", 5D).getDouble(5D);
usage.fluidicPlenisherUsage = Mekanism.configuration.get("usage", "FluidicPlenisherUsage", 100D).getDouble(100D); usage.fluidicPlenisherUsage = Mekanism.configuration.get("usage", "FluidicPlenisherUsage", 100D).getDouble(100D);
usage.laserUsage = Mekanism.configuration.get("usage", "LaserUsage", 5000D).getDouble(5000D);
if(Mekanism.configuration.hasChanged()) if(Mekanism.configuration.hasChanged())
{ {

View file

@ -1,8 +1,8 @@
package mekanism.common; package mekanism.common;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general;
import mekanism.api.lasers.ILaserReceptor; import mekanism.api.lasers.ILaserReceptor;
import mekanism.common.Mekanism;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
@ -12,12 +12,10 @@ import net.minecraftforge.common.util.ForgeDirection;
public class LaserManager public class LaserManager
{ {
public static int range = 100;
public static void fireLaser(Coord4D from, ForgeDirection direction, double energy, World world) public static void fireLaser(Coord4D from, ForgeDirection direction, double energy, World world)
{ {
Coord4D rangeFrom = from.getFromSide(direction, 1); Coord4D rangeFrom = from.getFromSide(direction, 1);
Coord4D to = from.getFromSide(direction, range); Coord4D to = from.getFromSide(direction, general.laserRange);
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord)); MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord));
if(mop != null) if(mop != null)
@ -41,7 +39,7 @@ public class LaserManager
public static void fireLaserClient(Coord4D from, ForgeDirection direction, World world) public static void fireLaserClient(Coord4D from, ForgeDirection direction, World world)
{ {
Coord4D rangeFrom = from.getFromSide(direction, 1); Coord4D rangeFrom = from.getFromSide(direction, 1);
Coord4D to = from.getFromSide(direction, range); Coord4D to = from.getFromSide(direction, general.laserRange);
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord)); MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord));
if(mop != null) if(mop != null)

View file

@ -5,6 +5,7 @@ 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.usage;
import mekanism.common.LaserManager; import mekanism.common.LaserManager;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
@ -13,13 +14,11 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityLaser extends TileEntityElectricBlock public class TileEntityLaser extends TileEntityElectricBlock
{ {
public static final double LASER_ENERGY = 5000;
public boolean on; public boolean on;
public TileEntityLaser() public TileEntityLaser()
{ {
super("Laser", 2*LASER_ENERGY); super("Laser", 2* usage.laserUsage);
inventory = new ItemStack[0]; inventory = new ItemStack[0];
} }
@ -37,7 +36,7 @@ public class TileEntityLaser extends TileEntityElectricBlock
} }
else else
{ {
if(getEnergy() >= LASER_ENERGY) if(getEnergy() >= usage.laserUsage)
{ {
if(!on) if(!on)
{ {
@ -45,8 +44,8 @@ public class TileEntityLaser extends TileEntityElectricBlock
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); 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); LaserManager.fireLaser(Coord4D.get(this), ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj);
setEnergy(getEnergy() - LASER_ENERGY); setEnergy(getEnergy() - usage.laserUsage);
} }
else if(on) else if(on)
{ {