Exemple #1
0
        public virtual void WritePlayerData(net.minecraft.src.EntityPlayer entityplayer)
        {
            try
            {
                net.minecraft.src.NBTTagCompound nbttagcompound = new net.minecraft.src.NBTTagCompound
                                                                      ();
                entityplayer.WriteToNBT(nbttagcompound);
                string file  = System.IO.Path.Combine(worldFile, "_tmp_.dat");
                string file1 = System.IO.Path.Combine(worldFile, (new java.lang.StringBuilder()).Append(entityplayer.username).Append(".dat").ToString());
                using (FileStream fs = File.Open(file, FileMode.OpenOrCreate))
                    net.minecraft.src.CompressedStreamTools.WriteGzippedCompoundToOutputStream(nbttagcompound, fs);
                if (File.Exists(file1))
                {
                    File.Delete(file1);
                }
                File.Move(file, file1);
            }
#if !DEBUG
            catch (System.Exception)
            {
                logger.Warning((new java.lang.StringBuilder()).Append("Failed to save player data for "
                                                                      ).Append(entityplayer.username).ToString());
            }
#else
            finally { }
#endif
        }
Exemple #2
0
        public override bool BlockActivated(net.minecraft.src.World world, int i, int j,
                                            int k, net.minecraft.src.EntityPlayer entityplayer)
        {
            if (blockMaterial == net.minecraft.src.Material.iron)
            {
                return(true);
            }
            int l = world.GetBlockMetadata(i, j, k);

            if ((l & 8) != 0)
            {
                if (world.GetBlockId(i, j - 1, k) == ID)
                {
                    BlockActivated(world, i, j - 1, k, entityplayer);
                }
                return(true);
            }
            if (world.GetBlockId(i, j + 1, k) == ID)
            {
                world.SetBlockMetadataWithNotify(i, j + 1, k, (l ^ 4) + 8);
            }
            world.SetBlockMetadataWithNotify(i, j, k, l ^ 4);
            world.MarkBlocksDirty(i, j - 1, k, i, j, k);
            world.SendSoundEffectToAllPlayersWithin64(entityplayer, 1003, i, j, k, 0);
            return(true);
        }
Exemple #3
0
        public override void OnCollideWithPlayer(net.minecraft.src.EntityPlayer entityplayer)
        {
            if (worldObj.singleplayerWorld)
            {
                return;
            }

            int stackSize = item.stackSize;

            if (delayBeforeCanPickup == 0 && SanityCheckStackSize() && entityplayer.inventory.AddItemStackToInventory(item))
            {
                //SHARP: Do these even matter in MP?
                //if (item.itemID == net.minecraft.src.Block.wood.blockID)
                //{
                //    entityplayer.AddStatistic(net.minecraft.src.AchievementList.aCollectWood);
                //}
                //if (item.itemID == net.minecraft.src.Item.leather.shiftedIndex)
                //{
                //    entityplayer.AddStatistic(net.minecraft.src.AchievementList.aKillCow);
                //}
                worldObj.PlaySoundAtEntity(this, "random.pop", 0.2F, ((rand.NextFloat() - rand.NextFloat()) * 0.7F + 1.0F) * 2.0F);
                entityplayer.OnItemPickup(this, stackSize);
                if (item.stackSize <= 0)
                {
                    SetEntityDead();
                }
            }
        }
