Skip to content

Commit

Permalink
Allow for arbitrary input and output items (WesJD#278)
Browse files Browse the repository at this point in the history
* Allow for arbitrary input and output items

* Increase version
  • Loading branch information
Sytm authored Aug 30, 2023
1 parent 37d9d12 commit 3773e12
Show file tree
Hide file tree
Showing 55 changed files with 323 additions and 75 deletions.
2 changes: 1 addition & 1 deletion 1_10_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_10_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ public AnvilContainer(EntityHuman entityhuman) {
super(entityhuman.inventory, entityhuman.world, new BlockPosition(0, 0, 0), entityhuman);
}

@Override
public void e() {
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.a = 0;

// Sync to the client
this.b();
}

@Override
public boolean a(EntityHuman entityhuman) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion 1_11_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_11_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ public AnvilContainer(EntityHuman entityhuman) {
super(entityhuman.inventory, entityhuman.world, new BlockPosition(0, 0, 0), entityhuman);
}

@Override
public void e() {
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.a = 0;

// Sync to the client
this.b();
}

@Override
public boolean a(EntityHuman entityhuman) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion 1_12_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_12_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,16 @@ public AnvilContainer(EntityHuman entityhuman) {

@Override
public void e() {
super.e();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost = 0;

// Sync to the client
this.b();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_13_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_13_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,16 @@ public AnvilContainer(EntityHuman entityhuman) {

@Override
public void d() {
super.d();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost = 0;

// Sync to the client
this.b();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_13_R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_13_R2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,16 @@ public AnvilContainer(EntityHuman entityhuman) {

@Override
public void d() {
super.d();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost = 0;

// Sync to the client
this.b();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_14_4_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_14_4_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ public AnvilContainer1_14_4_R1(Player player, int containerId, IChatBaseComponen

@Override
public void e() {
super.e();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost.set(0);

// Sync to the client
this.c();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_14_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_14_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,16 @@ public AnvilContainer(Player player, IChatBaseComponent guiTitle) {

@Override
public void e() {
super.e();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost.a(0);

// Sync to the client
this.c();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_15_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_15_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,16 @@ public AnvilContainer(Player player, IChatBaseComponent guiTitle) {

@Override
public void e() {
super.e();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost.set(0);

// Sync to the client
this.c();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_16_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_16_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,16 @@ public AnvilContainer(Player player, IChatBaseComponent guiTitle) {

@Override
public void e() {
super.e();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost.set(0);

// Sync to the client
this.c();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_16_R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_16_R2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,16 @@ public AnvilContainer(Player player, IChatBaseComponent guiTitle) {

@Override
public void e() {
super.e();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost.set(0);

// Sync to the client
this.c();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_16_R3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_16_R3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,16 @@ public AnvilContainer(Player player, IChatBaseComponent guiTitle) {

@Override
public void e() {
super.e();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.levelCost.set(0);

// Sync to the client
this.c();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_17_1_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_17_1_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.inventory.ContainerAccess;
import net.minecraft.world.inventory.ContainerAnvil;
import net.minecraft.world.inventory.Slot;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
Expand All @@ -23,8 +24,17 @@ public AnvilContainer1_17_1_R1(Player player, int containerId, IChatBaseComponen

@Override
public void l() {
super.l();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.w.set(0);

// Sync to the client
this.updateInventory();
this.d();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_17_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_17_R1</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.world.IInventory;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.inventory.Container;
import net.minecraft.world.inventory.ContainerAccess;
import net.minecraft.world.inventory.ContainerAnvil;
import net.minecraft.world.inventory.Containers;
import net.minecraft.world.inventory.*;
import net.wesjd.anvilgui.version.special.AnvilContainer1_17_1_R1;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
Expand Down Expand Up @@ -151,8 +148,20 @@ public AnvilContainer(Player player, IChatBaseComponent guiTitle) {

@Override
public void i() {
super.i();
// If the output is empty copy the left input into the output
Slot output = this.getSlot(2);
if (!output.hasItem()) {
output.set(this.getSlot(0).getItem().cloneItemStack());
}

this.w.set(0);

// Sync to the client
// This call has been added in 1.17.1, to fix
// https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6686
// but we can backport it here to 1.17
this.updateInventory();
this.d();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion 1_18_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>net.wesjd</groupId>
<artifactId>anvilgui-parent</artifactId>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
</parent>

<artifactId>anvilgui-1_18_R1</artifactId>
Expand Down
Loading

0 comments on commit 3773e12

Please sign in to comment.