public override void OnDecalTesselation(IWorldAccessor world, MeshData decalMesh, BlockPos pos) { base.OnDecalTesselation(world, decalMesh, pos); BlockEntityLongPlantContainer bept = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityLongPlantContainer; if (bept != null) { decalMesh.Rotate(new Vec3f(0.5f, 0.5f, 0.5f), 0, bept.MeshAngle, 0); } }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { BlockEntityLongPlantContainer be = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityLongPlantContainer; if (byPlayer.InventoryManager?.ActiveHotbarSlot?.Empty == false && be != null) { return(be.TryPutContents(byPlayer.InventoryManager.ActiveHotbarSlot, byPlayer)); } return(false); }
public override bool DoPlaceBlock(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, ItemStack byItemStack) { bool val = base.DoPlaceBlock(world, byPlayer, blockSel, byItemStack); if (val) { BlockEntityLongPlantContainer bect = world.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityLongPlantContainer; 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 deg45rad = GameMath.PI / 4; float roundRad = ((int)Math.Round(angleHor / deg45rad)) * deg45rad; bect.MeshAngle = roundRad; } } return(val); }
public ItemStack GetContents(IWorldAccessor world, BlockPos pos) { BlockEntityLongPlantContainer be = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityLongPlantContainer; return(be?.GetContents()); }