Skip to content

Commit

Permalink
anvil event feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Lildirt committed Jun 29, 2024
1 parent 37a91a5 commit 5f4a1be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public int getRepairCost() {

@Override
public int getRepairCostAmount() {
return ai.getRepairCost();
return ai.getRepairCostAmount();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.laytonsmith.abstraction.events;

import com.laytonsmith.abstraction.MCHumanEntity;
import com.laytonsmith.abstraction.MCInventory;
import com.laytonsmith.abstraction.MCItemStack;

import java.util.List;

public interface MCPrepareAnvilEvent extends MCInventoryEvent {
@Override
MCInventory getInventory();

List<MCHumanEntity> getViewers();

void setResult(MCItemStack i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,10 @@ public String getName() {
public String docs() {
return "{}"
+ " Fires when a recipe is formed in an anvil, but the result has not yet been clicked."
+ " { viewers: all human entities looking at this anvil "
+ " | first_item: the first item in the anvil"
+ " | second_item: the second item in the anvil"
+ " | result: the result of the anvil"
+ " { viewers: all players viewing this anvil's interface."
+ " | first_item: the first item being used in the recipe."
+ " | second_item: the second item being used in the recipe."
+ " | result: the result of the recipe."
+ " | max_repair_cost: the maximum possible cost of this repair."
+ " | level_repair_cost: how many levels are needed to perform this repair?"
+ " | item_repair_cost: how many items are needed to perform this repair? }"
Expand All @@ -1028,8 +1028,7 @@ public BindableEvent convert(CArray manualObject, Target t) {

@Override
public Map<String, Mixed> evaluate(BindableEvent event) throws EventException {
if(event instanceof MCPrepareAnvilEvent) {
MCPrepareAnvilEvent e = (MCPrepareAnvilEvent) event;
if(event instanceof MCPrepareAnvilEvent e) {
MCAnvilInventory anvil = (MCAnvilInventory) e.getInventory();
Map<String, Mixed> ret = evaluate_helper(e);

Expand Down Expand Up @@ -1059,9 +1058,8 @@ public Driver driver() {

@Override
public boolean modifyEvent(String key, Mixed value, BindableEvent event) {
if(event instanceof MCPrepareAnvilEvent) {
if(event instanceof MCPrepareAnvilEvent e) {
Target t = value.getTarget();
MCPrepareAnvilEvent e = (MCPrepareAnvilEvent) event;
if(key.equalsIgnoreCase("result")) {
e.setResult(ObjectGenerator.GetGenerator().item(value, t));
return true;
Expand Down

0 comments on commit 5f4a1be

Please sign in to comment.