Add Gui for configuring BOP world properties (saved per game)

This commit is contained in:
Cheeserolls 2015-06-19 00:22:53 +01:00
parent 6983d5df0a
commit 9362ba95ac
37 changed files with 1692 additions and 37 deletions

View file

@ -31,6 +31,7 @@ import biomesoplenty.api.biome.generation.GenerationManager;
import biomesoplenty.api.biome.generation.GeneratorStage; import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.api.biome.generation.IGenerator; import biomesoplenty.api.biome.generation.IGenerator;
import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import biomesoplenty.common.util.config.BOPConfig.IConfigObj;
import biomesoplenty.common.world.BOPWorldSettings;
public class BOPBiome extends BiomeGenBase implements IExtendedBiome public class BOPBiome extends BiomeGenBase implements IExtendedBiome
{ {
@ -57,6 +58,11 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
this.setOctaveWeights(1, 1, 1, 1, 1, 1); this.setOctaveWeights(1, 1, 1, 1, 1, 1);
} }
public void applySettings(BOPWorldSettings settings)
{
}
public void configure(IConfigObj conf) public void configure(IConfigObj conf)
{ {
@ -196,6 +202,11 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
this.generationManager.addGenerator(name, stage, generator); this.generationManager.addGenerator(name, stage, generator);
} }
public void removeGenerator(String name)
{
this.generationManager.removeGenerator(name);
}
@Override @Override
public GenerationManager getGenerationManager() public GenerationManager getGenerationManager()
{ {

View file

@ -0,0 +1,687 @@
package biomesoplenty.client.gui;
import com.google.common.base.Objects;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiLabel;
import net.minecraft.client.gui.GuiListButton;
import net.minecraft.client.gui.GuiListExtended;
import net.minecraft.client.gui.GuiPageButtonList;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiSlider;
import net.minecraft.client.gui.GuiTextField;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiBOPConfigPage extends GuiListExtended
{
private final List<GuiBOPConfigPage.GuiEntry> allRows = new ArrayList<GuiBOPConfigPage.GuiEntry>();
private final Map<Integer, Gui> fieldIdToGuiMap = new HashMap<Integer, Gui>();
private final List <GuiTextField>allTextFieldGuis = new ArrayList<GuiTextField>();
private final GuiBOPConfigPage.GuiListEntry[][] pages;
private int currentPageNum;
private GuiBOPConfigPage.GuiResponder responder;
private Gui field_178075_A;
public GuiBOPConfigPage(Minecraft mc, int width, int height, int p_i45536_4_, int p_i45536_5_, int p_i45536_6_, GuiBOPConfigPage.GuiResponder responder, GuiBOPConfigPage.GuiListEntry[] ... pages)
{
super(mc, width, height, p_i45536_4_, p_i45536_5_, p_i45536_6_);
this.responder = responder;
this.pages = pages;
this.field_148163_i = false;
this.init();
this.resetRows();
}
private void init()
{
GuiBOPConfigPage.GuiListEntry[][] pages = this.pages;
int i = pages.length;
for (int j = 0; j < i; ++j)
{
GuiBOPConfigPage.GuiListEntry[] page = pages[j];
// go through the fields in twos (so they go in 2 columns)
for (int k = 0; k < page.length; k += 2)
{
GuiBOPConfigPage.GuiListEntry fieldLeft = page[k];
GuiBOPConfigPage.GuiListEntry fieldRight = k < page.length - 1 ? page[k + 1] : null;
Gui guiLeft = this.createGui(fieldLeft, 0, fieldRight == null);
Gui guiRight = this.createGui(fieldRight, 160, fieldLeft == null);
GuiBOPConfigPage.GuiEntry row = new GuiBOPConfigPage.GuiEntry(guiLeft, guiRight);
this.allRows.add(row);
if (fieldLeft != null && guiLeft != null)
{
this.fieldIdToGuiMap.put(fieldLeft.getFieldId(), guiLeft);
if (guiLeft instanceof GuiTextField)
{
this.allTextFieldGuis.add((GuiTextField)guiLeft);
}
}
if (fieldRight != null && guiRight != null)
{
this.fieldIdToGuiMap.put(fieldRight.getFieldId(), guiRight);
if (guiRight instanceof GuiTextField)
{
this.allTextFieldGuis.add((GuiTextField)guiRight);
}
}
}
}
}
private void resetRows()
{
this.allRows.clear();
for (int i = 0; i < this.pages[this.currentPageNum].length; i += 2)
{
GuiBOPConfigPage.GuiListEntry guilistentryLeft = this.pages[this.currentPageNum][i];
GuiBOPConfigPage.GuiListEntry guilistentryRight = i < this.pages[this.currentPageNum].length - 1 ? this.pages[this.currentPageNum][i + 1] : null;
Gui guiLeft = (Gui)this.fieldIdToGuiMap.get(guilistentryLeft.getFieldId());
Gui guiRight = guilistentryRight != null ? (Gui)this.fieldIdToGuiMap.get(guilistentryRight.getFieldId()) : null;
GuiBOPConfigPage.GuiEntry guientry = new GuiBOPConfigPage.GuiEntry(guiLeft, guiRight);
this.allRows.add(guientry);
}
}
public int getCurrentPageNum()
{
return this.currentPageNum;
}
public int getNumPages()
{
return this.pages.length;
}
public Gui func_178056_g()
{
return this.field_178075_A;
}
public void gotToPrevPage()
{
if (this.currentPageNum > 0)
{
int oldPageNum = this.currentPageNum--;
this.resetRows();
this.swapPage(oldPageNum, this.currentPageNum);
this.amountScrolled = 0.0F;
}
}
public void goToNextPage()
{
if (this.currentPageNum < this.pages.length - 1)
{
int oldPageNum = this.currentPageNum++;
this.resetRows();
this.swapPage(oldPageNum, this.currentPageNum);
this.amountScrolled = 0.0F;
}
}
public Gui getGui(int fieldId)
{
return (Gui)this.fieldIdToGuiMap.get(fieldId);
}
private void swapPage(int oldPageNum, int newPageNum)
{
for (GuiBOPConfigPage.GuiListEntry field : this.pages[oldPageNum])
{
if (field != null)
{
Gui gui = this.fieldIdToGuiMap.get(field.getFieldId());
this.setVisible(gui, false);
}
}
for (GuiBOPConfigPage.GuiListEntry field : this.pages[newPageNum])
{
if (field != null)
{
Gui gui = this.fieldIdToGuiMap.get(field.getFieldId());
this.setVisible(gui, true);
}
}
}
private void setVisible(Gui gui, boolean isVisible)
{
if (gui instanceof GuiButton)
{
((GuiButton)gui).visible = isVisible;
}
else if (gui instanceof GuiTextField)
{
((GuiTextField)gui).setVisible(isVisible);
}
else if (gui instanceof GuiLabel)
{
((GuiLabel)gui).visible = isVisible;
}
}
private Gui createGui(GuiBOPConfigPage.GuiListEntry field, int xOffset, boolean hasNoNeighbor)
{
if (field instanceof GuiBOPConfigPage.GuiSlideEntry)
{
return (Gui)this.createSlider(this.width / 2 - 155 + xOffset, 0, (GuiBOPConfigPage.GuiSlideEntry)field);
}
else if (field instanceof GuiBOPConfigPage.GuiButtonEntry)
{
return (Gui)this.createListButton(this.width / 2 - 155 + xOffset, 0, (GuiBOPConfigPage.GuiButtonEntry)field);
}
else if (field instanceof GuiBOPConfigPage.EditBoxEntry)
{
return (Gui)this.createTextField(this.width / 2 - 155 + xOffset, 0, (GuiBOPConfigPage.EditBoxEntry)field);
}
else if (field instanceof GuiBOPConfigPage.GuiLabelEntry)
{
return (Gui)this.createLabel(this.width / 2 - 155 + xOffset, 0, (GuiBOPConfigPage.GuiLabelEntry)field, hasNoNeighbor);
}
else if (field instanceof GuiBOPConfigPage.GuiEnumButtonEntry)
{
return (Gui)this.createEnumButton(this.width / 2 - 155 + xOffset, 0, (GuiBOPConfigPage.GuiEnumButtonEntry)field);
}
else
{
return null;
}
}
@Override
public boolean mouseClicked(int mouseX, int mouseY, int mouseEvent)
{
boolean flag = super.mouseClicked(mouseX, mouseY, mouseEvent);
int l = this.getSlotIndexFromScreenCoords(mouseX, mouseY);
if (l >= 0)
{
GuiBOPConfigPage.GuiEntry row = this.getRow(l);
if (this.field_178075_A != row.focusedGui && this.field_178075_A != null && this.field_178075_A instanceof GuiTextField)
{
((GuiTextField)this.field_178075_A).setFocused(false);
}
this.field_178075_A = row.focusedGui;
}
return flag;
}
private GuiSlider createSlider(int xPosition, int yPosition, GuiBOPConfigPage.GuiSlideEntry field)
{
GuiSlider guislider = new GuiSlider(this.responder, field.getFieldId(), xPosition, yPosition, field.getLabelText(), field.getMin(), field.getMax(), field.getValue(), field.getFormatHelper());
guislider.visible = field.isVisible();
return guislider;
}
private GuiListButton createListButton(int xPosition, int yPosition, GuiBOPConfigPage.GuiButtonEntry field)
{
GuiListButton guilistbutton = new GuiListButton(this.responder, field.getFieldId(), xPosition, yPosition, field.getLabelText(), field.getValue());
guilistbutton.visible = field.isVisible();
return guilistbutton;
}
private GuiEnumButton createEnumButton(int xPosition, int yPosition, GuiBOPConfigPage.GuiEnumButtonEntry field)
{
GuiEnumButton guienumbutton = new GuiEnumButton(this.responder, field.getFieldId(), xPosition, yPosition, field.getLabelText(), field.getValue());
guienumbutton.visible = field.isVisible();
return guienumbutton;
}
private GuiTextField createTextField(int xPosition, int yPosition, GuiBOPConfigPage.EditBoxEntry field)
{
GuiTextField guitextfield = new GuiTextField(field.getFieldId(), this.mc.fontRendererObj, xPosition, yPosition, 150, 20);
guitextfield.setText(field.getLabelText());
guitextfield.func_175207_a(this.responder); // setResponder
guitextfield.setVisible(field.isVisible());
guitextfield.func_175205_a(field.getValidator()); // setValidator
return guitextfield;
}
private GuiLabel createLabel(int xPosition, int yPosition, GuiBOPConfigPage.GuiLabelEntry field, boolean hasNoNeighbor)
{
GuiLabel guilabel;
if (hasNoNeighbor)
{
guilabel = new GuiLabel(this.mc.fontRendererObj, field.getFieldId(), xPosition, yPosition, this.width - xPosition * 2, 20, -1);
}
else
{
guilabel = new GuiLabel(this.mc.fontRendererObj, field.getFieldId(), xPosition, yPosition, 150, 20, -1);
}
guilabel.visible = field.isVisible();
guilabel.func_175202_a(field.getLabelText()); // setText
guilabel.setCentered();
return guilabel;
}
public void func_178062_a(char p_178062_1_, int p_178062_2_)
{
if (this.field_178075_A instanceof GuiTextField)
{
GuiTextField guitextfield = (GuiTextField)this.field_178075_A;
int j;
if (!GuiScreen.isKeyComboCtrlV(p_178062_2_))
{
if (p_178062_2_ == 15)
{
guitextfield.setFocused(false);
int j1 = this.allTextFieldGuis.indexOf(this.field_178075_A);
if (GuiScreen.isShiftKeyDown())
{
if (j1 == 0)
{
j1 = this.allTextFieldGuis.size() - 1;
}
else
{
--j1;
}
}
else if (j1 == this.allTextFieldGuis.size() - 1)
{
j1 = 0;
}
else
{
++j1;
}
this.field_178075_A = (Gui)this.allTextFieldGuis.get(j1);
guitextfield = (GuiTextField)this.field_178075_A;
guitextfield.setFocused(true);
int k1 = guitextfield.yPosition + this.slotHeight;
j = guitextfield.yPosition;
if (k1 > this.bottom)
{
this.amountScrolled += (float)(k1 - this.bottom);
}
else if (j < this.top)
{
this.amountScrolled = (float)j;
}
}
else
{
guitextfield.textboxKeyTyped(p_178062_1_, p_178062_2_);
}
}
else
{
String s = GuiScreen.getClipboardString();
String[] astring = s.split(";");
j = this.allTextFieldGuis.indexOf(this.field_178075_A);
int k = j;
String[] astring1 = astring;
int l = astring.length;
for (int i1 = 0; i1 < l; ++i1)
{
String s1 = astring1[i1];
((GuiTextField)this.allTextFieldGuis.get(k)).setText(s1);
if (k == this.allTextFieldGuis.size() - 1)
{
k = 0;
}
else
{
++k;
}
if (k == j)
{
break;
}
}
}
}
}
public GuiBOPConfigPage.GuiEntry getRow(int rowNum)
{
return (GuiBOPConfigPage.GuiEntry)this.allRows.get(rowNum);
}
@Override
public int getSize()
{
return this.allRows.size();
}
@Override
public int getListWidth()
{
return 400;
}
@Override
protected int getScrollBarX()
{
return super.getScrollBarX() + 32;
}
@Override
public GuiListExtended.IGuiListEntry getListEntry(int rowNum)
{
return this.getRow(rowNum);
}
@SideOnly(Side.CLIENT)
public static class EditBoxEntry extends GuiBOPConfigPage.GuiListEntry
{
private final Predicate validator;
public EditBoxEntry(int fieldId, String labelText, boolean isVisible, Predicate validator)
{
super(fieldId, labelText, isVisible);
this.validator = (Predicate)Objects.firstNonNull(validator, Predicates.alwaysTrue());
}
public Predicate getValidator()
{
return this.validator;
}
}
@SideOnly(Side.CLIENT)
public static class GuiButtonEntry extends GuiBOPConfigPage.GuiListEntry
{
private final boolean value;
public GuiButtonEntry(int fieldId, String textLabel, boolean isVisible, boolean value)
{
super(fieldId, textLabel, isVisible);
this.value = value;
}
public boolean getValue()
{
return this.value;
}
}
@SideOnly(Side.CLIENT)
public static class GuiEnumButtonEntry<T extends Enum> extends GuiBOPConfigPage.GuiListEntry
{
private final T value;
public GuiEnumButtonEntry(int fieldId, String textLabel, boolean isVisible, T value)
{
super(fieldId, textLabel, isVisible);
this.value = value;
}
public T getValue()
{
return this.value;
}
}
@SideOnly(Side.CLIENT)
public static class GuiEntry implements GuiListExtended.IGuiListEntry
{
private final Minecraft minecraft = Minecraft.getMinecraft();
private final Gui guiLeft;
private final Gui guiRight;
private Gui focusedGui;
public GuiEntry(Gui guiLeft, Gui guiRight)
{
this.guiLeft = guiLeft;
this.guiRight = guiRight;
}
public Gui getGuiLeft()
{
return this.guiLeft;
}
public Gui getGuiRight()
{
return this.guiRight;
}
@Override
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isVisible)
{
this.drawGui(this.guiLeft, y, mouseX, mouseY, false);
this.drawGui(this.guiRight, y, mouseX, mouseY, false);
}
private void drawGui(Gui gui, int y, int mouseX, int mouseY, boolean isVisible)
{
if (gui != null)
{
if (gui instanceof GuiButton)
{
this.drawGuiButton((GuiButton)gui, y, mouseX, mouseY, isVisible);
}
else if (gui instanceof GuiTextField)
{
this.drawGuiTextField((GuiTextField)gui, y, isVisible);
}
else if (gui instanceof GuiLabel)
{
this.drawGuiLabel((GuiLabel)gui, y, mouseX, mouseY, isVisible);
}
}
}
private void drawGuiButton(GuiButton guiButton, int y, int mouseX, int mouseY, boolean isVisible)
{
guiButton.yPosition = y;
if (!isVisible)
{
guiButton.drawButton(this.minecraft, mouseX, mouseY);
}
}
private void drawGuiTextField(GuiTextField guiTextField, int y, boolean isVisible)
{
guiTextField.yPosition = y;
if (!isVisible)
{
guiTextField.drawTextBox();
}
}
private void drawGuiLabel(GuiLabel guiLabel, int y, int mouseX, int mouseY, boolean isVisible)
{
guiLabel.field_146174_h = y;
if (!isVisible)
{
guiLabel.drawLabel(this.minecraft, mouseX, mouseY);
}
}
@Override
public void setSelected(int p_178011_1_, int p_178011_2_, int p_178011_3_)
{
this.drawGui(this.guiLeft, p_178011_3_, 0, 0, true);
this.drawGui(this.guiRight, p_178011_3_, 0, 0, true);
}
@Override
public boolean mousePressed(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
return this.doMousePressed(this.guiLeft, x, y, mouseEvent) || this.doMousePressed(this.guiRight, x, y, mouseEvent);
}
private boolean doMousePressed(Gui gui, int x, int y, int mouseEvent)
{
if (gui == null)
{
return false;
}
else if (gui instanceof GuiButton)
{
if (((GuiButton)gui).mousePressed(this.minecraft, x, y))
{
this.focusedGui = gui;
return true;
}
else
{
return false;
}
}
else if (gui instanceof GuiTextField)
{
((GuiTextField)gui).mouseClicked(x, y, mouseEvent);
if (((GuiTextField)gui).isFocused())
{
this.focusedGui = gui;
}
return false;
}
return false;
}
@Override
public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY)
{
this.doMouseReleased(this.guiLeft, x, y);
this.doMouseReleased(this.guiRight, x, y);
}
public void doMouseReleased(Gui gui, int x, int y)
{
if (gui != null && (gui instanceof GuiButton))
{
((GuiButton)gui).mouseReleased(x, y);
}
}
}
@SideOnly(Side.CLIENT)
public static class GuiLabelEntry extends GuiBOPConfigPage.GuiListEntry
{
public GuiLabelEntry(int fieldId, String labelText, boolean isVisible)
{
super(fieldId, labelText, isVisible);
}
}
@SideOnly(Side.CLIENT)
public static class GuiListEntry
{
private final int fieldID;
private final String labelText;
private final boolean isVisible;
public GuiListEntry(int fieldId, String labelText, boolean isVisible)
{
this.fieldID = fieldId;
this.labelText = labelText;
this.isVisible = isVisible;
}
public int getFieldId()
{
return this.fieldID;
}
public String getLabelText()
{
return this.labelText;
}
public boolean isVisible()
{
return this.isVisible;
}
}
@SideOnly(Side.CLIENT)
public interface GuiResponder extends GuiPageButtonList.GuiResponder
{
void handleEnumSelection(int fieldId, int ordinal);
void handleBooleanSelection(int fieldId, boolean value);
void handleFloatSelection(int fieldId, float value);
void handleStringSelection(int fieldId, String value);
void handleIntSelection(int fieldId, int value);
}
@SideOnly(Side.CLIENT)
public static class GuiSlideEntry extends GuiBOPConfigPage.GuiListEntry
{
private final GuiSlider.FormatHelper formatHelper;
private final float min;
private final float max;
private final float value;
public GuiSlideEntry(int fieldId, String labelText, boolean isVisible, GuiSlider.FormatHelper formatHelper, float min, float max, float value)
{
super(fieldId, labelText, isVisible);
this.formatHelper = formatHelper;
this.min = min;
this.max = max;
this.value = value;
}
public GuiSlider.FormatHelper getFormatHelper()
{
return this.formatHelper;
}
public float getMin()
{
return this.min;
}
public float getMax()
{
return this.max;
}
public float getValue()
{
return this.value;
}
}
}

