Skip to content

Commit 3b3f76d

Browse files
Fix some issues with modelled doors
1 parent 02e6a81 commit 3b3f76d

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

src/main/java/me/eccentric_nz/TARDIS/customblocks/TARDISDisplayItemUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public static TARDISDisplayItem get(ItemDisplay display) {
5353
} else {
5454
return TARDISDisplayItem.getByModel(im.getItemModel());
5555
}
56+
} else if (im.getPersistentDataContainer().has(TARDIS.plugin.getCustomBlockKey())) {
57+
String str = im.getPersistentDataContainer().get(TARDIS.plugin.getCustomBlockKey(), PersistentDataType.STRING);
58+
NamespacedKey nsk = new NamespacedKey(TARDIS.plugin, str);
59+
return TARDISDisplayItem.getByModel(nsk);
5660
}
5761
}
5862
return null;
@@ -316,6 +320,9 @@ public static ItemDisplay set(TARDISDisplayItem tdi, Block block, int id) {
316320
ItemMeta im = is.getItemMeta();
317321
im.displayName(ComponentUtils.toWhite(tdi.getDisplayName()));
318322
im.getPersistentDataContainer().set(TARDIS.plugin.getCustomBlockKey(), PersistentDataType.STRING, tdi.getCustomModel().getKey());
323+
if (tdi.isDoor()) {
324+
im.setItemModel(tdi.getCustomModel());
325+
}
319326
is.setItemMeta(im);
320327
double ay = (tdi == TARDISDisplayItem.DOOR || tdi == TARDISDisplayItem.CLASSIC_DOOR || tdi == TARDISDisplayItem.BONE_DOOR) ? 0.0d : 0.5d;
321328
ItemDisplay display = (ItemDisplay) block.getWorld().spawnEntity(block.getLocation().add(0.5d, ay, 0.5d), EntityType.ITEM_DISPLAY);

src/main/java/me/eccentric_nz/TARDIS/schematic/TARDISSchematicBuilder.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,21 @@ public ArchiveData build() {
233233
JsonObject stack = new JsonObject();
234234
Material material = display.getItemStack().getType();
235235
ItemMeta im = display.getItemStack().getItemMeta();
236-
NamespacedKey model = im.getItemModel();
237236
stack.addProperty("type", material.toString());
238-
stack.addProperty("cmd", model.getKey());
237+
if (im.hasItemModel()) {
238+
NamespacedKey model = im.getItemModel();
239+
stack.addProperty("cmd", model.getKey());
240+
TARDISDisplayItem tdi = TARDISDisplayItem.getByModel(model);
241+
if (tdi != null) {
242+
stack.addProperty("light", tdi.isLight());
243+
stack.addProperty("lit", tdi.isLit());
244+
}
245+
}
239246
// save custom name
240247
if (im.hasDisplayName()) {
241248
JsonElement element = ComponentUtils.getJson(im.displayName());
242249
stack.add("name", element);
243250
}
244-
TARDISDisplayItem tdi = TARDISDisplayItem.getByModel(model);
245-
if (tdi != null) {
246-
stack.addProperty("light", tdi.isLight());
247-
stack.addProperty("lit", tdi.isLit());
248-
}
249251
item.add("stack", stack);
250252
itemDisplays.add(item);
251253
entities.add(entity);

src/main/java/me/eccentric_nz/TARDIS/utility/TARDISStaticUtils.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.bukkit.entity.Player;
4141
import org.bukkit.inventory.ItemStack;
4242
import org.bukkit.inventory.meta.ItemMeta;
43+
import org.bukkit.persistence.PersistentDataType;
4344

4445
import java.util.HashMap;
4546
import java.util.UUID;
@@ -230,7 +231,15 @@ public static boolean isDoorOpen(Block door) {
230231
}
231232

232233
private static boolean isCustomDoorOpen(ItemDisplay display) {
233-
return display.getItemStack().getItemMeta().getItemModel().getKey().endsWith("_open");
234+
ItemMeta im = display.getItemStack().getItemMeta();
235+
if (im.hasItemModel()) {
236+
return display.getItemStack().getItemMeta().getItemModel().getKey().endsWith("_open");
237+
} else if (im.getPersistentDataContainer().has(TARDIS.plugin.getCustomBlockKey())) {
238+
String str = im.getPersistentDataContainer().get(TARDIS.plugin.getCustomBlockKey(), PersistentDataType.STRING);
239+
return str.endsWith("_open");
240+
} else {
241+
return false;
242+
}
234243
}
235244

236245
/**
@@ -318,7 +327,7 @@ public static boolean isSonic(ItemStack is) {
318327
if (is != null && is.hasItemMeta()) {
319328
ItemMeta im = is.getItemMeta();
320329
if (im.hasDisplayName()) {
321-
return ComponentUtils.endsWith(im.displayName(),"Sonic Screwdriver");
330+
return ComponentUtils.endsWith(im.displayName(), "Sonic Screwdriver");
322331
}
323332
}
324333
return false;

todo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
| Priority | Feature | Link |
44
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
5-
| ![Static Badge](https://img.shields.io/badge/WIP-f90?style=flat-square) | **Update to 1.21.10**<br/>- Update schematics with CHAIN -> IRON_CHAIN - happy, observatory, nether rooms - cursed, delta, division, cave, fugitive consoles<br/>- Use new Mannequin api?<br/>- Add new blocks to appropriate rooms e.g. firefly bush to Mangrove, dry grass to Iistabul?<br/>- Related to above - [#902](https://github.com/eccentricdevotion/TARDIS/issues/902) Room updates | [#902](https://github.com/eccentricdevotion/TARDIS/issues/902) |
5+
| ![Static Badge](https://img.shields.io/badge/WIP-f90?style=flat-square) | **Update to 1.21.10**<br/>- Update resource pack - add WIDE console template icon<br/>- Use new Mannequin api?<br/>- Add new blocks to appropriate rooms e.g. firefly bush to Mangrove, dry grass to Iistabul?<br/>- Related to above - [#902](https://github.com/eccentricdevotion/TARDIS/issues/902) Room updates | [#902](https://github.com/eccentricdevotion/TARDIS/issues/902) |
66
| ![Static Badge](https://img.shields.io/badge/WIP-f90?style=flat-square) | **Fix bugs**<br/>! | - |
77
| ![Static Badge](https://img.shields.io/badge/1-f00?style=flat-square) | **Time Rotors and 3D Console Improvements**<br/>- Implement custom modelled consoles<br/>- Rotor/Console menu GUI<br/>- Change rotor placement in item frames<br/>- Additional models for cloister and off states | [#916](https://github.com/eccentricdevotion/TARDIS/issues/916) |
88
| ![Static Badge](https://img.shields.io/badge/1-f00?style=flat-square) | **Modelled controls**<br/>- Console lamp done | [#836](https://github.com/eccentricdevotion/TARDIS/issues/836) |

0 commit comments

Comments
 (0)