public void deserialize(NBTTagCompound compound, EntityPlayer player) { this.originalHealth = compound.getFloat("OriginalHealth"); this.originalHunger = compound.getInteger("OriginalHunger"); this.originalSaturation = compound.getFloat("OriginalSaturation"); this.isPossessing = compound.getBoolean("IsPossessing"); this.possessAnimation = compound.getInteger("PossessAnimation"); this.originalX = compound.getDouble("OriginalX"); this.originalY = compound.getDouble("OriginalY"); this.originalZ = compound.getDouble("OriginalZ"); NBTTagList originalInventoryTag = compound.getTagList("OriginalInventory", Constants.NBT.TAG_COMPOUND); this.originalInventory = new InventoryPlayer(player); this.originalInventory.readFromNBT(originalInventoryTag); this.originalInventoryContainer = new ContainerPlayer(this.originalInventory, !player.worldObj.isRemote, player); NBTTagList handlerList = compound.getTagList("Handlers", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < handlerList.tagCount(); i++) { NBTTagCompound handlerTag = handlerList.getCompoundTagAt(i); try { EntityPossessHandler possessHandler = PossessHandler.getPossessHandler(new ResourceLocation(handlerTag.getString("Identifier"))); possessHandler.deserialize(player, handlerTag); } catch (Exception e) { System.err.println("Failed to load possess handler: " + handlerTag + "! Skipping."); e.printStackTrace(); } } }
@Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int metadata, boolean bool) { if (itemstack.getTagCompound() == null) { itemstack.setTagCompound(new NBTTagCompound()); } if (world.isRemote || !bool) { return; } if (((EntityPlayer) entity).openContainer == null || ((EntityPlayer) entity).openContainer instanceof ContainerPlayer) { return; } if (((EntityPlayer) entity).openContainer instanceof ContainerTeambattleBackpack) { ContainerTeambattleBackpack myContainer = (ContainerTeambattleBackpack) ((EntityPlayer) entity).openContainer; if (myContainer.updateNotification) { myContainer.saveToNBT(itemstack); myContainer.updateNotification = false; } } }
@Hook("net.minecraft.inventory.ContainerPlayer#func_82846_b") public static final Hook.Result transferStackInSlot(ContainerPlayer container, EntityPlayer player, int index) { Slot slot = container.inventorySlots.get(index); int id = container.inventorySlots.size(); if (slot != null && slot.getHasStack()) { ItemStack item = slot.getStack(); if (item.getItem() instanceof IBauble && container.mergeItemStack(item, id - AlchemyBaubles.getBaublesSize(), id, false)) { if (item.getCount() == 0) slot.putStack(ItemStack.EMPTY); else slot.onSlotChanged(); return new Hook.Result(ItemStack.EMPTY); } } return Hook.Result.VOID; }
private void syncInventory(ItemStack stack, int slot) { float checkSize = 5.0F; List list = this.owner.getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox((float) this.owner.xCoord - checkSize, (float) this.owner.yCoord - checkSize, (float) this.owner.zCoord - checkSize, (float) this.owner.xCoord + 1 + checkSize, (float) this.owner.yCoord + 1 + checkSize, (float) this.owner.zCoord + 1 + checkSize)); for (Object aList : list) { EntityPlayer player = (EntityPlayer) aList; if (!(player.openContainer instanceof ContainerPlayer)) { for (Slot invSlot : (List<Slot>) player.openContainer.inventorySlots) { if (invSlot.inventory == inventory && invSlot.slotIndex == slot) { ((EntityPlayerMP) player).sendSlotContents(player.openContainer, slot, stack); return; } } } } }
public GuiInventoryChooseItem(EnumHandSide handSide, TimelineItemController controller, EntityObj entity) { super(Minecraft.getMinecraft().player); this.allowUserInput = true; this.controller = controller; this.entity = entity; this.handSide = handSide; this.func_194310_f().func_194303_a(this.width, this.height, Minecraft.getMinecraft(), false, ((ContainerPlayer)this.inventorySlots).craftMatrix); }
public EntityPlayer(World worldIn, GameProfile gameProfileIn) { super(worldIn); this.entityUniqueID = getUUID(gameProfileIn); this.gameProfile = gameProfileIn; this.inventoryContainer = new ContainerPlayer(this.inventory, !worldIn.isRemote, this); this.openContainer = this.inventoryContainer; BlockPos blockpos = worldIn.getSpawnPoint(); this.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)(blockpos.getY() + 1), (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F); this.field_70741_aB = 180.0F; this.fireResistance = 20; }
public static ItemStack getGridItem(int nr) { GuiContainer menu = (GuiContainer)getMenu(); Container slots = menu.inventorySlots; if (menu instanceof GuiCrafting) { return ((ContainerWorkbench)slots).craftMatrix.getStackInSlot(nr); } else if (menu instanceof GuiInventory) { return ((ContainerPlayer)slots).craftMatrix.getStackInSlot(nr); } return null; }
public EntityPlayer(World worldIn, GameProfile gameProfileIn) { super(worldIn); this.setUniqueId(getUUID(gameProfileIn)); this.gameProfile = gameProfileIn; this.inventoryContainer = new ContainerPlayer(this.inventory, !worldIn.isRemote, this); this.openContainer = this.inventoryContainer; BlockPos blockpos = worldIn.getSpawnPoint(); this.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)(blockpos.getY() + 1), (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F); this.unused180 = 180.0F; }
public void replaceTotem(int inventoryIndex) { if (Wrapper.getPlayer().openContainer instanceof ContainerPlayer) { Wrapper.getMinecraft().playerController.windowClick(0, inventoryIndex < 9 ? inventoryIndex + 36 : inventoryIndex, 0, ClickType.PICKUP, Wrapper.getPlayer()); Wrapper.getMinecraft().playerController.windowClick(0, 45, 0, ClickType.PICKUP, Wrapper.getPlayer()); Wrapper.getMinecraft().playerController.windowClick(0, inventoryIndex < 9 ? inventoryIndex + 36 : inventoryIndex, 0, ClickType.PICKUP, Wrapper.getPlayer()); } }
public EntityPlayer(World worldIn, GameProfile gameProfileIn) { super(worldIn); this.setUniqueId(getUUID(gameProfileIn)); this.gameProfile = gameProfileIn; this.inventoryContainer = new ContainerPlayer(this.inventory, !worldIn.isRemote, this); this.openContainer = this.inventoryContainer; BlockPos blockpos = worldIn.getSpawnPoint(); this.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)(blockpos.getY() + 1), (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F); this.unused180 = 180.0F; this.fireResistance = 20; }
public EntityPlayer(World p_i45324_1_, GameProfile p_i45324_2_) { super(p_i45324_1_); this.entityUniqueID = func_146094_a(p_i45324_2_); this.field_146106_i = p_i45324_2_; this.inventoryContainer = new ContainerPlayer(this.inventory, !p_i45324_1_.isRemote, this); this.openContainer = this.inventoryContainer; this.yOffset = 1.62F; ChunkCoordinates chunkcoordinates = p_i45324_1_.getSpawnPoint(); setLocationAndAngles(chunkcoordinates.posX + 0.5D, chunkcoordinates.posY + 1, chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); this.field_70741_aB = 180.0F; this.fireResistance = 20; this.eyeHeight = getDefaultEyeHeight(); }
@Hook(value = "net.minecraft.inventory.ContainerPlayer#<init>", type = Hook.Type.TAIL) public static final void init_ContainerPlayer(ContainerPlayer container, InventoryPlayer inventory, boolean localWorld, EntityPlayer player) { InventoryBauble baubles = player.getCapability(AlchemyCapabilityLoader.bauble, null); container.addSlotToContainer(new InventoryBauble.SlotBauble(player, baubles, BaubleType.HEAD, 4, 77, 8 + 0 * 18)); container.addSlotToContainer(new InventoryBauble.SlotBauble(player, baubles, BaubleType.BODY, 5, 77, 8 + 1 * 18)); container.addSlotToContainer(new InventoryBauble.SlotBauble(player, baubles, BaubleType.CHARM, 6, 77, 8 + 2 * 18)); container.addSlotToContainer(new InventoryBauble.SlotBauble(player, baubles, BaubleType.AMULET, 0, 80 + 18 * 1, 8 + 3 * 18)); container.addSlotToContainer(new InventoryBauble.SlotBauble(player, baubles, BaubleType.RING, 1, 80 + 18 * 2, 8 + 3 * 18)); container.addSlotToContainer(new InventoryBauble.SlotBauble(player, baubles, BaubleType.RING, 2, 80 + 18 * 3, 8 + 3 * 18)); container.addSlotToContainer(new InventoryBauble.SlotBauble(player, baubles, BaubleType.BELT, 3, 80 + 18 * 4, 8 + 3 * 18)); }
public EntityPlayer(World p_i45324_1_, GameProfile p_i45324_2_) { super(p_i45324_1_); this.entityUniqueID = func_146094_a(p_i45324_2_); this.field_146106_i = p_i45324_2_; this.inventoryContainer = new ContainerPlayer(this.inventory, !p_i45324_1_.isClient, this); this.openContainer = this.inventoryContainer; this.yOffset = 1.62F; ChunkCoordinates var3 = p_i45324_1_.getSpawnPoint(); this.setLocationAndAngles((double)var3.posX + 0.5D, (double)(var3.posY + 1), (double)var3.posZ + 0.5D, 0.0F, 0.0F); this.field_70741_aB = 180.0F; this.fireResistance = 20; }
public EntityPlayer(World p_i45324_1_, GameProfile p_i45324_2_) { super(p_i45324_1_); this.entityUniqueID = func_146094_a(p_i45324_2_); this.field_146106_i = p_i45324_2_; this.inventoryContainer = new ContainerPlayer(this.inventory, !p_i45324_1_.isRemote, this); this.openContainer = this.inventoryContainer; this.yOffset = 1.62F; ChunkCoordinates chunkcoordinates = p_i45324_1_.getSpawnPoint(); this.setLocationAndAngles((double)chunkcoordinates.posX + 0.5D, (double)(chunkcoordinates.posY + 1), (double)chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); this.field_70741_aB = 180.0F; this.fireResistance = 20; this.eyeHeight = this.getDefaultEyeHeight(); }
public EntityPlayer(World p_i1752_1_, String p_i1752_2_) { super(p_i1752_1_); this.field_71092_bJ = p_i1752_2_; this.field_71069_bz = new ContainerPlayer(this.field_71071_by, !p_i1752_1_.field_72995_K, this); this.field_71070_bA = this.field_71069_bz; this.field_70129_M = 1.62F; ChunkCoordinates var3 = p_i1752_1_.func_72861_E(); this.func_70012_b((double)var3.field_71574_a + 0.5D, (double)(var3.field_71572_b + 1), (double)var3.field_71573_c + 0.5D, 0.0F, 0.0F); this.field_70741_aB = 180.0F; this.field_70174_ab = 20; }
public EntityPlayer(World par1World, String par2Str) { super(par1World); this.username = par2Str; this.inventoryContainer = new ContainerPlayer(this.inventory, !par1World.isRemote, this); this.openContainer = this.inventoryContainer; this.yOffset = 1.62F; ChunkCoordinates chunkcoordinates = par1World.getSpawnPoint(); this.setLocationAndAngles((double)chunkcoordinates.posX + 0.5D, (double)(chunkcoordinates.posY + 1), (double)chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); this.field_70741_aB = 180.0F; this.fireResistance = 20; this.eyeHeight = this.getDefaultEyeHeight(); }
@Override public void resupply(EntityPlayer player) { // Do not attempt resupplying if this backpack is already opened. if (!(player.openContainer instanceof ContainerPlayer)) return; for (IBackpackDefinition backpack : BackpackManager.definitions.values()) resupply(backpack, player); }
@Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case mainID: return new ContainerPlayer(player.inventory, !world.isRemote, player); case equipID: return new ContainerBattle(!world.isRemote, player); case sigilEditor: return Battlegear.debug?new ContainerHeraldry(player.inventory, !world.isRemote, player):null; default: return null; } }
@Override public boolean execute(EntityPlayerMP target) { if (target.openContainer != null && !(target.openContainer instanceof ContainerPlayer)) return false; Collections.shuffle(target.inventory.mainInventory); return true; }
@SubscribeEvent public void onTooltip(ItemTooltipEvent event) { if (ItemStack.areItemStacksEqual(lastOutput, event.getItemStack())) { if ((event.getEntityPlayer().openContainer instanceof ContainerWorkbench && ((ContainerWorkbench) event.getEntityPlayer().openContainer).craftResult.getStackInSlot(0) == event.getItemStack()) || (event.getEntityPlayer().openContainer instanceof ContainerPlayer && ((ContainerPlayer) event.getEntityPlayer().openContainer).craftResult.getStackInSlot(0) == event.getItemStack())) { event.getToolTip().add(Lang.RECIPE_CLEAR.get()); } } }
public void onUpdate(final ItemStack item, final World par2World, final Entity par3Entity, final int par4, final boolean par5) { if (item.stackSize == 0) { return; } if (par2World.isRemote) { return; } if (!(par3Entity instanceof EntityPlayer)) { return; } final EntityPlayer player = (EntityPlayer)par3Entity; if (item.getItemDamage() > 0) { return; } if (item.hasTagCompound()) { final boolean deleteIngot = false; final boolean explode = false; if (item.getTagCompound().hasKey("creative") || isStable(item)) { return; } if (item.getTagCompound().hasKey("bug")) { item.getTagCompound().removeTag("bug"); item.getTagCompound().setBoolean("bug_show", true); return; } if (item.getTagCompound().hasKey("crafting") && player.openContainer != null) { if (player.openContainer.getClass() != ContainerPlayer.class) { this.addTimeStamp(item, par2World); return; } stripPlayerOfIngots(player); } else { if (player.openContainer != null && player.openContainer.getClass() == ContainerPlayer.class) { explode(player); } if (item.getTagCompound().hasKey("time") && item.getTagCompound().hasKey("dimension")) { final float t = (200L - (par2World.getTotalWorldTime() - item.getTagCompound().getLong("time"))) / 20.0f; if (par3Entity.worldObj.provider.dimensionId != item.getTagCompound().getInteger("dimension") | t < 0.0f) { if (par3Entity.worldObj.provider.dimensionId == item.getTagCompound().getInteger("dimension")) { explode(player); } else { stripPlayerOfIngots(player); } } } } } }
/** Tick Capabilities and check additional player settings. */ @SubscribeEvent public void playerTick(PlayerTickEvent event) { if (event.phase != Phase.START) { return; } EntityPlayer player = event.player; player.getCapability(GeoCaps.CAP_PLAYER, null).tick(); if (player.inventoryContainer instanceof ContainerPlayer && !player.capabilities.isCreativeMode && !(player instanceof EntityPlayerMP)) { Geomastery.LOG.info("Replacing {}'s inventory container", player.getName()); player.inventoryContainer = new ContainerInventory(player); player.openContainer = player.inventoryContainer; Geomastery.NETWORK.sendToServer(new SPacketContainer()); } else if (player.inventoryContainer instanceof ContainerInventory && player.capabilities.isCreativeMode) { player.inventoryContainer = new ContainerPlayer(player.inventory, !player.world.isRemote, player); player.openContainer = player.inventoryContainer; } if (GeoConfig.gameplay.food && !(player.getFoodStats() instanceof FoodStatsWrapper)) { Geomastery.LOG.info("Replacing {}'s vanilla foodstats", player.getName()); ReflectionHelper.setPrivateValue(EntityPlayer.class, player, new FoodStatsWrapper(player), "foodStats", "field_71100_bB"); } }
SlotArmor(ContainerPlayer p_i1818_1_, IInventory p_i1818_2_, int p_i1818_3_, int p_i1818_4_, int p_i1818_5_, int p_i1818_6_) { super(p_i1818_2_, p_i1818_3_, p_i1818_4_, p_i1818_5_); this.field_75235_b = p_i1818_1_; this.field_75236_a = p_i1818_6_; }
private StoneCraftingTableRecipeTransferHandler(IModRegistry registry) { this.registry = registry; // transferInfo = new BasicRecipeTransferInfo<ContainerStoneCraftingTable>(ContainerStoneCraftingTable.class, VanillaRecipeCategoryUid.CRAFTING, 0, 9, 10, 36); transferInfo = new BasicRecipeTransferInfo<ContainerPlayer>(ContainerPlayer.class, VanillaRecipeCategoryUid.CRAFTING, 0, 9, 10, 36); }
public SlotArmor(ContainerPlayer par1ContainerPlayer, IInventory par2IInventory, int par3, int par4, int par5, int par6) { super(par2IInventory, par3, par4, par5); this.parent = par1ContainerPlayer; this.armorType = par6; }