Skip to content
Open
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
280 changes: 255 additions & 25 deletions patches/minecraft/net/minecraft/client/gui/GuiCreateWorld.java.patch

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion patches/minecraft/net/minecraft/client/gui/GuiOptions.java.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
--- before/net/minecraft/client/gui/GuiOptions.java
+++ after/net/minecraft/client/gui/GuiOptions.java
@@ -85,7 +85,7 @@
@@ -61,7 +61,7 @@
i++;
}

- if (this.mc.world != null)
+ if (this.mc.world != null && !this.mc.player.canUseCommand(2, "gamerule"))
{
EnumDifficulty enumdifficulty = this.mc.world.getDifficulty();
this.difficultyButton = new GuiButton(
@@ -85,7 +85,8 @@
this.difficultyButton.enabled = false;
}
}
- else
+ else if (this.mc.world != null && this.mc.player.canUseCommand(2, "gamerule")) this.buttonList.add(new GuiButton(107, this.width / 2 + 5, this.height / 6 - 12, 150, 20, I18n.format("fml.world_options")));
+ else if (false) // removed realms button
{
this.buttonList
.add(
@@ -241,6 +242,11 @@
{
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(new GuiScreenOptionsSounds(this, this.settings));
+ }
+ if (button.id == 107)
+ {
+ this.mc.gameSettings.saveOptions();
+ this.mc.displayGuiScreen(new com.cleanroommc.client.gui.WorldOptionsGui(this));
}
}
}
42 changes: 42 additions & 0 deletions patches/minecraft/net/minecraft/world/WorldSettings.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--- before/net/minecraft/world/WorldSettings.java
+++ after/net/minecraft/world/WorldSettings.java
@@ -14,6 +14,7 @@
private boolean commandsAllowed;
private boolean bonusChestEnabled;
private String generatorOptions = "";
+ private EnumDifficulty difficulty = EnumDifficulty.NORMAL;

public WorldSettings(long seedIn, GameType gameType, boolean enableMapFeatures, boolean hardcoreMode, WorldType worldTypeIn)
{
@@ -24,9 +25,19 @@
this.terrainType = worldTypeIn;
}

+ public WorldSettings(long seedIn, GameType gameType, boolean enableMapFeatures, boolean hardcoreMode, WorldType worldTypeIn, EnumDifficulty difficulty)
+ {
+ this.seed = seedIn;
+ this.gameType = gameType;
+ this.mapFeaturesEnabled = enableMapFeatures;
+ this.hardcoreEnabled = hardcoreMode;
+ this.terrainType = worldTypeIn;
+ this.difficulty = difficulty;
+ }
+
public WorldSettings(WorldInfo info)
{
- this(info.getSeed(), info.getGameType(), info.isMapFeaturesEnabled(), info.isHardcoreModeEnabled(), info.getTerrainType());
+ this(info.getSeed(), info.getGameType(), info.isMapFeaturesEnabled(), info.isHardcoreModeEnabled(), info.getTerrainType(), info.getDifficulty());
}

public WorldSettings enableBonusChest()
@@ -91,5 +102,10 @@
public String getGeneratorOptions()
{
return this.generatorOptions;
+ }
+
+ public EnumDifficulty getDifficulty()
+ {
+ return this.difficulty;
}
}
23 changes: 19 additions & 4 deletions patches/minecraft/net/minecraft/world/storage/WorldInfo.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,30 @@
}
}
}
@@ -367,6 +368,7 @@
@@ -261,12 +262,13 @@
{
this.populateFromWorldSettings(settings);
this.levelName = name;
- this.difficulty = DEFAULT_DIFFICULTY;
+ this.difficulty = settings.getDifficulty();
this.initialized = false;
}

