Skip to content

Commit cd13f97

Browse files
committed
Increase maximum size of compact skies world
This can be configured via the customize screen or by adding a size property to the world gen options string, e.g. {"schema":"tinysapling","startLocked":true,"givePSD":true,"size":"LARGE"} Valid values are: Small: 16 players, single colors Medium: 64 players, dual colors, no combination twice Large: 256 players, dual colors, red+green != green+red
1 parent 7863e08 commit cd13f97

File tree

5 files changed

+95
-12
lines changed

5 files changed

+95
-12
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.dave.compactmachines3.skyworld;
2+
3+
public enum EnumSkyWorldSize {
4+
SMALL(4,4),
5+
MEDIUM(8,8),
6+
LARGE(16,16);
7+
8+
public int rows;
9+
public int cols;
10+
11+
EnumSkyWorldSize(int rows, int cols) {
12+
this.rows = rows;
13+
this.cols = cols;
14+
}
15+
}

src/main/java/org/dave/compactmachines3/skyworld/GuiSkyWorldConfiguration.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class GuiSkyWorldConfiguration extends GuiScreen {
2222
private GuiButton closeButton;
2323
private SchemaScrollingList guiSchemaList;
2424

25+
private GuiCheckBox smallButton;
26+
private GuiCheckBox mediumButton;
27+
private GuiCheckBox largeButton;
2528

2629
public GuiSkyWorldConfiguration(GuiCreateWorld parent) {
2730
this.parent = parent;
@@ -48,6 +51,17 @@ public void initGui() {
4851
this.buttonList.add(givePsdButton);
4952
yOffset += 14;
5053

54+
smallButton = new GuiCheckBox(2, 8, yOffset, I18n.format("gui.compactmachines3.compactsky.configuration.small"), config.size == EnumSkyWorldSize.SMALL);
55+
this.buttonList.add(smallButton);
56+
57+
mediumButton = new GuiCheckBox(3, 100, yOffset, I18n.format("gui.compactmachines3.compactsky.configuration.medium"), config.size == EnumSkyWorldSize.MEDIUM);
58+
this.buttonList.add(mediumButton);
59+
60+
largeButton = new GuiCheckBox(4, 192, yOffset, I18n.format("gui.compactmachines3.compactsky.configuration.large"), config.size == EnumSkyWorldSize.LARGE);
61+
this.buttonList.add(largeButton);
62+
63+
yOffset += 14;
64+
5165
int listHeight = this.height - 52 - yOffset;
5266
guiSchemaList = new SchemaScrollingList(this, 8, yOffset, 200, listHeight, 20);
5367

@@ -67,6 +81,24 @@ protected void actionPerformed(GuiButton button) throws IOException {
6781
this.config.givePSD = !this.config.givePSD;
6882
}
6983

84+
if(button.id == 2) {
85+
this.config.size = EnumSkyWorldSize.SMALL;
86+
mediumButton.setIsChecked(false);
87+
largeButton.setIsChecked(false);
88+
}
89+
90+
if(button.id == 3) {
91+
this.config.size = EnumSkyWorldSize.MEDIUM;
92+
smallButton.setIsChecked(false);
93+
largeButton.setIsChecked(false);
94+
}
95+
96+
if(button.id == 4) {
97+
this.config.size = EnumSkyWorldSize.LARGE;
98+
smallButton.setIsChecked(false);
99+
mediumButton.setIsChecked(false);
100+
}
101+
70102
parent.chunkProviderSettingsJson = this.config.getAsJsonString();
71103

72104
if(button.id == 100) {

src/main/java/org/dave/compactmachines3/skyworld/SkyTerrainGenerator.java

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ public class SkyTerrainGenerator {
1818
private final World world;
1919
private final SkyChunkGenerator chunkGenerator;
2020

21-
// Make configurable?
22-
private final static int ROWS = 4;
23-
private final static int COLS = 4;
24-
2521
public final static int ROOM_DIMENSION = 9;
2622
public final static int ROOM_PADDING = 16-ROOM_DIMENSION;
2723
public final static int ROOM_FLOOR_HEIGHT = 50;
@@ -74,8 +70,27 @@ private void generateMachine(int chunkX, int chunkZ, ChunkPrimer cp) {
7470
cp.setBlockState(machinePos.getX(), machinePos.getY(), machinePos.getZ(), Blockss.machine.getDefaultState().withProperty(BlockMachine.SIZE, startSize));
7571
}
7672

73+
@SuppressWarnings("deprecation")
7774
private void generateLighting(int chunkX, int chunkZ, ChunkPrimer cp) {
78-
int meta = chunkZ * 4 + chunkX;
75+
IBlockState carpetCornerState;
76+
IBlockState carpetCrossState;
77+
78+
switch (chunkGenerator.config.size) {
79+
default:
80+
case SMALL:
81+
carpetCornerState = Blocks.CARPET.getStateFromMeta(chunkZ * 4 + chunkX);
82+
carpetCrossState = carpetCornerState;
83+
break;
84+
case MEDIUM:
85+
carpetCornerState = Blocks.CARPET.getStateFromMeta(chunkX);
86+
carpetCrossState = Blocks.CARPET.getStateFromMeta(chunkZ+8);
87+
break;
88+
case LARGE:
89+
carpetCornerState = Blocks.CARPET.getStateFromMeta(chunkX);
90+
carpetCrossState = Blocks.CARPET.getStateFromMeta(chunkZ);
91+
break;
92+
}
93+
7994
int center = (int) Math.floor(ROOM_DIMENSION / 2.0f);
8095

8196
BlockPos floorCenter = new BlockPos(15-center, ROOM_FLOOR_HEIGHT-ROOM_DIMENSION+1, 15-center);
@@ -88,9 +103,10 @@ private void generateLighting(int chunkX, int chunkZ, ChunkPrimer cp) {
88103

89104
BlockPos thisPos = floorCenter.add(x, 0, z);
90105

91-
@SuppressWarnings("deprecation") IBlockState carpetState = Blocks.CARPET.getStateFromMeta(meta);
106+
IBlockState carpetStateToUse = x == 0 || z == 0 ? carpetCrossState : carpetCornerState;
107+
92108
cp.setBlockState(thisPos.getX(), thisPos.getY(), thisPos.getZ(), Blocks.GLOWSTONE.getDefaultState());
93-
cp.setBlockState(thisPos.getX(), thisPos.getY()+1, thisPos.getZ(), carpetState);
109+
cp.setBlockState(thisPos.getX(), thisPos.getY()+1, thisPos.getZ(), carpetStateToUse);
94110
}
95111
}
96112

@@ -230,11 +246,11 @@ private void generateConnections(int chunkX, int chunkZ, ChunkPrimer cp) {
230246
}
231247

232248
private boolean isOutside(int offsetChunkX, int offsetChunkZ) {
233-
if(offsetChunkX < 0 || offsetChunkX >= COLS) {
249+
if(offsetChunkX < 0 || offsetChunkX >= chunkGenerator.config.size.cols) {
234250
return true;
235251
}
236252

237-
if(offsetChunkZ < 0 || offsetChunkZ >= ROWS) {
253+
if(offsetChunkZ < 0 || offsetChunkZ >= chunkGenerator.config.size.rows) {
238254
return true;
239255
}
240256

@@ -246,15 +262,15 @@ private boolean hasLeftNeighbor(int offsetChunkX) {
246262
}
247263

248264
private boolean hasRightNeighbor(int offsetChunkX) {
249-
return offsetChunkX < COLS-1;
265+
return offsetChunkX < chunkGenerator.config.size.cols-1;
250266
}
251267

252268
private boolean hasTopNeighbor(int offsetChunkZ) {
253269
return offsetChunkZ > 0;
254270
}
255271

256272
private boolean hasBottomNeighbor(int offsetChunkZ) {
257-
return offsetChunkZ < ROWS-1;
273+
return offsetChunkZ < chunkGenerator.config.size.rows-1;
258274
}
259275

260276

src/main/java/org/dave/compactmachines3/skyworld/SkyWorldConfiguration.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@
66
import com.google.gson.JsonPrimitive;
77
import org.dave.compactmachines3.schema.Schema;
88
import org.dave.compactmachines3.schema.SchemaRegistry;
9+
import org.dave.compactmachines3.utility.Logz;
910

11+
import java.util.Arrays;
1012
import java.util.Collection;
1113

1214
public class SkyWorldConfiguration {
1315
public Schema schema;
1416
public boolean startLocked;
1517
public boolean givePSD;
1618

19+
public EnumSkyWorldSize size;
20+
1721
public SkyWorldConfiguration() {
1822
Collection<Schema> allSchemas = SchemaRegistry.instance.getSchemas();
1923
this.schema = allSchemas.stream().findFirst().orElse(null);
2024
startLocked = true;
2125
givePSD = true;
26+
size = EnumSkyWorldSize.SMALL;
2227
}
2328

2429
public SkyWorldConfiguration(String chunkProviderSettingsJson) {
@@ -46,6 +51,16 @@ public SkyWorldConfiguration(String chunkProviderSettingsJson) {
4651
if(rootObject.has("givePSD")) {
4752
this.givePSD = rootObject.get("givePSD").getAsBoolean();
4853
}
54+
55+
if(rootObject.has("size")) {
56+
String size = rootObject.get("size").getAsString();
57+
if(!Arrays.stream(EnumSkyWorldSize.values()).anyMatch(s -> s.name().equals(size))) {
58+
Logz.warn("Invalid size value specified: %s. Falling back to SMALL.", size);
59+
this.size = EnumSkyWorldSize.SMALL;
60+
} else {
61+
this.size = EnumSkyWorldSize.valueOf(size);
62+
}
63+
}
4964
}
5065

5166
public String getAsJsonString() {
@@ -57,6 +72,7 @@ public String getAsJsonString() {
5772

5873
rootObject.add("startLocked", new JsonPrimitive(startLocked));
5974
rootObject.add("givePSD", new JsonPrimitive(givePSD));
75+
rootObject.add("size", new JsonPrimitive(size.name()));
6076

6177
return rootObject.toString();
6278
}

src/main/resources/assets/compactmachines3/lang/en_us.lang

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,8 @@ gui.compactmachines3.compactsky.configuration.schema=Schema
153153
gui.compactmachines3.compactsky.configuration.close=Done
154154
gui.compactmachines3.compactsky.configuration.label.MachineSize=Machine Size
155155
gui.compactmachines3.compactsky.configuration.label.Description=Description
156-
gui.compactmachines3.compactsky.configuration.warning.PleaseSpecifyADescription=Please specify a description in the schemas .json file!
156+
gui.compactmachines3.compactsky.configuration.warning.PleaseSpecifyADescription=Please specify a description in the schemas .json file!
157+
158+
gui.compactmachines3.compactsky.configuration.small=16 Players
159+
gui.compactmachines3.compactsky.configuration.medium=64 Players
160+
gui.compactmachines3.compactsky.configuration.large=256 Players

0 commit comments

Comments
 (0)