수색…


보이드 생성기

보이드 생성기 클래스 :

public class VoidGenerator extends ChunkGenerator
{

    @SuppressWarnings("deprecation")
    public byte[] generate(World w, Random rand, int x, int z)
    {
        byte[] result = new byte[32768]; //chunksized array filled with 0 - Air
        //Build a platform with Bedrock where the player shall spawn later
        if(x == 0 && z == 0)
        {
            result[xyz(0, 64, 0)] = (byte)Material.BEDROCK.getId();
            result[xyz(1, 64, 0)] = (byte)Material.BEDROCK.getId();
            result[xyz(0, 64, 1)] = (byte)Material.BEDROCK.getId();
        }
        return result;
    }

    private Integer xyz(int x, int y, int z)
    {
        return (x * 16 + z)*128+y; //position inside the chunk
    }
    
}

새로운 세계를 만들고 싶은 모든 수업 :

public void generateWorld(String mapName)
{
    try
    {
        WorldCreator w = new WorldCreator(mapName);
        w.generateStructures(false); //no trees, etc.
        w.generator(new VoidGenerator()); //use the VoidGenerator
        w.environment(Environment.NORMAL); //no nether, etc.
        w.createWorld(); //create the world
    } 
    catch(Exception ex) 
    { 
      ex.printStackTrace(); 
    }
}


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow