Polished resistive heaters, fixed a small bug in the sound system (a bit uncleanly)

This commit is contained in:
aidancbrady 2016-02-27 01:27:26 -05:00
parent 63335a57c8
commit 9b9ed0a4c0
21 changed files with 147 additions and 28 deletions

View file

@ -5,6 +5,7 @@ import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.util.UnitDisplayUtils.TemperatureUnit;
import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiRedstoneControl;
import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType;
@ -39,6 +40,7 @@ public class GuiResistiveHeater extends GuiMekanism
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), 164, 15));
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), 14, 34).with(SlotOverlay.POWER));
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png")));
}
@Override

View file

@ -277,6 +277,7 @@ public class CommonProxy implements IGuiProvider
general.evaporationTempMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationTempMultiplier", 0.1D).getDouble();
general.evaporationSolarMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationSolarMultiplier", 0.2D).getDouble();
general.evaporationMaxTemp = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationMaxTemp", 3000D).getDouble();
general.energyPerHeat = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerHeat", 1000D).getDouble();
general.blacklistIC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistIC2Power", false).getBoolean();
general.blacklistRF = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false).getBoolean();

View file

@ -429,7 +429,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
}
}
private static final String[] methods = new String[] {"getStored", "getSecondaryStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getSecondaryStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
@Override
public String[] getMethods()

View file

@ -159,7 +159,7 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
return null;
}
private static final String[] methods = new String[] {"getStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
@Override
public String[] getMethods()

View file

@ -220,7 +220,7 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
return false;
}
private static final String[] methods = new String[] {"getStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
@Override
public String[] getMethods()

View file

@ -576,7 +576,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
nbtTags.setInteger("dumpRight", dumpRight.ordinal());
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getWater", "getWaterNeeded", "getHydrogen", "getHydrogenNeeded", "getOxygen", "getOxygenNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getWater", "getWaterNeeded", "getHydrogen", "getHydrogenNeeded", "getOxygen", "getOxygenNeeded"};
@Override
public String[] getMethods()

View file

@ -167,7 +167,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
return false;
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded"};
@Override
public String[] getMethods()

View file

@ -919,7 +919,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getInventoryName();
}
private static final String[] methods = new String[] {"getStored", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
@Override
public String[] getMethods()

View file

@ -13,6 +13,8 @@ import mekanism.api.IConfigurable;
import mekanism.api.MekanismConfig.general;
import mekanism.api.MekanismConfig.usage;
import mekanism.common.Upgrade;
import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.IRedstoneControl.RedstoneControl;
import mekanism.common.base.ISustainedTank;
import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.BlockMachine.MachineType;
@ -38,7 +40,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler;
public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IComputerIntegration, IConfigurable, IFluidHandler, ISustainedTank, IUpgradeTile
public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IComputerIntegration, IConfigurable, IFluidHandler, ISustainedTank, IUpgradeTile, IRedstoneControl
{
public Set<Coord4D> activeNodes = new HashSet<Coord4D>();
public Set<Coord4D> usedNodes = new HashSet<Coord4D>();
@ -60,6 +62,8 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
/** How many ticks this machine has been operating for. */
public int operatingTicks;
public RedstoneControl controlType = RedstoneControl.DISABLED;
private static EnumSet<ForgeDirection> dirs = EnumSet.complementOf(EnumSet.of(ForgeDirection.UP, ForgeDirection.UNKNOWN));
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3);
@ -278,6 +282,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
super.handlePacketData(dataStream);
finishedCalc = dataStream.readBoolean();
controlType = RedstoneControl.values()[dataStream.readInt()];
if(dataStream.readInt() == 1)
{
@ -296,6 +301,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
super.getNetworkedData(data);
data.add(finishedCalc);
data.add(controlType.ordinal());
if(fluidTank.getFluid() != null)
{
@ -317,6 +323,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
nbtTags.setInteger("operatingTicks", operatingTicks);
nbtTags.setBoolean("finishedCalc", finishedCalc);
nbtTags.setInteger("controlType", controlType.ordinal());
if(fluidTank.getFluid() != null)
{
@ -357,6 +364,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
operatingTicks = nbtTags.getInteger("operatingTicks");
finishedCalc = nbtTags.getBoolean("finishedCalc");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
if(nbtTags.hasKey("fluidTank"))
{
@ -579,4 +587,22 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
break;
}
}
@Override
public RedstoneControl getControlType()
{
return controlType;
}
@Override
public void setControlType(RedstoneControl type)
{
controlType = type;
}
@Override
public boolean canPulse()
{
return false;
}
}

View file

@ -180,7 +180,7 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
return structure != null ? structure.storageCap : 0;
}
public static final String[] methods = new String[] {"getStored", "getMaxEnergy", "getInput", "getOutput", "getTransferCap"};
public static final String[] methods = new String[] {"getEnergy", "getMaxEnergy", "getInput", "getOutput", "getTransferCap"};
@Override
public String[] getMethods()

View file

@ -310,7 +310,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
return MAX_ENERGY;
}
private static final String[] methods = new String[] {"getStored", "getMaxEnergy"};
private static final String[] methods = new String[] {"getEnergy", "getMaxEnergy"};
@Override
public String[] getMethods()

