orangeadam3 / terra121

A Minecraft Terrain Generating Mod for Cubic Chunks 1.12.2. attempting to generate real terrain, biomes, and features on a 1:1 scale
MIT License
280 stars 42 forks source link

(Suggestion) Gravel to mark train tracks #166

Open Tanukipack opened 3 years ago

Tanukipack commented 3 years ago

As titles says.

Tanukipack commented 3 years ago

I love to make train tracks with Immersive Railroading, and having gravel to mark the tracks would really help

MrDoritos commented 3 years ago

Totally possible, I might take a crack at this myself.

Tanukipack commented 3 years ago

thank you!

orangeadam3 commented 3 years ago

I just pushed a fork (traingang) where i was messing around with train tracks and they mostly work with some bugs here and there. You can try looking at that.

Tanukipack commented 3 years ago

how do I obtain this?

orangeadam3 commented 3 years ago

https://github.com/orangeadam3/terra121/tree/traingang

On Fri, Mar 12, 2021, 7:38 PM Tanukipack @.***> wrote:

how do I obtain this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/orangeadam3/terra121/issues/166#issuecomment-797843946, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTAQBDORIYRJND3I4N5PJDTDKXXXANCNFSM4YL6XOZA .

Tanukipack commented 3 years ago

worked very well but it generated tracks where there hadn't been for a very long time, and the minecart tracks hindered and building on said routes

dougdorisbrown commented 3 years ago

Here is my very crude attempt to add ballast under the tracks

file - RoadGenerator

                    case RAIL:
                        osm.placeThin(cubeX, cubeZ, e, (x, z) -> {
                            double[] geo = projection.toGeo(x + cubeX*(16), z + cubeZ*(16));
                            int y = 1+(int)Math.floor(heights.estimateLocal(geo[0], geo[1]) - cubeY*16);
                            if(!(y > 0 && y <= 16))
                                return;

                            BlockPos bpos = new BlockPos(x + cubeX * 16, y + cubeY * 16, z + cubeZ * 16);

                            world.setBlockState(bpos.up(), TRACK);
                            // Add balast
                            world.setBlockState(bpos, Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down(), Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down().north(), Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down().north().east(), Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down().north().west(), Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down().east(), Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down().west(), Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down().south(), Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down().south().east(), Blocks.GRAVEL.getDefaultState());
                            world.setBlockState(bpos.down().south().west(), Blocks.GRAVEL.getDefaultState());

                        });

                        osm.placeThin(cubeX, cubeZ, e, (x, z) -> {
                            double[] geo = projection.toGeo(x + cubeX*(16), z + cubeZ*(16));
                            int y = 1+(int)Math.floor(heights.estimateLocal(geo[0], geo[1]) - cubeY*16);
                            if(!(y > 0 && y <= 16))
                                return;

                            BlockPos bpos = new BlockPos(x + cubeX * 16, y + cubeY * 16, z + cubeZ * 16);

                            if(world.getBlockState(bpos.up()).getBlock()==TRACK.getBlock()) {
                                int neighbors = 0;
                                boolean north = world.getBlockState(bpos.up().north().down()).getBlock()==TRACK.getBlock();
                                boolean south = world.getBlockState(bpos.up().south().down()).getBlock()==TRACK.getBlock();
                                boolean east = world.getBlockState(bpos.up().east().down()).getBlock()==TRACK.getBlock();
                                boolean west = world.getBlockState(bpos.up().west().down()).getBlock()==TRACK.getBlock();
                                neighbors += north?1:0;
                                neighbors += south?1:0;
                                neighbors += east?1:0;
                                neighbors += west?1:0;

                                System.out.println("pass A " + neighbors + " " +bpos);

                                if(neighbors==2) {

                                    if(north)world.setBlockState(bpos.up().north().down(), Blocks.AIR.getDefaultState());
                                    if(south)world.setBlockState(bpos.up().south().down(), Blocks.AIR.getDefaultState());
                                    if(east)world.setBlockState(bpos.up().east().down(), Blocks.AIR.getDefaultState());
                                    if(west)world.setBlockState(bpos.up().west().down(), Blocks.AIR.getDefaultState());

                                    world.setBlockState(bpos.up(), Blocks.AIR.getDefaultState());
                                    world.setBlockState(bpos.up().down().down(), Blocks.GRAVEL.getDefaultState());
                                    world.setBlockState(bpos.up().down(), TRACK);

                                    if(north)world.setBlockState(bpos.up().north().down(), TRACK);
                                    if(south)world.setBlockState(bpos.up().south().down(), TRACK);
                                    if(east)world.setBlockState(bpos.up().east().down(), TRACK);
                                    if(west)world.setBlockState(bpos.up().west().down(), TRACK);
                                }

                            }
                        });

                        osm.placeThin(cubeX, cubeZ, e, (x, z) -> {
                            double[] geo = projection.toGeo(x + cubeX*(16), z + cubeZ*(16));
                            int y = 1+(int)Math.floor(heights.estimateLocal(geo[0], geo[1]) - cubeY*16);
                            if(!(y > 0 && y <= 16))
                                return;

                            BlockPos bpos = new BlockPos(x + cubeX * 16, y + cubeY * 16, z + cubeZ * 16);

                            if(world.getBlockState(bpos.up()).getBlock()==TRACK.getBlock()) {
                                int neighbors = 0;
                                neighbors += world.getBlockState(bpos.up().north().up()).getBlock()==TRACK.getBlock()?1:0;
                                neighbors += world.getBlockState(bpos.up().south().up()).getBlock()==TRACK.getBlock()?1:0;
                                neighbors += world.getBlockState(bpos.up().east().up()).getBlock()==TRACK.getBlock()?1:0;
                                neighbors += world.getBlockState(bpos.up().west().up()).getBlock()==TRACK.getBlock()?1:0;

              System.out.println("pass B " + neighbors + " " +bpos);

                                if(neighbors==2) {

                                    world.setBlockState(bpos, Blocks.GRAVEL.getDefaultState());
                                    world.setBlockState(bpos.up(), TRACK);
                                }
                            }
                        });

          osm.placeThin(cubeX, cubeZ, e, (x, z) -> {
                            double[] geo = projection.toGeo(x + cubeX*(16), z + cubeZ*(16));
                            int y = 1+(int)Math.floor(heights.estimateLocal(geo[0], geo[1]) - cubeY*16);
                            if(!(y > 0 && y <= 16))
                                return;

                            BlockPos bpos = new BlockPos(x + cubeX * 16, y + cubeY * 16, z + cubeZ * 16);

                            IBlockState mystate = world.getBlockState(bpos.up());

                            if(mystate.getBlock()==TRACK.getBlock() && isRailBend(mystate)) {
                                int bentneighbors = 0;
                                bentneighbors += isRailBend(world.getBlockState(bpos.up().north().down()))?1:0;
                                bentneighbors += isRailBend(world.getBlockState(bpos.up().south().down()))?1:0;
                                bentneighbors += isRailBend(world.getBlockState(bpos.up().east().down()))?1:0;
                                bentneighbors += isRailBend(world.getBlockState(bpos.up().west().down()))?1:0;

              System.out.println("pass C " + bentneighbors + " " +bpos);

                                if(bentneighbors==1) {
                                    BlockPos newtrack = null;
                                    BlockRailBase.EnumRailDirection mydir = mystate.getValue(BlockRail.SHAPE);

                                    switch(mydir) {
                                        case SOUTH_EAST:
                                            newtrack = bpos.up().south().east();
                                            break;

                                        case SOUTH_WEST:
                                            newtrack = bpos.up().south().west();
                                            break;

                                        case NORTH_EAST:
                                            newtrack = bpos.up().north().east();
                                            break;

                                        case NORTH_WEST:
                                            newtrack = bpos.up().north().west();
                                            break;

                                        default:
                                            return;
                                    }
                                    System.out.println(bpos+"fix em up" + bpos);

                                    world.setBlockState(bpos.up(), Blocks.AIR.getDefaultState());
                                    world.setBlockState(newtrack.down(), Blocks.GRAVEL.getDefaultState());
                                    world.setBlockState(newtrack, Blocks.GRAVEL.getDefaultState());
                                    world.setBlockState(newtrack.up(), TRACK);
                                }
                            }
                        });

                        break;
Emi1232 commented 3 years ago

I download

https://github.com/orangeadam3/terra121/tree/traingang On Fri, Mar 12, 2021, 7:38 PM Tanukipack @.***> wrote: how do I obtain this? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#166 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTAQBDORIYRJND3I4N5PJDTDKXXXANCNFSM4YL6XOZA .

I downloaded that but in .zip file there isnt any .jar file how do i install it?

ATMmachin3 commented 2 years ago

I download

https://github.com/orangeadam3/terra121/tree/traingang On Fri, Mar 12, 2021, 7:38 PM Tanukipack @.***> wrote: how do I obtain this? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#166 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTAQBDORIYRJND3I4N5PJDTDKXXXANCNFSM4YL6XOZA .

I downloaded that but in .zip file there isnt any .jar file how do i install it?

You will have to build the jar likely