コード例 #1
0
        public override void OnDecalTesselation(IWorldAccessor world, MeshData decalMesh, BlockPos pos)
        {
            base.OnDecalTesselation(world, decalMesh, pos);
            BlockEntityPlantContainer bept = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityPlantContainer;

            if (bept != null)
            {
                decalMesh.Rotate(new Vec3f(0.5f, 0.5f, 0.5f), 0, bept.MeshAngle, 0);
            }
        }
コード例 #2
0
        public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
        {
            BlockEntityPlantContainer be = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityPlantContainer;

            if (byPlayer.InventoryManager?.ActiveHotbarSlot?.Empty == false && be != null)
            {
                return(be.TryPutContents(byPlayer.InventoryManager.ActiveHotbarSlot, byPlayer));
            }

            return(false);
        }
コード例 #3
0
        public override bool DoPlaceBlock(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, ItemStack byItemStack)
        {
            bool val = base.DoPlaceBlock(world, byPlayer, blockSel, byItemStack);

            if (val)
            {
                BlockEntityPlantContainer bect = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityPlantContainer;
                if (bect != null)
                {
                    BlockPos targetPos = blockSel.DidOffset ? blockSel.Position.AddCopy(blockSel.Face.Opposite) : blockSel.Position;
                    double   dx        = byPlayer.Entity.Pos.X - (targetPos.X + blockSel.HitPosition.X);
                    double   dz        = (float)byPlayer.Entity.Pos.Z - (targetPos.Z + blockSel.HitPosition.Z);
                    float    angleHor  = (float)Math.Atan2(dx, dz);

                    float deg22dot5rad = GameMath.PIHALF / 4;
                    float roundRad     = ((int)Math.Round(angleHor / deg22dot5rad)) * deg22dot5rad;
                    bect.MeshAngle = roundRad;
                }
            }

            return(val);
        }
コード例 #4
0
        public ItemStack GetContents(IWorldAccessor world, BlockPos pos)
        {
            BlockEntityPlantContainer be = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityPlantContainer;

            return(be?.GetContents());
        }