Exemplo n.º 1
0
        public override void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldForResolving)
        {
            base.FromTreeAttributes(tree, worldForResolving);
            totalHoursForNextStage = tree.GetDouble("totalHoursForNextStage");
            canBloom = tree.GetInt("canBloom") > 0;

            foreach (BlockFacing facing in BlockFacing.HORIZONTALS)
            {
                pumpkinTotalHoursForNextStage[facing] = tree.GetDouble(facing.Code);
            }
            pumpkinGrowthTries = tree.GetInt("pumpkinGrowthTries");

            parentPlantPos     = new BlockPos(tree.GetInt("parentPlantPosX"), tree.GetInt("parentPlantPosY"), tree.GetInt("parentPlantPosZ"));
            preferredGrowthDir = BlockFacing.ALLFACES[tree.GetInt("preferredGrowthDir")];
            internalStage      = tree.GetInt("internalStage");
        }
Exemplo n.º 2
0
        internal virtual bool IsAttached(IBlockAccessor blockAccessor, BlockPos pos)
        {
            for (int i = 0; i < AttachedToFaces.Length; i++)
            {
                BlockFacing face = AttachedToFaces[i];

                Block block = blockAccessor.GetBlock(pos.AddCopy(face));

                if (block.CanAttachBlockAt(blockAccessor, block, pos.AddCopy(face), face.GetOpposite()))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        public override int GetRandomColor(ICoreClientAPI capi, BlockPos pos, BlockFacing facing, int rndIndex = -1)
        {
            BlockEntityGenericTypedContainer be = capi.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityGenericTypedContainer;

            if (be != null)
            {
                CompositeTexture tex = null;
                if (!Textures.TryGetValue(be.type + "-lid", out tex))
                {
                    Textures.TryGetValue(be.type + "-top", out tex);
                }
                return(capi.BlockTextureAtlas.GetRandomColor(tex?.Baked == null ? 0 : tex.Baked.TextureSubId, rndIndex));
            }

            return(base.GetRandomColor(capi, pos, facing, rndIndex));
        }
        bool TryAttachTo(IWorldAccessor world, BlockPos blockpos, BlockFacing onBlockFace)
        {
            BlockFacing oppositeFace = onBlockFace.Opposite;

            BlockPos attachingBlockPos = blockpos.AddCopy(oppositeFace);
            Block    block             = world.BlockAccessor.GetBlock(world.BlockAccessor.GetBlockId(attachingBlockPos));

            if (block.CanAttachBlockAt(world.BlockAccessor, this, attachingBlockPos, onBlockFace))
            {
                int blockId = world.BlockAccessor.GetBlock(CodeWithParts(oppositeFace.Code)).BlockId;
                world.BlockAccessor.SetBlock(blockId, blockpos);
                return(true);
            }

            return(false);
        }
        bool TryAttachTo(IWorldAccessor world, BlockPos blockpos, BlockFacing onBlockFace, ref string failureCode)
        {
            BlockFacing oppositeFace = onBlockFace.GetOpposite();

            BlockPos attachingBlockPos = blockpos.AddCopy(oppositeFace);
            Block    attachingBlock    = world.BlockAccessor.GetBlock(world.BlockAccessor.GetBlockId(attachingBlockPos));
            Block    orientedBlock     = world.BlockAccessor.GetBlock(block.CodeWithParts(oppositeFace.Code));

            if (attachingBlock.CanAttachBlockAt(world.BlockAccessor, block, attachingBlockPos, onBlockFace) && orientedBlock.IsSuitablePosition(world, blockpos, ref failureCode))
            {
                orientedBlock.DoPlaceBlock(world, blockpos, onBlockFace, null);
                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
        public override bool OnWorldEditCommand(WorldEdit worldEdit, CmdArgs args)
        {
            string cmd = args.PopWord();

            switch (cmd)
            {
            case "tm":
            {
                EnumMoveToolMode mode = EnumMoveToolMode.MoveBlocks;

                if (args.Length > 0)
                {
                    int index;
                    int.TryParse(args[0], out index);
                    if (Enum.IsDefined(typeof(EnumMoveToolMode), index))
                    {
                        mode = (EnumMoveToolMode)index;
                    }
                }

                MoveRepeatMode = mode;
                worldEdit.Good(Lang.Get("Tool mode now set to {0}", mode));
                return(true);
            }

            case "am":
            {
                Amount = (int)args.PopInt(1);
                worldEdit.Good(Lang.Get("Amount set to {0}", Amount));
                return(true);
            }

            case "north":
            case "east":
            case "west":
            case "south":
            case "up":
            case "down":
            {
                BlockFacing facing = BlockFacing.FromCode(cmd);
                Handle(worldEdit, facing.Normali);
                return(true);
            }
            }

            return(false);
        }
Exemplo n.º 7
0
        public override bool ShouldReceiveServerGameTicks(IWorldAccessor world, BlockPos pos, Random offThreadRandom, out object extra)
        {
            extra = null;
            if (!GlobalConstants.MeltingFreezingEnabled)
            {
                return(false);
            }
            if (habitat == EnumReedsHabitat.Land)
            {
                return(false);
            }

            if (habitat == EnumReedsHabitat.Ice)  // ice -> water
            {
                ClimateCondition conds = world.BlockAccessor.GetClimateAt(pos, EnumGetClimateMode.NowValues);
                if (conds == null)
                {
                    return(false);
                }

                float chance = GameMath.Clamp((conds.Temperature - 2f) / 20f, 0, 1);
                return(offThreadRandom.NextDouble() < chance);
            }

            // water -> ice
            if (offThreadRandom.NextDouble() < 0.6)
            {
                int rainY = world.BlockAccessor.GetRainMapHeightAt(pos);
                if (rainY <= pos.Y)
                {
                    for (int i = 0; i < BlockFacing.HORIZONTALS.Length; i++)
                    {
                        BlockFacing facing = BlockFacing.HORIZONTALS[i];
                        if (world.BlockAccessor.GetBlock(pos.AddCopy(facing)).Replaceable < 6000)
                        {
                            ClimateCondition conds = world.BlockAccessor.GetClimateAt(pos, EnumGetClimateMode.NowValues);
                            if (conds != null && conds.Temperature < -4)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 8
0
        public bool ShouldConnectAt(IWorldAccessor world, BlockPos ownPos, BlockFacing side)
        {
            Block block = world.BlockAccessor.GetBlock(ownPos.AddCopy(side));

            bool attrexists = block.Attributes?["fenceConnect"][side.Code].Exists == true;

            if (attrexists)
            {
                return(block.Attributes["fenceConnect"][side.Code].AsBool(true));
            }

            return
                ((block.FirstCodePart() == FirstCodePart() || block.FirstCodePart() == FirstCodePart() + "gate") ||
                 block.SideSolid[side.GetOpposite().Index]);

            ;
        }
Exemplo n.º 9
0
    public override bool OnTesselation(ITerrainMeshPool mesher, ITesselatorAPI tesselator)
    {
        ICoreClientAPI capi  = Api as ICoreClientAPI;
        Shape          shape = capi.Assets.TryGet("temporalengineering:shapes/block/engine/body.json").ToObject <Shape>();

        switch (BlockFacing.FromCode(Block.Variant["side"]).Index)
        {
        case 0:
            AxisSign = new int[] { 0, 0, -1 };
            rotateY  = 180;
            break;

        case 1:
            AxisSign = new int[] { -1, 0, 0 };
            rotateY  = 90;
            break;

        case 2:
            AxisSign = new int[] { 0, 0, -1 };
            rotateY  = 0;
            break;

        case 3:
            AxisSign = new int[] { -1, 0, 0 };
            rotateY  = 270;
            break;

        case 4:
            AxisSign = new int[] { 0, 1, 0 };
            rotateZ  = 270;
            break;

        case 5:
            AxisSign = new int[] { 0, 1, 0 };
            rotateZ  = 90;
            break;

        default:
            break;
        }
        MeshData mesh;

        capi.Tesselator.TesselateShape(Block, shape, out mesh, new Vec3f(rotateZ, rotateY, 0));
        mesher.AddMeshData(mesh);
        return(true);
    }
Exemplo n.º 10
0
        private void Handle(WorldEdit worldedit, BlockFacing blockFacing, int amount)
        {
            Vec3i vec           = blockFacing.Normali;
            bool  selectNewArea = SelectionMode == EnumRepeatSelectionMode.Move;
            bool  growToArea    = SelectionMode == EnumRepeatSelectionMode.Grow;

            switch (RepeatMode)
            {
            case EnumRepeatToolMode.Mirror:
                worldedit.MirrorArea(workspace.GetMarkedMinPos(), workspace.GetMarkedMaxPos(), blockFacing, selectNewArea, growToArea);
                break;

            case EnumRepeatToolMode.Repeat:
                worldedit.RepeatArea(workspace.GetMarkedMinPos(), workspace.GetMarkedMaxPos(), blockFacing, amount, selectNewArea, growToArea);
                break;
            }
        }
Exemplo n.º 11
0
        public override void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldForResolving)
        {
            InitInventory();

            int index = tree.GetInt("lastReceivedFromDir");

            if (index < 0)
            {
                LastReceivedFromDir = null;
            }
            else
            {
                LastReceivedFromDir = BlockFacing.ALLFACES[index];
            }

            base.FromTreeAttributes(tree, worldForResolving);
        }
        private bool IsReplacableBeneathAndSideways(IWorldAccessor world, BlockPos pos)
        {
            for (int i = 0; i < 4; i++)
            {
                BlockFacing facing = BlockFacing.HORIZONTALS[i];

                Block nBlock  = world.BlockAccessor.GetBlockOrNull(pos.X + facing.Normali.X, pos.Y + facing.Normali.Y, pos.Z + facing.Normali.Z);
                Block nBBlock = world.BlockAccessor.GetBlockOrNull(pos.X + facing.Normali.X, pos.Y + facing.Normali.Y - 1, pos.Z + facing.Normali.Z);

                if (nBlock != null && nBBlock != null && nBlock.Replaceable >= 6000 && nBBlock.Replaceable >= 6000)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 13
0
        public override void Initialize(JsonObject properties)
        {
            base.Initialize(properties);

            AttachedToFaces = new BlockFacing[] { BlockFacing.DOWN };

            if (properties["attachedToFaces"].Exists)
            {
                string[] faces = properties["attachedToFaces"].AsArray <string>();
                AttachedToFaces = new BlockFacing[faces.Length];

                for (int i = 0; i < faces.Length; i++)
                {
                    AttachedToFaces[i] = BlockFacing.FromCode(faces[i]);
                }
            }
        }
Exemplo n.º 14
0
        public override int GetRandomColor(ICoreClientAPI capi, BlockPos pos, BlockFacing facing)
        {
            IngotPileOverride be = capi.World.BlockAccessor.GetBlockEntity(pos) as IngotPileOverride;

            if (be == null)
            {
                return(base.GetRandomColor(capi, pos, facing));
            }
            string metalType = be.MetalType;

            if (metalType == null)
            {
                return(base.GetRandomColor(capi, pos, facing));
            }

            return(capi.BlockTextureAtlas.GetRandomColor(Textures[be.MetalType].Baked.TextureSubId));
        }
Exemplo n.º 15
0
        private void RotateFromCircuittoBE(ref Vec3f vector, ref BlockFacing facing, Vec3f center)
        {
            Vec3f rotation = SignalsUtils.FacingToRotation(this.orientation, this.facing);

            if (vector != null)
            {
                SignalsUtils.RotateVector(ref vector, 0, 0, rotation.Z, center);
                SignalsUtils.RotateVector(ref vector, 0, rotation.Y, 0, center);
                SignalsUtils.RotateVector(ref vector, rotation.X, 0, 0, center);
            }
            if (facing != null)
            {
                facing = facing.FaceWhenRotatedBy(0, 0, rotation.Z * GameMath.DEG2RAD);
                facing = facing.FaceWhenRotatedBy(0, rotation.Y * GameMath.DEG2RAD, 0);
                facing = facing.FaceWhenRotatedBy(rotation.X * GameMath.DEG2RAD, 0, 0);
            }
        }
Exemplo n.º 16
0
        bool TryAttachTo(IWorldAccessor world, BlockPos blockpos, BlockFacing onBlockFace)
        {
            BlockFacing onFace = onBlockFace;
            //if (onFace.IsHorizontal) onFace = onFace.GetOpposite(); - why is this here? Breaks attachment

            BlockPos attachingBlockPos = blockpos.AddCopy(onBlockFace.GetOpposite());
            Block    block             = world.BlockAccessor.GetBlock(world.BlockAccessor.GetBlockId(attachingBlockPos));

            if (block.CanAttachBlockAt(world.BlockAccessor, this, attachingBlockPos, onFace))
            {
                ushort blockId = world.BlockAccessor.GetBlock(CodeWithParts(onBlockFace.Code)).BlockId;
                world.BlockAccessor.SetBlock(blockId, blockpos);
                return(true);
            }

            return(false);
        }
Exemplo n.º 17
0
        public bool ShouldConnectAt(IWorldAccessor world, BlockPos ownPos, BlockFacing side)
        {
            Block block = world.BlockAccessor.GetBlock(ownPos.AddCopy(side));
            Block B1    = refBlock;

            String s1 = block.FirstCodePart();
            String s2 = B1.Code.FirstPathPart();

            if (block.BlockId != null)
            {//test same base block
                if (refBlock.FirstCodePart() == block.FirstCodePart())
                {
                    return(true);
                }
            }
            return((bool)block.SideSolid[side.GetOpposite().Index]); //test if neighbor face is solid
        }
Exemplo n.º 18
0
    protected void transferEnergy(BlockFacing side, float dt)
    {
        BlockPos    outPos     = Pos.Copy().Offset(side);
        BlockEntity tileEntity = Api.World.BlockAccessor.GetBlockEntity(outPos);

        if (tileEntity == null)
        {
            return;
        }
        if (!(tileEntity is IFluxStorage))
        {
            return;
        }
        float eout = Math.Min(energyStorage.getLimitExtract() * dt, energyStorage.getEnergyStored() * dt);

        energyStorage.modifyEnergyStored(-((IFluxStorage)tileEntity).receiveEnergy(side.Opposite, eout, false, dt));
    }
Exemplo n.º 19
0
        /// <summary>
        /// Searches a given horizontal radius for an air block next to a combustible block
        /// </summary>
        /// <param name="world"></param>
        /// <param name="lavaPos"></param>
        /// <param name="y">Current y level</param>
        /// <param name="radius">Horizontal Radius</param>
        /// <returns></returns>
        private FireLocation SearchRadiusForAirNextToCombustibleBlock(IWorldAccessor world, BlockPos lavaPos, int y, int radius)
        {
            for (int x = -radius; x <= radius; x++)
            {
                for (int z = -radius; z <= radius; z++)
                {
                    BlockPos airBlockPos = lavaPos.AddCopy(x, y, z);

                    BlockFacing facing = IsNextToCombustibleBlock(world, lavaPos, airBlockPos);
                    if (facing != null)
                    {
                        return(new FireLocation(airBlockPos, facing));
                    }
                }
            }
            return(null);
        }
Exemplo n.º 20
0
        private bool CanSupportThis(IBlockAccessor blockAccess, BlockPos pos, BlockFacing sideToTest)
        {
            Block block = blockAccess.GetBlock(pos);

            if (block.SideSolid[BlockFacing.UP.Index])
            {
                return(true);
            }
            if (sideToTest == null && block.FirstCodePart() == "roughhewnfence")
            {
                return(true);
            }
            Cuboidf[] boxes = block.CollisionBoxes;
            if (boxes != null)
            {
                for (int i = 0; i < boxes.Length; i++)
                {
                    if (boxes[i].Y2 == 1.0f)
                    {
                        if (sideToTest == null)
                        {
                            return(true);                      //any partial block below, with full height can support from beneath
                        }
                        if (sideToTest == BlockFacing.WEST && boxes[i].X1 != 0.0f)
                        {
                            continue;
                        }
                        if (sideToTest == BlockFacing.EAST && boxes[i].X2 != 1.0f)
                        {
                            continue;
                        }
                        if (sideToTest == BlockFacing.NORTH && boxes[i].Z1 != 0.0f)
                        {
                            continue;
                        }
                        if (sideToTest == BlockFacing.SOUTH && boxes[i].Z2 != 1.0f)
                        {
                            continue;
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 21
0
        private bool IsNeighborEmpty(
            ChunkPaletteStorage <Block>[,,] storages,
            int x, int y, int z, BlockFacing facing)
        {
            var cx = 1; var cy = 1; var cz = 1;

            switch (facing)
            {
            case BlockFacing.East: x += 1; if (x >= 16)
                {
                    cx += 1;
                }
                break;

            case BlockFacing.West: x -= 1; if (x < 0)
                {
                    cx -= 1;
                }
                break;

            case BlockFacing.Up: y += 1; if (y >= 16)
                {
                    cy += 1;
                }
                break;

            case BlockFacing.Down: y -= 1; if (y < 0)
                {
                    cy -= 1;
                }
                break;

            case BlockFacing.South: z += 1; if (z >= 16)
                {
                    cz += 1;
                }
                break;

            case BlockFacing.North: z -= 1; if (z < 0)
                {
                    cz -= 1;
                }
                break;
            }
            return(storages[cx, cy, cz]?[x & 0b1111, y & 0b1111, z & 0b1111].Prototype.IsNone ?? true);
Exemplo n.º 22
0
        public override void OnInteractStart(WorldEdit worldEdit, BlockSelection blockSelection)
        {
            if (blockSelection == null)
            {
                return;
            }

            BlockPos center = (workspace.StartMarker + workspace.EndMarker) / 2;

            center.Y = Math.Min(workspace.StartMarker.Y, workspace.EndMarker.Y);

            Vec3i       offset = (blockSelection.Position - center).ToVec3i();
            BlockFacing facing = BlockFacing.NORTH;
            int         amount = 1;

            if (Math.Abs(offset.X) > Math.Abs(offset.Y))
            {
                if (Math.Abs(offset.X) > Math.Abs(offset.Z))
                {
                    facing = offset.X >= 0 ? BlockFacing.EAST : BlockFacing.WEST;
                    amount = Math.Abs(offset.X) / Math.Abs(workspace.StartMarker.X - workspace.EndMarker.X);
                }
                else
                {
                    facing = offset.Z >= 0 ? BlockFacing.SOUTH : BlockFacing.NORTH;
                    amount = Math.Abs(offset.Z) / Math.Abs(workspace.StartMarker.Z - workspace.EndMarker.Z);
                }
            }
            else
            {
                if (Math.Abs(offset.Y) > Math.Abs(offset.Z))
                {
                    facing = offset.Y >= 0 ? BlockFacing.UP : BlockFacing.DOWN;
                    amount = Math.Abs(offset.Y) / Math.Abs(workspace.StartMarker.Y - workspace.EndMarker.Y);
                }
                else
                {
                    facing = offset.Z >= 0 ? BlockFacing.SOUTH : BlockFacing.NORTH;
                    amount = Math.Abs(offset.Z) / Math.Abs(workspace.StartMarker.Z - workspace.EndMarker.Z);
                }
            }


            Handle(worldEdit, facing, amount);
        }
Exemplo n.º 23
0
        public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
        {
            if (!world.Claims.TryAccess(byPlayer, blockSel.Position, EnumBlockAccessFlags.Use))
            {
                return(false);
            }

            BlockFacing    facing = BlockFacing.FromCode(LastCodePart()).Opposite;
            BlockEntityBed beBed  = world.BlockAccessor.GetBlockEntity(LastCodePart(1) == "feet" ? blockSel.Position.AddCopy(facing) : blockSel.Position) as BlockEntityBed;

            if (beBed == null)
            {
                return(false);
            }
            if (beBed.MountedBy != null)
            {
                return(false);
            }

            EntityBehaviorTiredness ebt = byPlayer.Entity.GetBehavior("tiredness") as EntityBehaviorTiredness;

            if (ebt != null && ebt.Tiredness <= 8)
            {
                if (world.Side == EnumAppSide.Client)
                {
                    (api as ICoreClientAPI).TriggerIngameError(this, "nottiredenough", Lang.Get("not-tired-enough"));
                }
                return(false);
            }

            int tempStormSleep = api.World.Config.GetString("temporalStormSleeping", "0").ToInt();

            if (tempStormSleep == 0 && api.ModLoader.GetModSystem <SystemTemporalStability>().StormStrength > 0)
            {
                if (world.Side == EnumAppSide.Client)
                {
                    (api as ICoreClientAPI).TriggerIngameError(this, "cantsleep-tempstorm", Lang.Get("cantsleep-tempstorm"));
                }
                return(false);
            }



            return(byPlayer.Entity.TryMount(beBed));
        }
        protected override MechPowerPath[] GetMechPowerExits(MechPowerPath fromExitTurnDir)
        {
            // This method could be called from another (earlier in the loading chunk) block's Initialise() method, i.e. before this itself is initialised.
            if (this.orientation == null)
            {
                this.SetOrientations();
            }

            string orientations = (Block as BlockAngledGears).Orientation;

            if (orientations.Length < 2 || orientations[0] != orientations[1])
            {
                bool          invert     = fromExitTurnDir.invert;
                BlockFacing[] connectors = (Block as BlockAngledGears).Facings;
                BlockFacing   inputSide  = fromExitTurnDir.OutFacing;
                if (!connectors.Contains(inputSide))
                {
                    inputSide = inputSide.Opposite;
                    invert    = !invert;
                }

                // The code for removing the inputSide from the MechPowerExits is unwanted for a newly placed AngledGears block - it needs to seek networks on both faces if newly placed
                if (!newlyPlaced)
                {
                    connectors = connectors.Remove(inputSide);
                }
                MechPowerPath[] paths = new MechPowerPath[connectors.Length];
                for (int i = 0; i < paths.Length; i++)
                {
                    BlockFacing pathFacing = connectors[i];

                    // An angled gear's output side rotates in the opposite sense from the input side
                    paths[i] = new MechPowerPath(pathFacing, this.GearedRatio, null, pathFacing == inputSide ? invert : !invert);
                }
                return(paths);
            }
            else
            {
                // Alternative code for a small gear connected to a Large Gear - essentially pass through
                MechPowerPath[] paths = new MechPowerPath[2];
                paths[0] = new MechPowerPath(this.orientation.Opposite, this.GearedRatio, null, this.orientation == fromExitTurnDir.OutFacing ? !fromExitTurnDir.invert : fromExitTurnDir.invert);
                paths[1] = new MechPowerPath(this.orientation, this.GearedRatio, null, this.orientation == fromExitTurnDir.OutFacing ? fromExitTurnDir.invert : !fromExitTurnDir.invert);
                return(paths);
            }
        }
Exemplo n.º 25
0
        internal MeshData GenMesh()
        {
            if (Block == null || contentCode == "")
            {
                return(null);
            }
            ContentConfig config = contentConfigs.FirstOrDefault(c => c.Code == contentCode);

            if (config == null)
            {
                return(null);
            }

            ICoreClientAPI capi = Api as ICoreClientAPI;

            ItemStack firstStack = inventory[0].Itemstack;

            if (firstStack == null)
            {
                return(null);
            }

            int    fillLevel = Math.Max(0, firstStack.StackSize / config.QuantityPerFillLevel - 1);
            string shapeLoc  = config.ShapesPerFillLevel[Math.Min(config.ShapesPerFillLevel.Length - 1, fillLevel)];

            Vec3f    rotation = new Vec3f(Block.Shape.rotateX, Block.Shape.rotateY, Block.Shape.rotateZ);
            MeshData meshbase;
            MeshData meshadd;

            blockTexPosSource = capi.Tesselator.GetTexSource(Block);
            capi.Tesselator.TesselateShape("betrough", Api.Assets.TryGet("shapes/" + shapeLoc + ".json").ToObject <Shape>(), out meshbase, this, rotation);

            BlockTroughDoubleBlock doubleblock = Block as BlockTroughDoubleBlock;

            if (doubleblock != null)
            {
                // Load only contents and flip 180 degrees
                capi.Tesselator.TesselateShape("betroughcontents", Api.Assets.TryGet("shapes/" + shapeLoc + ".json").ToObject <Shape>(), out meshadd, this, rotation.Add(0, 180, 0), 0, 0, 0, null, new string[] { "Origin point/contents/*" });
                BlockFacing facing = doubleblock.OtherPartPos();
                meshadd.Translate(facing.Normalf);
                meshbase.AddMeshData(meshadd);
            }

            return(meshbase);
        }
Exemplo n.º 26
0
 public virtual void WasPlaced(BlockFacing connectedOnFacing)
 {
     //Skip this if already called CreateJoinAndDiscoverNetwork in Initialize()
     if ((Api.Side == EnumAppSide.Client || OutFacingForNetworkDiscovery == null) && connectedOnFacing != null)
     {
         if (!tryConnect(connectedOnFacing))
         {
             if (DEBUG)
             {
                 Api.Logger.Notification("Was placed fail connect 2nd: " + connectedOnFacing + " at " + Position);
             }
         }
         else if (DEBUG)
         {
             Api.Logger.Notification("Was placed connected 1st: " + connectedOnFacing + " at " + Position);
         }
     }
 }
Exemplo n.º 27
0
        public override int GetRandomColor(ICoreClientAPI capi, BlockPos pos, BlockFacing facing, int rndIndex = -1)
        {
            if (Textures == null || Textures.Count == 0)
            {
                return(0);
            }
            BakedCompositeTexture tex = Textures?.First().Value?.Baked;

            if (tex == null)
            {
                return(0);
            }

            int color = capi.BlockTextureAtlas.GetRandomColor(tex.TextureSubId, rndIndex);

            color = capi.World.ApplyColorMapOnRgba("climatePlantTint", SeasonColorMap, color, pos.X, pos.Y, pos.Z);
            return(color);
        }
Exemplo n.º 28
0
        public bool IsOrientedTo(BlockFacing facing)
        {
            string dirs = Orientation;

            if (dirs[0] == facing.Code[0])
            {
                return(true);                            //all configurations of angled gear have a power connection on the first side
            }
            if (dirs.Length == 1)
            {
                return(false);                   //dead end
            }
            if (dirs[0] == dirs[1])
            {
                return(dirs[0] == facing.Opposite.Code[0]); //small gears on large gear can accept power from large gear hub
            }
            return(dirs[1] == facing.Code[0]);              //angled gears - secondary direction
        }
        bool TryAttachTo(IWorldAccessor world, BlockPos blockpos, BlockFacing onBlockFace, ItemStack itemstack)
        {
            BlockPos attachingBlockPos = blockpos.AddCopy(onBlockFace.GetOpposite());
            Block    attachingBlock    = world.BlockAccessor.GetBlock(world.BlockAccessor.GetBlockId(attachingBlockPos));

            BlockFacing onFace = onBlockFace;

            ///if (onFace.IsHorizontal) onFace = onFace.GetOpposite(); - why is this here? Breaks attachment

            if (attachingBlock.CanAttachBlockAt(world.BlockAccessor, block, attachingBlockPos, onFace))
            {
                Block orientedBlock = world.BlockAccessor.GetBlock(block.CodeWithPart(onBlockFace.Code, facingPos));
                orientedBlock.DoPlaceBlock(world, blockpos, onBlockFace, itemstack);
                return(true);
            }

            return(false);
        }
Exemplo n.º 30
0
        public override string GetPlacedBlockInfo(IWorldAccessor world, BlockPos pos, IPlayer forPlayer)
        {
            if (LastCodePart(1) == "feet")
            {
                BlockFacing facing = BlockFacing.FromCode(LastCodePart()).GetOpposite();
                pos = pos.AddCopy(facing);
            }

            BlockEntityTrough betr = world.BlockAccessor.GetBlockEntity(pos) as BlockEntityTrough;

            if (betr != null)
            {
                return(betr.GetBlockInfo(forPlayer));
            }


            return(base.GetPlacedBlockInfo(world, pos, forPlayer));
        }
Exemplo n.º 31
0
 /// <summary> Returns a neighboring block from the same IBlockStorage. </summary>
 public static IBlock Neighbor(this IBlock block, BlockFacing face)
 {
     return block.storage[face.MoveRelative(block.position)];
 }