public void populateFromWorldSettings(WorldSettings settings)
{
+ this.difficulty = settings.getDifficulty();
this.randomSeed = settings.getSeed();
this.gameType = settings.getGameType();
this.mapFeaturesEnabled = settings.isMapFeaturesEnabled();
@@ -367,6 +369,7 @@
nbt.setDouble("BorderSizeLerpTarget", this.borderSizeLerpTarget);
nbt.setDouble("BorderWarningBlocks", this.borderWarningDistance);
nbt.setDouble("BorderWarningTime", this.borderWarningTime);
+ net.minecraftforge.fml.common.FMLCommonHandler.instance().getDataFixer().writeVersionData(nbt);

if (this.difficulty != null)
{
@@ -377,9 +379,10 @@
@@ -377,9 +380,10 @@
nbt.setTag("GameRules", this.gameRules.writeToNBT());
NBTTagCompound nbttagcompound1 = new NBTTagCompound();

Expand All @@ -41,15 +56,15 @@
}

nbt.setTag("DimensionData", nbttagcompound1);
@@ -709,6 +712,7 @@
@@ -709,6 +713,7 @@

public void setDifficulty(EnumDifficulty newDifficulty)
{
+ net.minecraftforge.common.ForgeHooks.onDifficultyChange(newDifficulty, this.difficulty);
this.difficulty = newDifficulty;
}

@@ -832,16 +836,47 @@
@@ -832,16 +837,47 @@
}
);
}
Expand Down
172 changes: 172 additions & 0 deletions src/main/java/com/cleanroommc/client/gui/EditGameRulesGui.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
package com.cleanroommc.client.gui;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class EditGameRulesGui extends GuiScreen implements GuiYesNoCallback {
private final GuiScreen parent;
private final boolean[] ruleStates;
private final boolean[] originalStates;
private boolean changed = false;

private static final String[] TITLES = {
"fml.death_messages.title",
"fml.mob_loot.title",
"fml.destructive_mob_actions.title",
"fml.keep_inventory.title",
"fml.spectators_generate_terrain.title",
"fml.spawn_mobs.title",
"fml.advance_time.title",
"fml.update_weather.title"
};

private static final String[] RULE_KEYS = {
"showDeathMessages",
"doMobLoot",
"mobGriefing",
"keepInventory",
"spectatorsGenerateChunks",
"doMobSpawning",
"doDaylightCycle",
"doWeatherCycle"
};

public EditGameRulesGui(GuiScreen parentIn) {
this.parent = parentIn;
this.ruleStates = new boolean[RULE_KEYS.length];
this.originalStates = new boolean[RULE_KEYS.length];
loadRulesFromWorld();
}

private void loadRulesFromWorld() {
var mc = Minecraft.getMinecraft();
if (mc.world != null) {
var gameRules = mc.world.getGameRules();
for (int i = 0; i < 8; i++) {
ruleStates[i] = gameRules.getBoolean(RULE_KEYS[i]);
originalStates[i] = ruleStates[i];
}
} else {
for (int i = 0; i < 8; i++) {
ruleStates[i] = false;
originalStates[i] = false;
}
}
}

@Override
public void initGui() {
this.buttonList.add(new GuiButton(8, this.width / 2 - 154, this.height - 26, 150,
20, I18n.format("gui.done")));
this.buttonList.add(new GuiButton(9, this.width / 2 + 4, this.height - 26, 150,
20, I18n.format("gui.cancel")));

for (int i = 0; i < 8; i++) {
int y = 30 + 24 * i;
int x = this.width / 2 + 63;
var buttonText = ruleStates[i] ? I18n.format("gui.yes") : I18n.format("gui.no");
var btn = new GuiButton(i, x, y - 6, 45, 20, buttonText);
this.buttonList.add(btn);
}
}

@Override
protected void actionPerformed(GuiButton button) {
if (!button.enabled) {
return;
}

switch (button.id) {
case 8 -> {
applyChanges();
this.mc.displayGuiScreen(this.parent);
}
case 9 -> onCancel();
default -> {
int index = button.id;
ruleStates[index] = !ruleStates[index];
button.displayString = ruleStates[index] ? I18n.format("gui.yes") : I18n.format("gui.no");
boolean anyChanged = false;
for (int i = 0; i < 8; i++) {
if (ruleStates[i] != originalStates[i]) {
anyChanged = true;
break;
}
}
setChanged(anyChanged);
}
}
}

private void applyChanges() {
var mc = Minecraft.getMinecraft();
for (int i = 0; i < 8; i++) {
if (ruleStates[i] != originalStates[i]) {
var command = String.format("/gamerule %s %s", RULE_KEYS[i], ruleStates[i]);
mc.player.sendChatMessage(command);
if (mc.world != null) {
mc.world.getGameRules().setOrCreateGameRule(RULE_KEYS[i], Boolean.toString(ruleStates[i]));
}
}
}
System.arraycopy(ruleStates, 0, originalStates, 0, ruleStates.length);
setChanged(false);
}

@Override
protected void keyTyped(char typedChar, int keyCode) throws java.io.IOException {
if (keyCode == 1) {
onCancel();
} else {
super.keyTyped(typedChar, keyCode);
}
}

private void onCancel() {
if (isChange()) {
this.mc.displayGuiScreen(new GuiYesNo(this,
I18n.format("fml.game_rule_changes.title"),
I18n.format("fml.abandon_game_rule_changes"),
0));
} else {
this.mc.displayGuiScreen(this.parent);
}
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("fml.edit_game_rules.title"),
this.width / 2, 4, 0xFFFFFF);

for (int i = 0; i < 8; i++) {
int y = 30 + 24 * i;
this.drawCenteredString(this.fontRenderer, I18n.format(TITLES[i]), this.width / 2 - 65, y, 0xFFFFFF);
}
super.drawScreen(mouseX, mouseY, partialTicks);
}