Exemple #4
0
 protected internal virtual void Func_27013_Q()
 {
     net.minecraft.src.EntityPlayer entityplayer = worldObj.GetClosestPlayerToEntity(this
                                                                                     , -1D);
     if (Func_25020_s() && entityplayer != null)
     {
         double d  = ((net.minecraft.src.Entity)(entityplayer)).posX - posX;
         double d1 = ((net.minecraft.src.Entity)(entityplayer)).posY - posY;
         double d2 = ((net.minecraft.src.Entity)(entityplayer)).posZ - posZ;
         double d3 = d * d + d1 * d1 + d2 * d2;
         if (d3 > 16384D)
         {
             SetEntityDead();
         }
         if (age > 600 && rand.Next(800) == 0)
         {
             if (d3 < 1024D)
             {
                 age = 0;
             }
             else
             {
                 SetEntityDead();
             }
         }
     }
 }
        private static int DetermineOrientation(net.minecraft.src.World world, int i, int
                                                j, int k, net.minecraft.src.EntityPlayer entityplayer)
        {
            if (net.minecraft.src.MathHelper.Abs((float)entityplayer.posX - (float)i) < 2.0F &&
                net.minecraft.src.MathHelper.Abs((float)entityplayer.posZ - (float)k) < 2.0F)
            {
                double d = (entityplayer.posY + 1.8200000000000001D) - (double)entityplayer.yOffset;
                if (d - (double)j > 2D)
                {
                    return(1);
                }
                if ((double)j - d > 0.0D)
                {
                    return(0);
                }
            }
            int l = net.minecraft.src.MathHelper.Floor_double((double)((entityplayer.rotationYaw
                                                                        * 4F) / 360F) + 0.5D) & 3;

            if (l == 0)
            {
                return(2);
            }
            if (l == 1)
            {
                return(5);
            }
            if (l == 2)
            {
                return(3);
            }
            return(l != 3 ? 0 : 4);
        }