View file

@ -0,0 +1,539 @@
package biomesoplenty.client.gui;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.BOPWorldSettings.TemperatureVariationScheme;
import biomesoplenty.common.world.BOPWorldSettings.BiomeSize;
import com.google.common.base.Predicate;
import com.google.common.primitives.Floats;
import java.io.IOException;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.client.gui.GuiListButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiSlider;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiBOPConfigureWorld extends GuiScreen implements GuiSlider.FormatHelper, GuiBOPConfigPage.GuiResponder
{
private GuiCreateWorld parentScreen;
protected String screenTitle = "Customize World Settings";
protected String pageInfo = "Page 1 of 3";
protected String page0Title = "Basic Settings";
protected String[] pageNames;
private GuiBOPConfigPage pages;
private GuiButton doneButton;
private GuiButton defaultsButton;
private GuiButton prevButton;
private GuiButton nextButton;
private GuiButton yesButton;
private GuiButton noButton;
private int modalAction = 0;
private boolean field_175340_C = false;
private Predicate validFloatPredicate = new Predicate()
{
public boolean tryParseValidFloat(String p_178956_1_)
{
Float f = Floats.tryParse(p_178956_1_);
return p_178956_1_.length() == 0 || f != null && Floats.isFinite(f.floatValue()) && f.floatValue() >= 0.0F;
}
@Override
public boolean apply(Object p_apply_1_)
{
return this.tryParseValidFloat((String)p_apply_1_);
}
};
private BOPWorldSettings settings;
public GuiBOPConfigureWorld(GuiScreen parentScreen, String settingsStringIn)
{
this.parentScreen = (GuiCreateWorld)parentScreen;
this.settings = new BOPWorldSettings();
if (settingsStringIn.isEmpty())
{
this.settings.setDefault();
} else {
this.settings.fromJson(settingsStringIn);
}
}
private static enum Actions
{
PREVIOUS (301),
NEXT (302),
DEFAULTS (303),
DONE (304),
YES (305),
NO (306);
private int id;
private Actions(int id)
{
this.id = id;
}
public int getId()
{
return this.id;
}
public static Actions fromId(int id)
{
for (Actions action : Actions.values())
{
if (action.id == id)
{
return action;
}
}
return null;
}
}
@Override
public void initGui()
{
this.screenTitle = I18n.format("options.customizeTitle", new Object[0]);
this.buttonList.clear();
this.buttonList.add(this.prevButton = new GuiButton(Actions.PREVIOUS.getId(), 20, 5, 80, 20, I18n.format("createWorld.customize.custom.prev", new Object[0])));
this.buttonList.add(this.nextButton = new GuiButton(Actions.NEXT.getId(), this.width - 100, 5, 80, 20, I18n.format("createWorld.customize.custom.next", new Object[0])));
this.buttonList.add(this.defaultsButton = new GuiButton(Actions.DEFAULTS.getId(), this.width / 2 - 187, this.height - 27, 90, 20, I18n.format("createWorld.customize.custom.defaults", new Object[0])));
this.buttonList.add(this.doneButton = new GuiButton(Actions.DONE.getId(), this.width / 2 + 98, this.height - 27, 90, 20, I18n.format("gui.done", new Object[0])));
this.yesButton = new GuiButton(Actions.YES.getId(), this.width / 2 - 55, 160, 50, 20, I18n.format("gui.yes", new Object[0]));
this.yesButton.visible = false;
this.buttonList.add(this.yesButton);
this.noButton = new GuiButton(Actions.NO.getId(), this.width / 2 + 5, 160, 50, 20, I18n.format("gui.no", new Object[0]));
this.noButton.visible = false;
this.buttonList.add(this.noButton);
this.setupPages();
}
@Override
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
this.pages.handleMouseInput();
}
private static enum GuiEntries
{
TEMP_SCHEME (101),
GENERATE_BOP_GEMS (102),
AMPLITUDE_LABEL(103),
AMPLITUDE (104),
BIOME_SIZE (105);
private int id;
private GuiEntries(int id)
{
this.id = id;
}
public int getId()
{
return this.id;
}
public static GuiEntries fromId(int id)
{
for (GuiEntries entry : GuiEntries.values())
{
if (entry.id == id)
{
return entry;
}
}
return null;
}
}
private void setupPages()
{
this.pageNames = new String[3];
this.pageNames[0] = "World";
GuiBOPConfigPage.GuiListEntry[] page0 = new GuiBOPConfigPage.GuiListEntry[] {
new GuiBOPConfigPage.GuiEnumButtonEntry<BiomeSize>(GuiEntries.BIOME_SIZE.getId(), "Biome Size: %s", true, this.settings.biomeSize),
new GuiBOPConfigPage.GuiEnumButtonEntry<TemperatureVariationScheme>(GuiEntries.TEMP_SCHEME.getId(), "Temperature: %s", true, this.settings.tempScheme),
new GuiBOPConfigPage.GuiSlideEntry(GuiEntries.AMPLITUDE.getId(), "Amplitude", true, this, 0.2F, 3.0F, this.settings.amplitude)
};
this.pageNames[1] = "Biomes";
GuiBOPConfigPage.GuiListEntry[] page1 = new GuiBOPConfigPage.GuiListEntry[] {
};
this.pageNames[2] = "Features";
GuiBOPConfigPage.GuiListEntry[] page2 = new GuiBOPConfigPage.GuiListEntry[] {
new GuiBOPConfigPage.GuiButtonEntry(GuiEntries.GENERATE_BOP_GEMS.getId(), "Generate BOP gems", true, this.settings.generateBopGems)
};
this.pages = new GuiBOPConfigPage(this.mc, this.width, this.height, 32, this.height - 32, 25, this, new GuiBOPConfigPage.GuiListEntry[][] {page0, page1, page2});
this.showNewPage();
}
public String serialize()
{
return this.settings.toString().replace("\n", "");
}
@Override
public String func_175318_a(int p_175318_1_, String p_175318_2_, float p_175318_3_)
{
return p_175318_2_ + ": " + this.stringFormatFloat(p_175318_1_, p_175318_3_);
}
private String stringFormatFloat(int fieldId, float value)
{
GuiEntries entry = GuiEntries.fromId(fieldId);
if (entry == null) {return "";}
switch (entry)
{
case AMPLITUDE:
return String.format("%5.3f", new Object[] {Float.valueOf(value)});
default:
return "";
}
}
@Override
public void handleEnumSelection(int fieldId, int ordinal)
{
GuiEntries entry = GuiEntries.fromId(fieldId);
if (entry == null) {return;}
switch (entry)
{
case TEMP_SCHEME:
TemperatureVariationScheme[] temp_values = TemperatureVariationScheme.values();
this.settings.tempScheme = temp_values[ordinal % temp_values.length];
break;
case BIOME_SIZE:
BiomeSize[] size_values = BiomeSize.values();
this.settings.biomeSize = size_values[ordinal % size_values.length];
break;
default:
break;
}
System.out.println("settings currently: "+this.settings.toJson());
}
@Override
public void handleBooleanSelection(int fieldId, boolean value)
{
GuiEntries entry = GuiEntries.fromId(fieldId);
if (entry == null) {return;}
switch (entry)
{
case GENERATE_BOP_GEMS:
this.settings.generateBopGems = value;
break;
default:
break;
}
System.out.println("settings currently: "+this.settings.toJson());
}
@Override
public void handleFloatSelection(int fieldId, float value)
{
GuiEntries entry = GuiEntries.fromId(fieldId);
if (entry == null) {return;}
switch (entry)
{
case AMPLITUDE:
this.settings.amplitude = value;
break;
default:
break;
}
System.out.println("settings currently: "+this.settings.toJson());
}
@Override
public void handleStringSelection(int fieldId, String value)
{
;
}
@Override
public void handleIntSelection(int fieldId, int value)
{
;
}
// These 3 are the original functions required by GuiPageButtonList.GuiResponder - just pass off to the better named functions
@Override
public void func_175319_a(int fieldId, String value) {this.handleStringSelection(fieldId, value);}
@Override
public void func_175320_a(int fieldId, float value) {this.handleFloatSelection(fieldId, value);}
@Override
public void func_175321_a(int fieldId, boolean value) {this.handleBooleanSelection(fieldId, value);}
@Override
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
Actions action = Actions.fromId(button.id);
if (action == null) {return;}
switch (action)
{
case DONE:
this.parentScreen.chunkProviderSettingsJson = this.settings.toJson();
System.out.println("settings sent to world screen "+this.parentScreen.chunkProviderSettingsJson);
this.mc.displayGuiScreen(this.parentScreen);
break;
case PREVIOUS:
this.pages.gotToPrevPage(); // prev page
this.showNewPage();
break;
case NEXT:
this.pages.goToNextPage(); // next page
this.showNewPage();
break;
case DEFAULTS:
this.confirmSetDefaults(button.id);
break;
case YES:
this.handleModalClose();
break;
case NO:
this.modalAction = 0;
this.handleModalClose();
}
}
}
private void doSetDefaults()
{
this.settings.setDefault();
this.setupPages();
}
private void confirmSetDefaults(int actionId)
{
this.modalAction = actionId;
this.showModal(true);
}
private void handleModalClose() throws IOException
{
Actions action = Actions.fromId(this.modalAction);
if (action != null) {
switch (action)
{
case DONE:
this.actionPerformed((GuiListButton)this.pages.getGui(300));
break;
case DEFAULTS:
this.doSetDefaults();
break;
default:
break;
}
}
this.modalAction = 0;
this.field_175340_C = true;
this.showModal(false);
}
private void showModal(boolean flag)
{
this.yesButton.visible = flag;
this.noButton.visible = flag;
this.doneButton.enabled = !flag;
this.prevButton.enabled = !flag;
this.nextButton.enabled = !flag;
this.defaultsButton.enabled = !flag;
}
private void showNewPage()
{
this.prevButton.enabled = this.pages.getCurrentPageNum() != 0;
this.nextButton.enabled = this.pages.getCurrentPageNum() != this.pages.getNumPages() - 1;
this.pageInfo = I18n.format("book.pageIndicator", new Object[] {Integer.valueOf(this.pages.getCurrentPageNum() + 1), Integer.valueOf(this.pages.getNumPages())});
this.page0Title = this.pageNames[this.pages.getCurrentPageNum()];
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
super.keyTyped(typedChar, keyCode);
if (this.modalAction == 0)
{
switch (keyCode)
{
case 200:
this.func_175327_a(1.0F);
break;
case 208:
this.func_175327_a(-1.0F);
break;
default:
this.pages.func_178062_a(typedChar, keyCode);
}
}
}
private void func_175327_a(float p_175327_1_)
{
Gui gui = this.pages.func_178056_g();
if (gui instanceof GuiTextField)
{
float f1 = p_175327_1_;
if (GuiScreen.isShiftKeyDown())
{
f1 = p_175327_1_ * 0.1F;
if (GuiScreen.isCtrlKeyDown())
{
f1 *= 0.1F;
}
}
else if (GuiScreen.isCtrlKeyDown())
{
f1 = p_175327_1_ * 10.0F;
if (GuiScreen.isAltKeyDown())
{
f1 *= 10.0F;
}
}
GuiTextField guitextfield = (GuiTextField)gui;
Float f2 = Floats.tryParse(guitextfield.getText());
if (f2 != null)
{
f2 = Float.valueOf(f2.floatValue() + f1);
int i = guitextfield.getId();
String s = this.stringFormatFloat(guitextfield.getId(), f2.floatValue());
guitextfield.setText(s);
this.func_175319_a(i, s);
}
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
super.mouseClicked(mouseX, mouseY, mouseButton);
if (this.modalAction == 0 && !this.field_175340_C)
{
this.pages.mouseClicked(mouseX, mouseY, mouseButton);
}
}
@Override
protected void mouseReleased(int mouseX, int mouseY, int state)
{
super.mouseReleased(mouseX, mouseY, state);
if (this.field_175340_C)
{
this.field_175340_C = false;
}
else if (this.modalAction == 0)
{
this.pages.mouseReleased(mouseX, mouseY, state);
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
this.pages.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 2, 16777215);
this.drawCenteredString(this.fontRendererObj, this.pageInfo, this.width / 2, 12, 16777215);
this.drawCenteredString(this.fontRendererObj, this.page0Title, this.width / 2, 22, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
if (this.modalAction != 0)
{
drawRect(0, 0, this.width, this.height, Integer.MIN_VALUE);
this.drawHorizontalLine(this.width / 2 - 91, this.width / 2 + 90, 99, -2039584);
this.drawHorizontalLine(this.width / 2 - 91, this.width / 2 + 90, 185, -6250336);
this.drawVerticalLine(this.width / 2 - 91, 99, 185, -2039584);
this.drawVerticalLine(this.width / 2 + 90, 99, 185, -6250336);
GlStateManager.disableLighting();
GlStateManager.disableFog();
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
this.mc.getTextureManager().bindTexture(optionsBackground);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
worldrenderer.startDrawingQuads();
worldrenderer.setColorOpaque_I(4210752);
worldrenderer.addVertexWithUV((double)(this.width / 2 - 90), 185.0D, 0.0D, 0.0D, 2.65625D);
worldrenderer.addVertexWithUV((double)(this.width / 2 + 90), 185.0D, 0.0D, 5.625D, 2.65625D);
worldrenderer.addVertexWithUV((double)(this.width / 2 + 90), 100.0D, 0.0D, 5.625D, 0.0D);
worldrenderer.addVertexWithUV((double)(this.width / 2 - 90), 100.0D, 0.0D, 0.0D, 0.0D);
tessellator.draw();
this.drawCenteredString(this.fontRendererObj, I18n.format("createWorld.customize.custom.confirmTitle", new Object[0]), this.width / 2, 105, 16777215);
this.drawCenteredString(this.fontRendererObj, I18n.format("createWorld.customize.custom.confirm1", new Object[0]), this.width / 2, 125, 16777215);
this.drawCenteredString(this.fontRendererObj, I18n.format("createWorld.customize.custom.confirm2", new Object[0]), this.width / 2, 135, 16777215);
this.yesButton.drawButton(this.mc, mouseX, mouseY);
this.noButton.drawButton(this.mc, mouseX, mouseY);
}
}
}

View file

@ -0,0 +1,54 @@
package biomesoplenty.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiEnumButton<T extends Enum> extends GuiButton
{
private T value;
private String localizationStr;
private final GuiBOPConfigPage.GuiResponder guiResponder;
public GuiEnumButton(GuiBOPConfigPage.GuiResponder responder, int fieldId, int x, int y, String localizationStr, T initialValue)
{
super(fieldId, x, y, 150, 20, "");
this.localizationStr = localizationStr;
this.value = initialValue;
this.displayString = this.buildDisplayString();
this.guiResponder = responder;
}
private String buildDisplayString()
{
return I18n.format(this.localizationStr, new Object[] {this.value.toString()});
}
public void setValue(T value)
{
this.value = value;
this.displayString = this.buildDisplayString();
this.guiResponder.handleEnumSelection(this.id, value.ordinal());
}
@Override
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY)
{
if (super.mousePressed(mc, mouseX, mouseY))
{
Object[] values = this.value.getClass().getEnumConstants();
int len = values.length;
this.value = (T)(values[(this.value.ordinal() + 1) % len]);
this.displayString = this.buildDisplayString();
this.guiResponder.handleEnumSelection(this.id, this.value.ordinal());
return true;
}
else
{
return false;
}
}
}

