Skip to content

Commit

Permalink
Fixed item disappearing when put into output slot
Browse files Browse the repository at this point in the history
  • Loading branch information
AverageGithub committed Oct 29, 2023
1 parent 68b2282 commit 5d7674f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'com.artillexstudios.axsmithing'
version = '1.0'
version = '1.2'

repositories {
mavenCentral()
Expand Down Expand Up @@ -40,6 +40,12 @@ compileJava {
options.encoding = "UTF-8"
}

processResources {
filesMatching("plugin.yml") {
expand(version: version)
}
}

shadowJar {
relocate("net.byteflux.libby", "com.artillexstudios.axsmithing.libs.libby")
relocate("net.kyori", "com.artillexstudios.axsmithing.libs.kyori")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ public void handleClose(InventoryCloseEvent event) {
public void handleDrag(InventoryDragEvent event) {
if (!(event.getInventory().getHolder() instanceof SmithingTable_V1_16)) return;

ItemStack outputItem = event.getInventory().getItem(outputSlot);
if (event.getRawSlots().contains(outputSlot) && (outputItem == null || outputItem.getType().isAir()) && !event.getOldCursor().getType().isAir()) {
event.setCancelled(true);
return;
}

if (event.getInventory().getItem(outputSlot) != null && event.getInventory().getItem(outputSlot).getType() != Material.AIR) {
event.getInventory().getItem(outputSlot).setAmount(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,24 @@ public void handleClick(InventoryClickEvent event) {
public void handleClose(InventoryCloseEvent event) {
if (!(event.getInventory().getHolder() instanceof SmithingTable_V1_20)) return;

if (event.getInventory().getItem(templateSlot) != null)
if (event.getInventory().getItem(templateSlot) != null && event.getInventory().getItem(templateSlot).getType() != Material.AIR)
event.getPlayer().getInventory().addItem(event.getInventory().getItem(templateSlot));
if (event.getInventory().getItem(itemSlot) != null)
if (event.getInventory().getItem(itemSlot) != null && event.getInventory().getItem(itemSlot).getType() != Material.AIR)
event.getPlayer().getInventory().addItem(event.getInventory().getItem(itemSlot));
if (event.getInventory().getItem(upgradeSlot) != null)
if (event.getInventory().getItem(upgradeSlot) != null && event.getInventory().getItem(upgradeSlot).getType() != Material.AIR)
event.getPlayer().getInventory().addItem(event.getInventory().getItem(upgradeSlot));
}

@Override
public void handleDrag(InventoryDragEvent event) {
if (!(event.getInventory().getHolder() instanceof SmithingTable_V1_20)) return;

ItemStack outputItem = event.getInventory().getItem(outputSlot);
if (event.getRawSlots().contains(outputSlot) && (outputItem == null || outputItem.getType().isAir()) && !event.getOldCursor().getType().isAir()) {
event.setCancelled(true);
return;
}

if (event.getInventory().getItem(outputSlot) != null) {
event.getInventory().getItem(outputSlot).setAmount(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "AxSmithing"
main: "com.artillexstudios.axsmithing.AxSmithingPlugin"
version: "1.0"
version: "$version"
api-version: "1.16"
depend:
- ViaVersion
Expand Down

0 comments on commit 5d7674f

Please sign in to comment.