@Override public void call(String[] args) throws CmdException { if(args.length > 0) throw new CmdSyntaxError(); // check for creative mode EntityPlayerSP player = WMinecraft.getPlayer(); if(!player.capabilities.isCreativeMode) throw new CmdError("Creative mode only."); // validate item ItemStack item = player.inventory.getCurrentItem(); if(item == null) throw new CmdError("You need an item in your hand."); if(!item.isItemStackDamageable()) throw new CmdError("This item can't take damage."); if(!item.isItemDamaged()) throw new CmdError("This item is not damaged."); // repair item item.setItemDamage(0); WConnection.sendPacket(new CPacketCreativeInventoryAction( 36 + player.inventory.currentItem, item)); }
public static boolean placeStackInHotbar(ItemStack stack) { for(int i = 0; i < 9; i++) if(isSlotEmpty(i)) { WConnection.sendPacket( new CPacketCreativeInventoryAction(36 + i, stack)); return true; } return false; }
@Override public void onUpdate() { if(infinite) { Item item = null; while(item == null) item = Item.getItemById(new Random().nextInt(431)); WConnection.sendPacket(new CPacketCreativeInventoryAction(-1, new ItemStack(item, 64))); return; } if(wurst.special.yesCheatSpf.getProfile().ordinal() >= Profile.OLDER_NCP .ordinal()) { timer++; if(timer >= 5) { WPlayerController.windowClick_THROW(counter); counter++; timer = 0; if(counter >= 45) wurst.events.remove(UpdateListener.class, this); } }else { for(int i = 9; i < 45; i++) WPlayerController.windowClick_THROW(i); wurst.events.remove(UpdateListener.class, this); } }
/** * Used in PlayerControllerMP to update the server with an ItemStack in a slot. */ public void sendSlotPacket(ItemStack itemStackIn, int slotId) { if (this.currentGameType.isCreative()) { this.connection.sendPacket(new CPacketCreativeInventoryAction(slotId, itemStackIn)); } }
/** * Sends a Packet107 to the server to drop the item on the ground */ public void sendPacketDropItem(ItemStack itemStackIn) { if (this.currentGameType.isCreative() && !itemStackIn.func_190926_b()) { this.connection.sendPacket(new CPacketCreativeInventoryAction(-1, itemStackIn)); } }
public static boolean placeStackInHotbar(IItemStack stack) { for (int i = 0; i < 9; i++) if (getStackInSlot(i).isEmpty()) { Minecraft.getMinecraft().player.connection .sendPacket(new CPacketCreativeInventoryAction(36 + i, stack.getStack())); return true; } return false; }
/** * Sends a Packet107 to the server to drop the item on the ground */ public void sendPacketDropItem(ItemStack itemStackIn) { if (this.currentGameType.isCreative() && itemStackIn != null) { this.connection.sendPacket(new CPacketCreativeInventoryAction(-1, itemStackIn)); } }
/** * Update the server with an ItemStack in a slot. */ public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld()); if (this.playerEntity.interactionManager.isCreative()) { boolean flag = packetIn.getSlotId() < 0; ItemStack itemstack = packetIn.getStack(); if (!itemstack.func_190926_b() && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10)) { NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag"); if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z")) { BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z")); TileEntity tileentity = this.playerEntity.world.getTileEntity(blockpos); if (tileentity != null) { NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound()); nbttagcompound1.removeTag("x"); nbttagcompound1.removeTag("y"); nbttagcompound1.removeTag("z"); itemstack.setTagInfo("BlockEntityTag", nbttagcompound1); } } } boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45; boolean flag2 = itemstack.func_190926_b() || itemstack.getMetadata() >= 0 && itemstack.func_190916_E() <= 64 && !itemstack.func_190926_b(); if (flag1 && flag2) { if (itemstack.func_190926_b()) { this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), ItemStack.field_190927_a); } else { this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack); } this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true); } else if (flag && flag2 && this.itemDropThreshold < 200) { this.itemDropThreshold += 20; EntityItem entityitem = this.playerEntity.dropItem(itemstack, true); if (entityitem != null) { entityitem.setAgeToCreativeDespawnTime(); } } } }
/** * Update the server with an ItemStack in a slot. */ public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld()); if (this.playerEntity.interactionManager.isCreative()) { boolean flag = packetIn.getSlotId() < 0; ItemStack itemstack = packetIn.getStack(); if (itemstack != null && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10)) { NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag"); if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z")) { BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z")); TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(blockpos); if (tileentity != null) { NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound()); nbttagcompound1.removeTag("x"); nbttagcompound1.removeTag("y"); nbttagcompound1.removeTag("z"); itemstack.setTagInfo("BlockEntityTag", nbttagcompound1); } } } boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45; boolean flag2 = itemstack == null || itemstack.getItem() != null; boolean flag3 = itemstack == null || itemstack.getMetadata() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0; if (flag1 && flag2 && flag3) { if (itemstack == null) { this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), (ItemStack)null); } else { this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack); } this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true); } else if (flag && flag2 && flag3 && this.itemDropThreshold < 200) { this.itemDropThreshold += 20; EntityItem entityitem = this.playerEntity.dropItem(itemstack, true); if (entityitem != null) { entityitem.setAgeToCreativeDespawnTime(); } } } }
@Override public void processCreativeInventoryAction(CPacketCreativeInventoryAction p_147344_1_) { }
@Override public void processCreativeInventoryAction(@Nonnull CPacketCreativeInventoryAction p_147344_1_) { }
@Override public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn) { }
/** * Update the server with an ItemStack in a slot. */ void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn);