コード例 #1
0
        public void DidUnmount(EntityAgent entityAgent)
        {
            EntityBehaviorTiredness ebt = MountedBy?.GetBehavior("tiredness") as EntityBehaviorTiredness;

            if (ebt != null)
            {
                ebt.IsSleeping = false;
            }
            MountedBy = null;

            if (!blockBroken)
            {
                foreach (BlockFacing facing in BlockFacing.HORIZONTALS)
                {
                    Vec3d placepos = Pos.ToVec3d().AddCopy(facing).Add(0.5, 0.001, 0.5);
                    if (!Api.World.CollisionTester.IsColliding(Api.World.BlockAccessor, entityAgent.SelectionBox, placepos, false))
                    {
                        entityAgent.TeleportTo(placepos);
                        break;
                    }
                }
            }

            base.OnBlockRemoved();
        }
コード例 #2
0
        public override void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
        {
            ItemStack content = GetContent(slot.Itemstack);

            if (secondsUsed > 1.45f && byEntity.World.Side == EnumAppSide.Server && content != null)
            {
                if (essencesDic.TryGetValue("duration", out duration))
                {
                    if (!essencesDic.ContainsKey("health"))
                    {
                        TempEffect potionEffect = new TempEffect();
                        potionEffect.tempEntityStats((byEntity as EntityPlayer), essencesDic);
                    }
                    else
                    {
                        TempEffect potionEffect = new TempEffect();
                        potionEffect.tempTickEntityStats((byEntity as EntityPlayer), essencesDic, tickSec, essencesDic["health"]);
                    }
                    if (byEntity is EntityPlayer)
                    {
                        IServerPlayer sPlayer = (byEntity.World.PlayerByUid((byEntity as EntityPlayer).PlayerUID) as IServerPlayer);
                        if (essencesDic.ContainsKey("recall"))
                        {
                            if (api.Side.IsServer())
                            {
                                FuzzyEntityPos spawn = sPlayer.GetSpawnPosition(false);
                                byEntity.TeleportTo(spawn);
                            }
                        }
                        sPlayer.SendMessage(GlobalConstants.InfoLogChatGroup, "You feel the effects of the " + content.GetName(), EnumChatType.Notification);
                    }
                    IPlayer player = null;
                    if (byEntity is EntityPlayer)
                    {
                        player = byEntity.World.PlayerByUid(((EntityPlayer)byEntity).PlayerUID);
                    }
                    if (slot.StackSize > 1)
                    {
                        ItemStack newStack = slot.Itemstack.Clone();
                        newStack.StackSize = slot.StackSize - 1;
                        ItemStack newContent = GetContent(newStack);
                        api.World.SpawnItemEntity(newStack, byEntity.Pos.XYZ);
                        slot.TakeOut(slot.StackSize - 1);
                    }
                    splitStackAndPerformAction(byEntity, slot, (stack) => TryTakeLiquid(stack, 0.25f)?.StackSize ?? 0);
                    slot.MarkDirty();

                    EntityPlayer entityPlayer = byEntity as EntityPlayer;
                    if (entityPlayer == null)
                    {
                        return;
                    }
                    entityPlayer.Player.InventoryManager.BroadcastHotbarSlot();
                }
            }
            base.OnHeldInteractStop(secondsUsed, slot, byEntity, blockSel, entitySel);
        }
コード例 #3
0
        public override void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
        {
            if (secondsUsed > 1.45f && byEntity.World.Side == EnumAppSide.Server)
            {
                if (tickSec == 0)
                {
                    TempEffect potionEffect = new TempEffect();
                    potionEffect.tempEntityStats((byEntity as EntityPlayer), essencesDic);
                }
                else
                {
                    TempEffect potionEffect = new TempEffect();
                    potionEffect.tempTickEntityStats((byEntity as EntityPlayer), essencesDic, tickSec, health);
                }
                if (byEntity is EntityPlayer)
                {
                    IServerPlayer player = (byEntity.World.PlayerByUid((byEntity as EntityPlayer).PlayerUID) as IServerPlayer);
                    if (essencesDic.ContainsKey("recall"))
                    {
                        if (api.Side.IsServer())
                        {
                            FuzzyEntityPos spawn = player.GetSpawnPosition(false);
                            byEntity.TeleportTo(spawn);
                        }
                        player.SendMessage(GlobalConstants.InfoLogChatGroup, "You feel the effects of the " + slot.Itemstack.GetName(), EnumChatType.Notification);
                    }
                    else
                    {
                        player.SendMessage(GlobalConstants.InfoLogChatGroup, "You feel the effects of the " + slot.Itemstack.GetName(), EnumChatType.Notification);
                    }
                }

                slot.TakeOut(1);
                slot.MarkDirty();
            }
        }