improve renaming and cheats
This commit is contained in:
parent
4d406a70e1
commit
7e9673dc25
36 changed files with 346 additions and 186 deletions
|
@ -43,7 +43,6 @@ import common.inventory.Slot;
|
|||
import common.inventory.SlotCrafting;
|
||||
import common.item.ItemControl;
|
||||
import common.item.ItemStack;
|
||||
import common.item.tool.ItemArmor;
|
||||
import common.log.Log;
|
||||
import common.net.util.concurrent.Future;
|
||||
import common.net.util.concurrent.GenericFutureListener;
|
||||
|
@ -1961,10 +1960,15 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.entity.setDescription(msg.isEmpty() ? null : msg);
|
||||
break;
|
||||
|
||||
// case ITEM:
|
||||
// if(this.entity.openContainer instanceof ContainerRepair)
|
||||
// ((ContainerRepair)this.entity.openContainer).updateItemName(msg);
|
||||
// break;
|
||||
case ITEM:
|
||||
if(msg.length() > 30)
|
||||
throw new IllegalArgumentException("Ungültiger Name");
|
||||
if(packetIn.getArg() == -1)
|
||||
this.entity.inventoryContainer.renameItem(36 + this.entity.inventory.currentItem, msg);
|
||||
else
|
||||
this.entity.openContainer.renameItem(packetIn.getArg(), msg);
|
||||
this.entity.openContainer.detectAndSendChanges();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Ungültiger Nachrichten-Typ!");
|
||||
|
@ -2873,35 +2877,51 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
if(this.charEditor || !this.isAdmin())
|
||||
return;
|
||||
ItemStack stack = packet.getStack();
|
||||
if (stack.getItem() != null && stack.size <= stack.getMaxStackSize() && stack.size > 0 && (!stack.hasTag() || stack.getItem().isValidTag(stack.getTag())))
|
||||
if(stack.getItem() != null && stack.size <= stack.getMaxStackSize() && stack.size > 0 && (!stack.hasTag() || stack.getItem().isValidTag(stack.getTag())))
|
||||
{
|
||||
int amount = stack.size;
|
||||
if(amount <= 0)
|
||||
return;
|
||||
if(packet.getSlot() == -1) {
|
||||
this.entity.inventory.addItemStackToInventory(stack);
|
||||
amount -= stack.size;
|
||||
}
|
||||
else if(packet.getSlot() >= 0 && packet.getSlot() < this.entity.inventory.getSizeInventory() && (packet.getSlot() < this.entity.inventory.mainInventory.length || (stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).armorType.getArmorSlot() == packet.getSlot() - this.entity.inventory.mainInventory.length))) {
|
||||
ItemStack old = this.entity.inventory.getStackInSlot(packet.getSlot());
|
||||
if(old != null) {
|
||||
if(ItemStack.areItemsEqual(stack, old) && ItemStack.areItemStackTagsEqual(stack, old)) {
|
||||
stack.size = Math.min(stack.getMaxStackSize(), old.size + stack.size);
|
||||
amount = stack.size - old.size;
|
||||
}
|
||||
else if(old.size == 1)
|
||||
this.addFeed(TextColor.DRED + "* %s zerstört",
|
||||
old.getColoredName(TextColor.DRED));
|
||||
else
|
||||
this.addFeed(TextColor.DRED + "* %d %s zerstört", old.size,
|
||||
old.getColoredName(TextColor.DRED));
|
||||
}
|
||||
this.entity.inventory.setInventorySlotContents(packet.getSlot(), stack);
|
||||
if(amount <= 0)
|
||||
return;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
if(packet.getSlot() <= -2 - 9)
|
||||
return;
|
||||
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(36 + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
|
||||
if(slot == null || !slot.canCheatItem())
|
||||
return;
|
||||
stack.size = Math.min(slot.getSlotStackLimit(), stack.size);
|
||||
amount = stack.size;
|
||||
if(amount <= 0)
|
||||
return;
|
||||
if(slot.getHasStack()) {
|
||||
ItemStack old = slot.getStack();
|
||||
if(ItemStack.areItemsEqual(stack, old) && ItemStack.areItemStackTagsEqual(stack, old)) {
|
||||
stack.size = Math.min(slot.getSlotStackLimit(), Math.min(stack.getMaxStackSize(), old.size + stack.size));
|
||||
amount = stack.size - old.size;
|
||||
if(amount <= 0 || !slot.isItemValid(stack))
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if(!slot.isItemValid(stack))
|
||||
return;
|
||||
if(old.size == 1)
|
||||
this.addFeed(TextColor.DRED + "* %s zerstört",
|
||||
old.getColoredName(TextColor.DRED));
|
||||
else
|
||||
this.addFeed(TextColor.DRED + "* %d %s zerstört", old.size,
|
||||
old.getColoredName(TextColor.DRED));
|
||||
}
|
||||
}
|
||||
else if(!slot.isItemValid(stack))
|
||||
return;
|
||||
slot.putStack(stack);
|
||||
}
|
||||
this.entity.openContainer.detectAndSendChanges();
|
||||
if(amount <= 0)
|
||||
return;
|
||||
this.entity.worldObj.playSoundAtEntity(this.entity, SoundEvent.POP, 0.2F);
|
||||
if(amount == 1)
|
||||
this.addFeed(TextColor.DGREEN + "* %s geschummelt",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue