public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { BEHelveHammer beh = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BEHelveHammer; if (beh != null && beh.HammerStack == null && !byPlayer.InventoryManager.ActiveHotbarSlot.Empty) { if (byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Collectible.FirstCodePart().Equals("helvehammer")) { beh.HammerStack = byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack.Clone(); beh.MarkDirty(); if (byPlayer.WorldData.CurrentGameMode != EnumGameMode.Creative) { byPlayer.InventoryManager.ActiveHotbarSlot.TakeOut(1); } byPlayer.InventoryManager.ActiveHotbarSlot.MarkDirty(); api.World.PlaySoundAt(new AssetLocation("sounds/player/build"), blockSel.Position.X + 0.5, blockSel.Position.Y + 0.5, blockSel.Position.Z + 0.5, null, 0.88f + (float)api.World.Rand.NextDouble() * 0.24f, 16); return(true); } } return(base.OnBlockInteractStart(world, byPlayer, blockSel)); }
public override float GetResistance() { bool hasHammer = false; BEHelveHammer behh = Api.World.BlockAccessor.GetBlockEntity(sides[0]) as BEHelveHammer; if (behh != null && behh.HammerStack != null) { hasHammer = true; } else { behh = Api.World.BlockAccessor.GetBlockEntity(sides[1]) as BEHelveHammer; if (behh != null && behh.HammerStack != null) { hasHammer = true; } } //Exponentially increase hammer resistance if the network is turning faster - should almost always prevent helvehammering at crazy speeds; float speed = this.network == null ? 0f : Math.Abs(this.network.Speed * this.GearedRatio); float speedLimiter = 5f * (float)Math.Exp(speed * 2.8 - 5.0); return(hasHammer ? 0.125f + speedLimiter : 0.0005f); }