public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            if (removedBlockentity != null)
            {
                this.blockEntityAttributes = new TreeAttribute();
                removedBlockentity.ToTreeAttributes(blockEntityAttributes);
                blockEntityClass = api.World.ClassRegistry.GetBlockEntityClass(removedBlockentity.GetType());
            }

            SimulationRange = (int)(0.75f * GlobalConstants.DefaultTrackingRange);
            base.Initialize(properties, api, InChunkIndex3d);

            // Need to capture this now before we remove the block and start to fall
            drops = Block.GetDrops(api.World, initialPos, null);

            lightHsv = Block.GetLightHsv(World.BlockAccessor, initialPos);

            SidedPos.Motion.Y = -0.02;
            blockAsStack      = new ItemStack(Block);


            if (api.Side == EnumAppSide.Client && fallSound != null && fallingNow.Count < 100)
            {
                fallingNow.Add(EntityId);
                ICoreClientAPI capi = api as ICoreClientAPI;
                sound = capi.World.LoadSound(new SoundParams()
                {
                    Location  = fallSound.WithPathPrefixOnce("sounds/").WithPathAppendixOnce(".ogg"),
                    Position  = new Vec3f((float)Pos.X, (float)Pos.Y, (float)Pos.Z),
                    Range     = 32,
                    Pitch     = 0.8f + (float)capi.World.Rand.NextDouble() * 0.3f,
                    Volume    = 1,
                    SoundType = EnumSoundType.Ambient
                });
                sound.Start();
                soundStartDelay = 0.05f + (float)capi.World.Rand.NextDouble() / 3f;
            }

            canFallSideways = WatchedAttributes.GetBool("canFallSideways");
            dustIntensity   = WatchedAttributes.GetFloat("dustIntensity");


            if (WatchedAttributes.HasAttribute("fallSound"))
            {
                fallSound = new AssetLocation(WatchedAttributes.GetString("fallSound"));
            }

            if (api.World.Side == EnumAppSide.Client)
            {
                particleSys = api.ModLoader.GetModSystem <FallingBlockParticlesModSystem>();
                particleSys.Register(this);
                physicsBh = GetBehavior <EntityBehaviorPassivePhysics>();
            }
        }
Пример #2
0
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            if (removedBlockentity != null)
            {
                this.blockEntityAttributes = new TreeAttribute();
                removedBlockentity.ToTreeAttributes(blockEntityAttributes);
                blockEntityClass = api.World.ClassRegistry.GetBlockEntityClass(removedBlockentity.GetType());
            }

            SimulationRange = 3 * api.World.BlockAccessor.ChunkSize;

            base.Initialize(properties, api, InChunkIndex3d);

            // Need to capture this now before we remove the block and start to fall
            drops = Block.GetDrops(api.World, initialPos, null);
        }
Пример #3
0
        void HeatEntities(float dt)
        {
            IPlayer[] players = api.World.AllOnlinePlayers;

            foreach (IPlayer curPlayer in players)
            {
                EntityPlayer playerEntity = curPlayer.Entity;
                float        distance     = block.Pos.DistanceTo(playerEntity.Pos.AsBlockPos);

                if (distance > heatRange || !playerEntity.HasBehavior("bodyheat"))
                {
                    continue;
                }

                float distanceModifier = (heatRange - distance) / heatRange;

                switch (block.GetType().Name)
                {
                case "BlockEntityForge":
                    if (((BlockEntityForge)block).IsBurning)
                    {
                        break;
                    }
                    continue;

                case "BlockEntityFirepit":
                    if (((BlockEntityFirepit)block).IsBurning)
                    {
                        break;
                    }
                    continue;

                case "BlockEntityCharcoalPit":
                    if (((BlockEntityCharcoalPit)block).Lit)
                    {
                        break;
                    }
                    continue;

                default:
                    continue;
                }

                playerEntity.GetBehavior <EntityBehaviorBodyheat>()?.HeatUp(heatTemp * distanceModifier);
            }
        }
Пример #4
0
        public override void Initialize(EntityProperties properties, ICoreAPI api, long InChunkIndex3d)
        {
            if (removedBlockentity != null)
            {
                this.blockEntityAttributes = new TreeAttribute();
                removedBlockentity.ToTreeAttributes(blockEntityAttributes);
                blockEntityClass = api.World.ClassRegistry.GetBlockEntityClass(removedBlockentity.GetType());
            }

            SimulationRange = 3 * api.World.BlockAccessor.ChunkSize;
            base.Initialize(properties, api, InChunkIndex3d);

            // Need to capture this now before we remove the block and start to fall
            drops = Block.GetDrops(api.World, initialPos, null);

            lightHsv = Block.GetLightHsv(World.BlockAccessor, initialPos);

            LocalPos.Motion.Y = -0.02;
            blockAsStack      = new ItemStack(Block);


            if (api.Side == EnumAppSide.Client && fallSound != null)
            {
                ICoreClientAPI capi = api as ICoreClientAPI;
                sound = capi.World.LoadSound(new SoundParams()
                {
                    Location  = fallSound.WithPathPrefixOnce("sounds/").WithPathAppendixOnce(".ogg"),
                    Position  = new Vec3f((float)Pos.X, (float)Pos.Y, (float)Pos.Z),
                    Range     = 32,
                    Pitch     = 0.8f + (float)capi.World.Rand.NextDouble() * 0.3f,
                    Volume    = 1,
                    SoundType = EnumSoundType.Ambient
                });
                soundStartDelay = 0.05f + (float)capi.World.Rand.NextDouble() / 3f;
            }

            canFallSideways = WatchedAttributes.GetBool("canFallSideways");
            dustyFall       = WatchedAttributes.GetBool("dustyFall");


            if (WatchedAttributes.HasAttribute("fallSound"))
            {
                fallSound = new AssetLocation(WatchedAttributes.GetString("fallSound"));
            }
        }