public override void FromBytes(BinaryReader reader, bool forClient) { base.FromBytes(reader, forClient); initialPos = new BlockPos(); initialPos.X = reader.ReadInt32(); initialPos.Y = reader.ReadInt32(); initialPos.Z = reader.ReadInt32(); blockCode = new AssetLocation(reader.ReadString()); bool beIsNull = reader.ReadBoolean(); if (!beIsNull) { blockEntityAttributes = new TreeAttribute(); blockEntityAttributes.FromBytes(reader); blockEntityClass = reader.ReadString(); } if (WatchedAttributes.HasAttribute("fallSound")) { fallSound = new AssetLocation(WatchedAttributes.GetString("fallSound")); } canFallSideways = WatchedAttributes.GetBool("canFallSideways"); dustIntensity = WatchedAttributes.GetFloat("dustIntensity"); DoRemoveBlock = reader.ReadBoolean(); }
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>(); } }
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")); } }