View file

@ -105,7 +105,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
ejectorComponent = new TileComponentEjector(this);
ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3));
}
@Override
public void onUpdate()
{
@ -424,7 +424,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
return data;
}
private static final String[] methods = new String[] {"getStored", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getInfuse", "getInfuseNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getInfuse", "getInfuseNeeded"};
@Override
public String[] getMethods()

View file

@ -67,7 +67,7 @@ public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlo
{
if(this instanceof IUpgradeTile && ((IUpgradeTile)this).getComponent().supports(Upgrade.MUFFLING))
{
return 1F - (float)((IUpgradeTile)this).getComponent().getUpgrades(Upgrade.MUFFLING)/(float)Upgrade.MUFFLING.getMax();
return Math.max(0.001F, 1F - (float)((IUpgradeTile)this).getComponent().getUpgrades(Upgrade.MUFFLING)/(float)Upgrade.MUFFLING.getMax());
}
return 1F;

View file

@ -293,7 +293,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
return null;
}
private static final String[] methods = new String[] {"getStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getFluidStored", "getGasStored"};
private static final String[] methods = new String[] {"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getFluidStored", "getGasStored"};
@Override
public String[] getMethods()

View file

@ -9,7 +9,9 @@ import mekanism.api.IHeatTransfer;
import mekanism.api.MekanismConfig.general;
import mekanism.api.Range4D;
import mekanism.common.Mekanism;
import mekanism.common.base.IRedstoneControl;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.integration.IComputerIntegration;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.HeatUtils;
@ -19,7 +21,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock implements IHeatTransfer
public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock implements IHeatTransfer, IComputerIntegration, IRedstoneControl
{
public double energyUsage = 100;
@ -35,6 +37,10 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
/** How many ticks must pass until this block's active state can sync with the client. */
public int updateDelay;
public float soundScale = 1;
public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileEntityResistiveHeater()
{
super("machine.resistiveheater", "ResistiveHeater", MachineType.RESISTIVE_HEATER.baseEnergy);
@ -59,28 +65,56 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
if(!worldObj.isRemote)
{
boolean packet = false;
if(updateDelay > 0)
{
updateDelay--;
if(updateDelay == 0 && clientActive != isActive)
{
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
packet = true;
}
}
ChargeUtils.discharge(0, this);
double toUse = Math.min(getEnergy(), energyUsage);
heatToAbsorb += toUse/general.energyPerHeat;
setEnergy(getEnergy() - toUse);
double toUse = 0;
if(MekanismUtils.canFunction(this))
{
toUse = Math.min(getEnergy(), energyUsage);
heatToAbsorb += toUse/general.energyPerHeat;
setEnergy(getEnergy() - toUse);
}
setActive(toUse > 0);
simulateHeat();
applyTemperatureChange();
float newSoundScale = (float)Math.max(0, (toUse/1E5));
if(Math.abs(newSoundScale-soundScale) > 0.01)
{
packet = true;
}
soundScale = newSoundScale;
if(packet)
{
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
}
}
}
@Override
public float getVolume()
{
return super.getVolume()*Math.max(0.001F, soundScale);
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
@ -89,6 +123,7 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
energyUsage = nbtTags.getDouble("energyUsage");
temperature = nbtTags.getDouble("temperature");
clientActive = isActive = nbtTags.getBoolean("isActive");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
maxEnergy = energyUsage * 400;
}
@ -101,6 +136,7 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
nbtTags.setDouble("energyUsage", energyUsage);
nbtTags.setDouble("temperature", temperature);
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("controlType", controlType.ordinal());
}
@Override
@ -120,6 +156,8 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
temperature = dataStream.readDouble();
clientActive = dataStream.readBoolean();
maxEnergy = dataStream.readDouble();
soundScale = dataStream.readFloat();
controlType = RedstoneControl.values()[dataStream.readInt()];
if(updateDelay == 0 && clientActive != isActive)
{
@ -138,6 +176,8 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
data.add(temperature);
data.add(isActive);
data.add(maxEnergy);
data.add(soundScale);
data.add(controlType.ordinal());
return data;
}
@ -223,7 +263,7 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
@Override
public boolean renderUpdate()
{
return true;
return false;
}
@Override
@ -231,4 +271,56 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
{
return true;
}
private static final String[] methods = new String[] {"getEnergy", "getMaxEnergy", "getTemperature", "setEnergyUsage"};
@Override
public String[] getMethods()
{
return methods;
}
@Override
public Object[] invoke(int method, Object[] arguments) throws Exception
{
switch(method)
{
case 0:
return new Object[] {getEnergy()};
case 1:
return new Object[] {getMaxEnergy()};
case 2:
return new Object[] {temperature};
case 3:
if(arguments.length == 1)
{
if(arguments[0] instanceof Double)
{
temperature = (Double)arguments[0];
}
}
return new Object[] {"Invalid parameters."};
default:
throw new NoSuchMethodException();
}
}
@Override
public RedstoneControl getControlType()
{
return controlType;
}
@Override
public void setControlType(RedstoneControl type)
{
controlType = type;
}
@Override
public boolean canPulse()
{
return false;
}
}

