Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add permitted list of dimension for windmill #47

Merged
merged 16 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/mekanism/api/MekanismConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mekanism.api;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import mekanism.api.util.UnitDisplayUtils.EnergyType;
Expand Down Expand Up @@ -74,6 +76,7 @@ public static class general
public static boolean EnablePoorOresCompat;
public static boolean OreDictOsmium;
public static boolean OreDictPlatinum;
public static boolean enableSiliconCompat;
}

public static class client
Expand Down Expand Up @@ -158,6 +161,9 @@ public static class generators
public static double turbineVentGasFlow;
public static double turbineDisperserGasFlow;
public static int condenserRate;
public static boolean enableWindmillWhitelist;
public static List<String> winddimensionids;

}

public static class tools
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mekanism/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public void loadConfiguration()
general.EnablePoorOresCompat = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnablePoorOresCompat", true).getBoolean();
general.OreDictOsmium = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OreDictOsmium", true).getBoolean();
general.OreDictPlatinum = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OreDictPlatinum", false).getBoolean();
general.enableSiliconCompat = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSiliconCompat", true).getBoolean();


String s = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyType", "J", null, new String[]{"J", "RF", "MJ", "EU"}).getString();
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/mekanism/common/Mekanism.java
Original file line number Diff line number Diff line change
Expand Up @@ -1516,13 +1516,11 @@ public void init(FMLInitializationEvent event)
}
}
}
if(Loader.isModLoaded("EnderIO") || Loader.isModLoaded("GalacticraftCore"))
if (MekanismConfig.general.enableSiliconCompat)
{
isSiliconLoaded = true;
}
if(Loader.isModLoaded("ProjRed|Core"))
{
isSiliconLoaded = true;
if (Loader.isModLoaded("EnderIO") || Loader.isModLoaded("GalacticraftCore") || Loader.isModLoaded("ProjRed|Core")) {
isSiliconLoaded = true;
}
}
//Integrate certain OreDictionary recipes
registerOreDict();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/mekanism/common/network/PacketConfigSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void toBytes(ByteBuf dataStream)
dataStream.writeBoolean(general.EnablePoorOresCompat);
dataStream.writeBoolean(general.OreDictOsmium);
dataStream.writeBoolean(general.OreDictPlatinum);
dataStream.writeBoolean(general.enableSiliconCompat);

for(MachineType type : MachineType.getValidMachines())
{
Expand Down Expand Up @@ -295,6 +296,7 @@ public void fromBytes(ByteBuf dataStream)
general.EnablePoorOresCompat = dataStream.readBoolean();
general.OreDictOsmium = dataStream.readBoolean();
general.OreDictPlatinum = dataStream.readBoolean();
general.enableSiliconCompat = dataStream.readBoolean();

for(MachineType type : MachineType.getValidMachines())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
if(!tileEntity.getActive())
{
size += 9;
fontRendererObj.drawString(EnumColor.DARK_RED + LangUtils.localize("gui.skyBlocked"), 51, size, 0x00CD00);
final String message = LangUtils.localize(!tileEntity.isInWhitelistedDimension() ? "mekanism.gui.noWind" : "gui.skyBlocked");
fontRendererObj.drawString(EnumColor.DARK_RED + message, 51, size, 0x00CD00);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.GameRegistry;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
* Common proxy for the Mekanism Generators module.
* @author AidanBrady
Expand All @@ -48,6 +52,7 @@
public class GeneratorsCommonProxy implements IGuiProvider
{
public static int GENERATOR_RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
public static List<Integer> dimid = null;

/**
* Register normal tile entities
Expand Down Expand Up @@ -101,18 +106,26 @@ public void loadConfiguration()
generators.solarGeneration = Mekanism.configuration.get("generation", "SolarGeneration", 50D).getDouble();

loadWindConfiguration();

generators.turbineBladesPerCoil = Mekanism.configuration.get("generation", "TurbineBladesPerCoil", 4).getInt();
generators.turbineVentGasFlow = Mekanism.configuration.get("generation", "TurbineVentGasFlow", 16000D).getDouble();
generators.turbineDisperserGasFlow = Mekanism.configuration.get("generation", "TurbineDisperserGasFlow", 640D).getDouble();
generators.condenserRate = Mekanism.configuration.get("generation", "TurbineCondenserFlowRate", 32000).getInt();
generators.enableWindmillWhitelist = Mekanism.configuration.get("generation", "EnableWindmillWhitelist", true).getBoolean();

if(Mekanism.configuration.hasChanged())
{
Mekanism.configuration.save();
}
}


public void loadwinddimension()
{
String[] windid = {"0"};
generators.winddimensionids = Arrays.asList(Mekanism.configuration.getStringList("winddimensionids", "generation", windid, "List of dimension id to be whitelisted"));
dimid = generators.winddimensionids.stream().map(Integer::parseInt).collect(Collectors.toList());
System.out.println("Windmill whitelist : " + dimid);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should take this debug option before making a release

}

private void loadWindConfiguration()
{
generators.windGenerationMin = Mekanism.configuration.get("generation", "WindGenerationMin", 60D).getDouble();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void init(FMLInitializationEvent event)

//Load the proxy
proxy.loadConfiguration();
proxy.loadwinddimension();
proxy.registerRegularTileEntities();
proxy.registerSpecialTileEntities();
proxy.registerRenderInformation();
Expand Down Expand Up @@ -281,6 +282,7 @@ public void writeConfig(ByteBuf dataStream) throws IOException
dataStream.writeDouble(generators.turbineVentGasFlow);
dataStream.writeDouble(generators.turbineDisperserGasFlow);
dataStream.writeInt(generators.condenserRate);
dataStream.writeBoolean(generators.enableWindmillWhitelist);
}

@Override
Expand All @@ -305,6 +307,7 @@ public void readConfig(ByteBuf dataStream) throws IOException
generators.turbineVentGasFlow = dataStream.readDouble();
generators.turbineDisperserGasFlow = dataStream.readDouble();
generators.condenserRate = dataStream.readInt();
generators.enableWindmillWhitelist = dataStream.readBoolean();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mekanism.common.base.IBoundingBlock;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.generators.common.GeneratorsCommonProxy;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
Expand Down Expand Up @@ -72,6 +73,10 @@ public ArrayList getNetworkedData(ArrayList data)
/** Determines the current output multiplier, taking sky visibility and height into account. **/
public float getMultiplier()
{
if (!isInWhitelistedDimension())
{
return 0;
}
if(worldObj.canBlockSeeTheSky(xCoord, yCoord+4, zCoord))
{
final float minY = (float)generators.windGenerationMinY;
Expand All @@ -91,7 +96,20 @@ public float getMultiplier()
return 0;
}
}

public boolean isInWhitelistedDimension()
{
if (!generators.enableWindmillWhitelist)
{
return true;
}
if (GeneratorsCommonProxy.dimid != null && GeneratorsCommonProxy.dimid.contains(worldObj.provider.dimensionId)){
//System.out.println("Windmill can operate");
return true;
}
//System.out.println("Windmill has no wind");
return false;
}

@Override
@SideOnly(Side.CLIENT)
public float getVolume()
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/mekanism/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1095,3 +1095,5 @@ mekanism.configgui.ctgy.tools.tools=Tools Balance
mekanism.configgui.ctgy.tools.general.tooltip=Settings regarding MekanismTools' general configuration
mekanism.configgui.ctgy.tools.armor.tooltip=Settings regarding the protection values and balance of MekanismTools armor sets
mekanism.configgui.ctgy.tools.tools.tooltip=Settings regarding the efficiency values and balance of MekanismTools tool sets

mekanism.gui.noWind=No wind