View file

@ -12,6 +12,7 @@ import net.minecraft.init.Blocks;
import net.minecraftforge.common.BiomeManager.BiomeType; import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.api.biome.BOPBiome; import biomesoplenty.api.biome.BOPBiome;
import biomesoplenty.api.biome.generation.GeneratorStage; import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
public class BiomeGenAlps extends BOPBiome public class BiomeGenAlps extends BOPBiome
@ -40,4 +41,10 @@ public class BiomeGenAlps extends BOPBiome
this.addGenerator("emeralds", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(Blocks.emerald_ore.getDefaultState()).create()); this.addGenerator("emeralds", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(Blocks.emerald_ore.getDefaultState()).create());
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("emeralds");}
}
} }

View file

@ -13,6 +13,7 @@ import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.api.biome.BOPBiome; import biomesoplenty.api.biome.BOPBiome;
import biomesoplenty.api.biome.generation.GeneratorStage; import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
public class BiomeGenArctic extends BOPBiome public class BiomeGenArctic extends BOPBiome
@ -35,6 +36,12 @@ public class BiomeGenArctic extends BOPBiome
this.addGenerator("tanzanite", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.TANZANITE).create()); this.addGenerator("tanzanite", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.TANZANITE).create());
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("tanzanite");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -31,6 +31,7 @@ import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.enums.BOPTrees; import biomesoplenty.common.enums.BOPTrees;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import biomesoplenty.common.util.config.BOPConfig.IConfigObj;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorColumns; import biomesoplenty.common.world.feature.GeneratorColumns;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
@ -99,6 +100,12 @@ public class BiomeGenBambooForest extends BOPBiome
this.alternateTopBlock = conf.getBlockState("alternateTopBlock", this.alternateTopBlock); this.alternateTopBlock = conf.getBlockState("alternateTopBlock", this.alternateTopBlock);
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("topaz");}
}
@Override @Override
public void genTerrainBlocks(World world, Random rand, ChunkPrimer primer, int x, int z, double noise) public void genTerrainBlocks(World world, Random rand, ChunkPrimer primer, int x, int z, double noise)
{ {

View file

@ -29,6 +29,7 @@ import biomesoplenty.common.enums.BOPWoods;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.util.block.BlockQuery; import biomesoplenty.common.util.block.BlockQuery;
import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery; import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorColumns; import biomesoplenty.common.world.feature.GeneratorColumns;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
@ -106,6 +107,12 @@ public class BiomeGenBayou extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("malachite");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -29,6 +29,7 @@ import biomesoplenty.common.block.BlockBOPPlant;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorColumns; import biomesoplenty.common.world.feature.GeneratorColumns;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -105,6 +106,12 @@ public class BiomeGenBog extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("malachite");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -15,6 +15,7 @@ import biomesoplenty.common.block.BlockBOPLilypad;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.enums.BOPTrees; import biomesoplenty.common.enums.BOPTrees;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -78,6 +79,12 @@ public class BiomeGenBorealForest extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("amber");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -14,6 +14,7 @@ import biomesoplenty.common.block.BlockBOPSand;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
@ -65,6 +66,12 @@ public class BiomeGenBrushland extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("ruby");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -14,6 +14,7 @@ import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.block.BlockQuery; import biomesoplenty.common.util.block.BlockQuery;
import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery; import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
@ -80,6 +81,12 @@ public class BiomeGenCanyon extends BOPBiome
this.addGenerator("ruby", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.RUBY).create()); this.addGenerator("ruby", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.RUBY).create());
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("ruby");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -20,6 +20,7 @@ import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -82,6 +83,12 @@ public class BiomeGenChaparral extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("peridot");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)