View file

@ -698,7 +698,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
return ChargeUtils.canBeOutputted(itemstack, false);
}
private static final String[] methods = new String[] {"getStored", "canTeleport", "getMaxEnergy", "getEnergyNeeded", "teleport", "set"};
private static final String[] methods = new String[] {"getEnergy", "canTeleport", "getMaxEnergy", "teleport", "set"};
@Override
public String[] getMethods()
@ -718,11 +718,9 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
case 2:
return new Object[] {getMaxEnergy()};
case 3:
return new Object[] {(getMaxEnergy()-getEnergy())};
case 4:
teleport();
return new Object[] {"Attempted to teleport."};
case 5:
case 4:
if(!(arguments[0] instanceof String) || !(arguments[1] instanceof Boolean))
{
return new Object[] {"Invalid parameters."};

View file

@ -211,7 +211,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite());
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded"};
@Override
public String[] getMethods()

View file

@ -156,7 +156,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
return fuelTank.getStored()*i / MAX_GAS;
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getGas", "getGasNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getGas", "getGasNeeded"};
@Override
public String[] getMethods()

View file

@ -276,7 +276,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
return data;
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getFuel", "getFuelNeeded"};
private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getFuel", "getFuelNeeded"};
@Override
public String[] getMethods()

View file

@ -139,7 +139,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
return 0;
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getSeesSun"};
private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getSeesSun"};
@Override
public String[] getMethods()

View file

@ -71,7 +71,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou
return 1.5F*super.getVolume();
}
private static final String[] methods = new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier"};
private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier"};
@Override
public String[] getMethods()