예제 #1
0
        public override bool TryPlaceBlock(IWorldAccessor world, IPlayer byPlayer, ItemStack itemstack, BlockSelection blockSel)
        {
            if (!world.TestPlayerAccessBlock(byPlayer, blockSel.Position, EnumBlockAccessFlags.BuildOrBreak))
            {
                byPlayer.InventoryManager.ActiveHotbarSlot.MarkDirty();
                return(false);
            }

            if (!byPlayer.Entity.Controls.Sneak)
            {
                return(false);
            }
            if (IsSuitablePosition(world, blockSel.Position) && world.BlockAccessor.GetBlock(blockSel.Position.DownCopy()).SideSolid[BlockFacing.UP.Index])
            {
                DoPlaceBlock(world, blockSel.Position, blockSel.Face, itemstack);

                BlockEntity be = world.BlockAccessor.GetBlockEntity(blockSel.Position);
                if (be is BlockEntitySmeltedContainer)
                {
                    BlockEntitySmeltedContainer   belmc    = (BlockEntitySmeltedContainer)be;
                    KeyValuePair <ItemStack, int> contents = GetContents(world, itemstack);
                    contents.Key.Collectible.SetTemperature(world, contents.Key, GetTemperature(world, itemstack));
                    belmc.contents = contents.Key;
                    belmc.units    = contents.Value;
                }

                return(true);
            }

            return(false);
        }
예제 #2
0
        public override bool TryPlaceBlock(IWorldAccessor world, IPlayer byPlayer, ItemStack itemstack, BlockSelection blockSel, ref string failureCode)
        {
            if (!byPlayer.Entity.Controls.Sneak || world.BlockAccessor.GetBlockEntity(blockSel.Position.DownCopy()) is ILiquidMetalSink)
            {
                failureCode = "__ignore__";
                return(false);
            }

            if (!CanPlaceBlock(world, byPlayer, blockSel, ref failureCode))
            {
                return(false);
            }

            if (world.BlockAccessor.GetBlock(blockSel.Position.DownCopy()).CanAttachBlockAt(world.BlockAccessor, this, blockSel.Position, BlockFacing.UP))
            {
                DoPlaceBlock(world, byPlayer, blockSel, itemstack);

                BlockEntity be = world.BlockAccessor.GetBlockEntity(blockSel.Position);
                if (be is BlockEntitySmeltedContainer)
                {
                    BlockEntitySmeltedContainer   belmc    = (BlockEntitySmeltedContainer)be;
                    KeyValuePair <ItemStack, int> contents = GetContents(world, itemstack);
                    contents.Key.Collectible.SetTemperature(world, contents.Key, GetTemperature(world, itemstack));
                    belmc.contents = contents.Key.Clone();
                    belmc.units    = contents.Value;
                }
                return(true);
            }

            failureCode = "requiresolidground";

            return(false);
        }
예제 #3
0
        public override ItemStack[] GetDrops(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, float dropQuantityMultiplier = 1f)
        {
            ItemStack[] stacks = base.GetDrops(world, pos, byPlayer);

            BlockEntity be = world.BlockAccessor.GetBlockEntity(pos);

            if (be is BlockEntitySmeltedContainer)
            {
                BlockEntitySmeltedContainer belmc = (BlockEntitySmeltedContainer)be;
                SetContents(stacks[0], belmc.contents, belmc.units);
                belmc.contents?.ResolveBlockOrItem(world);
                stacks[0].Collectible.SetTemperature(world, stacks[0], belmc.contents.Collectible.GetTemperature(world, belmc.contents));
            }

            return(stacks);
        }
예제 #4
0
        public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer)
        {
            BlockEntity be = world.BlockAccessor.GetBlockEntity(pos);

            if (be is BlockEntitySmeltedContainer)
            {
                BlockEntitySmeltedContainer belmc = (BlockEntitySmeltedContainer)be;
                belmc.contents.ResolveBlockOrItem(world);

                return
                    ("Units: " + (int)(belmc.units) + "\n" +
                     "Metal: " + belmc.contents.GetName() + "\n" +
                     "Temperature: " + (int)belmc.Temperature + " °C\n"
                    );
            }

            return(base.GetPlacedBlockInfo(world, pos, forPlayer));
        }
        public override bool TryPlaceBlock(IWorldAccessor world, IPlayer byPlayer, ItemStack itemstack, BlockSelection blockSel, ref string failureCode)
        {
            if (!world.Claims.TryAccess(byPlayer, blockSel.Position, EnumBlockAccessFlags.BuildOrBreak))
            {
                byPlayer.InventoryManager.ActiveHotbarSlot.MarkDirty();
                failureCode = "claimed";
                return(false);
            }

            if (!byPlayer.Entity.Controls.Sneak || world.BlockAccessor.GetBlockEntity(blockSel.Position.DownCopy()) is ILiquidMetalSink)
            {
                failureCode = "__ignore__";
                return(false);
            }

            if (!IsSuitablePosition(world, blockSel.Position, ref failureCode))
            {
                return(false);
            }

            if (world.BlockAccessor.GetBlock(blockSel.Position.DownCopy()).SideSolid[BlockFacing.UP.Index])
            {
                DoPlaceBlock(world, blockSel.Position, blockSel.Face, itemstack);

                BlockEntity be = world.BlockAccessor.GetBlockEntity(blockSel.Position);
                if (be is BlockEntitySmeltedContainer)
                {
                    BlockEntitySmeltedContainer   belmc    = (BlockEntitySmeltedContainer)be;
                    KeyValuePair <ItemStack, int> contents = GetContents(world, itemstack);
                    contents.Key.Collectible.SetTemperature(world, contents.Key, GetTemperature(world, itemstack));
                    belmc.contents = contents.Key.Clone();
                    belmc.units    = contents.Value;
                }
                return(true);
            }

            failureCode = "requiresolidground";

            return(false);
        }