View file

@ -24,6 +24,7 @@ import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.enums.BOPTrees; import biomesoplenty.common.enums.BOPTrees;
import biomesoplenty.common.enums.BOPWoods; import biomesoplenty.common.enums.BOPWoods;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorBlobs; import biomesoplenty.common.world.feature.GeneratorBlobs;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
@ -85,6 +86,12 @@ public class BiomeGenCherryBlossomGrove extends BOPBiome
this.addGenerator("topaz", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.TOPAZ).create()); this.addGenerator("topaz", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.TOPAZ).create());
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("topaz");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -13,6 +13,7 @@ import net.minecraftforge.common.BiomeManager.BiomeType;
import biomesoplenty.api.biome.BOPBiome; import biomesoplenty.api.biome.BOPBiome;
import biomesoplenty.api.biome.generation.GeneratorStage; import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.api.block.BOPBlocks; import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
public class BiomeGenCrag extends BOPBiome public class BiomeGenCrag extends BOPBiome
@ -42,4 +43,10 @@ public class BiomeGenCrag extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("emeralds");}
}
} }

View file

@ -16,6 +16,7 @@ import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import biomesoplenty.common.util.config.BOPConfig.IConfigObj;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
@ -73,6 +74,11 @@ public class BiomeGenDenseForest extends BOPBiome
this.addGenerator("amber", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.AMBER).create()); this.addGenerator("amber", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.AMBER).create());
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("amber");}
}
@Override @Override
public void configure(IConfigObj conf) public void configure(IConfigObj conf)

