Skip to content

Commit f71b79b

Browse files
Merge pull request #1058 from eccentricdevotion/staircase-room
Add staircase room
2 parents a6e0183 + 9406a09 commit f71b79b

30 files changed

+321
-60
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
branches: [ "master" ]
1010

1111
env:
12-
VERSION: '6.3.6'
12+
VERSION: '6.3.7'
1313
RELEASE_TAG: '1.21.11'
1414

1515
jobs:

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212

1313
group = "me.eccentric_nz"
1414
val buildNumber = "-b${System.getenv("BUILD_NUMBER") ?: (System.getenv("SHORT_SHA") ?: ".local")}"
15-
version = "6.3.6${buildNumber}"
15+
version = "6.3.7${buildNumber}"
1616

1717
repositories {
1818
mavenCentral()

src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARS.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,19 @@ public enum TARDISARS implements ARS {
6767
SHELL("DEAD_BRAIN_CORAL_BLOCK", "Shell", 1, RoomVariant.SHELL.getKey()),
6868
SMELTER("CHEST", "Smelter", 1, RoomVariant.SMELTER.getKey()),
6969
STABLE("HAY_BLOCK", "Horse Stable", 1, RoomVariant.STABLE.getKey()),
70+
STAIRCASE("PURPLE_TERRACOTTA", "Endless Staircase", 0, RoomVariant.STAIRCASE.getKey()),
7071
STALL("BROWN_GLAZED_TERRACOTTA", "Llama Stall", 1, RoomVariant.STALL.getKey()),
7172
SURGERY("RED_CONCRETE", "Hospital Surgery", 1, RoomVariant.SURGERY.getKey()),
7273
TRENZALORE("BRICKS", "Trenzalore", 1, RoomVariant.TRENZALORE.getKey()),
7374
VAULT("DISPENSER", "Storage Vault", 1, RoomVariant.VAULT.getKey()),
7475
VILLAGE("OAK_LOG", "Village", 1, RoomVariant.VILLAGE.getKey()),
7576
WOOD("OAK_PLANKS", "Wood Secondary Console", 1, RoomVariant.WOOD.getKey()),
7677
WORKSHOP("RED_NETHER_BRICKS", "Workshop", 1, RoomVariant.WORKSHOP.getKey()),
77-
ZERO("GRASS_BLOCK", "Zero Room", 0, null),
78-
JETTISON("TNT", "Jettison", 0, RoomVariant.JETTISON.getKey()),
79-
SLOT("STONE", "Empty slot", 0, RoomVariant.SLOT.getKey()),
80-
CUSTOM("", "Custom room", 0, null),
81-
CONSOLE("", "Console", 0, null);
78+
ZERO("GRASS_BLOCK", "Zero Room", 0, null, false),
79+
JETTISON("TNT", "Jettison", 0, RoomVariant.JETTISON.getKey(), false),
80+
SLOT("STONE", "Empty slot", 0, RoomVariant.SLOT.getKey(), false),
81+
CUSTOM("", "Custom room", 0, null, false),
82+
CONSOLE("", "Console", 0, null, false);
8283

8384
private final static HashMap<String, ARS> EXTENDED_MATERIAL = new HashMap<>();
8485

@@ -93,13 +94,24 @@ public enum TARDISARS implements ARS {
9394
private final String configPath;
9495
private final int offset;
9596
private final NamespacedKey key;
97+
private final boolean inGUI;
9698

9799
TARDISARS(String material, String descriptiveName, int offset, NamespacedKey key) {
98100
this.material = material;
99101
this.descriptiveName = descriptiveName;
100102
configPath = toString();
101103
this.offset = offset;
102104
this.key = key;
105+
this.inGUI = true;
106+
}
107+
108+
TARDISARS(String material, String descriptiveName, int offset, NamespacedKey key, boolean inGUI) {
109+
this.material = material;
110+
this.descriptiveName = descriptiveName;
111+
configPath = toString();
112+
this.offset = offset;
113+
this.key = key;
114+
this.inGUI = inGUI;
103115
}
104116

105117
/**
@@ -171,4 +183,13 @@ public int getOffset() {
171183
public NamespacedKey getKey() {
172184
return key;
173185
}
186+
187+
/**
188+
* Gets if this room is in the ARS GUI
189+
*
190+
* @return whether to show this room in the ARS GUI options
191+
*/
192+
public boolean isInGUI() {
193+
return inGUI;
194+
}
174195
}

src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSInventory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private ItemStack[] getItemStack(Player player) {
155155

156156
int i = 45;
157157
for (TARDISARS a : TARDISARS.values()) {
158-
if (a.getOffset() != 0 && i < 54) {
158+
if (a.isInGUI() && i < 54) {
159159
ItemStack room = ItemStack.of(Material.getMaterial(a.getMaterial()), 1);
160160
ItemMeta im = room.getItemMeta();
161161
im.displayName(Component.text(a.getDescriptiveName()));

src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private void getRoomIdAndNames() {
257257
room_materials = new ArrayList<>();
258258
room_names = new ArrayList<>();
259259
for (TARDISARS a : ars) {
260-
if (a.getOffset() != 0) {
260+
if (a.isInGUI()) {
261261
room_materials.add(Material.valueOf(a.getMaterial()));
262262
room_names.add(a.getDescriptiveName());
263263
}

src/main/java/me/eccentric_nz/TARDIS/ARS/TARDISARSProcessor.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ public boolean compare3DArray(String[][][] start, String[][][] end) {
7878
}
7979
} else {
8080
switch (end[l][x][z]) {
81+
case "PURPLE_TERRACOTTA" -> {
82+
if (l == 0 && start[1][x][z].equals("PURPLE_TERRACOTTA")) {
83+
plugin.getTrackerKeeper().getIsStackedStaircase().put(id, false);
84+
} else if (l == 1 && start[0][x][z].equals("PURPLE_TERRACOTTA")) {
85+
plugin.getTrackerKeeper().getIsStackedStaircase().put(id, true);
86+
} else if (l == 1 && start[2][x][z].equals("PURPLE_TERRACOTTA")) {
87+
plugin.getTrackerKeeper().getIsStackedStaircase().put(id, false);
88+
} else if (l == 2 && start[1][x][z].equals("PURPLE_TERRACOTTA")) {
89+
plugin.getTrackerKeeper().getIsStackedStaircase().put(id, true);
90+
}
91+
TARDISARSSlot slot = new TARDISARSSlot();
92+
slot.setChunk(c);
93+
slot.setY(l);
94+
slot.setX(x);
95+
slot.setZ(z);
96+
changed.put(slot, TARDISARS.ARSFor(end[l][x][z]));
97+
}
8198
case "SANDSTONE" -> {
8299
if (l == 0 || (l == 1 && !end[l - 1][x][z].equals("SANDSTONE")) || (l == 2 && !end[l - 1][x][z].equals("SANDSTONE")) || (l == 2 && end[l - 1][x][z].equals("SANDSTONE") && end[l - 2][x][z].equals("SANDSTONE"))) {
83100
// only remember the bottom slot of an antigravity well

src/main/java/me/eccentric_nz/TARDIS/TARDISTrackerInstanceKeeper.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
public class TARDISTrackerInstanceKeeper {
5757

5858
private final HashMap<Integer, Boolean> malfunction = new HashMap<>();
59+
private final HashMap<Integer, Boolean> isStackedStaircase = new HashMap<>();
5960
private final HashMap<Integer, Integer> cloisterBells = new HashMap<>();
6061
private final HashMap<Integer, Integer> destinationVortex = new HashMap<>();
6162
private final HashMap<Integer, Integer> hadsDamage = new HashMap<>();
@@ -962,6 +963,15 @@ public Set<Integer> getIsGrowingRooms() {
962963
return isGrowingRooms;
963964
}
964965

966+
/**
967+
* Tracks TARDISes that are growing rooms
968+
*
969+
* @return a collection of TARDIS ids
970+
*/
971+
public HashMap<Integer, Boolean> getIsStackedStaircase() {
972+
return isStackedStaircase;
973+
}
974+
965975
/**
966976
* Tracks players that are rearranging saves in the Saves GUI
967977
*

src/main/java/me/eccentric_nz/TARDIS/blueprints/BlueprintRoom.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public enum BlueprintRoom {
6565
SHELL("tardis.room.shell"),
6666
SMELTER("tardis.room.smelter"),
6767
STABLE("tardis.room.stable", BlueprintFeature.FARM),
68+
STAIRCASE("tardis.room.staircase"),
6869
STALL("tardis.room.stall", BlueprintFeature.FARM),
6970
TRENZALORE("tardis.room.trenzalore"),
7071
VAULT("tardis.room.vault", BlueprintFeature.VAULT),

src/main/java/me/eccentric_nz/TARDIS/commands/dev/StaircaseCommand.java

Lines changed: 103 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
import org.bukkit.entity.Player;
2727
import org.bukkit.util.Vector;
2828

29+
import java.io.BufferedWriter;
30+
import java.io.File;
31+
import java.io.FileWriter;
32+
import java.io.IOException;
2933
import java.util.List;
3034

3135
public class StaircaseCommand {
@@ -66,31 +70,99 @@ public class StaircaseCommand {
6670
new Vector(7, 15, 3)
6771
);
6872

73+
private final List<Vector> smaller = List.of(
74+
new Vector(9, 0, 5),
75+
new Vector(10, 0, 6),
76+
new Vector(11, 1, 7),
77+
new Vector(11, 1, 8),
78+
new Vector(11, 2, 9),
79+
new Vector(10, 2, 10),
80+
new Vector(9, 3, 11),
81+
new Vector(8, 3, 11),
82+
new Vector(7, 4, 11),
83+
new Vector(6, 4, 10),
84+
new Vector(5, 5, 9),
85+
new Vector(5, 5, 8),
86+
new Vector(5, 6, 7),
87+
new Vector(6, 6, 6),
88+
new Vector(7, 7, 5),
89+
new Vector(8, 7, 5),
90+
new Vector(9, 8, 5),
91+
new Vector(10, 8, 6),
92+
new Vector(11, 9, 7),
93+
new Vector(11, 9, 8),
94+
new Vector(11, 10, 9),
95+
new Vector(10, 10, 10),
96+
new Vector(9, 11, 11),
97+
new Vector(8, 11, 11),
98+
new Vector(7, 12, 11),
99+
new Vector(6, 12, 10),
100+
new Vector(5, 13, 9),
101+
new Vector(5, 13, 8),
102+
new Vector(5, 14, 7),
103+
new Vector(6, 14, 6),
104+
new Vector(6, 15, 5),
105+
new Vector(7, 15, 5)
106+
);
107+
69108
public boolean spiral(Player player) {
70109
Location location = player.getLocation().clone();
71110
Chunk chunk = location.getChunk();
72111
int x = (chunk.getX() * 16);
73112
int z = (chunk.getZ() * 16);
74113
int y = location.getBlockY();
75114
Block block = location.getWorld().getBlockAt(x, y, z);
76-
walls(block.getLocation().clone().add(8,0,8));
77-
build(block.getLocation().add(0.5d, 0, 0.5d));
115+
walls(block.getLocation().clone().add(8, 0, 8));
116+
build(block.getLocation().add(0.5d, 0, 0.5d), false);
117+
return true;
118+
}
119+
120+
public boolean smaller(Player player) {
121+
Location location = player.getLocation().clone();
122+
Chunk chunk = location.getChunk();
123+
int x = (chunk.getX() * 16);
124+
int z = (chunk.getZ() * 16);
125+
int y = location.getBlockY();
126+
Block block = location.getWorld().getBlockAt(x, y, z);
127+
walls(block.getLocation().clone().add(8, 0, 8));
128+
build(block.getLocation().add(0.5d, 0, 0.5d), true);
78129
return true;
79130
}
80131

81-
private void build(Location location) {
132+
private void build(Location location, boolean bool) {
82133
for (int i = 0; i < 32; i++) {
83-
Vector v = vectors.get(i);
134+
Vector v = bool ? smaller.get(i) : vectors.get(i);
84135
location.add(v.getX(), v.getY(), v.getZ());
85136
threeByThree(location.getBlock(), i);
86137
location.subtract(v.getX(), v.getY(), v.getZ());
87138
}
88139
}
89140

141+
public boolean mark(Player player) {
142+
Location location = player.getLocation().clone();
143+
Chunk chunk = location.getChunk();
144+
int x = (chunk.getX() * 16);
145+
int z = (chunk.getZ() * 16);
146+
int y = location.getBlockY();
147+
Block block = location.getWorld().getBlockAt(x, y, z);
148+
walls(block.getLocation().clone().add(8, 0, 8));
149+
placeMarkers(block.getLocation().add(0.5d, 0, 0.5d));
150+
return true;
151+
}
152+
153+
private void placeMarkers(Location location) {
154+
for (int i = 0; i < 32; i++) {
155+
Vector v = vectors.get(i);
156+
location.add(v.getX(), v.getY(), v.getZ());
157+
location.getBlock().setType(Material.VERDANT_FROGLIGHT);
158+
location.subtract(v.getX(), v.getY(), v.getZ());
159+
}
160+
}
161+
90162
private void threeByThree(Block block, int i) {
91163
slab.setType((i % 2 == 1) ? Slab.Type.TOP : Slab.Type.BOTTOM);
92164
block.setBlockData(slab);
93-
for (BlockFace face: TARDIS.plugin.getGeneralKeeper().getSurrounding()) {
165+
for (BlockFace face : TARDIS.plugin.getGeneralKeeper().getSurrounding()) {
94166
slab.setType((i % 2 == 1) ? Slab.Type.TOP : Slab.Type.BOTTOM);
95167
if (!block.getRelative(face).getType().isAir()) {
96168
slab.setType(Slab.Type.DOUBLE);
@@ -123,4 +195,30 @@ private void walls(Location loc) {
123195
}
124196
}
125197
}
198+
199+
public boolean scan(Player player) {
200+
Location location = player.getLocation().clone();
201+
Chunk chunk = location.getChunk();
202+
int sx = (chunk.getX() * 16);
203+
int sz = (chunk.getZ() * 16);
204+
int sy = location.getBlockY();
205+
StringBuilder builder = new StringBuilder();
206+
for (int y = 0; y < 16; y++) {
207+
for (int x = 0; x < 16; x++) {
208+
for (int z = 0; z < 16; z++) {
209+
if (location.getWorld().getBlockAt(sx + x, sy + y, sz + z).getType() == Material.PEARLESCENT_FROGLIGHT) {
210+
builder.append("new Vector(").append(x).append(", ").append(y).append(", ").append(z).append("),").append("\n");
211+
}
212+
}
213+
}
214+
}
215+
File file = new File(TARDIS.plugin.getDataFolder() + File.separator + "user_schematics" + File.separator + "staircase.java");
216+
// save to file
217+
try {
218+
try (BufferedWriter bw = new BufferedWriter(new FileWriter(file, false))) {
219+
bw.write(builder.toString());
220+
}
221+
} catch (IOException ignored) { }
222+
return true;
223+
}
126224
}

src/main/java/me/eccentric_nz/TARDIS/commands/dev/TARDISDevCommand.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,22 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
293293
}
294294
}
295295
switch (first) {
296+
case "staircase" -> {
297+
if (sender instanceof Player player) {
298+
switch (args[1]) {
299+
case "mark" -> {
300+
return new StaircaseCommand().mark(player);
301+
}
302+
case "scan" -> {
303+
return new StaircaseCommand().scan(player);
304+
}
305+
default -> {
306+
return new StaircaseCommand().smaller(player);
307+
}
308+
}
309+
}
310+
return false;
311+
}
296312
case "advancements" -> {
297313
TARDISAchievementFactory.checkAdvancement(args[1]);
298314
return true;

0 commit comments

Comments
 (0)