Target HUD
-
package net.minecraft.entity; import com.google.common.collect.Sets; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Set; import net.minecraft.block.Block; import net.minecraft.entity.ai.attributes.ServersideAttributeMap; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.item.EntityBoat; import net.minecraft.entity.item.EntityEnderCrystal; import net.minecraft.entity.item.EntityEnderEye; import net.minecraft.entity.item.EntityEnderPearl; import net.minecraft.entity.item.EntityExpBottle; import net.minecraft.entity.item.EntityFallingBlock; import net.minecraft.entity.item.EntityFireworkRocket; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.item.EntityPainting; import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.passive.IAnimals; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityEgg; import net.minecraft.entity.projectile.EntityFireball; import net.minecraft.entity.projectile.EntityFishHook; import net.minecraft.entity.projectile.EntityPotion; import net.minecraft.entity.projectile.EntitySmallFireball; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraft.entity.projectile.EntityWitherSkull; import net.minecraft.init.Items; import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S04PacketEntityEquipment; import net.minecraft.network.play.server.S0APacketUseBed; import net.minecraft.network.play.server.S0CPacketSpawnPlayer; import net.minecraft.network.play.server.S0EPacketSpawnObject; import net.minecraft.network.play.server.S0FPacketSpawnMob; import net.minecraft.network.play.server.S10PacketSpawnPainting; import net.minecraft.network.play.server.S11PacketSpawnExperienceOrb; import net.minecraft.network.play.server.S12PacketEntityVelocity; import net.minecraft.network.play.server.S14PacketEntity; import net.minecraft.network.play.server.S18PacketEntityTeleport; import net.minecraft.network.play.server.S19PacketEntityHeadLook; import net.minecraft.network.play.server.S1BPacketEntityAttach; import net.minecraft.network.play.server.S1CPacketEntityMetadata; import net.minecraft.network.play.server.S1DPacketEntityEffect; import net.minecraft.network.play.server.S20PacketEntityProperties; import net.minecraft.network.play.server.S49PacketUpdateEntityNBT; import net.minecraft.potion.PotionEffect; import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.world.storage.MapData; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class EntityTrackerEntry { private static final Logger logger = LogManager.getLogger(); /** The entity that this EntityTrackerEntry tracks. */ public Entity trackedEntity; public int trackingDistanceThreshold; /** check for sync when ticks % updateFrequency==0 */ public int updateFrequency; /** The encoded entity X position. */ public int encodedPosX; /** The encoded entity Y position. */ public int encodedPosY; /** The encoded entity Z position. */ public int encodedPosZ; /** The encoded entity yaw rotation. */ public int encodedRotationYaw; /** The encoded entity pitch rotation. */ public int encodedRotationPitch; public int lastHeadMotion; public double lastTrackedEntityMotionX; public double lastTrackedEntityMotionY; public double motionZ; public int updateCounter; private double lastTrackedEntityPosX; private double lastTrackedEntityPosY; private double lastTrackedEntityPosZ; private boolean firstUpdateDone; private boolean sendVelocityUpdates; /** * every 400 ticks a full teleport packet is sent, rather than just a "move me +x" command, so that position * remains fully synced. */ private int ticksSinceLastForcedTeleport; private Entity field_85178_v; private boolean ridingEntity; private boolean field_180234_y; public boolean playerEntitiesUpdated; /** * Holds references to all the players that are currently receiving position updates for this entity. */ public Set trackingPlayers = Sets.newHashSet(); private static final String __OBFID = "CL_00001443"; public EntityTrackerEntry(Entity p_i1525_1_, int p_i1525_2_, int p_i1525_3_, boolean p_i1525_4_) { this.trackedEntity = p_i1525_1_; this.trackingDistanceThreshold = p_i1525_2_; this.updateFrequency = p_i1525_3_; this.sendVelocityUpdates = p_i1525_4_; this.encodedPosX = MathHelper.floor_double(p_i1525_1_.posX * 32.0D); this.encodedPosY = MathHelper.floor_double(p_i1525_1_.posY * 32.0D); this.encodedPosZ = MathHelper.floor_double(p_i1525_1_.posZ * 32.0D); this.encodedRotationYaw = MathHelper.floor_float(p_i1525_1_.rotationYaw * 256.0F / 360.0F); this.encodedRotationPitch = MathHelper.floor_float(p_i1525_1_.rotationPitch * 256.0F / 360.0F); this.lastHeadMotion = MathHelper.floor_float(p_i1525_1_.getRotationYawHead() * 256.0F / 360.0F); this.field_180234_y = p_i1525_1_.onGround; } public boolean equals(Object p_equals_1_) { return p_equals_1_ instanceof EntityTrackerEntry ? ((EntityTrackerEntry)p_equals_1_).trackedEntity.getEntityId() == this.trackedEntity.getEntityId() : false; } public int hashCode() { return this.trackedEntity.getEntityId(); } public void updatePlayerList(List p_73122_1_) { this.playerEntitiesUpdated = false; if (!this.firstUpdateDone || this.trackedEntity.getDistanceSq(this.lastTrackedEntityPosX, this.lastTrackedEntityPosY, this.lastTrackedEntityPosZ) > 16.0D) { this.lastTrackedEntityPosX = this.trackedEntity.posX; this.lastTrackedEntityPosY = this.trackedEntity.posY; this.lastTrackedEntityPosZ = this.trackedEntity.posZ; this.firstUpdateDone = true; this.playerEntitiesUpdated = true; this.updatePlayerEntities(p_73122_1_); } if (this.field_85178_v != this.trackedEntity.ridingEntity || this.trackedEntity.ridingEntity != null && this.updateCounter % 60 == 0) { this.field_85178_v = this.trackedEntity.ridingEntity; this.func_151259_a(new S1BPacketEntityAttach(0, this.trackedEntity, this.trackedEntity.ridingEntity)); } if (this.trackedEntity instanceof EntityItemFrame && this.updateCounter % 10 == 0) { EntityItemFrame var2 = (EntityItemFrame)this.trackedEntity; ItemStack var3 = var2.getDisplayedItem(); if (var3 != null && var3.getItem() instanceof ItemMap) { MapData var4 = Items.filled_map.getMapData(var3, this.trackedEntity.worldObj); Iterator var5 = p_73122_1_.iterator(); while (var5.hasNext()) { EntityPlayer var6 = (EntityPlayer)var5.next(); EntityPlayerMP var7 = (EntityPlayerMP)var6; var4.updateVisiblePlayers(var7, var3); Packet var8 = Items.filled_map.createMapDataPacket(var3, this.trackedEntity.worldObj, var7); if (var8 != null) { var7.playerNetServerHandler.sendPacket(var8); } } } this.sendMetadataToAllAssociatedPlayers(); } if (this.updateCounter % this.updateFrequency == 0 || this.trackedEntity.isAirBorne || this.trackedEntity.getDataWatcher().hasObjectChanged()) { int var23; int var24; if (this.trackedEntity.ridingEntity == null) { ++this.ticksSinceLastForcedTeleport; var23 = MathHelper.floor_double(this.trackedEntity.posX * 32.0D); var24 = MathHelper.floor_double(this.trackedEntity.posY * 32.0D); int var25 = MathHelper.floor_double(this.trackedEntity.posZ * 32.0D); int var27 = MathHelper.floor_float(this.trackedEntity.rotationYaw * 256.0F / 360.0F); int var28 = MathHelper.floor_float(this.trackedEntity.rotationPitch * 256.0F / 360.0F); int var29 = var23 - this.encodedPosX; int var30 = var24 - this.encodedPosY; int var9 = var25 - this.encodedPosZ; Object var10 = null; boolean var11 = Math.abs(var29) >= 4 || Math.abs(var30) >= 4 || Math.abs(var9) >= 4 || this.updateCounter % 60 == 0; boolean var12 = Math.abs(var27 - this.encodedRotationYaw) >= 4 || Math.abs(var28 - this.encodedRotationPitch) >= 4; if (this.updateCounter > 0 || this.trackedEntity instanceof EntityArrow) { if (var29 >= -128 && var29 < 128 && var30 >= -128 && var30 < 128 && var9 >= -128 && var9 < 128 && this.ticksSinceLastForcedTeleport <= 400 && !this.ridingEntity && this.field_180234_y == this.trackedEntity.onGround) { if (var11 && var12) { var10 = new S14PacketEntity.S17PacketEntityLookMove(this.trackedEntity.getEntityId(), (byte)var29, (byte)var30, (byte)var9, (byte)var27, (byte)var28, this.trackedEntity.onGround); } else if (var11) { var10 = new S14PacketEntity.S15PacketEntityRelMove(this.trackedEntity.getEntityId(), (byte)var29, (byte)var30, (byte)var9, this.trackedEntity.onGround); } else if (var12) { var10 = new S14PacketEntity.S16PacketEntityLook(this.trackedEntity.getEntityId(), (byte)var27, (byte)var28, this.trackedEntity.onGround); } } else { this.field_180234_y = this.trackedEntity.onGround; this.ticksSinceLastForcedTeleport = 0; var10 = new S18PacketEntityTeleport(this.trackedEntity.getEntityId(), var23, var24, var25, (byte)var27, (byte)var28, this.trackedEntity.onGround); } } if (this.sendVelocityUpdates) { double var13 = this.trackedEntity.motionX - this.lastTrackedEntityMotionX; double var15 = this.trackedEntity.motionY - this.lastTrackedEntityMotionY; double var17 = this.trackedEntity.motionZ - this.motionZ; double var19 = 0.02D; double var21 = var13 * var13 + var15 * var15 + var17 * var17; if (var21 > var19 * var19 || var21 > 0.0D && this.trackedEntity.motionX == 0.0D && this.trackedEntity.motionY == 0.0D && this.trackedEntity.motionZ == 0.0D) { this.lastTrackedEntityMotionX = this.trackedEntity.motionX; this.lastTrackedEntityMotionY = this.trackedEntity.motionY; this.motionZ = this.trackedEntity.motionZ; this.func_151259_a(new S12PacketEntityVelocity(this.trackedEntity.getEntityId(), this.lastTrackedEntityMotionX, this.lastTrackedEntityMotionY, this.motionZ)); } } if (var10 != null) { this.func_151259_a((Packet)var10); } this.sendMetadataToAllAssociatedPlayers(); if (var11) { this.encodedPosX = var23; this.encodedPosY = var24; this.encodedPosZ = var25; } if (var12) { this.encodedRotationYaw = var27; this.encodedRotationPitch = var28; } this.ridingEntity = false; } else { var23 = MathHelper.floor_float(this.trackedEntity.rotationYaw * 256.0F / 360.0F); var24 = MathHelper.floor_float(this.trackedEntity.rotationPitch * 256.0F / 360.0F); boolean var26 = Math.abs(var23 - this.encodedRotationYaw) >= 4 || Math.abs(var24 - this.encodedRotationPitch) >= 4; if (var26) { this.func_151259_a(new S14PacketEntity.S16PacketEntityLook(this.trackedEntity.getEntityId(), (byte)var23, (byte)var24, this.trackedEntity.onGround)); this.encodedRotationYaw = var23; this.encodedRotationPitch = var24; } this.encodedPosX = MathHelper.floor_double(this.trackedEntity.posX * 32.0D); this.encodedPosY = MathHelper.floor_double(this.trackedEntity.posY * 32.0D); this.encodedPosZ = MathHelper.floor_double(this.trackedEntity.posZ * 32.0D); this.sendMetadataToAllAssociatedPlayers(); this.ridingEntity = true; } var23 = MathHelper.floor_float(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F); if (Math.abs(var23 - this.lastHeadMotion) >= 4) { this.func_151259_a(new S19PacketEntityHeadLook(this.trackedEntity, (byte)var23)); this.lastHeadMotion = var23; } this.trackedEntity.isAirBorne = false; } ++this.updateCounter; if (this.trackedEntity.velocityChanged) { this.func_151261_b(new S12PacketEntityVelocity(this.trackedEntity)); this.trackedEntity.velocityChanged = false; } } /** * Sends the entity metadata (DataWatcher) and attributes to all players tracking this entity, including the entity * itself if a player. */ private void sendMetadataToAllAssociatedPlayers() { DataWatcher var1 = this.trackedEntity.getDataWatcher(); if (var1.hasObjectChanged()) { this.func_151261_b(new S1CPacketEntityMetadata(this.trackedEntity.getEntityId(), var1, false)); } if (this.trackedEntity instanceof EntityLivingBase) { ServersideAttributeMap var2 = (ServersideAttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap(); Set var3 = var2.getAttributeInstanceSet(); if (!var3.isEmpty()) { this.func_151261_b(new S20PacketEntityProperties(this.trackedEntity.getEntityId(), var3)); } var3.clear(); } } public void func_151259_a(Packet p_151259_1_) { Iterator var2 = this.trackingPlayers.iterator(); while (var2.hasNext()) { EntityPlayerMP var3 = (EntityPlayerMP)var2.next(); var3.playerNetServerHandler.sendPacket(p_151259_1_); } } public void func_151261_b(Packet p_151261_1_) { this.func_151259_a(p_151261_1_); if (this.trackedEntity instanceof EntityPlayerMP) { ((EntityPlayerMP)this.trackedEntity).playerNetServerHandler.sendPacket(p_151261_1_); } } public void sendDestroyEntityPacketToTrackedPlayers() { Iterator var1 = this.trackingPlayers.iterator(); while (var1.hasNext()) { EntityPlayerMP var2 = (EntityPlayerMP)var1.next(); var2.func_152339_d(this.trackedEntity); } } public void removeFromTrackedPlayers(EntityPlayerMP p_73118_1_) { if (this.trackingPlayers.contains(p_73118_1_)) { p_73118_1_.func_152339_d(this.trackedEntity); this.trackingPlayers.remove(p_73118_1_); } } public void updatePlayerEntity(EntityPlayerMP p_73117_1_) { if (p_73117_1_ != this.trackedEntity) { if (this.func_180233_c(p_73117_1_)) { if (!this.trackingPlayers.contains(p_73117_1_) && (this.isPlayerWatchingThisChunk(p_73117_1_) || this.trackedEntity.forceSpawn)) { this.trackingPlayers.add(p_73117_1_); Packet var2 = this.func_151260_c(); p_73117_1_.playerNetServerHandler.sendPacket(var2); if (!this.trackedEntity.getDataWatcher().getIsBlank()) { p_73117_1_.playerNetServerHandler.sendPacket(new S1CPacketEntityMetadata(this.trackedEntity.getEntityId(), this.trackedEntity.getDataWatcher(), true)); } NBTTagCompound var3 = this.trackedEntity.func_174819_aU(); if (var3 != null) { p_73117_1_.playerNetServerHandler.sendPacket(new S49PacketUpdateEntityNBT(this.trackedEntity.getEntityId(), var3)); } if (this.trackedEntity instanceof EntityLivingBase) { ServersideAttributeMap var4 = (ServersideAttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap(); Collection var5 = var4.getWatchedAttributes(); if (!var5.isEmpty()) { p_73117_1_.playerNetServerHandler.sendPacket(new S20PacketEntityProperties(this.trackedEntity.getEntityId(), var5)); } } this.lastTrackedEntityMotionX = this.trackedEntity.motionX; this.lastTrackedEntityMotionY = this.trackedEntity.motionY; this.motionZ = this.trackedEntity.motionZ; if (this.sendVelocityUpdates && !(var2 instanceof S0FPacketSpawnMob)) { p_73117_1_.playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(this.trackedEntity.getEntityId(), this.trackedEntity.motionX, this.trackedEntity.motionY, this.trackedEntity.motionZ)); } if (this.trackedEntity.ridingEntity != null) { p_73117_1_.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this.trackedEntity, this.trackedEntity.ridingEntity)); } if (this.trackedEntity instanceof EntityLiving && ((EntityLiving)this.trackedEntity).getLeashedToEntity() != null) { p_73117_1_.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, this.trackedEntity, ((EntityLiving)this.trackedEntity).getLeashedToEntity())); } if (this.trackedEntity instanceof EntityLivingBase) { for (int var7 = 0; var7 < 5; ++var7) { ItemStack var10 = ((EntityLivingBase)this.trackedEntity).getEquipmentInSlot(var7); if (var10 != null) { p_73117_1_.playerNetServerHandler.sendPacket(new S04PacketEntityEquipment(this.trackedEntity.getEntityId(), var7, var10)); } } } if (this.trackedEntity instanceof EntityPlayer) { EntityPlayer var8 = (EntityPlayer)this.trackedEntity; if (var8.isPlayerSleeping()) { p_73117_1_.playerNetServerHandler.sendPacket(new S0APacketUseBed(var8, new BlockPos(this.trackedEntity))); } } if (this.trackedEntity instanceof EntityLivingBase) { EntityLivingBase var9 = (EntityLivingBase)this.trackedEntity; Iterator var11 = var9.getActivePotionEffects().iterator(); while (var11.hasNext()) { PotionEffect var6 = (PotionEffect)var11.next(); p_73117_1_.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(this.trackedEntity.getEntityId(), var6)); } } } } else if (this.trackingPlayers.contains(p_73117_1_)) { this.trackingPlayers.remove(p_73117_1_); p_73117_1_.func_152339_d(this.trackedEntity); } } } public boolean func_180233_c(EntityPlayerMP p_180233_1_) { double var2 = p_180233_1_.posX - (double)(this.encodedPosX / 32); double var4 = p_180233_1_.posZ - (double)(this.encodedPosZ / 32); return var2 >= (double)(-this.trackingDistanceThreshold) && var2 <= (double)this.trackingDistanceThreshold && var4 >= (double)(-this.trackingDistanceThreshold) && var4 <= (double)this.trackingDistanceThreshold && this.trackedEntity.func_174827_a(p_180233_1_); } private boolean isPlayerWatchingThisChunk(EntityPlayerMP p_73121_1_) { return p_73121_1_.getServerForPlayer().getPlayerManager().isPlayerWatchingChunk(p_73121_1_, this.trackedEntity.chunkCoordX, this.trackedEntity.chunkCoordZ); } public void updatePlayerEntities(List p_73125_1_) { for (int var2 = 0; var2 < p_73125_1_.size(); ++var2) { this.updatePlayerEntity((EntityPlayerMP)p_73125_1_.get(var2)); } } private Packet func_151260_c() { if (this.trackedEntity.isDead) { logger.warn("Fetching addPacket for removed entity"); } if (this.trackedEntity instanceof EntityItem) { return new S0EPacketSpawnObject(this.trackedEntity, 2, 1); } else if (this.trackedEntity instanceof EntityPlayerMP) { return new S0CPacketSpawnPlayer((EntityPlayer)this.trackedEntity); } else if (this.trackedEntity instanceof EntityMinecart) { EntityMinecart var9 = (EntityMinecart)this.trackedEntity; return new S0EPacketSpawnObject(this.trackedEntity, 10, var9.func_180456_s().func_180039_a()); } else if (this.trackedEntity instanceof EntityBoat) { return new S0EPacketSpawnObject(this.trackedEntity, 1); } else if (this.trackedEntity instanceof IAnimals) { this.lastHeadMotion = MathHelper.floor_float(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F); return new S0FPacketSpawnMob((EntityLivingBase)this.trackedEntity); } else if (this.trackedEntity instanceof EntityFishHook) { EntityPlayer var8 = ((EntityFishHook)this.trackedEntity).angler; return new S0EPacketSpawnObject(this.trackedEntity, 90, var8 != null ? var8.getEntityId() : this.trackedEntity.getEntityId()); } else if (this.trackedEntity instanceof EntityArrow) { Entity var7 = ((EntityArrow)this.trackedEntity).shootingEntity; return new S0EPacketSpawnObject(this.trackedEntity, 60, var7 != null ? var7.getEntityId() : this.trackedEntity.getEntityId()); } else if (this.trackedEntity instanceof EntitySnowball) { return new S0EPacketSpawnObject(this.trackedEntity, 61); } else if (this.trackedEntity instanceof EntityPotion) { return new S0EPacketSpawnObject(this.trackedEntity, 73, ((EntityPotion)this.trackedEntity).getPotionDamage()); } else if (this.trackedEntity instanceof EntityExpBottle) { return new S0EPacketSpawnObject(this.trackedEntity, 75); } else if (this.trackedEntity instanceof EntityEnderPearl) { return new S0EPacketSpawnObject(this.trackedEntity, 65); } else if (this.trackedEntity instanceof EntityEnderEye) { return new S0EPacketSpawnObject(this.trackedEntity, 72); } else if (this.trackedEntity instanceof EntityFireworkRocket) { return new S0EPacketSpawnObject(this.trackedEntity, 76); } else { S0EPacketSpawnObject var2; if (this.trackedEntity instanceof EntityFireball) { EntityFireball var6 = (EntityFireball)this.trackedEntity; var2 = null; byte var10 = 63; if (this.trackedEntity instanceof EntitySmallFireball) { var10 = 64; } else if (this.trackedEntity instanceof EntityWitherSkull) { var10 = 66; } if (var6.shootingEntity != null) { var2 = new S0EPacketSpawnObject(this.trackedEntity, var10, ((EntityFireball)this.trackedEntity).shootingEntity.getEntityId()); } else { var2 = new S0EPacketSpawnObject(this.trackedEntity, var10, 0); } var2.func_149003_d((int)(var6.accelerationX * 8000.0D)); var2.func_149000_e((int)(var6.accelerationY * 8000.0D)); var2.func_149007_f((int)(var6.accelerationZ * 8000.0D)); return var2; } else if (this.trackedEntity instanceof EntityEgg) { return new S0EPacketSpawnObject(this.trackedEntity, 62); } else if (this.trackedEntity instanceof EntityTNTPrimed) { return new S0EPacketSpawnObject(this.trackedEntity, 50); } else if (this.trackedEntity instanceof EntityEnderCrystal) { return new S0EPacketSpawnObject(this.trackedEntity, 51); } else if (this.trackedEntity instanceof EntityFallingBlock) { EntityFallingBlock var5 = (EntityFallingBlock)this.trackedEntity; return new S0EPacketSpawnObject(this.trackedEntity, 70, Block.getStateId(var5.getBlock())); } else if (this.trackedEntity instanceof EntityArmorStand) { return new S0EPacketSpawnObject(this.trackedEntity, 78); } else if (this.trackedEntity instanceof EntityPainting) { return new S10PacketSpawnPainting((EntityPainting)this.trackedEntity); } else { BlockPos var3; if (this.trackedEntity instanceof EntityItemFrame) { EntityItemFrame var4 = (EntityItemFrame)this.trackedEntity; var2 = new S0EPacketSpawnObject(this.trackedEntity, 71, var4.field_174860_b.getHorizontalIndex()); var3 = var4.func_174857_n(); var2.func_148996_a(MathHelper.floor_float((float)(var3.getX() * 32))); var2.func_148995_b(MathHelper.floor_float((float)(var3.getY() * 32))); var2.func_149005_c(MathHelper.floor_float((float)(var3.getZ() * 32))); return var2; } else if (this.trackedEntity instanceof EntityLeashKnot) { EntityLeashKnot var1 = (EntityLeashKnot)this.trackedEntity; var2 = new S0EPacketSpawnObject(this.trackedEntity, 77); var3 = var1.func_174857_n(); var2.func_148996_a(MathHelper.floor_float((float)(var3.getX() * 32))); var2.func_148995_b(MathHelper.floor_float((float)(var3.getY() * 32))); var2.func_149005_c(MathHelper.floor_float((float)(var3.getZ() * 32))); return var2; } else if (this.trackedEntity instanceof EntityXPOrb) { return new S11PacketSpawnExperienceOrb((EntityXPOrb)this.trackedEntity); } else { throw new IllegalArgumentException("Don\'t know how to add " + this.trackedEntity.getClass() + "!"); } } } } /** * Remove a tracked player from our list and tell the tracked player to destroy us from their world. */ public void removeTrackedPlayerSymmetric(EntityPlayerMP p_73123_1_) { if (this.trackingPlayers.contains(p_73123_1_)) { this.trackingPlayers.remove(p_73123_1_); p_73123_1_.func_152339_d(this.trackedEntity); } } }
-
package net.minecraft.client.gui.inventory; import com.google.common.collect.Lists; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Map; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.achievement.GuiAchievements; import net.minecraft.client.gui.achievement.GuiStats; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.InventoryEffectRenderer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.GameSettings; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryBasic; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; public class GuiContainerCreative extends InventoryEffectRenderer { /** * The location of the creative inventory tabs texture */ private static final ResourceLocation creativeInventoryTabs = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); public static InventoryBasic field_147060_v = new InventoryBasic("tmp", true, 45); /** * Currently selected creative inventory tab index. */ private static int selectedTabIndex = CreativeTabs.tabBlock.getTabIndex(); /** * Amount scrolled in Creative mode inventory (0 = top, 1 = bottom) */ private float currentScroll; /** * True if the scrollbar is being dragged */ private boolean isScrolling; /** * True if the left mouse button was held down last time drawScreen was called. */ private boolean wasClicking; private GuiTextField searchField; private List<Slot> field_147063_B; private Slot field_147064_C; private boolean field_147057_D; private CreativeCrafting field_147059_E; public GuiContainerCreative(EntityPlayer p_i1088_1_) { super(new GuiContainerCreative.ContainerCreative(p_i1088_1_)); p_i1088_1_.openContainer = this.inventorySlots; this.allowUserInput = true; this.ySize = 136; this.xSize = 195; } /** * Called from the main game loop to update the screen. */ public void updateScreen() { if (!this.mc.playerController.isInCreativeMode()) { this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer)); } this.updateActivePotionEffects(); } /** * Called when the mouse is clicked over a slot or outside the gui. */ public void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) { this.field_147057_D = true; boolean flag = clickType == 1; clickType = slotId == -999 && clickType == 0 ? 4 : clickType; if (slotIn == null && selectedTabIndex != CreativeTabs.tabInventory.getTabIndex() && clickType != 5) { InventoryPlayer inventoryplayer1 = this.mc.thePlayer.inventory; if (inventoryplayer1.getItemStack() != null) { if (clickedButton == 0) { this.mc.thePlayer.dropPlayerItemWithRandomChoice(inventoryplayer1.getItemStack(), true); this.mc.playerController.sendPacketDropItem(inventoryplayer1.getItemStack()); inventoryplayer1.setItemStack((ItemStack) null); } if (clickedButton == 1) { ItemStack itemstack5 = inventoryplayer1.getItemStack().splitStack(1); this.mc.thePlayer.dropPlayerItemWithRandomChoice(itemstack5, true); this.mc.playerController.sendPacketDropItem(itemstack5); if (inventoryplayer1.getItemStack().stackSize == 0) { inventoryplayer1.setItemStack((ItemStack) null); } } } } else if (slotIn == this.field_147064_C && flag) { for (int j = 0; j < this.mc.thePlayer.inventoryContainer.getInventory().size(); ++j) { this.mc.playerController.sendSlotPacket((ItemStack) null, j); } } else if (selectedTabIndex == CreativeTabs.tabInventory.getTabIndex()) { if (slotIn == this.field_147064_C) { this.mc.thePlayer.inventory.setItemStack((ItemStack) null); } else if (clickType == 4 && slotIn != null && slotIn.getHasStack()) { ItemStack itemstack = slotIn.decrStackSize(clickedButton == 0 ? 1 : slotIn.getStack().getMaxStackSize()); this.mc.thePlayer.dropPlayerItemWithRandomChoice(itemstack, true); this.mc.playerController.sendPacketDropItem(itemstack); } else if (clickType == 4 && this.mc.thePlayer.inventory.getItemStack() != null) { this.mc.thePlayer.dropPlayerItemWithRandomChoice(this.mc.thePlayer.inventory.getItemStack(), true); this.mc.playerController.sendPacketDropItem(this.mc.thePlayer.inventory.getItemStack()); this.mc.thePlayer.inventory.setItemStack((ItemStack) null); } else { this.mc.thePlayer.inventoryContainer.slotClick(slotIn == null ? slotId : ((GuiContainerCreative.CreativeSlot) slotIn).slot.slotNumber, clickedButton, clickType, this.mc.thePlayer); this.mc.thePlayer.inventoryContainer.detectAndSendChanges(); } } else if (clickType != 5 && slotIn.inventory == field_147060_v) { InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory; ItemStack itemstack1 = inventoryplayer.getItemStack(); ItemStack itemstack2 = slotIn.getStack(); if (clickType == 2) { if (itemstack2 != null && clickedButton >= 0 && clickedButton < 9) { ItemStack itemstack7 = itemstack2.copy(); itemstack7.stackSize = itemstack7.getMaxStackSize(); this.mc.thePlayer.inventory.setInventorySlotContents(clickedButton, itemstack7); this.mc.thePlayer.inventoryContainer.detectAndSendChanges(); } return; } if (clickType == 3) { if (inventoryplayer.getItemStack() == null && slotIn.getHasStack()) { ItemStack itemstack6 = slotIn.getStack().copy(); itemstack6.stackSize = itemstack6.getMaxStackSize(); inventoryplayer.setItemStack(itemstack6); } return; } if (clickType == 4) { if (itemstack2 != null) { ItemStack itemstack3 = itemstack2.copy(); itemstack3.stackSize = clickedButton == 0 ? 1 : itemstack3.getMaxStackSize(); this.mc.thePlayer.dropPlayerItemWithRandomChoice(itemstack3, true); this.mc.playerController.sendPacketDropItem(itemstack3); } return; } if (itemstack1 != null && itemstack2 != null && itemstack1.isItemEqual(itemstack2)) { if (clickedButton == 0) { if (flag) { itemstack1.stackSize = itemstack1.getMaxStackSize(); } else if (itemstack1.stackSize < itemstack1.getMaxStackSize()) { ++itemstack1.stackSize; } } else if (itemstack1.stackSize <= 1) { inventoryplayer.setItemStack((ItemStack) null); } else { --itemstack1.stackSize; } } else if (itemstack2 != null && itemstack1 == null) { inventoryplayer.setItemStack(ItemStack.copyItemStack(itemstack2)); itemstack1 = inventoryplayer.getItemStack(); if (flag) { itemstack1.stackSize = itemstack1.getMaxStackSize(); } } else { inventoryplayer.setItemStack((ItemStack) null); } } else { this.inventorySlots.slotClick(slotIn == null ? slotId : slotIn.slotNumber, clickedButton, clickType, this.mc.thePlayer); if (Container.getDragEvent(clickedButton) == 2) { for (int i = 0; i < 9; ++i) { this.mc.playerController.sendSlotPacket(this.inventorySlots.getSlot(45 + i).getStack(), 36 + i); } } else if (slotIn != null) { ItemStack itemstack4 = this.inventorySlots.getSlot(slotIn.slotNumber).getStack(); this.mc.playerController.sendSlotPacket(itemstack4, slotIn.slotNumber - this.inventorySlots.inventorySlots.size() + 9 + 36); } } } protected void updateActivePotionEffects() { int i = this.guiLeft; super.updateActivePotionEffects(); if (this.searchField != null && this.guiLeft != i) { this.searchField.xPosition = this.guiLeft + 82; } } /** * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the * window resizes, the buttonList is cleared beforehand. */ public void initGui() { if (this.mc.playerController.isInCreativeMode()) { super.initGui(); this.buttonList.clear(); Keyboard.enableRepeatEvents(true); this.searchField = new GuiTextField(0, this.fontRendererObj, this.guiLeft + 82, this.guiTop + 6, 89, this.fontRendererObj.FONT_HEIGHT); this.searchField.setMaxStringLength(15); this.searchField.setEnableBackgroundDrawing(false); this.searchField.setVisible(false); this.searchField.setTextColor(16777215); int i = selectedTabIndex; selectedTabIndex = -1; this.setCurrentCreativeTab(CreativeTabs.creativeTabArray[i]); this.field_147059_E = new CreativeCrafting(this.mc); this.mc.thePlayer.inventoryContainer.onCraftGuiOpened(this.field_147059_E); } else { this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer)); } } /** * Called when the screen is unloaded. Used to disable keyboard repeat events */ public void onGuiClosed() { super.onGuiClosed(); if (this.mc.thePlayer != null && this.mc.thePlayer.inventory != null) { this.mc.thePlayer.inventoryContainer.removeCraftingFromCrafters(this.field_147059_E); } Keyboard.enableRepeatEvents(false); } /** * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code) */ protected void keyTyped(char typedChar, int keyCode) throws IOException { if (selectedTabIndex != CreativeTabs.tabAllSearch.getTabIndex()) { if (GameSettings.isKeyDown(this.mc.gameSettings.keyBindChat)) { this.setCurrentCreativeTab(CreativeTabs.tabAllSearch); } else { super.keyTyped(typedChar, keyCode); } } else { if (this.field_147057_D) { this.field_147057_D = false; this.searchField.setText(""); } if (!this.checkHotbarKeys(keyCode)) { if (this.searchField.textboxKeyTyped(typedChar, keyCode)) { this.updateCreativeSearch(); } else { super.keyTyped(typedChar, keyCode); } } } } private void updateCreativeSearch() { GuiContainerCreative.ContainerCreative guicontainercreative$containercreative = (GuiContainerCreative.ContainerCreative) this.inventorySlots; guicontainercreative$containercreative.itemList.clear(); for (Item item : Item.itemRegistry) { if (item != null && item.getCreativeTab() != null) { item.getSubItems(item, (CreativeTabs) null, guicontainercreative$containercreative.itemList); } } for (Enchantment enchantment : Enchantment.enchantmentsBookList) { if (enchantment != null && enchantment.type != null) { Items.enchanted_book.getAll(enchantment, guicontainercreative$containercreative.itemList); } } Iterator<ItemStack> iterator = guicontainercreative$containercreative.itemList.iterator(); String s1 = this.searchField.getText().toLowerCase(); while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); boolean flag = false; for (String s : itemstack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips)) { if (EnumChatFormatting.getTextWithoutFormattingCodes(s).toLowerCase().contains(s1)) { flag = true; break; } } if (!flag) { iterator.remove(); } } this.currentScroll = 0.0F; guicontainercreative$containercreative.scrollTo(0.0F); } /** * Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY */ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { CreativeTabs creativetabs = CreativeTabs.creativeTabArray[selectedTabIndex]; if (creativetabs.drawInForegroundOfTab()) { GlStateManager.disableBlend(); this.fontRendererObj.drawString(I18n.format(creativetabs.getTranslatedTabLabel(), new Object[0]), 8, 6, 4210752); } } /** * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton */ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { if (mouseButton == 0) { int i = mouseX - this.guiLeft; int j = mouseY - this.guiTop; for (CreativeTabs creativetabs : CreativeTabs.creativeTabArray) { if (this.isMouseOverTab(creativetabs, i, j)) { return; } } } super.mouseClicked(mouseX, mouseY, mouseButton); } /** * Called when a mouse button is released. Args : mouseX, mouseY, releaseButton */ protected void mouseReleased(int mouseX, int mouseY, int state) { if (state == 0) { int i = mouseX - this.guiLeft; int j = mouseY - this.guiTop; for (CreativeTabs creativetabs : CreativeTabs.creativeTabArray) { if (this.isMouseOverTab(creativetabs, i, j)) { this.setCurrentCreativeTab(creativetabs); return; } } } super.mouseReleased(mouseX, mouseY, state); } /** * returns (if you are not on the inventoryTab) and (the flag isn't set) and (you have more than 1 page of items) */ private boolean needsScrollBars() { return selectedTabIndex != CreativeTabs.tabInventory.getTabIndex() && CreativeTabs.creativeTabArray[selectedTabIndex].shouldHidePlayerInventory() && ((GuiContainerCreative.ContainerCreative) this.inventorySlots).func_148328_e(); } private void setCurrentCreativeTab(CreativeTabs p_147050_1_) { int i = selectedTabIndex; selectedTabIndex = p_147050_1_.getTabIndex(); GuiContainerCreative.ContainerCreative guicontainercreative$containercreative = (GuiContainerCreative.ContainerCreative) this.inventorySlots; this.dragSplittingSlots.clear(); guicontainercreative$containercreative.itemList.clear(); p_147050_1_.displayAllReleventItems(guicontainercreative$containercreative.itemList); if (p_147050_1_ == CreativeTabs.tabInventory) { Container container = this.mc.thePlayer.inventoryContainer; if (this.field_147063_B == null) { this.field_147063_B = guicontainercreative$containercreative.inventorySlots; } guicontainercreative$containercreative.inventorySlots = Lists.<Slot>newArrayList(); for (int j = 0; j < container.inventorySlots.size(); ++j) { Slot slot = new GuiContainerCreative.CreativeSlot(container.inventorySlots.get(j), j); guicontainercreative$containercreative.inventorySlots.add(slot); if (j >= 5 && j < 9) { int j1 = j - 5; int k1 = j1 / 2; int l1 = j1 % 2; slot.xDisplayPosition = 9 + k1 * 54; slot.yDisplayPosition = 6 + l1 * 27; } else if (j >= 0 && j < 5) { slot.yDisplayPosition = -2000; slot.xDisplayPosition = -2000; } else if (j < container.inventorySlots.size()) { int k = j - 9; int l = k % 9; int i1 = k / 9; slot.xDisplayPosition = 9 + l * 18; if (j >= 36) { slot.yDisplayPosition = 112; } else { slot.yDisplayPosition = 54 + i1 * 18; } } } this.field_147064_C = new Slot(field_147060_v, 0, 173, 112); guicontainercreative$containercreative.inventorySlots.add(this.field_147064_C); } else if (i == CreativeTabs.tabInventory.getTabIndex()) { guicontainercreative$containercreative.inventorySlots = this.field_147063_B; this.field_147063_B = null; } if (this.searchField != null) { if (p_147050_1_ == CreativeTabs.tabAllSearch) { this.searchField.setVisible(true); this.searchField.setCanLoseFocus(false); this.searchField.setFocused(true); this.searchField.setText(""); this.updateCreativeSearch(); } else { this.searchField.setVisible(false); this.searchField.setCanLoseFocus(true); this.searchField.setFocused(false); } } this.currentScroll = 0.0F; guicontainercreative$containercreative.scrollTo(0.0F); } /** * Handles mouse input. */ public void handleMouseInput() throws IOException { super.handleMouseInput(); int i = Mouse.getEventDWheel(); if (i != 0 && this.needsScrollBars()) { int j = ((GuiContainerCreative.ContainerCreative) this.inventorySlots).itemList.size() / 9 - 5; if (i > 0) { i = 1; } if (i < 0) { i = -1; } this.currentScroll = (float) ((double) this.currentScroll - (double) i / (double) j); this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F); ((GuiContainerCreative.ContainerCreative) this.inventorySlots).scrollTo(this.currentScroll); } } /** * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks */ public void drawScreen(int mouseX, int mouseY, float partialTicks) { boolean flag = Mouse.isButtonDown(0); int i = this.guiLeft; int j = this.guiTop; int k = i + 175; int l = j + 18; int i1 = k + 14; int j1 = l + 112; if (!this.wasClicking && flag && mouseX >= k && mouseY >= l && mouseX < i1 && mouseY < j1) { this.isScrolling = this.needsScrollBars(); } if (!flag) { this.isScrolling = false; } this.wasClicking = flag; if (this.isScrolling) { this.currentScroll = ((float) (mouseY - l) - 7.5F) / ((float) (j1 - l) - 15.0F); this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F); ((GuiContainerCreative.ContainerCreative) this.inventorySlots).scrollTo(this.currentScroll); } super.drawScreen(mouseX, mouseY, partialTicks); for (CreativeTabs creativetabs : CreativeTabs.creativeTabArray) { if (this.renderCreativeInventoryHoveringText(creativetabs, mouseX, mouseY)) { break; } } if (this.field_147064_C != null && selectedTabIndex == CreativeTabs.tabInventory.getTabIndex() && this.isPointInRegion(this.field_147064_C.xDisplayPosition, this.field_147064_C.yDisplayPosition, 16, 16, mouseX, mouseY)) { this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), mouseX, mouseY); } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableLighting(); } protected void renderToolTip(ItemStack stack, int x, int y) { if (selectedTabIndex == CreativeTabs.tabAllSearch.getTabIndex()) { List<String> list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); CreativeTabs creativetabs = stack.getItem().getCreativeTab(); if (creativetabs == null && stack.getItem() == Items.enchanted_book) { Map<Integer, Integer> map = EnchantmentHelper.getEnchantments(stack); if (map.size() == 1) { Enchantment enchantment = Enchantment.getEnchantmentById(((Integer) map.keySet().iterator().next()).intValue()); for (CreativeTabs creativetabs1 : CreativeTabs.creativeTabArray) { if (creativetabs1.hasRelevantEnchantmentType(enchantment.type)) { creativetabs = creativetabs1; break; } } } } if (creativetabs != null) { list.add(1, "" + EnumChatFormatting.BOLD + EnumChatFormatting.BLUE + I18n.format(creativetabs.getTranslatedTabLabel(), new Object[0])); } for (int i = 0; i < list.size(); ++i) { if (i == 0) { list.set(i, stack.getRarity().rarityColor + list.get(i)); } else { list.set(i, EnumChatFormatting.GRAY + list.get(i)); } } this.drawHoveringText(list, x, y); } else { super.renderToolTip(stack, x, y); } } /** * Args : renderPartialTicks, mouseX, mouseY */ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); RenderHelper.enableGUIStandardItemLighting(); CreativeTabs creativetabs = CreativeTabs.creativeTabArray[selectedTabIndex]; for (CreativeTabs creativetabs1 : CreativeTabs.creativeTabArray) { this.mc.getTextureManager().bindTexture(creativeInventoryTabs); if (creativetabs1.getTabIndex() != selectedTabIndex) { this.drawTab(creativetabs1); } } this.mc.getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/creative_inventory/tab_" + creativetabs.getBackgroundImageName())); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); this.searchField.drawTextBox(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); int i = this.guiLeft + 175; int j = this.guiTop + 18; int k = j + 112; this.mc.getTextureManager().bindTexture(creativeInventoryTabs); if (creativetabs.shouldHidePlayerInventory()) { this.drawTexturedModalRect(i, j + (int) ((float) (k - j - 17) * this.currentScroll), 232 + (this.needsScrollBars() ? 0 : 12), 0, 12, 15); } this.drawTab(creativetabs); if (creativetabs == CreativeTabs.tabInventory) { GuiInventory.drawEntityOnScreen(this.guiLeft + 43, this.guiTop + 45, 20, (float) (this.guiLeft + 43 - mouseX), (float) (this.guiTop + 45 - 30 - mouseY), this.mc.thePlayer); } } protected boolean isMouseOverTab(CreativeTabs currentTab, int mouseX, int mouseY) { int i = currentTab.getTabColumn(); int x = 28 * i; int y = 0; if (i == 5) { x = this.xSize - 28 + 2; } else if (i > 0) { x += i; } if (currentTab.isTabInFirstRow()) { y = y - 32; } else { y = y + this.ySize; } return mouseX >= x && mouseX <= x + 28 && mouseY >= y && mouseY <= y + 32; } /** * Renders the creative inventory hovering text if mouse is over it. Returns true if did render or false otherwise. * Params: current creative tab to be checked, current mouse x position, current mouse y position. */ protected boolean renderCreativeInventoryHoveringText(CreativeTabs currentTab, int mouseX, int mouseY) { int i = currentTab.getTabColumn(); int x = 28 * i; int y = 0; if (i == 5) { x = this.xSize - 28 + 2; } else if (i > 0) { x += i; } if (currentTab.isTabInFirstRow()) { y = y - 32; } else { y = y + this.ySize; } if (this.isPointInRegion(x + 3, y + 3, 23, 27, mouseX, mouseY)) { this.drawCreativeTabHoveringText(I18n.format(currentTab.getTranslatedTabLabel()), mouseX, mouseY); return true; } else { return false; } } protected void drawTab(CreativeTabs currentTab) { boolean flag = currentTab.getTabIndex() == selectedTabIndex; boolean flag1 = currentTab.isTabInFirstRow(); int i = currentTab.getTabColumn(); int j = i * 28; int k = 0; int x = this.guiLeft + 28 * i; int y = this.guiTop; int j1 = 32; if (flag) { k += 32; } if (i == 5) { x = this.guiLeft + this.xSize - 28; } else if (i > 0) { x += i; } if (flag1) { y -= 28; } else { k += 64; y += (this.ySize - 4); } GlStateManager.disableLighting(); this.drawTexturedModalRect(x, y, j, k, 28, j1); this.zLevel = 100.0F; this.itemRender.zLevel = 100.0F; x = x + 6; y = y + 8 + (flag1 ? 1 : -1); GlStateManager.enableLighting(); GlStateManager.enableRescaleNormal(); ItemStack itemstack = currentTab.getIconItemStack(); this.itemRender.renderItemAndEffectIntoGUI(itemstack, x, y); this.itemRender.renderItemOverlays(this.fontRendererObj, itemstack, x, y); GlStateManager.disableLighting(); this.itemRender.zLevel = 0.0F; this.zLevel = 0.0F; } /** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 0) { this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter())); } if (button.id == 1) { this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter())); } } public int getSelectedTabIndex() { return selectedTabIndex; } public static class ContainerCreative extends Container { public List<ItemStack> itemList = Lists.<ItemStack>newArrayList(); public ContainerCreative(EntityPlayer p_i1086_1_) { InventoryPlayer inventoryplayer = p_i1086_1_.inventory; for (int i = 0; i < 5; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(GuiContainerCreative.field_147060_v, i * 9 + j, 9 + j * 18, 18 + i * 18)); } } for (int k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(inventoryplayer, k, 9 + k * 18, 112)); } this.scrollTo(0.0F); } public boolean canInteractWith(EntityPlayer playerIn) { return true; } public void scrollTo(float p_148329_1_) { int i = (this.itemList.size() + 9 - 1) / 9 - 5; int j = (int) ((double) (p_148329_1_ * (float) i) + 0.5D); if (j < 0) { j = 0; } for (int k = 0; k < 5; ++k) { for (int l = 0; l < 9; ++l) { int i1 = l + (k + j) * 9; if (i1 >= 0 && i1 < this.itemList.size()) { GuiContainerCreative.field_147060_v.setInventorySlotContents(l + k * 9, (ItemStack) this.itemList.get(i1)); } else { GuiContainerCreative.field_147060_v.setInventorySlotContents(l + k * 9, (ItemStack) null); } } } } public boolean func_148328_e() { return this.itemList.size() > 45; } protected void retrySlotClick(int slotId, int clickedButton, boolean mode, EntityPlayer playerIn) { } public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { if (index >= this.inventorySlots.size() - 9 && index < this.inventorySlots.size()) { Slot slot = (Slot) this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { slot.putStack((ItemStack) null); } } return null; } public boolean canMergeSlot(ItemStack stack, Slot p_94530_2_) { return p_94530_2_.yDisplayPosition > 90; } public boolean canDragIntoSlot(Slot p_94531_1_) { return p_94531_1_.inventory instanceof InventoryPlayer || p_94531_1_.yDisplayPosition > 90 && p_94531_1_.xDisplayPosition <= 162; } } public static class CreativeSlot extends Slot { public final Slot slot; public CreativeSlot(Slot p_i46313_2_, int p_i46313_3_) { super(p_i46313_2_.inventory, p_i46313_3_, 0, 0); this.slot = p_i46313_2_; } public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) { this.slot.onPickupFromSlot(playerIn, stack); } public boolean isItemValid(ItemStack stack) { return this.slot.isItemValid(stack); } public ItemStack getStack() { return this.slot.getStack(); } public boolean getHasStack() { return this.slot.getHasStack(); } public void putStack(ItemStack stack) { this.slot.putStack(stack); } public void onSlotChanged() { this.slot.onSlotChanged(); } public int getSlotStackLimit() { return this.slot.getSlotStackLimit(); } public int getItemStackLimit(ItemStack stack) { return this.slot.getItemStackLimit(stack); } public String getSlotTexture() { return this.slot.getSlotTexture(); } public ItemStack decrStackSize(int amount) { return this.slot.decrStackSize(amount); } public boolean isHere(IInventory inv, int slotIn) { return this.slot.isHere(inv, slotIn); } } }
-
@skiddermaster412 OMG it's so hotttt tysm!!!!