View file

@ -17,6 +17,7 @@ import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.api.biome.generation.GeneratorWeighted; import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
@ -55,6 +56,12 @@ public class BiomeGenFlowerField extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("peridot");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -22,6 +22,7 @@ import biomesoplenty.common.block.BlockBOPMushroom;
import biomesoplenty.common.block.BlockBOPPlant; import biomesoplenty.common.block.BlockBOPPlant;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorColumns; import biomesoplenty.common.world.feature.GeneratorColumns;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
@ -82,4 +83,10 @@ public class BiomeGenGrassland extends BOPBiome {
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("peridot");}
}
} }

View file

@ -23,6 +23,7 @@ import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.enums.BOPTrees; import biomesoplenty.common.enums.BOPTrees;
import biomesoplenty.common.enums.BOPWoods; import biomesoplenty.common.enums.BOPWoods;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -86,6 +87,12 @@ public class BiomeGenHeathland extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("peridot");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)

View file

@ -17,6 +17,7 @@ import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.api.biome.generation.GeneratorWeighted; import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorBlobs; import biomesoplenty.common.world.feature.GeneratorBlobs;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
@ -57,4 +58,10 @@ public class BiomeGenHighland extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("peridot");}
}
} }

View file

@ -19,6 +19,7 @@ import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.api.block.BOPBlocks; import biomesoplenty.api.block.BOPBlocks;
import biomesoplenty.common.block.BlockBOPStone; import biomesoplenty.common.block.BlockBOPStone;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -70,6 +71,12 @@ public class BiomeGenJadeCliffs extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("emeralds");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -19,6 +19,7 @@ import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.enums.BOPTrees; import biomesoplenty.common.enums.BOPTrees;
import biomesoplenty.common.enums.BOPWoods; import biomesoplenty.common.enums.BOPWoods;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
@ -55,7 +56,13 @@ public class BiomeGenLavenderFields extends BOPBiome
// gem // gem
this.addGenerator("peridot", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.PERIDOT).create()); this.addGenerator("peridot", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.PERIDOT).create());
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("peridot");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)

View file

@ -24,6 +24,7 @@ import biomesoplenty.common.block.BlockBOPCoral;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -86,4 +87,10 @@ public class BiomeGenMarsh extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("malachite");}
}
} }

View file

