コード例 #1
0
ファイル: Chunk.cs プロジェクト: AlphaDelta/SharpBukkit
        public virtual void GetEntitiesOfTypeWithinAAAB(Type class1, net.minecraft.src.AxisAlignedBB axisalignedbb, List <Entity> list)
        {
            int i = net.minecraft.src.MathHelper.Floor_double((axisalignedbb.minY - 2D) / 16D
                                                              );
            int j = net.minecraft.src.MathHelper.Floor_double((axisalignedbb.maxY + 2D) / 16D
                                                              );

            if (i < 0)
            {
                i = 0;
            }
            if (j >= entities.Length)
            {
                j = entities.Length - 1;
            }
            for (int k = i; k <= j; k++)
            {
                List <Entity> list1 = entities[k];
                for (int l = 0; l < list1.Count; l++)
                {
                    net.minecraft.src.Entity entity = (net.minecraft.src.Entity)list1[l];
                    if (class1.IsAssignableFrom(entity.GetType()) && entity.
                        boundingBox.IntersectsWith(axisalignedbb))
                    {
                        list.Add(entity);
                    }
                }
            }
        }
コード例 #2
0
        public override void HandleUseEntity(net.minecraft.src.Packet7UseEntity packet7useentity)
        {
            if (this.playerEntity.isDead)
            {
                return;                           // CRAFTBUKKIT
            }
            net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity.dimension);
            net.minecraft.src.Entity      entity      = worldserver.Func_6158_a(packet7useentity.targetEntity);
            ItemStack itemInHand = this.playerEntity.inventory.GetCurrentItem(); // CRAFTBUKKIT

            if (entity != null && playerEntity.CanEntityBeSeen(entity) && playerEntity.GetDistanceSqToEntity(entity) < 36D)
            {
                if (packet7useentity.isLeftClick == 0)
                {
                    playerEntity.UseCurrentItemOnEntity(entity);

                    // CRAFTBUKKIT start - update the client if the item is an infinite one
                    if (itemInHand != null && itemInHand.stackSize <= -1)
                    {
                        this.playerEntity.UpdateInventory(this.playerEntity.currentCraftingInventory);
                    }
                    // CRAFTBUKKIT end
                }
                else if (packet7useentity.isLeftClick == 1)
                {
                    // CRAFTBUKKIT start
                    if ((entity is EntityItem) || (entity is EntityArrow))
                    {
                        String type = entity.GetType().Name;
                        KickPlayer("Attacking an " + type + " is not permitted");
                        logger.Warning("Player " + playerEntity.username + " tried to attack an " + type + ", so I have disconnected them for exploiting.");
                        return;
                    }
                    // CRAFTBUKKIT end

                    playerEntity.AttackTargetEntityWithCurrentItem(entity);

                    // CRAFTBUKKIT start - update the client if the item is an infinite one
                    if (itemInHand != null && itemInHand.stackSize <= -1)
                    {
                        this.playerEntity.UpdateInventory(this.playerEntity.currentCraftingInventory);
                    }
                    // CRAFTBUKKIT end
                }
            }
        }