public override void Initialize(ICoreAPI api) { base.Initialize(api); RegisterGameTickListener(OnTick, 50); if (fuseSound == null && api.Side == EnumAppSide.Client) { fuseSound = ((IClientWorldAccessor)api.World).LoadSound(new SoundParams() { Location = new AssetLocation("sounds/effect/fuse"), ShouldLoop = true, Position = pos.ToVec3f().Add(0.5f, 0.25f, 0.5f), DisposeOnFinish = false, Volume = 0.1f, Range = 16, }); } block = api.World.BlockAccessor.GetBlock(pos); blastRadius = block.Attributes["blastRadius"].AsInt(4); injureRadius = block.Attributes["injureRadius"].AsInt(8); blastType = (EnumBlastType)block.Attributes["blastType"].AsInt((int)EnumBlastType.OreBlast); }
static bool Prefix( Block __instance, ref double __result, IWorldAccessor world, BlockPos pos, Vec3f blastDirectionVector, EnumBlastType blastType ) { if (blastType == EnumBlastType.EntityBlast) { return(true); // execute original } // 60 is both magic and arbitrary. Its purpose is just to not explode mantle. if (__instance.Resistance < 60 && __instance.BlockMaterial == EnumBlockMaterial.Stone) { __result = 0.0d; } else { __result = BlockMaterialUtil.MaterialBlastResistance(blastType, __instance.BlockMaterial); } return(false); // do not execute original }
public virtual void DoOverload() { ////BOOOOM! if (!IsOn) { return; } EnumBlastType blastType = EnumBlastType.OreBlast; var iswa = Api.World as IServerWorldAccessor; Api.World.BlockAccessor.SetBlock(0, Pos); if (iswa != null) { iswa.CreateExplosion(Pos, blastType, 4, 15); isOn = false; } }
/// <summary> /// Calculates the blast drop chance of a given material. /// </summary> /// <param name="blastType">The blast type the material is being it with.</param> /// <param name="material">The material of the block.</param> /// <returns>the resulting drop chance.</returns> public static double MaterialBlastDropChances(EnumBlastType blastType, EnumBlockMaterial material) { return(blastDropChances[(int)blastType][(int)material]); }
public override void OnBlockExploded(IWorldAccessor world, BlockPos pos, BlockPos explosionCenter, EnumBlastType blastType) { EnumHandling handled = EnumHandling.PassThrough; foreach (BlockBehavior behavior in BlockBehaviors) { behavior.OnBlockExploded(world, pos, explosionCenter, blastType, ref handled); if (handled == EnumHandling.PreventSubsequent) { break; } } if (handled == EnumHandling.PreventDefault) { return; } double dropChancce = ExplosionDropChance(world, pos, blastType); if (world.Rand.NextDouble() < dropChancce) { ItemStack[] drops = GetDrops(world, pos, null); if (drops == null) { return; } for (int i = 0; i < drops.Length; i++) { if (SplitDropStacks) { for (int k = 0; k < drops[i].StackSize; k++) { ItemStack stack = drops[i].Clone(); if (stack.Collectible.Code.Path.Contains("crystal")) { continue; // Do not drop crystalized ores when the ore is being blown up } stack.StackSize = 1; world.SpawnItemEntity(stack, new Vec3d(pos.X + 0.5, pos.Y + 0.5, pos.Z + 0.5), null); } } } } if (EntityClass != null) { BlockEntity entity = world.BlockAccessor.GetBlockEntity(pos); if (entity != null) { entity.OnBlockBroken(); } } }
public override void OnBlockExploded(IWorldAccessor world, BlockPos pos, BlockPos explosionCenter, EnumBlastType blastType) { BlockEntityBomb bebomb = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityBomb; bebomb?.OnBlockExploded(pos); }
public override double GetBlastResistance(IWorldAccessor world, BlockPos pos, Vec3f blastDirectionVector, EnumBlastType blastType) { return(0.5); }
public override void OnBlockExploded(IWorldAccessor world, BlockPos pos, BlockPos explosionCenter, EnumBlastType blastType) { if (world.Rand.NextDouble() < 0.25) { ItemStack stack = new ItemStack(this); stack.StackSize = 1; world.SpawnItemEntity(stack, new Vec3d(pos.X + 0.5, pos.Y + 0.5, pos.Z + 0.5), null); } else { int startquantity = 3; if (Variant["variant"] == "cluster1" || Variant["variant"] == "cluster2") { startquantity = 5; } if (Variant["variant"] == "large1" || Variant["variant"] == "large2") { startquantity = 7; } int quantity = (int)(startquantity * Math.Min(1, world.Rand.NextDouble() * 0.31f + 0.7f)); string type = Variant["type"]; if (Variant["type"] == "milkyquartz") { type = "clearquartz"; } ItemStack stack = new ItemStack(api.World.GetItem(new AssetLocation(type))); for (int k = 0; k < quantity; k++) { ItemStack drop = stack.Clone(); drop.StackSize = 1; world.SpawnItemEntity(drop, new Vec3d(pos.X + 0.5, pos.Y + 0.5, pos.Z + 0.5), null); } } }
public override double ExplosionDropChance(IWorldAccessor world, BlockPos pos, EnumBlastType blastType) { return(0.2); }
public virtual void OnBlockExploded(IWorldAccessor world, BlockPos pos, BlockPos explosionCenter, EnumBlastType blastType, ref EnumHandling handling) { handling = EnumHandling.PassThrough; }