@ -24,6 +24,7 @@ import biomesoplenty.common.enums.BOPFlowers;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.*; import biomesoplenty.common.world.feature.*;
public class BiomeGenMoor extends BOPBiome public class BiomeGenMoor extends BOPBiome
@ -83,6 +84,12 @@ public class BiomeGenMoor extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("malachite");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -32,6 +32,7 @@ import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.util.block.BlockQuery; import biomesoplenty.common.util.block.BlockQuery;
import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery; import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery;
import biomesoplenty.common.util.config.BOPConfig.IConfigObj; import biomesoplenty.common.util.config.BOPConfig.IConfigObj;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -143,7 +144,7 @@ public class BiomeGenMountain extends BOPBiome
// TODO: some flowers? // TODO: some flowers?
// gem // gem
this.addGenerator("emerald", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(Blocks.emerald_ore.getDefaultState()).create()); this.addGenerator("emeralds", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(Blocks.emerald_ore.getDefaultState()).create());
} }
@ -160,6 +161,12 @@ public class BiomeGenMountain extends BOPBiome
this.packedSnowBlock = conf.getBlockState("packedSnowBlock", this.packedSnowBlock); this.packedSnowBlock = conf.getBlockState("packedSnowBlock", this.packedSnowBlock);
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("emeralds");}
}
@Override @Override

View file

@ -20,6 +20,7 @@ import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.block.BlockQuery; import biomesoplenty.common.util.block.BlockQuery;
import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery; import biomesoplenty.common.util.block.BlockQuery.IBlockPosQuery;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.*; import biomesoplenty.common.world.feature.*;
import biomesoplenty.common.world.feature.tree.*; import biomesoplenty.common.world.feature.tree.*;
@ -72,4 +73,10 @@ public class BiomeGenOutback extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("ruby");}
}
} }

View file

@ -19,6 +19,7 @@ import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.common.block.BlockBOPDoublePlant; import biomesoplenty.common.block.BlockBOPDoublePlant;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -71,4 +72,10 @@ public class BiomeGenShrubland extends BOPBiome
// gem // gem
this.addGenerator("peridot", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.PERIDOT).create()); this.addGenerator("peridot", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.PERIDOT).create());
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("peridot");}
}
} }

View file

@ -17,6 +17,7 @@ import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.common.block.BlockBOPPlant; import biomesoplenty.common.block.BlockBOPPlant;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
@ -48,6 +49,12 @@ public class BiomeGenSteppe extends BOPBiome
this.addGenerator("ruby", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.RUBY).create()); this.addGenerator("ruby", GeneratorStage.SAND, (new GeneratorOreSingle.Builder()).amountPerChunk(12).with(BOPGems.RUBY).create());
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("ruby");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -17,6 +17,7 @@ import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.api.biome.generation.GeneratorWeighted; import biomesoplenty.api.biome.generation.GeneratorWeighted;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorOreSingle; import biomesoplenty.common.world.feature.GeneratorOreSingle;
import biomesoplenty.common.world.feature.GeneratorWaterside; import biomesoplenty.common.world.feature.GeneratorWaterside;
@ -57,6 +58,12 @@ public class BiomeGenThicket extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("amber");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -19,6 +19,7 @@ import biomesoplenty.common.enums.BOPFlowers;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod; import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorBlobs; import biomesoplenty.common.world.feature.GeneratorBlobs;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.common.world.feature.GeneratorGrass; import biomesoplenty.common.world.feature.GeneratorGrass;
@ -83,6 +84,12 @@ public class BiomeGenTundra extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("tanzanite");}
}
@Override @Override
public int getGrassColorAtPos(BlockPos pos) public int getGrassColorAtPos(BlockPos pos)
{ {

View file

@ -21,6 +21,7 @@ import biomesoplenty.common.block.BlockBOPMushroom;
import biomesoplenty.common.enums.BOPGems; import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants; import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.enums.BOPWoods; import biomesoplenty.common.enums.BOPWoods;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.feature.GeneratorBigMushroom; import biomesoplenty.common.world.feature.GeneratorBigMushroom;
import biomesoplenty.common.world.feature.GeneratorDoubleFlora; import biomesoplenty.common.world.feature.GeneratorDoubleFlora;
import biomesoplenty.common.world.feature.GeneratorFlora; import biomesoplenty.common.world.feature.GeneratorFlora;
@ -97,4 +98,10 @@ public class BiomeGenWoodland extends BOPBiome
} }
@Override
public void applySettings(BOPWorldSettings settings)
{
if (!settings.generateBopGems) {this.removeGenerator("amber");}
}
} }

View file

@ -0,0 +1,141 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.world;
import java.io.File;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import biomesoplenty.common.util.config.BOPConfig;
import biomesoplenty.core.BiomesOPlenty;
public class BOPWorldSettings
{
public static Gson serializer = new GsonBuilder().create();
public static enum TemperatureVariationScheme
{
VANILLA,
RANDOM,
LATITUDE;
}
public static enum BiomeSize
{
TINY (2),
SMALL (3),
MEDIUM (4),
LARGE (5),
HUGE (6);
private final int value;
BiomeSize(int value)
{
this.value = value;
}
public int getValue()
{
return this.value;
}
}
// BOP World properties
public TemperatureVariationScheme tempScheme = TemperatureVariationScheme.VANILLA;
public BiomeSize biomeSize = BiomeSize.MEDIUM;
public float amplitude = 1.0F;
public boolean generateBopGems = true;
// Vanilla properties - not configurable (yet) but included for consistency with vanilla ChunkProviderSettings
public int seaLevel;
public boolean useCaves;
public boolean useDungeons;
public int dungeonChance;
public boolean useStrongholds;
public boolean useVillages;
public boolean useMineShafts;
public boolean useTemples;
public boolean useMonuments;
public boolean useRavines;
public boolean useWaterLakes;
public int waterLakeChance;
public boolean useLavaLakes;
public int lavaLakeChance;
public boolean useLavaOceans;
public BOPWorldSettings()
{
this.setDefault();
}
public String toJson()
{
JsonObject obj = new JsonObject();
obj.addProperty("tempScheme", this.tempScheme.name().toLowerCase());
obj.addProperty("biomeSize", this.biomeSize.name().toLowerCase());
obj.addProperty("amplitude", this.amplitude);
obj.addProperty("generateBopOre", this.generateBopGems);
return serializer.toJson(obj);
}
public void fromJson(String jsonString)
{
this.fromConfigObj(new BOPConfig.ConfigObj(jsonString));
}
public void fromConfigObj(BOPConfig.IConfigObj worldConfig)
{
this.tempScheme = worldConfig.getEnum("tempScheme", this.tempScheme, TemperatureVariationScheme.class);
this.biomeSize = worldConfig.getEnum("biomeSize", this.biomeSize, BiomeSize.class);
this.amplitude = worldConfig.getFloat("amplitude", this.amplitude);
this.generateBopGems = worldConfig.getBool("generateBopOre", this.generateBopGems);
}
public void setDefault()
{
// BOP default values
this.tempScheme = TemperatureVariationScheme.VANILLA;
this.biomeSize = BiomeSize.MEDIUM;
this.amplitude = 1.0F;
this.generateBopGems = true;
// Vanilla default values
this.seaLevel = 63;
this.useCaves = true;
this.useDungeons = true;
this.dungeonChance = 8;
this.useStrongholds = true;
this.useVillages = true;
this.useMineShafts = true;
this.useTemples = true;
this.useMonuments = true;
this.useRavines = true;
this.useWaterLakes = true;
this.waterLakeChance = 4;
this.useLavaLakes = true;
this.lavaLakeChance = 80;
this.useLavaOceans = false;
// Allow defaults to be overridden from file
BOPConfig.IConfigObj worldConfig = new BOPConfig.ConfigFileObj(new File(BiomesOPlenty.configDirectory, "world.json"));
this.fromConfigObj(worldConfig);
}
}

View file