Exemple #6
0
        public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                       entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
        {
            int i1 = world.GetBlockId(i, j, k);
            int j1 = world.GetBlockId(i, j + 1, k);

            if (l != 0 && j1 == 0 && i1 == net.minecraft.src.Block.GRASS.ID || i1 == net.minecraft.src.Block
                .DIRT.ID)
            {
                net.minecraft.src.Block block = net.minecraft.src.Block.SOIL;
                world.PlaySoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, block.stepSound
                                      .Func_737_c(), (block.stepSound.GetVolume() + 1.0F) / 2.0F, block.stepSound.GetPitch
                                          () * 0.8F);
                if (world.singleplayerWorld)
                {
                    return(true);
                }
                else
                {
                    world.SetBlockWithNotify(i, j, k, block.ID);
                    itemstack.DamageItem(1, entityplayer);
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Exemple #7
0
 protected internal override void UpdatePlayerActionState()
 {
     Func_27013_Q();
     net.minecraft.src.EntityPlayer entityplayer = worldObj.GetClosestPlayerToEntity(this
                                                                                     , 16D);
     if (entityplayer != null)
     {
         FaceEntity(entityplayer, 10F, 20F);
     }
     if (onGround && ticksTillJump-- <= 0)
     {
         ticksTillJump = rand.Next(20) + 10;
         if (entityplayer != null)
         {
             ticksTillJump /= 3;
         }
         isJumping = true;
         if (Func_25027_m() > 1)
         {
             worldObj.PlaySoundAtEntity(this, "mob.slime", GetSoundVolume(), ((rand.NextFloat(
                                                                                   ) - rand.NextFloat()) * 0.2F + 1.0F) * 0.8F);
         }
         field_401_a  = 1.0F;
         moveStrafing = 1.0F - rand.NextFloat() * 2.0F;
         moveForward  = 1 * Func_25027_m();
     }
     else
     {
         isJumping = false;
         if (onGround)
         {
             moveStrafing = moveForward = 0.0F;
         }
     }
 }
Exemple #8
0
        public EntityFish(net.minecraft.src.World world, net.minecraft.src.EntityPlayer entityplayer
                          )
            : base(world)
        {
            xTile             = -1;
            yTile             = -1;
            zTile             = -1;
            inTile            = 0;
            inGround          = false;
            shake             = 0;
            ticksInAir        = 0;
            ticksCatchable    = 0;
            bobber            = null;
            field_28008_bI    = true;
            angler            = entityplayer;
            angler.fishEntity = this;
            SetSize(0.25F, 0.25F);
            SetLocationAndAngles(entityplayer.posX, (entityplayer.posY + 1.6200000000000001D)
                                 - (double)entityplayer.yOffset, entityplayer.posZ, entityplayer.rotationYaw, entityplayer
                                 .rotationPitch);
            posX -= net.minecraft.src.MathHelper.Cos((rotationYaw / 180F) * 3.141593F) * 0.16F;
            posY -= 0.10000000149011612D;
            posZ -= net.minecraft.src.MathHelper.Sin((rotationYaw / 180F) * 3.141593F) * 0.16F;
            SetPosition(posX, posY, posZ);
            yOffset = 0.0F;
            float f = 0.4F;

            motionX = -net.minecraft.src.MathHelper.Sin((rotationYaw / 180F) * 3.141593F) * net.minecraft.src.MathHelper
                      .Cos((rotationPitch / 180F) * 3.141593F) * f;
            motionZ = net.minecraft.src.MathHelper.Cos((rotationYaw / 180F) * 3.141593F) * net.minecraft.src.MathHelper
                      .Cos((rotationPitch / 180F) * 3.141593F) * f;
            motionY = -net.minecraft.src.MathHelper.Sin((rotationPitch / 180F) * 3.141593F) *
                      f;
            Func_6142_a(motionX, motionY, motionZ, 1.5F, 1.0F);
        }
Exemple #9
0
 public virtual bool CanInteractWith(net.minecraft.src.EntityPlayer entityplayer)
 {
     if (isDead)
     {
         return(false);
     }
     return(entityplayer.GetDistanceSqToEntity(this) <= 64D);
 }
        public virtual void UpdatePlayerEntity(net.minecraft.src.EntityPlayerMP entityplayermp
                                               )
        {
            if (entityplayermp == trackedEntity)
            {
                return;
            }
            double d  = entityplayermp.posX - (double)(encodedPosX / 32);
            double d1 = entityplayermp.posZ - (double)(encodedPosZ / 32);

            if (d >= (double)(-trackingDistanceThreshold) && d <= (double)trackingDistanceThreshold &&
                d1 >= (double)(-trackingDistanceThreshold) && d1 <= (double)trackingDistanceThreshold)
            {
                if (!trackedPlayers.Contains(entityplayermp))
                {
                    trackedPlayers.Add(entityplayermp);
                    entityplayermp.netServerHandler.SendPacket(GetSpawnPacket());
                    if (shouldSendMotionUpdates)
                    {
                        entityplayermp.netServerHandler.SendPacket(new net.minecraft.src.Packet28EntityVelocity
                                                                       (trackedEntity.entityId, trackedEntity.motionX, trackedEntity.motionY, trackedEntity
                                                                       .motionZ));
                    }
                    net.minecraft.src.ItemStack[] aitemstack = trackedEntity.GetInventory();
                    if (aitemstack != null)
                    {
                        for (int i = 0; i < aitemstack.Length; i++)
                        {
                            entityplayermp.netServerHandler.SendPacket(new net.minecraft.src.Packet5PlayerInventory
                                                                           (trackedEntity.entityId, i, aitemstack[i]));
                        }
                    }
                    if (trackedEntity is net.minecraft.src.EntityPlayer)
                    {
                        net.minecraft.src.EntityPlayer entityplayer = (net.minecraft.src.EntityPlayer)trackedEntity;
                        if (entityplayer.IsSleeping())
                        {
                            entityplayermp.netServerHandler.SendPacket(new net.minecraft.src.Packet17Sleep(
                                                                           trackedEntity,
                                                                           0,
                                                                           net.minecraft.src.MathHelper.Floor_double(trackedEntity.posX),
                                                                           net.minecraft.src.MathHelper.Floor_double(trackedEntity.posY),
                                                                           net.minecraft.src.MathHelper.Floor_double(trackedEntity.posZ)
                                                                           ));
                        }
                    }
                }
            }
            else
            {
                if (trackedPlayers.Contains(entityplayermp))
                {
                    trackedPlayers.Remove(entityplayermp);
                    entityplayermp.netServerHandler.SendPacket(new net.minecraft.src.Packet29DestroyEntity
                                                                   (trackedEntity.entityId));
                }
            }
        }
Exemple #11
0
 public virtual void ReadPlayerData(net.minecraft.src.EntityPlayer entityplayer)
 {
     net.minecraft.src.NBTTagCompound nbttagcompound = GetPlayerData(entityplayer.username
                                                                     );
     if (nbttagcompound != null)
     {
         entityplayer.ReadFromNBT(nbttagcompound);
     }
 }
Exemple #12
0
 public SlotFurnace(net.minecraft.src.EntityPlayer entityplayer, net.minecraft.src.IInventory
                    iinventory, int i, int j, int k)
     : base(iinventory, i, j, k)
 {
     // Referenced classes of package net.minecraft.src:
     //            Slot, EntityPlayer, ItemStack, Item,
     //            AchievementList, IInventory
     field_27007_d = entityplayer;
 }
Exemple #13
0
 public virtual void OnCraftGuiClosed(net.minecraft.src.EntityPlayer entityplayer)
 {
     net.minecraft.src.InventoryPlayer inventoryplayer = entityplayer.inventory;
     if (inventoryplayer.GetItemStack() != null)
     {
         entityplayer.DropPlayerItem(inventoryplayer.GetItemStack());
         inventoryplayer.SetItemStack(null);
     }
 }
Exemple #14
0
 public virtual bool CanInteractWith(net.minecraft.src.EntityPlayer entityplayer)
 {
     if (worldObj.GetBlockTileEntity(xCoord, yCoord, zCoord) != this)
     {
         return(false);
     }
     return(entityplayer.GetDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (
                                           double)zCoord + 0.5D) <= 64D);
 }
 public SlotCrafting(net.minecraft.src.EntityPlayer entityplayer, net.minecraft.src.IInventory
                     iinventory, net.minecraft.src.IInventory iinventory1, int i, int j, int k)
     : base(iinventory1, i, j, k)
 {
     // Referenced classes of package net.minecraft.src:
     //            Slot, EntityPlayer, ItemStack, Block,
     //            AchievementList, Item, IInventory
     field_25004_e = entityplayer;
     craftMatrix   = iinventory;
 }
Exemple #16
0
 public override bool CanInteractWith(net.minecraft.src.EntityPlayer entityplayer)
 {
     if (field_20150_c.GetBlockId(field_20149_h, field_20148_i, field_20147_j) != net.minecraft.src.Block
         .WORKBENCH.ID)
     {
         return(false);
     }
     return(entityplayer.GetDistanceSq((double)field_20149_h + 0.5D, (double)field_20148_i
                                       + 0.5D, (double)field_20147_j + 0.5D) <= 64D);
 }
Exemple #17
0
        public override bool BlockActivated(net.minecraft.src.World world, int i, int j,
                                            int k, net.minecraft.src.EntityPlayer entityplayer)
        {
            int l  = world.GetBlockMetadata(i, j, k);
            int i1 = (l & 0xc) >> 2;

            i1 = i1 + 1 << 2 & 0xc;
            world.SetBlockMetadataWithNotify(i, j, k, i1 | l & 3);
            return(true);
        }
Exemple #18
0
 public override void OnBlockClicked(net.minecraft.src.World world, int i, int j,
                                     int k, net.minecraft.src.EntityPlayer entityplayer)
 {
     if (entityplayer.GetCurrentEquippedItem() != null && entityplayer.GetCurrentEquippedItem
             ().itemID == net.minecraft.src.Item.FLINT_AND_STEEL.ID)
     {
         world.SetBlockMetadata(i, j, k, 1);
     }
     base.OnBlockClicked(world, i, j, k, entityplayer);
 }
Exemple #19
0
 public override void HarvestBlock(net.minecraft.src.World world, net.minecraft.src.EntityPlayer
                                   entityplayer, int i, int j, int k, int l)
 {
     base.HarvestBlock(world, entityplayer, i, j, k, l);
     net.minecraft.src.Material material = world.GetBlockMaterial(i, j - 1, k);
     if (material.GetIsSolid() || material.GetIsLiquid())
     {
         world.SetBlockWithNotify(i, j, k, net.minecraft.src.Block.WATER.ID);
     }
 }
Exemple #20
0
 public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
 {
     if (l == 0)
     {
         return(false);
     }
     if (!world.GetBlockMaterial(i, j, k).IsSolid())
     {
         return(false);
     }
     if (l == 1)
     {
         j++;
     }
     if (l == 2)
     {
         k--;
     }
     if (l == 3)
     {
         k++;
     }
     if (l == 4)
     {
         i--;
     }
     if (l == 5)
     {
         i++;
     }
     if (!net.minecraft.src.Block.SIGN_POST.CanPlaceBlockAt(world, i, j, k))
     {
         return(false);
     }
     if (l == 1)
     {
         world.SetBlockAndMetadataWithNotify(
             i, j, k,
             net.minecraft.src.Block.SIGN_POST.ID,
             net.minecraft.src.MathHelper.Floor_double((double)(((entityplayer.rotationYaw + 180F) * 16F) / 360F) + 0.5D) & 0xf);
     }
     else
     {
         world.SetBlockAndMetadataWithNotify(i, j, k, net.minecraft.src.Block.WALL_SIGN.ID, l);
     }
     itemstack.stackSize--;
     net.minecraft.src.TileEntitySign tileentitysign = (net.minecraft.src.TileEntitySign
                                                        )world.GetBlockTileEntity(i, j, k);
     if (tileentitysign != null)
     {
         entityplayer.DisplayGUIEditSign(tileentitysign);
     }
     return(true);
 }
Exemple #21
0
        public void HitEntity(net.minecraft.src.EntityLiving entityliving, net.minecraft.src.EntityPlayer
                              entityplayer)
        {
            bool flag = net.minecraft.src.Item.itemsList[itemID].HitEntity(this, entityliving
                                                                           , entityplayer);

            if (flag)
            {
                entityplayer.AddStat(net.minecraft.src.StatList.StatUseItem[itemID], 1);
            }
        }
Exemple #22
0
        public void Func_25124_a(int i, int j, int k, int l, net.minecraft.src.EntityPlayer
                                 entityplayer)
        {
            bool flag = net.minecraft.src.Item.itemsList[itemID].Func_25007_a(this, i, j, k,
                                                                              l, entityplayer);

            if (flag)
            {
                entityplayer.AddStat(net.minecraft.src.StatList.StatUseItem[itemID], 1);
            }
        }
Exemple #23
0
        public bool UseItem(net.minecraft.src.EntityPlayer entityplayer, net.minecraft.src.World
                            world, int i, int j, int k, int l)
        {
            bool flag = GetItem().OnItemUse(this, entityplayer, world, i, j, k, l);

            if (flag)
            {
                entityplayer.AddStat(net.minecraft.src.StatList.StatUseItem[itemID], 1);
            }
            return(flag);
        }
Exemple #24
0
 public override bool OnItemUse(net.minecraft.src.ItemStack itemstack, net.minecraft.src.EntityPlayer
                                entityplayer, net.minecraft.src.World world, int i, int j, int k, int l)
 {
     if (world.GetBlockId(i, j, k) == net.minecraft.src.Block.SNOW.ID)
     {
         l = 0;
     }
     else
     {
         if (l == 0)
         {
             j--;
         }
         if (l == 1)
         {
             j++;
         }
         if (l == 2)
         {
             k--;
         }
         if (l == 3)
         {
             k++;
         }
         if (l == 4)
         {
             i--;
         }
         if (l == 5)
         {
             i++;
         }
     }
     if (itemstack.stackSize == 0)
     {
         return(false);
     }
     if (world.CanBlockBePlacedAt(field_253_a, i, j, k, false, l))
     {
         net.minecraft.src.Block block = net.minecraft.src.Block.blocksList[field_253_a];
         if (world.SetBlockWithNotify(i, j, k, field_253_a))
         {
             net.minecraft.src.Block.blocksList[field_253_a].OnBlockPlaced(world, i, j, k, l);
             net.minecraft.src.Block.blocksList[field_253_a].OnBlockPlacedBy(world, i, j, k, entityplayer
                                                                             );
             world.PlaySoundEffect((float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, block.stepSound
                                   .Func_737_c(), (block.stepSound.GetVolume() + 1.0F) / 2.0F, block.stepSound.GetPitch
                                       () * 0.8F);
             itemstack.stackSize--;
         }
     }
     return(true);
 }
Exemple #25
0
 public virtual void SetCanCraft(net.minecraft.src.EntityPlayer entityplayer, bool
                                 flag)
 {
     if (flag)
     {
         field_20131_b.Remove(entityplayer);
     }
     else
     {
         field_20131_b.Add(entityplayer);
     }
 }
Exemple #26
0
        public override void OnCollideWithPlayer(net.minecraft.src.EntityPlayer entityplayer
                                                 )
        {
            int i = Func_25027_m();

            if (i > 1 && CanEntityBeSeen(entityplayer) && (double)GetDistanceToEntity(entityplayer
                                                                                      ) < 0.59999999999999998D * (double)i && entityplayer.AttackEntityFrom(this, i))
            {
                worldObj.PlaySoundAtEntity(this, "mob.slimeattack", 1.0F, (rand.NextFloat() - rand
                                                                           .NextFloat()) * 0.2F + 1.0F);
            }
        }
Exemple #27
0
        public override bool CanMineBlock(net.minecraft.src.EntityPlayer entityplayer, int
                                          i, int j, int k)
        {
            int l  = (int)net.minecraft.src.MathHelper.Abs(i - worldInfo.GetSpawnX());
            int i1 = (int)net.minecraft.src.MathHelper.Abs(k - worldInfo.GetSpawnZ());

            if (l > i1)
            {
                i1 = l;
            }
            return(i1 > 16 || mcServer.serverConfigurationManager.IsOp(entityplayer.username));
        }
 public InventoryPlayer(net.minecraft.src.EntityPlayer entityplayer)
 {
     // Referenced classes of package net.minecraft.src:
     //            IInventory, ItemStack, EntityPlayer, NBTTagCompound,
     //            NBTTagList, Block, Material, ItemArmor,
     //            Entity
     mainInventory    = new net.minecraft.src.ItemStack[36];
     armorInventory   = new net.minecraft.src.ItemStack[4];
     currentItem      = 0;
     inventoryChanged = false;
     player           = entityplayer;
 }
Exemple #29
0
 public override void OnCollideWithPlayer(net.minecraft.src.EntityPlayer entityplayer
                                          )
 {
     if (inGroundSnowball && owner == entityplayer && shakeSnowball <= 0 && entityplayer
         .inventory.AddItemStackToInventory(new net.minecraft.src.ItemStack(net.minecraft.src.Item
                                                                            .ARROW, 1)))
     {
         worldObj.PlaySoundAtEntity(this, "random.pop", 0.2F, ((rand.NextFloat() - rand.NextFloat
                                                                    ()) * 0.7F + 1.0F) * 2.0F);
         entityplayer.OnItemPickup(this, 1);
         SetEntityDead();
     }
 }
Exemple #30
0
 public override bool Interact(net.minecraft.src.EntityPlayer entityplayer)
 {
     if (riddenByEntity != null && (riddenByEntity is net.minecraft.src.EntityPlayer) &&
         riddenByEntity != entityplayer)
     {
         return(true);
     }
     if (!worldObj.singleplayerWorld)
     {
         entityplayer.MountEntity(this);
     }
     return(true);
 }