Skip to content

Commit c05da01

Browse files
committed
Allow Compact Sky world types to start without a PSD
1 parent 1fdb0db commit c05da01

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class GuiSkyWorldConfiguration extends GuiScreen {
1818
private SkyWorldConfiguration config;
1919

2020
private GuiCheckBox lockedButton;
21+
private GuiCheckBox givePsdButton;
2122
private GuiButton closeButton;
2223
private SchemaScrollingList guiSchemaList;
2324

@@ -43,6 +44,10 @@ public void initGui() {
4344
this.buttonList.add(lockedButton);
4445
yOffset += 14;
4546

47+
givePsdButton = new GuiCheckBox(1, 8, yOffset, I18n.format("gui.compactmachines3.compactsky.configuration.givePSD"), config.givePSD);
48+
this.buttonList.add(givePsdButton);
49+
yOffset += 14;
50+
4651
int listHeight = this.height - 52 - yOffset;
4752
guiSchemaList = new SchemaScrollingList(this, 8, yOffset, 200, listHeight, 20);
4853

@@ -58,6 +63,10 @@ protected void actionPerformed(GuiButton button) throws IOException {
5863
this.config.startLocked = !this.config.startLocked;
5964
}
6065

66+
if(button.id == 1) {
67+
this.config.givePSD = !this.config.givePSD;
68+
}
69+
6170
parent.chunkProviderSettingsJson = this.config.getAsJsonString();
6271

6372
if(button.id == 100) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
public class SkyWorldConfiguration {
1313
public Schema schema;
1414
public boolean startLocked;
15+
public boolean givePSD;
1516

1617
public SkyWorldConfiguration() {
1718
Collection<Schema> allSchemas = SchemaRegistry.instance.getSchemas();
1819
this.schema = allSchemas.stream().findFirst().orElse(null);
1920
startLocked = true;
21+
givePSD = true;
2022
}
2123

2224
public SkyWorldConfiguration(String chunkProviderSettingsJson) {
@@ -40,6 +42,10 @@ public SkyWorldConfiguration(String chunkProviderSettingsJson) {
4042
this.schema = SchemaRegistry.instance.getSchema(schemaName);
4143
}
4244
}
45+
46+
if(rootObject.has("givePSD")) {
47+
this.givePSD = rootObject.get("givePSD").getAsBoolean();
48+
}
4349
}
4450

4551
public String getAsJsonString() {
@@ -50,6 +56,7 @@ public String getAsJsonString() {
5056
}
5157

5258
rootObject.add("startLocked", new JsonPrimitive(startLocked));
59+
rootObject.add("givePSD", new JsonPrimitive(givePSD));
5360

5461
return rootObject.toString();
5562
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
5050
return;
5151
}
5252

53-
if(!ShrinkingDeviceUtils.hasShrinkingDeviceInInventory(event.player) && !SkyWorldSavedData.instance.hasReceivedStartingInventory(event.player)) {
53+
boolean givePSD = ((SkyChunkGenerator) worldServer.getChunkProvider().chunkGenerator).config.givePSD;
54+
boolean hasPSD = ShrinkingDeviceUtils.hasShrinkingDeviceInInventory(event.player);
55+
boolean hasAlreadyReceivedPSD = SkyWorldSavedData.instance.hasReceivedStartingInventory(event.player);
56+
57+
if(givePSD && !hasPSD && !hasAlreadyReceivedPSD) {
5458
ItemStack psdStack = new ItemStack(Itemss.psd, 1, 0);
5559
if(!event.player.addItemStackToInventory(psdStack)) {
5660
EntityItem entityItem = new EntityItem(world, event.player.posX, event.player.posY + event.player.getEyeHeight() + 0.5f, event.player.posZ, psdStack);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ gui.compactmachines3.psd.crafting.text=To craft Compact Machines you will need t
147147

148148

149149
gui.compactmachines3.compactsky.configuration.startLocked=Start machines in locked state
150+
gui.compactmachines3.compactsky.configuration.givePSD=Give players a Shrinking Device on first spawn
150151
gui.compactmachines3.compactsky.configuration.voidDimensions=Use void dimensions
151152
gui.compactmachines3.compactsky.configuration.schema=Schema
152153
gui.compactmachines3.compactsky.configuration.close=Done

0 commit comments

Comments
 (0)