remove slot magic value for npcs
This commit is contained in:
parent
acc43e2d42
commit
e1fc81962a
59 changed files with 776 additions and 825 deletions
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.util.Equipment;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
|
@ -25,8 +26,9 @@ public class CommandClear extends Command {
|
|||
}
|
||||
else {
|
||||
((EntityNPC)entity).getExtendedInventory().clear();
|
||||
for(int z = 0; z < 5; z++) {
|
||||
((EntityNPC)entity).setItem(z, null);
|
||||
((EntityNPC)entity).setHeldItem(null);
|
||||
for(Equipment slot : Equipment.ARMOR) {
|
||||
((EntityNPC)entity).setArmor(slot, null);
|
||||
}
|
||||
}
|
||||
exec.log("Inventar von %s gelöscht", entity.getCommandName());
|
||||
|
|
|
@ -1101,7 +1101,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
{
|
||||
if(this.onPlayerInteract(true, pos)) {
|
||||
this.sendPacket(new SPacketBlockChange(this.entity.worldObj, pos));
|
||||
if(this.entity.getCurrentEquippedItem() != null && this.entity.getCurrentEquippedItem().isEmpty())
|
||||
if(this.entity.getHeldItem() != null && this.entity.getHeldItem().isEmpty())
|
||||
this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = null;
|
||||
this.entity.openContainer.detectAndSendChanges();
|
||||
return;
|
||||
|
@ -1211,7 +1211,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
// }
|
||||
// else
|
||||
// {
|
||||
ItemStack itemstack1 = this.entity.getCurrentEquippedItem();
|
||||
ItemStack itemstack1 = this.entity.getHeldItem();
|
||||
boolean flag = this.entity.canHarvestBlock(iblockstate.getBlock());
|
||||
|
||||
if (itemstack1 != null)
|
||||
|
@ -1323,7 +1323,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
|
||||
private boolean onPlayerInteract(boolean primary, BlockPos pos) {
|
||||
if(this.entity.getCurrentEquippedItem() != null && this.entity.getCurrentEquippedItem().getItem().onAction(this.entity.getCurrentEquippedItem(), this.entity, this.entity.worldObj, primary ? ItemControl.PRIMARY : ItemControl.SECONDARY, pos))
|
||||
if(this.entity.getHeldItem() != null && this.entity.getHeldItem().getItem().onAction(this.entity.getHeldItem(), this.entity, this.entity.worldObj, primary ? ItemControl.PRIMARY : ItemControl.SECONDARY, pos))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -2634,7 +2634,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
break;
|
||||
|
||||
case ITEM_ACTION:
|
||||
ItemStack item = this.entity.getCurrentEquippedItem();
|
||||
ItemStack item = this.entity.getHeldItem();
|
||||
if(item != null) {
|
||||
item.getItem().onAction(item, this.entity, this.entity.worldObj,
|
||||
ItemControl.values()[packetIn.getAuxData() % ItemControl.values().length], null);
|
||||
|
@ -2703,8 +2703,8 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(this.entity.getCurrentEquippedItem() != null) {
|
||||
ItemStack stack = this.entity.getCurrentEquippedItem();
|
||||
else if(this.entity.getHeldItem() != null) {
|
||||
ItemStack stack = this.entity.getHeldItem();
|
||||
stack.setSize(stack.getMaxStackSize());
|
||||
stack.setRepairCost(0);
|
||||
if(stack.getItem().getMaxDamage() > 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue