MCPcopy Create free account
hub / github.com/Teneted/Tenet / AnvilUpdateEvent

Class AnvilUpdateEvent

src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java:35–70  ·  view source on GitHub ↗

AnvilUpdateEvent is fired when a player places items in both the left and right slots of a anvil. If the event is canceled, vanilla behavior will not run, and the output will be set to null. If the event is not canceled, but the output is not null, it will set the output and not run vanilla behavior

Source from the content-addressed store, hash-verified

33 * if the output is null, and the event is not canceled, vanilla behavior will execute.
34 */
35@Cancelable
36public class AnvilUpdateEvent extends Event
37{
38 @Nonnull
39 private final ItemStack left; // The left side of the input
40 @Nonnull
41 private final ItemStack right; // The right side of the input
42 private final String name; // The name to set the item, if the user specified one.
43 @Nonnull
44 private ItemStack output; // Set this to set the output stack
45 private int cost; // The base cost, set this to change it if output != null
46 private int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack.
47
48 public AnvilUpdateEvent(@Nonnull ItemStack left, @Nonnull ItemStack right, String name, int cost)
49 {
50 this.left = left;
51 this.right = right;
52 this.output = ItemStack.EMPTY;
53 this.name = name;
54 this.setCost(cost);
55 this.setMaterialCost(0);
56 }
57
58 @Nonnull
59 public ItemStack getLeft() { return left; }
60 @Nonnull
61 public ItemStack getRight() { return right; }
62 public String getName() { return name; }
63 @Nonnull
64 public ItemStack getOutput() { return output; }
65 public void setOutput(@Nonnull ItemStack output) { this.output = output; }
66 public int getCost() { return cost; }
67 public void setCost(int cost) { this.cost = cost; }
68 public int getMaterialCost() { return materialCost; }
69 public void setMaterialCost(int materialCost) { this.materialCost = materialCost; }
70}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected