mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
72 files changed
+224
-165
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package mekanism.common.config;
|
||||
|
||||
import java.util.Set;
|
||||
import mekanism.common.util.UnitDisplayUtils.EnergyType;
|
||||
import mekanism.common.util.UnitDisplayUtils.TempType;
|
||||
|
||||
@@ -138,6 +139,8 @@ public class MekanismConfig {
|
||||
public static int windGenerationMinY;
|
||||
public static int windGenerationMaxY;
|
||||
|
||||
public static Set<Integer> windGenerationDimBlacklist;
|
||||
|
||||
public static int turbineBladesPerCoil;
|
||||
public static double turbineVentGasFlow;
|
||||
public static double turbineDisperserGasFlow;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class GuiWindGenerator extends GuiMekanism {
|
||||
MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png")));
|
||||
guiElements.add(new GuiEnergyInfo(() -> ListUtils.asList(
|
||||
LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(
|
||||
tileEntity.isActive ? generators.windGenerationMin * tileEntity.currentMultiplier : 0) + "/t",
|
||||
tileEntity.isActive ? generators.windGenerationMin * tileEntity.getCurrentMultiplier() : 0) + "/t",
|
||||
LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput())
|
||||
+ "/t"), this, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png")));
|
||||
guiElements
|
||||
@@ -57,7 +57,7 @@ public class GuiWindGenerator extends GuiMekanism {
|
||||
.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26,
|
||||
0x00CD00);
|
||||
fontRenderer.drawString(LangUtils.localize("gui.power") + ": " + powerFormat
|
||||
.format(MekanismUtils.convertToDisplay(generators.windGenerationMin * tileEntity.currentMultiplier)), 51,
|
||||
.format(MekanismUtils.convertToDisplay(generators.windGenerationMin * tileEntity.getCurrentMultiplier())), 51,
|
||||
35, 0x00CD00);
|
||||
fontRenderer.drawString(
|
||||
LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t",
|
||||
@@ -67,7 +67,11 @@ public class GuiWindGenerator extends GuiMekanism {
|
||||
|
||||
if (!tileEntity.getActive()) {
|
||||
size += 9;
|
||||
fontRenderer.drawString(EnumColor.DARK_RED + LangUtils.localize("gui.skyBlocked"), 51, size, 0x00CD00);
|
||||
String reason = "gui.skyBlocked";
|
||||
if (tileEntity.isBlacklistDimension()) {
|
||||
reason = "gui.noWind";
|
||||
}
|
||||
fontRenderer.drawString(EnumColor.DARK_RED + LangUtils.localize(reason), 51, size, 0x00CD00);
|
||||
}
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
|
||||
@@ -35,10 +35,10 @@ public class RenderWindGenerator extends TileEntitySpecialRenderer<TileEntityWin
|
||||
|
||||
GlStateManager.rotate(180, 0F, 0F, 1F);
|
||||
|
||||
double angle = tileEntity.angle;
|
||||
double angle = tileEntity.getAngle();
|
||||
|
||||
if (tileEntity.isActive) {
|
||||
angle = (tileEntity.angle
|
||||
angle = (tileEntity.getAngle()
|
||||
+ ((tileEntity.getPos().getY() + 4F) / TileEntityWindGenerator.SPEED_SCALED) * partialTick) % 360;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package mekanism.generators.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IGuiProvider;
|
||||
import mekanism.common.config.MekanismConfig.generators;
|
||||
@@ -38,6 +42,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import scala.actors.threadpool.Arrays;
|
||||
|
||||
/**
|
||||
* Common proxy for the Mekanism Generators module.
|
||||
@@ -122,6 +127,10 @@ public class GeneratorsCommonProxy implements IGuiProvider {
|
||||
Mekanism.configuration.get("generators", type.blockName + "Enabled", true).getBoolean());
|
||||
}
|
||||
|
||||
int[] windGenerationBlacklistDims = Mekanism.configuration.get("generation", "WindGenerationDimBlacklist", new int[]{}).getIntList();
|
||||
generators.windGenerationDimBlacklist = IntStream.of(windGenerationBlacklistDims).boxed().
|
||||
collect(Collectors.toCollection(HashSet::new));
|
||||
|
||||
if (Mekanism.configuration.hasChanged()) {
|
||||
Mekanism.configuration.save();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package mekanism.generators.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IBoundingBlock;
|
||||
import mekanism.common.base.TileNetworkList;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import mekanism.common.config.MekanismConfig.generators;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -15,19 +17,31 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou
|
||||
|
||||
public static final float SPEED = 32F;
|
||||
public static final float SPEED_SCALED = 256F / SPEED;
|
||||
private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded",
|
||||
static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded",
|
||||
"getMultiplier"};
|
||||
/**
|
||||
* The angle the blades of this Wind Turbine are currently at.
|
||||
*/
|
||||
public double angle;
|
||||
public float currentMultiplier;
|
||||
|
||||
private double angle;
|
||||
private float currentMultiplier;
|
||||
private boolean isBlacklistDimension = false;
|
||||
|
||||
public TileEntityWindGenerator() {
|
||||
super("wind", "WindGenerator", 200000, (generators.windGenerationMax) * 2);
|
||||
inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
|
||||
// Check the blacklist and force an update if we're in the blacklist. Otherwise, we'll never send
|
||||
// an initial activity status and the client (in MP) will show the windmills turning while not
|
||||
// generating any power
|
||||
isBlacklistDimension = generators.windGenerationDimBlacklist.contains(world.provider.getDimension());
|
||||
if (isBlacklistDimension) {
|
||||
setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
@@ -35,8 +49,15 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou
|
||||
if (!world.isRemote) {
|
||||
ChargeUtils.charge(0, this);
|
||||
|
||||
// If we're in a blacklisted dimension, there's nothing more to do
|
||||
if (isBlacklistDimension) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ticker % 20 == 0) {
|
||||
setActive((currentMultiplier = getMultiplier()) > 0);
|
||||
// Recalculate the current multiplier once a second
|
||||
currentMultiplier = getMultiplier();
|
||||
setActive(currentMultiplier > 0);
|
||||
}
|
||||
|
||||
if (getActive()) {
|
||||
@@ -55,6 +76,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou
|
||||
|
||||
if (world.isRemote) {
|
||||
currentMultiplier = dataStream.readFloat();
|
||||
isBlacklistDimension = dataStream.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +85,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(currentMultiplier);
|
||||
data.add(isBlacklistDimension);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -129,6 +152,9 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou
|
||||
MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 2), current);
|
||||
MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 3), current);
|
||||
MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 4), current);
|
||||
|
||||
// Check to see if the placement is happening in a blacklisted dimension
|
||||
isBlacklistDimension = generators.windGenerationDimBlacklist.contains(world.provider.getDimension());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,4 +176,16 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou
|
||||
public boolean lightUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getCurrentMultiplier() {
|
||||
return currentMultiplier;
|
||||
}
|
||||
|
||||
public double getAngle() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public boolean isBlacklistDimension() {
|
||||
return isBlacklistDimension;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user