public boolean isChange() {
return changed;
}

public void setChanged(boolean changed) {
this.changed = changed;
}

@Override
public void confirmClicked(boolean result, int id) {
if (result) {
this.mc.displayGuiScreen(this.parent);
} else {
this.mc.displayGuiScreen(this);
}
}
}
95 changes: 95 additions & 0 deletions src/main/java/com/cleanroommc/client/gui/RestrictionsGui.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.cleanroommc.client.gui;

import java.io.IOException;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScreenChatOptions;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer.EnumChatVisibility;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RestrictionsGui extends GuiScreen {
private final GuiScreen parent;

public RestrictionsGui(GuiScreen parentIn) {
this.parent = parentIn;
}

@Override
public void initGui() {
if (this.mc.gameSettings.chatVisibility != EnumChatVisibility.FULL) {
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, 80, I18n.format("fml.chat_settings_screen")));
}
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height - 26, I18n.format("gui.done")));
}

@Override
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
switch (button.id) {
case 0 -> this.mc.displayGuiScreen(new ScreenChatOptions(this.parent, this.mc.gameSettings));
case 1 -> this.mc.displayGuiScreen(this.parent);
}
}
}

@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
if (keyCode == 1) {
this.mc.displayGuiScreen(this.parent);
} else {
super.keyTyped(typedChar, keyCode);
}
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, I18n.format("fml.restrictions.title"), this.width / 2,
12, 0xFFFFFF);
this.drawChatStatus(this.mc.gameSettings.chatVisibility);
super.drawScreen(mouseX, mouseY, partialTicks);
}

private void drawChatStatus(EnumChatVisibility enumChatVisibility) {
switch (enumChatVisibility) {
case FULL -> {
this.drawCenteredString(this.fontRenderer, I18n.format("fml.send_chat_messages"),
this.width / 2, 67, 0x00FF00);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.send_commands"),
this.width / 2, 76, 0x00FF00);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.receive_system_messages"),
this.width / 2, 85, 0x00FF00);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.receive_player_messages"),
this.width / 2, 94, 0x00FF00);
}
case SYSTEM -> {
this.drawCenteredString(this.fontRenderer, I18n.format("fml.chat_restricted"),
this.width / 2, 67, 0xFF0000);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.cannot_send_chat_messages"),
this.width / 2, 114, 0xFF0000);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.send_commands"),
this.width / 2, 123, 0x00FF00);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.receive_system_messages"),
this.width / 2, 132, 0x00FF00);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.cannot_receive_player_messages"),
this.width / 2, 141, 0xFF0000);
}
case HIDDEN -> {
this.drawCenteredString(this.fontRenderer, I18n.format("fml.chat_restricted"),
this.width / 2, 67, 0xFF0000);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.cannot_send_chat_messages"),
this.width / 2, 114, 0xFF0000);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.cannot_send_commands"),
this.width / 2, 123, 0xFF0000);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.cannot_receive_system_messages"),
this.width / 2, 132, 0xFF0000);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.cannot_receive_player_messages"),
this.width / 2, 141, 0xFF0000);
}
}
}
}
Loading