Permalink
Browse files

Make MainHand and OffHand methods consistent

  • Loading branch information...
PseudoKnight committed Aug 14, 2018
1 parent e1fd395 commit 035360ab731634aef7974beaa9297cadfa96b316
@@ -10,6 +10,8 @@
void setBoots(MCItemStack stack);
void setItemInMainHand(MCItemStack stack);
void setItemInOffHand(MCItemStack stack);
MCItemStack getHelmet();
@@ -20,6 +22,8 @@
MCItemStack getBoots();
MCItemStack getItemInMainHand();
MCItemStack getItemInOffHand();
int getHeldItemSlot();
@@ -43,6 +43,11 @@ public void setBoots(MCItemStack stack) {
this.i.setBoots(((BukkitMCItemStack) stack).__ItemStack());
}
@Override
public void setItemInMainHand(MCItemStack stack) {
this.i.setItemInMainHand(((BukkitMCItemStack) stack).__ItemStack());
}
@Override
public void setItemInOffHand(MCItemStack stack) {
this.i.setItemInOffHand(((BukkitMCItemStack) stack).__ItemStack());
@@ -68,6 +73,11 @@ public MCItemStack getBoots() {
return new BukkitMCItemStack(this.i.getBoots());
}
@Override
public MCItemStack getItemInMainHand() {
return new BukkitMCItemStack(this.i.getItemInMainHand());
}
@Override
public MCItemStack getItemInOffHand() {
return new BukkitMCItemStack(this.i.getItemInOffHand());
@@ -288,7 +288,7 @@ public BindableEvent convert(CArray manualObject, Target t) {
CArray drops = new CArray(t);
Collection<MCItemStack> items = event.getDrops();
if(items == null) {
items = event.getBlock().getDrops(event.getPlayer().getItemInHand());
items = event.getBlock().getDrops(event.getPlayer().getInventory().getItemInMainHand());
}
for(MCItemStack stack : items) {
CArray item = (CArray) ObjectGenerator.GetGenerator().item(stack, t);
@@ -154,15 +154,14 @@ public Construct exec(Target t, Environment env, Construct... args) throws Confi
}
private Construct getInvSlot(MCPlayer m, Integer slot, Target t) {
if(slot == null) {
return ObjectGenerator.GetGenerator().item(m.getItemInHand(), t);
}
MCPlayerInventory inv = m.getInventory();
if(inv == null) {
throw new CRENotFoundException(
"Could not find the inventory of the given player (are you running in cmdline mode?)", t);
}
if(slot == null) {
return ObjectGenerator.GetGenerator().item(inv.getItemInMainHand(), t);
}
if(slot.equals(36)) {
slot = 100;
}
@@ -93,7 +93,7 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
}
Static.AssertPlayerNonNull(p, t);
if(slot instanceof CNull) {
is = p.getItemInHand();
is = p.getItemAt(null);
} else {
is = p.getItemAt(Static.getInt32(slot, t));
}
@@ -192,7 +192,7 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
}
Static.AssertPlayerNonNull(p, t);
if(slot instanceof CNull) {
is = p.getItemInHand();
is = p.getItemAt(null);
} else {
is = p.getItemAt(Static.getInt32(slot, t));
}
@@ -963,7 +963,7 @@ public Construct exec(Target t, Environment env, Construct... args) throws Cance
}
if(index == 6 || index == -1) {
//Item in hand
MCItemStack is = p.getItemInHand();
MCItemStack is = p.getInventory().getItemInMainHand();
retVals.add(new CString(is.getType().getName(), t));
}
if(index == 7 || index == -1) {

0 comments on commit 035360a

Please sign in to comment.