Increased Map Height (128+) Test Plugin

Discussion in 'Bukkit Discussion' started by DeLux, Nov 29, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Isocadia

    So it's not yet server ready? I'm currently holding my entire server on hold waiting for higher world ( would like 512, but 256 should do too ) because 128 simply isn't enough :p Because from what I understand blocks above 128 are turning to bedrock?
     
  2. Offline

    Hazilo

    They are if you forget to change a lot of those hard-coded values.

    On my server, I've changed a lot of those hard coded 128, the world is fine at 256, the only problem I have is some blocks being almost unbreakable with tools.

    There are a lot of places where values need to be changed. Would be boring to remember where I changed what. Some are the chunk size that is 16 * 128 * 16 * 5 / 2 by default (81 920), if we keep a chunk of 16 x 16 x height, it should be calculated more easily that way: 5 << (heightBits + 7). To make it quick, in the code there are also some Y & 0x7f, some functions with (0,0,0, 16, 128, 16), etc...
     
  3. Offline

    croxis

    @Hazilo would it be possible for you to post a diff/patch, or send me your code so I can make it?
     
  4. Offline

    Hazilo

    Wait a little, I'm gonna fork the repos I used

    Edit: Oh god, I'm totally lost when it comes to these repo, can't figure out how to get a decent patch for you, eclipse, git and all these are a nightmare when you come from a C environment.
     
  5. Offline

    croxis

    Thats kinds funny as Linus invented git for the linux kernel, which is C ;)

    Help me help you, where are you stuck at?
     
  6. Offline

    Hazilo

    Well, the problem isn't git, but it's integration into eclipse, and all these into windows...

    To make it easy, is there a way to create a diff/patch from a project in eclipse without messing with git?
     
  7. Offline

    croxis

    Unfortunately I don't know the gui option, but the command isn't that complicated:
    git diff commitid1 commitid2 > patch.txt

    I think I got most of the changes. Here is my updated patch file.
    Code:
    diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
    index ea939f8..8d44bdc 100644
    --- a/src/main/java/net/minecraft/server/World.java
    +++ b/src/main/java/net/minecraft/server/World.java
    @@ -33,7 +33,7 @@ import org.bukkit.block.BlockState;
     
     public class World implements IBlockAccess {
     
    -    public int heightBits = 7;
    +    public int heightBits = 8;
         public int heightBitsPlusFour;
         public int height;
         public int heightMinusOne;
    @@ -117,7 +117,6 @@ public class World implements IBlockAccess {
             this.generator = gen;
             this.world = new CraftWorld((WorldServer) this, gen, env);
             // CraftBukkit end
    -
             this.heightBitsPlusFour = this.heightBits + 4;
             this.height = 1 << this.heightBits;
             this.heightMinusOne = this.height - 1;
    diff --git a/src/main/java/org/bukkit/craftbukkit/ChunkCompressionThread.java b/src/main/java/org/bukkit/craftbukkit/ChunkCompressionThread.java
    index 9f9cd48..30fb4e5 100644
    --- a/src/main/java/org/bukkit/craftbukkit/ChunkCompressionThread.java
    +++ b/src/main/java/org/bukkit/craftbukkit/ChunkCompressionThread.java
    @@ -18,7 +18,7 @@ public final class ChunkCompressionThread implements Runnable {
         private final HashMap<EntityPlayer, Integer> queueSizePerPlayer = new HashMap<EntityPlayer, Integer>();
         private final BlockingQueue<QueuedPacket> packetQueue = new LinkedBlockingQueue<QueuedPacket>(QUEUE_CAPACITY);
     
    -    private final int CHUNK_SIZE = 16 * 128 * 16 * 5 / 2;
    +    private final int CHUNK_SIZE = 16 * 256 * 16 * 5 / 2;
         private final int REDUCED_DEFLATE_THRESHOLD = CHUNK_SIZE / 4;
         private final int DEFLATE_LEVEL_CHUNKS = 6;
         private final int DEFLATE_LEVEL_PARTS = 1;
    diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
    index 3e9fcac..63c3db4 100644
    --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
    +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
    @@ -64,7 +64,7 @@ public class CraftChunk implements Chunk {
         }
     
         public Block getBlock(int x, int y, int z) {
    -        return new CraftBlock(this, (getX() << 4) | (x & 0xF), y & 0x7F, (getZ() << 4) | (z & 0xF));
    +        return new CraftBlock(this, (getX() << 4) | (x & 0xF), y & 0xFF, (getZ() << 4) | (z & 0xF));
         }
     
         public Entity[] getEntities() {
    @@ -130,8 +130,8 @@ public class CraftChunk implements Chunk {
     
         public ChunkSnapshot getChunkSnapshot(boolean includeMaxblocky, boolean includeBiome, boolean includeBiomeTempRain) {
             net.minecraft.server.Chunk chunk = getHandle();
    -        byte[] buf = new byte[32768 + 16384 + 16384 + 16384]; // Get big enough buffer for whole chunk
    -        chunk.getData(buf, 0, 0, 0, 16, 128, 16, 0); // Get whole chunk
    +        byte[] buf = new byte[65536 + 32768 + 32768 + 32768]; // Get big enough buffer for whole chunk
    +        chunk.getData(buf, 0, 0, 0, 16, 256, 16, 0); // Get whole chunk
             byte[] hmap = null;
     
             if (includeMaxblocky) {
    diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
    index d113942..1c9db47 100644
    --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
    +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
    @@ -66,7 +66,7 @@ public class CraftWorld implements World {
         }
     
         public Block getBlockAt(int x, int y, int z) {
    -        return getChunkAt(x >> 4, z >> 4).getBlock(x & 0xF, y & 0x7F, z & 0xF);
    +        return getChunkAt(x >> 4, z >> 4).getBlock(x & 0xF, y & 0xFF, z & 0xF);
         }
     
         public int getBlockTypeIdAt(int x, int y, int z) {
    @@ -208,7 +208,7 @@ public class CraftWorld implements World {
             for (int xx = px; xx < (px + 16); xx++) {
                 world.notify(xx, 0, pz);
             }
    -        world.notify(px, 127, pz + 15);
    +        world.notify(px, 255, pz + 15);
     
             return true;
         }
    diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
    index 1cf5ae7..bfdf2b3 100644
    --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
    +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
    @@ -66,7 +66,7 @@ public class CraftBlock implements Block {
         }
     
         public byte getData() {
    -        return (byte) chunk.getHandle().getData(this.x & 0xF, this.y & 0x7F, this.z & 0xF);
    +        return (byte) chunk.getHandle().getData(this.x & 0xF, this.y & 0xFF, this.z & 0xF);
         }
     
         public void setType(final Material type) {
    @@ -102,7 +102,7 @@ public class CraftBlock implements Block {
         }
     
         public int getTypeId() {
    -        return chunk.getHandle().getTypeId(this.x & 0xF, this.y & 0x7F, this.z & 0xF);
    +        return chunk.getHandle().getTypeId(this.x & 0xF, this.y & 0xFF, this.z & 0xF);
         }
     
         public byte getLightLevel() {
    diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
    index 3c0893b..4a77634 100644
    --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
    +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
    @@ -254,7 +254,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
                 return false;
             }
     
    -        if ((x + sx - 1) >> 4 != cx || (z + sz - 1) >> 4 != cz || y < 0 || y + sy > 128) {
    +        if ((x + sx - 1) >> 4 != cx || (z + sz - 1) >> 4 != cz || y < 0 || y + sy > 256) {
                 return false;
             }
     
    diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
    index 17438f7..0611dcc 100644
    --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
    +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
    @@ -176,7 +176,6 @@ public class CraftEventFactory {
     
             PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
             craftServer.getPluginManager().callEvent(event);
    -
             return event;
         }
     
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  8. Offline

    Hazilo

    Looking at your file, I saw the one that I forgot!

    But here is my correction:
    This one is wrong, the Y is not a height, but a coordinate to draw a map item:
    Code:
    @@ -276,8 +276,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
             for (int x = 0; x < 128; ++x) {
                 byte[] bytes = new byte[131];
                 bytes[1] = (byte) x;
    -            for (int y = 0; y < 128; ++y) {
    -                bytes[y + 3] = data.buffer[y * 128 + x];
    +            for (int y = 0; y < 256; ++y) {
    +                bytes[y + 3] = data.buffer[y * 256 + x];
                 }
                 Packet131ItemData packet = new Packet131ItemData((short) Material.MAP.getId(), map.getId(), bytes);
                 getHandle().netServerHandler.sendPacket(packet);
    And here are some more:
    in CraftChunk.java:
    Code:
    -         byte[] buf = new byte[32768 + 16384 + 16384 + 16384];
    +         byte[] buf = new byte[65536 + 32768 + 32768 + 32768];
    CraftWorld.java:
    Code:
    line 215
    -        world.notify(px, 127, pz + 15);
    +        world.notify(px, 255, pz + 15);
     
  9. Offline

    croxis

    Hazilo, do you think BLOCKDATA_OFF, BLOCKLIGHT_OFF, SKYLIGHT_OFF be changed as well?

    I'm also making your recommended changes and updated my previous post
     
  10. Offline

    Hazilo

    I've already looked a little, I made some changes that broke the world and went back. Gonna look into it further.

    I'm gonna try to make the whole height thing being read from the config file, if it gives any good, I'll post it here to allow someone to make a plugin out of it.
    (Config for height, sea height, max gen height etc...)

    Edit: looks better with those changes too, light and blocks that weren't updated, are now. I think I made a mess somewhere else when I tried changing these
    Code:
        private static final int BLOCKDATA_OFF = 2 * 32768;
        private static final int BLOCKLIGHT_OFF = BLOCKDATA_OFF + 2 * 16384;
        private static final int SKYLIGHT_OFF = BLOCKLIGHT_OFF + 2 * 16384;
     
  11. Offline

    croxis

    I think the ideal situation is being able to set height on a per world basis. Adding it as a field to the bukkit.yml world definitions would be the best IMHO
     
  12. Offline

    4ethernity4

    SO hows is this going? Any hopes of a stable plugin yet? Cant wait for this so acctualy get done, will be awsome :D
     
  13. Offline

    croxis

    The only way I can think of getting this to work as a plugin is using the same technique SpoutPlugin does for modifying CraftBukkit. I'll try to learn how to do it, unless someone else beats me to it.
     
  14. Offline

    Isocadia

    Have you though about writing the plugin based on spout? I mean, the client already has higher world support, shouldn't the server already have some kind of API in place to send that info to the client?
     
  15. Offline

    croxis

    SpoutServer will be supporting cubic chunks, so map height is a non issue.
     
  16. Offline

    Isocadia

    Exept that that's still gonna take a month or 2 :p
     
  17. Offline

    GluEx3

    Hey Isocadia, I dont really know how to put the Plugin onto my Bukkit Server (1.0.0 R1). I put the TallMapPOC.jar into my Plugins folder and started the Server, but nothing happend.. :p Please could you Explain it to me ? :D

    Thanks !
    -GluEx3
     
  18. Offline

    ZNickq

    reflection. it is pretty easy to do actually ;)
     
  19. Offline

    linwe

    Eh, so the last news from Afforess (via IRC) are that they are halfway of writing an open-source server, which will be supporting unlimited height.
    It will be named Spout (as usual).
    I hope they don't give up the idea.
    Unlimited height is just splendid.
    At the moment the only way to extend height is either 1) vanilla modloader and cubic chunks(else 3 mods exist), or 2) Croxis' fine art, for which I'm deeply thankful.
     
  20. Offline

    iPhysX

    @linwe eeh.
    I don't think I care for unlimited height, Just imagine the massive ugly stuff people could build :D
     
  21. Offline

    ibitmyeye3

    So did you fix this to work? Sorry but I really want a height of 256.
     
  22. Offline

    Fujikatoma

  23. Offline

    chubbz

    Hey same here but I'd rather have it work instea of a buggy version
     
  24. Offline

    croxis

    I've got it working just fine with the extended map height modifying CB directly. Site policy prevents me from publishing my build.
     
  25. Offline

    Isocadia

    Could you email it? Email send in PM

    Edit: Hmm, I cannot enter a message when trying to PM you. Could you send it here: [email protected]
     
  26. Offline

    Hazilo

    All my changes together work great for 256 height. I can't get any higher value to work...
     
  27. Offline

    croxis

    I've had a hard time getting this to work as a plugin and I got other projects that need my attentions. I'll hand that off to someone else much better at java than me.
     
  28. Offline

    chubbz

    Wait do you need spoutcraft for this to work
     
  29. Offline

    croxis

  30. Offline

    chubbz

    ok thanks
     
Thread Status:
Not open for further replies.

Share This Page