private void GenerateSteamParticles(BlockPos pos, IWorldAccessor world) { float minQuantity = 50; float maxQuantity = 100; int color = ColorUtil.ToRgba(100, 225, 225, 225); Vec3d minPos = new Vec3d(); Vec3d addPos = new Vec3d(); Vec3f minVelocity = new Vec3f(-0.25f, 0.1f, -0.25f); Vec3f maxVelocity = new Vec3f(0.25f, 0.1f, 0.25f); float lifeLength = 2.0f; float gravityEffect = -0.015f; float minSize = 0.1f; float maxSize = 0.1f; SimpleParticleProperties steamParticles = new SimpleParticleProperties( minQuantity, maxQuantity, color, minPos, addPos, minVelocity, maxVelocity, lifeLength, gravityEffect, minSize, maxSize, EnumParticleModel.Quad ); steamParticles.minPos.Set(pos.ToVec3d().AddCopy(0.5, 1.1, 0.5)); steamParticles.addPos.Set(new Vec3d(0.5, 1.0, 0.5)); steamParticles.SizeEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEARINCREASE, 1.0f); world.SpawnParticles(steamParticles); }
public override void OnBlockBroken(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, float dropQuantityMultiplier = 1) { BlockEntity be = world.BlockAccessor.GetBlockEntity(pos); BlockPos masterPos = pos; if (be is GenericStorageCapBE) { masterPos = (be as GenericStorageCapBE).core; be = world.BlockAccessor.GetBlockEntity(masterPos); } if (be == null) { world.BlockAccessor.SetBlock(0, pos); return; } GenericStorageCoreBE core = be as GenericStorageCoreBE; foreach (BlockPos cap in core.caps) { breakParticle.MinPos = cap.ToVec3d(); breakParticle.ColorByBlock = world.BlockAccessor.GetBlock(masterPos); world.BlockAccessor.SetBlock(0, cap); world.BlockAccessor.RemoveBlockEntity(cap); world.SpawnParticles(breakParticle, byPlayer); } world.BlockAccessor.SetBlock(0, masterPos); }
public override void OnClientGameTick(IWorldAccessor world, BlockPos pos, float secondsTicking) { if (world.Rand.NextDouble() > particleQuantity) { return; } AdvancedParticleProperties bps = ParticleProperties[0]; bps.basePos.X = pos.X; bps.basePos.Y = pos.Y; bps.basePos.Z = pos.Z; bps.Velocity[0].avg = (float)PushVector.X * 250; bps.Velocity[1].avg = (float)PushVector.Y * 250; bps.Velocity[2].avg = (float)PushVector.Z * 250; bps.GravityEffect.avg = 0.5f; bps.HsvaColor[3].avg = 180 * Math.Min(1, secondsTicking / 7f); bps.Quantity.avg = 1; bps.PosOffset[1].avg = 2 / 16f; bps.PosOffset[1].var = LiquidLevel / 8f * 0.75f; bps.SwimOnLiquid = true; world.SpawnParticles(bps); }
public override void OnClientGameTick(IWorldAccessor world, BlockPos pos, float secondsTicking) { if (ParticleProperties != null && ParticleProperties.Length > 0) { for (int i = 0; i < 4; i++) { if (world.Rand.NextDouble() > particleQuantity) { continue; } BlockFacing facing = BlockFacing.HORIZONTALS[i]; Block block = world.BlockAccessor.GetBlock(pos.X + facing.Normali.X, pos.Y, pos.Z + facing.Normali.Z); if (block.IsLiquid() || block.SideSolid[facing.GetOpposite().Index]) { continue; } AdvancedParticleProperties bps = ParticleProperties[i]; bps.basePos.X = pos.X + TopMiddlePos.X; bps.basePos.Y = pos.Y; bps.basePos.Z = pos.Z + TopMiddlePos.Z; bps.HsvaColor[3].avg = 180 * Math.Min(1, secondsTicking / 7f); bps.Quantity.avg = 1; bps.Velocity[1].avg = -0.4f; world.SpawnParticles(bps); } } }
public override void OnBlockBroken(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, float dropQuantityMultiplier = 1) { SimpleParticleProperties props = new SimpleParticleProperties( 15, 22, ColorUtil.ToRgba(150, 255, 255, 255), new Vec3d(pos.X, pos.Y, pos.Z), new Vec3d(pos.X + 1, pos.Y + 1, pos.Z + 1), new Vec3f(-0.2f, -0.1f, -0.2f), new Vec3f(0.2f, 0.2f, 0.2f), 1.5f, 0, 0.5f, 1.0f, EnumParticleModel.Quad ); props.OpacityEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEAR, -200); props.SizeEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEAR, 2); world.SpawnParticles(props); SimpleParticleProperties spiders = new SimpleParticleProperties( 8, 16, ColorUtil.ToRgba(255, 30, 30, 30), new Vec3d(pos.X, pos.Y, pos.Z), new Vec3d(pos.X + 1, pos.Y + 1, pos.Z + 1), new Vec3f(-2f, -0.3f, -2f), new Vec3f(2f, 1f, 2f), 1f, 0.5f, 0.5f, 1.5f, EnumParticleModel.Cube ); world.SpawnParticles(spiders); base.OnBlockBroken(world, pos, byPlayer, dropQuantityMultiplier); }
void SpawnParticles(IWorldAccessor world, Vec3d pos, bool final) { if (final || world.Rand.NextDouble() > 0.8) { int h = 110 + world.Rand.Next(15); int v = 100 + world.Rand.Next(50); particlesHeld.minPos = pos; particlesHeld.color = ColorUtil.ReverseColorBytes(ColorUtil.HsvToRgba(h, 180, v)); world.SpawnParticles(particlesHeld); } }
void SpawnParticles(IWorldAccessor world, Vec3d pos, bool final) { if (final || world.Rand.NextDouble() > 0.8) { int h = 110 + world.Rand.Next(15); int v = 100 + world.Rand.Next(50); particlesHeld.MinPos = pos; particlesHeld.Color = ColorUtil.ReverseColorBytes(ColorUtil.HsvToRgba(h, 180, v)); particlesHeld.MinSize = 0.2f; particlesHeld.ParticleModel = EnumParticleModel.Quad; particlesHeld.OpacityEvolve = EvolvingNatFloat.create(EnumTransformFunction.LINEAR, -150); particlesHeld.Color = ColorUtil.ReverseColorBytes(ColorUtil.HsvToRgba(h, 180, v, 150)); world.SpawnParticles(particlesHeld); } }
public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel, float dropQuantityMultiplier = 1) { IPlayer byPlayer = null; if (byEntity is EntityPlayer) { byPlayer = byEntity.World.PlayerByUid(((EntityPlayer)byEntity).PlayerUID); } ITreeAttribute tempAttr = itemslot.Itemstack.TempAttributes; //tempAttr.SetInt("breakCounter", 0); double windspeed = api.ModLoader.GetModSystem <WeatherSystemBase>()?.WeatherDataSlowAccess.GetWindSpeed(byEntity.SidedPos.XYZ) ?? 0; string treeType; Stack <BlockPos> foundPositions = FindTree(world, blockSel.Position, out treeType); Block leavesBranchyBlock = world.GetBlock(new AssetLocation("leavesbranchy-grown-" + treeType)); Block leavesBlock = world.GetBlock(new AssetLocation("leaves-grown-" + treeType)); if (foundPositions.Count == 0) { return(base.OnBlockBrokenWith(world, byEntity, itemslot, blockSel, dropQuantityMultiplier)); } bool damageable = DamagedBy != null && DamagedBy.Contains(EnumItemDamageSource.BlockBreaking); float leavesMul = 1; float leavesBranchyMul = 0.8f; int blocksbroken = 0; while (foundPositions.Count > 0) { BlockPos pos = foundPositions.Pop(); blocksbroken++; Block block = world.BlockAccessor.GetBlock(pos); bool isLog = block.Code.Path.StartsWith("beehive-inlog-" + treeType) || block.Code.Path.StartsWith("log-resinharvested-" + treeType) || block.Code.Path.StartsWith("log-resin-" + treeType) || block.Code.Path.StartsWith("log-grown-" + treeType) || block.Code.Path.StartsWith("bamboo-grown-brown-segment") || block.Code.Path.StartsWith("bamboo-grown-green-segment"); bool isBranchy = block == leavesBranchyBlock; bool isLeaves = block == leavesBlock || block.Code.Path == "bambooleaves-grown"; world.BlockAccessor.BreakBlock(pos, byPlayer, isLeaves ? leavesMul : (isBranchy ? leavesBranchyMul : 1)); if (world.Side == EnumAppSide.Client) { dustParticles.Color = block.GetRandomColor(world.Api as ICoreClientAPI, pos, BlockFacing.UP); dustParticles.Color |= 255 << 24; dustParticles.MinPos.Set(pos.X, pos.Y, pos.Z); if (block.BlockMaterial == EnumBlockMaterial.Leaves) { dustParticles.GravityEffect = (float)world.Rand.NextDouble() * 0.1f + 0.01f; dustParticles.ParticleModel = EnumParticleModel.Quad; dustParticles.MinVelocity.Set(-0.4f + 4 * (float)windspeed, -0.4f, -0.4f); dustParticles.AddVelocity.Set(0.8f + 4 * (float)windspeed, 1.2f, 0.8f); } else { dustParticles.GravityEffect = 0.8f; dustParticles.ParticleModel = EnumParticleModel.Cube; dustParticles.MinVelocity.Set(-0.4f + (float)windspeed, -0.4f, -0.4f); dustParticles.AddVelocity.Set(0.8f + (float)windspeed, 1.2f, 0.8f); } world.SpawnParticles(dustParticles); } if (damageable && isLog) { DamageItem(world, byEntity, itemslot); } if (itemslot.Itemstack == null) { return(true); } if (isLeaves && leavesMul > 0.03f) { leavesMul *= 0.85f; } if (isBranchy && leavesBranchyMul > 0.015f) { leavesBranchyMul *= 0.6f; } } if (blocksbroken > 35) { Vec3d pos = blockSel.Position.ToVec3d().Add(0.5, 0.5, 0.5); api.World.PlaySoundAt(new AssetLocation("sounds/effect/treefell"), pos.X, pos.Y, pos.Z, byPlayer, false, 32, GameMath.Clamp(blocksbroken / 100f, 0.25f, 1)); } return(true); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { int stockMod = 1; if (byPlayer.Entity.Controls.Sprint) { stockMod = byPlayer.InventoryManager.ActiveHotbarSlot.MaxSlotStackSize; } BlockEntity be = world.BlockAccessor.GetBlockEntity(blockSel.Position); RubbleStorageBE rcbe = world.BlockAccessor.GetBlockEntity(blockSel.Position) as RubbleStorageBE; if (be is GenericStorageCapBE) { rcbe = world.BlockAccessor.GetBlockEntity((be as GenericStorageCapBE).core) as RubbleStorageBE; } if (rcbe == null) { return(true); } // if the player is looking at one of the buttons on the crate. if (blockSel.SelectionBoxIndex == 1 && byPlayer.Entity.Controls.Sneak) { setLock(rcbe, RubbleStorageBE.StorageLocksEnum.Sand); } else if (blockSel.SelectionBoxIndex == 2 && byPlayer.Entity.Controls.Sneak) { setLock(rcbe, RubbleStorageBE.StorageLocksEnum.Gravel); } else if (blockSel.SelectionBoxIndex == 3 && byPlayer.Entity.Controls.Sneak) { setLock(rcbe, RubbleStorageBE.StorageLocksEnum.Stone); } if (blockSel.SelectionBoxIndex == 1) { if (rcbe.RemoveResource(world, byPlayer, blockSel, "sand", stockMod)) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer); interactParticles.MinPos = blockSel.Position.ToVec3d() + blockSel.HitPosition; interactParticles.ColorByBlock = world.BlockAccessor.GetBlock(blockSel.Position); world.SpawnParticles(interactParticles, byPlayer); } } else if (blockSel.SelectionBoxIndex == 2) { if (rcbe.RemoveResource(world, byPlayer, blockSel, "gravel", stockMod)) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer); interactParticles.MinPos = blockSel.Position.ToVec3d() + blockSel.HitPosition; interactParticles.ColorByBlock = world.BlockAccessor.GetBlock(blockSel.Position); world.SpawnParticles(interactParticles, byPlayer); } } else if (blockSel.SelectionBoxIndex == 3) { if (rcbe.RemoveResource(world, byPlayer, blockSel, "stone", stockMod)) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer); interactParticles.MinPos = blockSel.Position.ToVec3d() + blockSel.HitPosition; interactParticles.ColorByBlock = world.BlockAccessor.GetBlock(blockSel.Position); world.SpawnParticles(interactParticles, byPlayer); } } else if (blockSel.SelectionBoxIndex == 0 && byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack != null) { // attempts to add the players resource to the block. if (byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.ItemAttributes["rubbleable"].AsBool()) { if (rcbe.Degrade()) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } world.PlaySoundAt(new AssetLocation("game", "sounds/block/heavyice"), byPlayer, byPlayer); } } else if (byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Attributes.GetTreeAttribute("contents") != null && byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Attributes.GetTreeAttribute("contents").GetItemstack("0") != null) { ItemStack tstack = byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Attributes.GetTreeAttribute("contents").GetItemstack("0"); if (tstack.Collectible.Code.Domain == "game" && tstack.Collectible.Code.Path == "waterportion") { if (rcbe.Drench(world, blockSel)) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } world.PlaySoundAt(new AssetLocation("game", "sounds/environment/largesplash1"), byPlayer, byPlayer); } } } else { if (rcbe.AddResource(byPlayer.InventoryManager.ActiveHotbarSlot, stockMod)) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer); } } } else if (blockSel.SelectionBoxIndex == 0 && byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack == null) { // if the players hand is empty we want to take all the matching blocks outs of their inventory. if (rcbe.AddAll(byPlayer)) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } world.PlaySoundAt(new AssetLocation("game", "sounds/effect/stonecrush"), byPlayer, byPlayer); } } rcbe.CheckDisplayVariant(world, blockSel); return(true); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { PlugnFeatherBE be = world.BlockAccessor.GetBlockEntity(blockSel.Position) as PlugnFeatherBE; ItemStack playerStack = byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack; maxSearchRange = world.BlockAccessor.GetBlock(blockSel.Position).Attributes["searchrange"].AsInt(); if (byPlayer.InventoryManager.ActiveHotbarSlot.Empty) { } if (playerStack == null) { return(false); } Item playerItem = playerStack.Item; if (playerItem == null) { return(false); } if (playerStack.ItemAttributes != null && playerStack.ItemAttributes.KeyExists("quarrystarter") && playerStack.ItemAttributes["quarrystarter"].AsBool() == true && be != null && be.master == null) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } //Debug.WriteLine("making network"); MakeNetwork(world, byPlayer, blockSel); int maxwork = WorkNeeded(be.slaveCount + 1); be.SetMaxWork(maxwork); if (be.master == null) { return(false); } breakParticle2.MinPos = be.master.AsBlockPos.ToVec3d(); breakParticle2.AddPos = new Vec3d(1, 1, 1); breakParticle2.ColorByBlock = world.BlockAccessor.GetBlock(be.master.AsBlockPos); breakParticle2.MinVelocity = new Vec3f(.1f, .3f, .1f); breakParticle2.AddVelocity = new Vec3f(0f, .3f, 0f); world.SpawnParticles(breakParticle2, byPlayer); foreach (Vec3i slave in be.slaves) { breakParticle2.MinPos = slave.AsBlockPos.ToVec3d(); world.SpawnParticles(breakParticle2, byPlayer); PlugnFeatherBE slavebe = world.BlockAccessor.GetBlockEntity(slave.AsBlockPos) as PlugnFeatherBE; if (slavebe != null) { slavebe.SetMaxWork(maxwork); } } } if (playerStack.ItemAttributes.KeyExists("quarryimpact") && be != null && be.master != null) { /*breakParticle2.MinPos = blockSel.Position.ToVec3d(); * breakParticle2.AddPos = new Vec3d(1, 1, 1); * breakParticle2.ColorByBlock = world.BlockAccessor.GetBlock(blockSel.Position); * breakParticle2.MinVelocity = new Vec3f(.1f, .3f, .1f); * breakParticle2.AddVelocity = new Vec3f(0f, .3f, 0f); * * world.SpawnParticles(breakParticle2, byPlayer);*/ if (be.IncreaseWork(10) == true) { if (be.state != be.maxstate) { world.PlaySoundAt(cracksound, blockSel.Position.X, blockSel.Position.Y, blockSel.Position.Z, byPlayer, volume: .5f); Debug.WriteLine("work Maxed"); be.IncreaseState(1); SwitchState(be.state, world, byPlayer, blockSel); } if (CheckDone(be, world) == true) { Debug.WriteLine("all blocks at max"); BreakAll(be, world, byPlayer); } } world.PlaySoundAt(hammersound, blockSel.Position.X, blockSel.Position.Y, blockSel.Position.Z, byPlayer, volume: 0.5f); if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } Debug.WriteLine(be.work); } return(true); }
public void BreakAll(PlugnFeatherBE be, IWorldAccessor world, IPlayer byPlayer) { PlugnFeatherBE master = world.BlockAccessor.GetBlockEntity(be.master.AsBlockPos) as PlugnFeatherBE; List <Vec3i> points = new List <Vec3i> { be.master }; foreach (Vec3i slave in master.slaves) { points.Add(slave); } Vec3i[] cube = FindCube(points); List <BlockPos> blocks = FindBlocksPos(cube[0], cube[1]); //world.HighlightBlocks(byPlayer, 0, blocks); IDictionary <string, int> stones = FindStoneTypes(world, blocks); string rockpath = ""; int rockamount = 0; foreach (KeyValuePair <string, int> k in stones) { if (k.Value > rockamount) { rockpath = k.Key; rockamount = k.Value; } } //Debug.WriteLine(rockpath); foreach (BlockPos point in blocks) { if (world.BlockAccessor.GetBlock(point).Code.Path == "rock-" + rockpath) { breakParticle2.ColorByBlock = world.BlockAccessor.GetBlock(point); breakParticle2.MinQuantity = 5; breakParticle2.AddQuantity = 2; breakParticle2.MinPos = point.ToVec3d(); breakParticle2.AddPos = new Vec3d(1, 1, 1); breakParticle2.MinVelocity = new Vec3f(0, 3, 0); breakParticle2.AddVelocity = new Vec3f(.1f, .5f, .1f); breakParticle2.MinSize = 1f; breakParticle2.MaxSize = 3f; world.BlockAccessor.SetBlock(0, point); world.SpawnParticles(breakParticle2, byPlayer); } } // This is where our system decide what to drop. string dropItemFillerString = GetDropType(rockamount); string sizeModFillerString = GetSizeFillerString(dropItemFillerString); string dropItemString = "stonestorage" + dropItemFillerString + "-" + rockpath + sizeModFillerString + "north"; Block dropItem = world.GetBlock(new AssetLocation(Code.Domain, dropItemString.ToLower())); if (dropItem != null) { ItemStack dropItemStack = new ItemStack(dropItem, 1); dropItemStack.Attributes.SetInt("stonestored", rockamount); world.SpawnItemEntity(dropItemStack, new Vec3d(((cube[1].X - cube[0].X) / 2) + cube[0].X, ((cube[1].Y - cube[0].Y) / 2) + cube[0].Y, ((cube[1].Z - cube[0].Z) / 2) + cube[0].Z)); } world.BlockAccessor.BreakBlock(be.master.AsBlockPos, byPlayer); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { AssetLocation interactsound = new AssetLocation("game", "sounds/block/heavyice"); BlockEntity be = world.BlockAccessor.GetBlockEntity(blockSel.Position); if (be is GenericStorageCapBE) { be = world.BlockAccessor.GetBlockEntity((be as GenericStorageCapBE).core); } var rcbe = be as RoughCutStorageBE; if (rcbe == null || rcbe.blockStack == null) { return(false); } if (byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack == null) { if (rcbe.blockStack.Attributes.HasAttribute("stonestored")) { if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).ShowChatNotification("Contains: " + rcbe.blockStack.Attributes["stonestored"].ToString() + " stone"); } } return(false); } if (rcbe.blockStack.Attributes.GetInt("stonestored") <= 0) { return(false); } if (world.Side == EnumAppSide.Client) { (byPlayer as IClientPlayer).TriggerFpAnimation(EnumHandInteract.HeldItemAttack); } ItemStack activeStack = byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack; AssetLocation dropCode = null; int dropRate = 0; interactParticles.ColorByBlock = world.BlockAccessor.GetBlock(blockSel.Position); interactParticles.MinPos = blockSel.Position.ToVec3d() + blockSel.HitPosition; world.SpawnParticles(interactParticles, byPlayer); world.PlaySoundAt(interactsound, byPlayer, byPlayer, true, 32, .5f); if (activeStack.ItemAttributes != null) { if (activeStack.ItemAttributes.KeyExists("polishedrrate")) { dropCode = new AssetLocation("game", "rockpolished-" + rcbe.blockStack.Block.FirstCodePart(1)); dropRate = activeStack.ItemAttributes["polishedrrate"].AsInt(); } else if (activeStack.ItemAttributes.KeyExists("brickrrate")) { dropCode = new AssetLocation("game", "stonebrick-" + rcbe.blockStack.Block.FirstCodePart(1)); dropRate = activeStack.ItemAttributes["brickrrate"].AsInt(); } else if (activeStack.ItemAttributes.KeyExists("stonerrate")) { dropCode = new AssetLocation("game", "stone-" + rcbe.blockStack.Block.FirstCodePart(1)); dropRate = activeStack.ItemAttributes["stonerrate"].AsInt(); } else if (activeStack.ItemAttributes.KeyExists("rockrrate")) { dropCode = new AssetLocation("game", "rock-" + rcbe.blockStack.Block.FirstCodePart(1)); dropRate = activeStack.ItemAttributes["rockrrate"].AsInt(); } } if (dropCode != null) { var colObj = (CollectibleObject)world.GetItem(dropCode) ?? world.GetBlock(dropCode); var stackSize = DropCount(activeStack.ItemAttributes["rchances"].AsInt(), dropRate, world.Rand); var dropStack = new ItemStack(colObj, stackSize); var dropPos = blockSel.Position.ToVec3d() + blockSel.HitPosition; var dropVel = new Vec3d(.05 * blockSel.Face.Normalf.ToVec3d().X, .1, .05 * blockSel.Face.Normalf.ToVec3d().Z); world.SpawnItemEntity(dropStack, dropPos, dropVel); rcbe.blockStack.Attributes.SetInt("stonestored", rcbe.blockStack.Attributes.GetInt("stonestored") - 1); if (rcbe.blockStack.Attributes.GetInt("stonestored") <= 0) { world.BlockAccessor.BreakBlock(blockSel.Position, byPlayer); } byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Item.DamageItem(world, byPlayer.Entity, byPlayer.InventoryManager.ActiveHotbarSlot, 1); } return(true); }