Skip to content

Commit

Permalink
(possibly?) fix FakeItem command duration values
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 23, 2019
1 parent 92399f1 commit d5d8071
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -82,10 +82,8 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
final Element player_only = scriptEntry.getElement("player_only");

if (scriptEntry.dbCallShouldDebug()) {

dB.report(scriptEntry, getName(), aH.debugList("items", items) + elSlot.debug() + duration.debug()
+ aH.debugList("players", players) + player_only.debug());

}

int slot = SlotHelper.nameToIndex(elSlot.asString());
Expand Down Expand Up @@ -117,8 +115,8 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
public void run() {
for (dPlayer player : players) {
Player ent = player.getPlayerEntity();
ItemStack original = ent.getOpenInventory().getItem(translateSlot(ent, slotSnapshot, playerOnly));
packetHelper.setSlot(ent, slotSnapshot, original, playerOnly);
ItemStack original = ent.getOpenInventory().getItem(slotSnapshot);
packetHelper.setSlot(ent, translateSlot(ent, slotSnapshot, playerOnly), original, playerOnly);
}
}
}, (float) duration.getSeconds()));
Expand All @@ -127,6 +125,7 @@ public void run() {
}

static int translateSlot(Player player, int slot, boolean player_only) {
// This is (probably?) a server-slot-order to network-slot-order translation
if (slot < 0) {
return 0;
}
Expand All @@ -144,6 +143,6 @@ else if (slot > 35) {
if (slot > total) {
return total;
}
return (int) (slot + (total - 9) - (9 * (2 * Math.floor(slot / 9))));
return (int) (slot + (total - 9) - (9 * (2 * Math.floor(slot / 9.0))));
}
}

0 comments on commit d5d8071

Please sign in to comment.