コード例 #1
0
ファイル: ItemHammer.cs プロジェクト: bitcynth/vssurvivalmod
        public override void OnHeldAttackStop(float secondsPassed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
        {
            if (blockSel == null)
            {
                return;
            }
            if (!(byEntity.World.BlockAccessor.GetBlock(blockSel.Position) is BlockAnvil))
            {
                return;
            }

            BlockEntityAnvil bea = byEntity.World.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityAnvil;

            if (bea == null)
            {
                return;
            }

            IPlayer byPlayer = null;

            if (byEntity is IEntityPlayer)
            {
                byPlayer = byEntity.World.PlayerByUid(((IEntityPlayer)byEntity).PlayerUID);
            }
            if (byPlayer == null)
            {
                return;
            }


            if (bea.AvailableVoxels <= 0 && GetToolMode(slot, byPlayer, blockSel) != 5)
            {
                bea.didBeginUse--;
                return;
            }

            // The server side call is made using a custom network packet
            if (byEntity.World is IClientWorldAccessor)
            {
                bea.OnUseOver(byPlayer, blockSel.SelectionBoxIndex);
            }
        }
コード例 #2
0
        public override void OnHeldAttackStop(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
        {
            if (blockSel == null || secondsPassed < 0.4f)
            {
                return;
            }
            IPlayer byPlayer = (byEntity as EntityPlayer)?.Player;

            BlockEntity be = byEntity.World.BlockAccessor.GetBlockEntity(blockSel.Position);

            if (be is BlockEntityAnvilPart bep)
            {
                bep.OnHammerHitOver(byPlayer, blockSel.HitPosition);
            }

            if (!(byEntity.World.BlockAccessor.GetBlock(blockSel.Position) is BlockAnvil))
            {
                return;
            }
            BlockEntityAnvil bea = be as BlockEntityAnvil;

            if (bea == null)
            {
                return;
            }


            /*if (bea.AvailableMetalVoxels <= 0 && GetToolMode(slot, byPlayer, blockSel) != 5)
             * {
             *  return;
             * }*/

            // The server side call is made using a custom network packet
            if (byEntity.World is IClientWorldAccessor cWorld)
            {
                bea.OnUseOver(byPlayer, blockSel.SelectionBoxIndex);
            }
        }