Skip to content

Commit 94c0c5b

Browse files
committed
Maybe fix open, added support for not converting items with custom model data
1 parent b054264 commit 94c0c5b

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/main/java/com/artillexstudios/axsmithing/gui/impl/SmithingTable_V1_16.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ public class SmithingTable_V1_16 implements SmithingTable, InventoryHolder {
3030
private final int outputSlot;
3131
private final int upgradeSlot;
3232
private final int itemSlot;
33+
private final boolean dontConvertWithModelData;
3334

3435
public SmithingTable_V1_16() {
3536
YamlDocument config = AxSmithingPlugin.getConfiguration();
3637
outputSlot = config.getInt("menu.1_16.output-slot");
3738
upgradeSlot = config.getInt("menu.1_16.upgrade-slot");
3839
itemSlot = config.getInt("menu.1_16.item-slot");
40+
dontConvertWithModelData = config.getBoolean("menu.1_16.dont-convert-with-modeldata");
3941
}
4042

4143
@Override
@@ -184,6 +186,10 @@ private boolean checkRecipe(Inventory inventory, ItemStack finalBase, ItemStack
184186
ItemMeta baseItemMeta = finalBase.getItemMeta();
185187
boolean test2 = smithingRecipe.getAddition().test(finalAddition);
186188

189+
if (dontConvertWithModelData && baseItemMeta.hasCustomModelData()) {
190+
return false;
191+
}
192+
187193
if (test1 && test2) {
188194
ItemStack item = smithingRecipe.getResult();
189195
item.setItemMeta(baseItemMeta);

src/main/java/com/artillexstudios/axsmithing/gui/impl/SmithingTable_V1_20.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class SmithingTable_V1_20 implements SmithingTable, InventoryHolder {
3838
private final int itemSlot;
3939
private final int templateSlot;
4040
private final boolean needNetheriteTemplate;
41+
private final boolean dontConvertWithModelData;
4142

4243
public SmithingTable_V1_20() {
4344
YamlDocument config = AxSmithingPlugin.getConfiguration();
@@ -46,6 +47,7 @@ public SmithingTable_V1_20() {
4647
templateSlot = config.getInt("menu.1_20.template-slot");
4748
itemSlot = config.getInt("menu.1_20.item-slot");
4849
needNetheriteTemplate = config.getBoolean("menu.1_20.need-netherite-template");
50+
dontConvertWithModelData = config.getBoolean("menu.1_20.dont-convert-with-modeldata");
4951
}
5052

5153
@Override
@@ -259,6 +261,10 @@ private boolean checkRecipe(Inventory inventory, ItemStack finalTemplate, ItemSt
259261
ItemMeta baseItemMeta = finalBase.getItemMeta();
260262
boolean test3 = transformRecipe.getAddition().test(finalAddition);
261263

264+
if (dontConvertWithModelData && baseItemMeta.hasCustomModelData()) {
265+
return false;
266+
}
267+
262268
if (test1 && test2 && test3) {
263269
ItemStack item = transformRecipe.getResult();
264270
item.setItemMeta(baseItemMeta);

src/main/java/com/artillexstudios/axsmithing/listener/InteractListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ public void onInventoryOpenEvent(@NotNull final InventoryOpenEvent event) {
5555
}
5656

5757
event.getPlayer().closeInventory();
58-
AxSmithingPlugin.getSmithingTableImpl().open((Player) event.getPlayer());
58+
Bukkit.getScheduler().runTaskLater(AxSmithingPlugin.getInstance(), () -> AxSmithingPlugin.getSmithingTableImpl().open((Player) event.getPlayer()),1L);
5959
}
6060
}

src/main/resources/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ menu:
1212
# If we should force our gui instead of the default one, for 1.20 players.
1313
# Can be useful, if you want to remove the need for netherite template usage
1414
force-for-1_20-clients: false
15+
dont-convert-with-modeldata: false
1516
items:
1617
'1':
1718
slots:
@@ -30,6 +31,7 @@ menu:
3031
item-slot: 11
3132
upgrade-slot: 12
3233
output-slot: 14
34+
dont-convert-with-modeldata: false
3335
items:
3436
'1':
3537
slots:

0 commit comments

Comments
 (0)