@ -28,7 +28,6 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderSettings;
import net.minecraft.world.gen.MapGenBase; import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.MapGenCaves; import net.minecraft.world.gen.MapGenCaves;
import net.minecraft.world.gen.MapGenRavine; import net.minecraft.world.gen.MapGenRavine;
@ -58,7 +57,7 @@ public class ChunkProviderGenerateBOP implements IChunkProvider
public NoiseGeneratorBOPByte byteNoiseGen; public NoiseGeneratorBOPByte byteNoiseGen;
private World worldObj; private World worldObj;
private final boolean mapFeaturesEnabled; private final boolean mapFeaturesEnabled;
private ChunkProviderSettings settings; private BOPWorldSettings settings;
private IBlockState seaBlockState; private IBlockState seaBlockState;
private IBlockState stoneBlockState; private IBlockState stoneBlockState;
private MapGenBase caveGenerator; private MapGenBase caveGenerator;
@ -79,15 +78,20 @@ public class ChunkProviderGenerateBOP implements IChunkProvider
public ChunkProviderGenerateBOP(World worldIn, long seed, boolean mapFeaturesEnabled, String chunkProviderSettingsString) public ChunkProviderGenerateBOP(World worldIn, long seed, boolean mapFeaturesEnabled, String chunkProviderSettingsString)
{ {
System.out.println("ChunkProviderGenerateBOP json: "+chunkProviderSettingsString);
this.worldObj = worldIn; this.worldObj = worldIn;
this.mapFeaturesEnabled = mapFeaturesEnabled; this.mapFeaturesEnabled = mapFeaturesEnabled;
this.rand = new Random(seed); this.rand = new Random(seed);
this.settings = new BOPWorldSettings();
this.settings.fromJson(chunkProviderSettingsString);
System.out.println("ChunkProviderGenerateBOP settings: "+this.settings.toJson());
// set up structure generators (overridable by forge) // set up structure generators (overridable by forge)
this.caveGenerator = TerrainGen.getModdedMapGen(new MapGenCaves(), CAVE); this.caveGenerator = TerrainGen.getModdedMapGen(new MapGenCaves(), CAVE);
this.strongholdGenerator = (MapGenStronghold)TerrainGen.getModdedMapGen(new MapGenStronghold(), STRONGHOLD); this.strongholdGenerator = (MapGenStronghold)TerrainGen.getModdedMapGen(new MapGenStronghold(), STRONGHOLD);
this. villageGenerator = (MapGenVillage)TerrainGen.getModdedMapGen(new MapGenVillage(), VILLAGE); this.villageGenerator = (MapGenVillage)TerrainGen.getModdedMapGen(new MapGenVillage(), VILLAGE);
this.mineshaftGenerator = (MapGenMineshaft)TerrainGen.getModdedMapGen(new MapGenMineshaft(), MINESHAFT); this.mineshaftGenerator = (MapGenMineshaft)TerrainGen.getModdedMapGen(new MapGenMineshaft(), MINESHAFT);
this.scatteredFeatureGenerator = (MapGenScatteredFeature)TerrainGen.getModdedMapGen(new MapGenScatteredFeature(), SCATTERED_FEATURE); this.scatteredFeatureGenerator = (MapGenScatteredFeature)TerrainGen.getModdedMapGen(new MapGenScatteredFeature(), SCATTERED_FEATURE);
this.ravineGenerator = TerrainGen.getModdedMapGen(new MapGenRavine(), RAVINE); this.ravineGenerator = TerrainGen.getModdedMapGen(new MapGenRavine(), RAVINE);
@ -105,11 +109,6 @@ public class ChunkProviderGenerateBOP implements IChunkProvider
// blockstates for stone and sea blocks // blockstates for stone and sea blocks
this.stoneBlockState = Blocks.stone.getDefaultState(); this.stoneBlockState = Blocks.stone.getDefaultState();
this.seaBlockState = Blocks.water.getDefaultState(); this.seaBlockState = Blocks.water.getDefaultState();
if (chunkProviderSettingsString != null)
{
this.settings = ChunkProviderSettings.Factory.func_177865_a(chunkProviderSettingsString).func_177864_b();
this.seaBlockState = this.settings.useLavaOceans ? Blocks.lava.getDefaultState() : Blocks.water.getDefaultState();
}
// store a TerrainSettings object for each biome // store a TerrainSettings object for each biome
this.biomeTerrainSettings = new HashMap<BiomeGenBase, TerrainSettings>(); this.biomeTerrainSettings = new HashMap<BiomeGenBase, TerrainSettings>();
@ -419,10 +418,18 @@ public class ChunkProviderGenerateBOP implements IChunkProvider
private void populateNoiseArray(int chunkX, int chunkZ) private void populateNoiseArray(int chunkX, int chunkZ)
{ {
// TODO: vanilla biomes are not hilly enough for some reason - must have got the sums a little wrong
BiomeGenBase[] biomes = this.worldObj.getWorldChunkManager().getBiomesForGeneration(null, chunkX * 4 - 2, chunkZ * 4 - 2, 10, 10); BiomeGenBase[] biomes = this.worldObj.getWorldChunkManager().getBiomesForGeneration(null, chunkX * 4 - 2, chunkZ * 4 - 2, 10, 10);
float coordinateScale = this.settings.coordinateScale; // values from vanilla
float heightScale = this.settings.heightScale; float coordinateScale = 684.412F;
float heightScale = 684.412F;
double upperLimitScale = 512.0D;
double lowerLimitScale = 512.0D;
float mainNoiseScaleX = 80.0F;
float mainNoiseScaleY = 160.0F;
float mainNoiseScaleZ = 80.0F;
int subchunkX = chunkX * 4; int subchunkX = chunkX * 4;
int subchunkY = 0; int subchunkY = 0;
@ -432,7 +439,7 @@ public class ChunkProviderGenerateBOP implements IChunkProvider
this.byteNoiseGen.generateNoise(subchunkX, subchunkZ); this.byteNoiseGen.generateNoise(subchunkX, subchunkZ);
// generate the xyz noise for the chunk // generate the xyz noise for the chunk
this.xyzBalanceNoiseArray = this.xyzBalanceNoiseGen.generateNoiseOctaves(this.xyzBalanceNoiseArray, subchunkX, subchunkY, subchunkZ, 5, 33, 5, (double)(coordinateScale / this.settings.mainNoiseScaleX), (double)(heightScale / this.settings.mainNoiseScaleY), (double)(coordinateScale / this.settings.mainNoiseScaleZ)); this.xyzBalanceNoiseArray = this.xyzBalanceNoiseGen.generateNoiseOctaves(this.xyzBalanceNoiseArray, subchunkX, subchunkY, subchunkZ, 5, 33, 5, (double)(coordinateScale / mainNoiseScaleX), (double)(heightScale / mainNoiseScaleY), (double)(coordinateScale / mainNoiseScaleZ));
this.xyzNoiseArrayA = this.xyzNoiseGenA.generateNoiseOctaves(this.xyzNoiseArrayA, subchunkX, subchunkY, subchunkZ, 5, 33, 5, (double)coordinateScale, (double)heightScale, (double)coordinateScale); this.xyzNoiseArrayA = this.xyzNoiseGenA.generateNoiseOctaves(this.xyzNoiseArrayA, subchunkX, subchunkY, subchunkZ, 5, 33, 5, (double)coordinateScale, (double)heightScale, (double)coordinateScale);
this.xyzNoiseArrayB = this.xyzNoiseGenB.generateNoiseOctaves(this.xyzNoiseArrayB, subchunkX, subchunkY, subchunkZ, 5, 33, 5, (double)coordinateScale, (double)heightScale, (double)coordinateScale); this.xyzNoiseArrayB = this.xyzNoiseGenB.generateNoiseOctaves(this.xyzNoiseArrayB, subchunkX, subchunkY, subchunkZ, 5, 33, 5, (double)coordinateScale, (double)heightScale, (double)coordinateScale);
@ -450,7 +457,7 @@ public class ChunkProviderGenerateBOP implements IChunkProvider
double sidewaysNoiseFactor = settings.sidewaysNoiseAmount * 0.4D * settings.amplitude(); double sidewaysNoiseFactor = settings.sidewaysNoiseAmount * 0.4D * settings.amplitude();
// get the scaled xz noise value // get the scaled xz noise value
double xzNoiseAmplitude = settings.amplitude() - 2.5D * sidewaysNoiseFactor; double xzNoiseAmplitude = settings.amplitude() * this.settings.amplitude - 2.5D * sidewaysNoiseFactor;
if (xzNoiseAmplitude < 0) {xzNoiseAmplitude = 0.0D;} if (xzNoiseAmplitude < 0) {xzNoiseAmplitude = 0.0D;}
double xzNoiseVal = this.byteNoiseGen.getWeightedDouble(xzCounter, settings.octaveWeights) * xzNoiseAmplitude; double xzNoiseVal = this.byteNoiseGen.getWeightedDouble(xzCounter, settings.octaveWeights) * xzNoiseAmplitude;
@ -461,8 +468,8 @@ public class ChunkProviderGenerateBOP implements IChunkProvider
{ {
// calculate the sideways noise value // calculate the sideways noise value
double xyzNoiseA = this.xyzNoiseArrayA[xyzCounter] / (double)this.settings.lowerLimitScale; double xyzNoiseA = this.xyzNoiseArrayA[xyzCounter] / lowerLimitScale;
double xyzNoiseB = this.xyzNoiseArrayB[xyzCounter] / (double)this.settings.upperLimitScale; double xyzNoiseB = this.xyzNoiseArrayB[xyzCounter] / upperLimitScale;
double balance = (this.xyzBalanceNoiseArray[xyzCounter] / 10.0D + 1.0D) / 2.0D; double balance = (this.xyzBalanceNoiseArray[xyzCounter] / 10.0D + 1.0D) / 2.0D;
double sidewaysNoiseValue = MathHelper.denormalizeClamp(xyzNoiseA, xyzNoiseB, balance) / 50.0D; double sidewaysNoiseValue = MathHelper.denormalizeClamp(xyzNoiseA, xyzNoiseB, balance) / 50.0D;

View file

@ -8,13 +8,12 @@
package biomesoplenty.common.world; package biomesoplenty.common.world;
import java.io.File; import biomesoplenty.api.biome.BOPBiome;
import biomesoplenty.common.world.BOPWorldSettings.TemperatureVariationScheme;
import biomesoplenty.common.util.config.BOPConfig;
import biomesoplenty.common.world.layer.*; import biomesoplenty.common.world.layer.*;
import biomesoplenty.core.BiomesOPlenty;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldType; import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.WorldChunkManager; import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.gen.layer.*; import net.minecraft.world.gen.layer.*;
@ -22,6 +21,7 @@ public class WorldChunkManagerBOP extends WorldChunkManager
{ {
// TODO: ability to vary landmass creation - eg continents, archipelago etc // TODO: ability to vary landmass creation - eg continents, archipelago etc
// TODO: client reported different chunkProviderSettings than the server
public WorldChunkManagerBOP(long seed, WorldType worldType, String chunkProviderSettings) public WorldChunkManagerBOP(long seed, WorldType worldType, String chunkProviderSettings)
{ {
super(); super();
@ -30,12 +30,25 @@ public class WorldChunkManagerBOP extends WorldChunkManager
throw new RuntimeException("WorldChunkManagerBOP requires a world of type WorldTypeBOP"); throw new RuntimeException("WorldChunkManagerBOP requires a world of type WorldTypeBOP");
} }
this.field_180301_f = chunkProviderSettings; // load the settings object
BOPConfig.IConfigObj worldConfig = new BOPConfig.ConfigFileObj(new File(BiomesOPlenty.configDirectory, "world.json")); BOPWorldSettings settings = new BOPWorldSettings();
settings.fromJson(chunkProviderSettings);
System.out.println("settings for world: "+settings.toJson());
GenLayer[] agenlayer = setupBOPGenLayers(seed, (WorldTypeBOP)worldType, chunkProviderSettings, worldConfig);
// loop through the biomes and apply the settings
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
{
if (biome == null) {continue;}
if (biome instanceof BOPBiome)
{
((BOPBiome)biome).applySettings(settings);
}
}
// set up all the gen layers
GenLayer[] agenlayer = setupBOPGenLayers(seed, (WorldTypeBOP)worldType, settings);
agenlayer = getModdedBiomeGenerators(worldType, seed, agenlayer); agenlayer = getModdedBiomeGenerators(worldType, seed, agenlayer);
this.genBiomes = agenlayer[0]; this.genBiomes = agenlayer[0];
this.biomeIndexLayer = agenlayer[1]; this.biomeIndexLayer = agenlayer[1];
} }
@ -59,8 +72,6 @@ public class WorldChunkManagerBOP extends WorldChunkManager
return stack; return stack;
} }
public enum TemperatureVariationScheme {VANILLA, RANDOM, LATITUDE}
// superimpose hot and cold regions an a land and sea layer // superimpose hot and cold regions an a land and sea layer
public static GenLayer addHotAndColdRegions(GenLayer landAndSea, TemperatureVariationScheme scheme, long worldSeed) public static GenLayer addHotAndColdRegions(GenLayer landAndSea, TemperatureVariationScheme scheme, long worldSeed)
{ {
@ -106,10 +117,10 @@ public class WorldChunkManagerBOP extends WorldChunkManager
return stack; return stack;
} }
public static GenLayer allocateBiomes(long worldSeed, WorldTypeBOP worldType, String chunkProviderSettingsJson, GenLayer hotAndCold, GenLayer riversAndSubBiomesInit) public static GenLayer allocateBiomes(long worldSeed, WorldTypeBOP worldType, BOPWorldSettings settings, GenLayer hotAndCold, GenLayer riversAndSubBiomesInit)
{ {
// allocate the basic biomes // allocate the basic biomes
GenLayer stack = new GenLayerBiomeBOP(200L, hotAndCold, worldType, chunkProviderSettingsJson); GenLayer stack = new GenLayerBiomeBOP(200L, hotAndCold, worldType);
stack = GenLayerZoom.magnify(1000L, stack, 2); stack = GenLayerZoom.magnify(1000L, stack, 2);
stack = new GenLayerBiomeEdgeBOP(1000L, stack); stack = new GenLayerBiomeEdgeBOP(1000L, stack);
@ -120,18 +131,17 @@ public class WorldChunkManagerBOP extends WorldChunkManager
} }
public static GenLayer[] setupBOPGenLayers(long worldSeed, WorldTypeBOP worldType, String chunkProviderSettingsJson, BOPConfig.IConfigObj conf) public static GenLayer[] setupBOPGenLayers(long worldSeed, WorldTypeBOP worldType, BOPWorldSettings settings)
{ {
int biomeSize = 4; int biomeSize = settings.biomeSize.getValue();
int riverSize = 4; int riverSize = 4;
// first few layers just create areas of land and sea, continents and islands // first few layers just create areas of land and sea, continents and islands
GenLayer mainBranch = initialLandAndSeaLayer(); GenLayer mainBranch = initialLandAndSeaLayer();
// now add hot and cold regions (and two zooms) // now add hot and cold regions (and two zooms)
TemperatureVariationScheme scheme = conf.getEnum("temperatureVariationScheme", TemperatureVariationScheme.VANILLA, TemperatureVariationScheme.class); mainBranch = addHotAndColdRegions(mainBranch, settings.tempScheme, worldSeed);
mainBranch = addHotAndColdRegions(mainBranch, scheme, worldSeed);
// add mushroom islands and deep oceans // add mushroom islands and deep oceans
mainBranch = new GenLayerAddIsland(4L, mainBranch); mainBranch = new GenLayerAddIsland(4L, mainBranch);
@ -142,7 +152,7 @@ public class WorldChunkManagerBOP extends WorldChunkManager
GenLayer riversAndSubBiomesInit = new GenLayerRiverInit(100L, mainBranch); GenLayer riversAndSubBiomesInit = new GenLayerRiverInit(100L, mainBranch);
// allocate the biomes // allocate the biomes
mainBranch = allocateBiomes(worldSeed, worldType, chunkProviderSettingsJson, mainBranch, riversAndSubBiomesInit); mainBranch = allocateBiomes(worldSeed, worldType, settings, mainBranch, riversAndSubBiomesInit);
// do a bit more zooming, depending on biomeSize // do a bit more zooming, depending on biomeSize
mainBranch = new GenLayerRareBiome(1001L, mainBranch); mainBranch = new GenLayerRareBiome(1001L, mainBranch);

View file

@ -8,10 +8,15 @@
package biomesoplenty.common.world; package biomesoplenty.common.world;
import biomesoplenty.client.gui.GuiBOPConfigureWorld;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldType; import net.minecraft.world.WorldType;
import net.minecraft.world.biome.WorldChunkManager; import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class WorldTypeBOP extends WorldType public class WorldTypeBOP extends WorldType
{ {
@ -34,4 +39,17 @@ public class WorldTypeBOP extends WorldType
return new ChunkProviderGenerateBOP(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions); return new ChunkProviderGenerateBOP(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions);
//return new ChunkProviderGenerateVanilla(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions); //return new ChunkProviderGenerateVanilla(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions);
} }
@Override
public boolean isCustomizable()
{
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void onCustomizeButton(Minecraft mc, GuiCreateWorld guiCreateWorld)
{
mc.displayGuiScreen(new GuiBOPConfigureWorld(guiCreateWorld, guiCreateWorld.chunkProviderSettingsJson));
}
} }

View file

@ -40,9 +40,9 @@ public class GenLayerBiomeBOP extends GenLayerBiome
{ {
private List<BiomeEntry>[] biomes; private List<BiomeEntry>[] biomes;
public GenLayerBiomeBOP(long seed, GenLayer parentLayer, WorldTypeBOP worldType, String chunkProviderSettings) public GenLayerBiomeBOP(long seed, GenLayer parentLayer, WorldTypeBOP worldType)
{ {
super(seed, parentLayer, worldType, chunkProviderSettings); super(seed, parentLayer, worldType, "");
// get the vanilla biomes (and their hard-coded default weights) from the vanilla GenLayerBiome class private field 'biomes' // get the vanilla biomes (and their hard-coded default weights) from the vanilla GenLayerBiome class private field 'biomes'
biomes = ReflectionHelper.getPrivateValue(GenLayerBiome.class, this, "biomes"); biomes = ReflectionHelper.getPrivateValue(GenLayerBiome.class, this, "biomes");