Solved Replace Blocks on Chunk Generation Without Making Custom Chunk Generator

Discussion in 'Plugin Development' started by Conarnar, Apr 19, 2014.

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

    Conarnar

    Like the title says, is there any way to say like, replace all bedrock with stone when a chunk generates. I don't want to make a custom chunk generator because i want it to be exactly like in vanilla except for the bedrock part. I think it has to with block populators, but I don't know how to use those without making a custom chunk generator.
     
  2. Offline

    akabarblake

    *Checks bukkit javaDocs* Ok, not an expert, but here's what I'm guessing. not giving all the info because I just looked in the javaDocs, and some other forums. no testing.
    Code:
    Block bedrock = chunk.getBlock(x, y, z);
                        if(bedrock.getType() == Material.BEDROCK){
                            bedrock.setType(Material.STONE);
     
  3. Offline

    Conarnar

    But how do I get it while the chunk is generating?
     
  4. Offline

    akabarblake

    OnEnable....? This will make it stone every time the plugin is enabled. right when the world is loading; also the first time it will do, So if you did that you should disable it after, it may cause a HUGE lag spike.
     
  5. Offline

    TGRHavoc

    Use the "chunkLoadEvent" event.
     
  6. Offline

    akabarblake

    ChunkLoadEvent would happen after onEnable, but yes; it is more accurate.
     
  7. Offline

    TGRHavoc

    akabarblake He asked how he could get the chunk when it is generating :p
     
  8. Offline

    Conarnar

    TGRHavoc When I do that, I get spammed with an extremely long stacktrace that is so big that I can't put it on pastebin because of the file size limit.
     
  9. Offline

    coasterman10

    Do it the proper way and use a custom chunk generator. If you want it to be exactly like vanilla, then look through the source code and find the vanilla chunk generator.
     
  10. Offline

    Conarnar

    coasterman10 I don't think there is a "vanilla chunk generator" written in craftbukkit code. All the vanilla code is in the nms packages.
     
  11. Offline

    TGRHavoc

    Conarnar Can you take a screenshot of the error?
     
  12. Offline

    Conarnar

    TGRHavoc It's extremely long, so I can't fit all of it into a screenshot. While I was looking through the logs I found this which may me the cause of it.
    Code:
    Caused by: java.lang.RuntimeException: Already decorating!!
        at net.minecraft.server.v1_7_R1.BiomeDecorator.a(SourceFile:21) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.BiomeBase.a(SourceFile:362) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderGenerate.getChunkAt(SourceFile:432) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.generator.NormalChunkGenerator.getChunkAt(NormalChunkGenerator.java:49) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:238) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.Chunk.a(Chunk.java:828) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderServer.originalGetChunkAt(ChunkProviderServer.java:161) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:110) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:89) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.getChunkAt(CraftWorld.java:118) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.getBlockAt(CraftWorld.java:82) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.World.e(World.java:477) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.World.applyPhysics(World.java:435) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.World.update(World.java:407) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.World.setTypeAndData(World.java:304) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.block.CraftBlock.setTypeIdAndData(CraftBlock.java:128) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.block.CraftBlock.setTypeId(CraftBlock.java:123) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.block.CraftBlock.setTypeId(CraftBlock.java:119) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.block.CraftBlock.setType(CraftBlock.java:115) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at test.Test.l(Test.java:22) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_21]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_21]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:486) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:471) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:260) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.Chunk.a(Chunk.java:828) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderServer.originalGetChunkAt(ChunkProviderServer.java:161) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:110) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:89) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.getChunkAt(CraftWorld.java:118) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.getBlockAt(CraftWorld.java:82) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.World.e(World.java:477) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        at net.minecraft.server.v1_7_R1.World.applyPhysics(World.java:435) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
        ... 988 more
     
  13. Offline

    TGRHavoc

    Conarnar What's the code for your class?
     
  14. Offline

    Conarnar

    TGRHavoc
    Code:java
    1. package test;
    2.  
    3. import org.bukkit.Material;
    4. import org.bukkit.block.Block;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.EventPriority;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class Test extends JavaPlugin implements Listener {
    11. public void onEnable() {
    12. getServer().getPluginManager().registerEvents(this, this);
    13. }
    14.  
    15. @EventHandler(priority = EventPriority.MONITOR)
    16. public void l(org.bukkit.event.world.ChunkLoadEvent q) {
    17. for (int x = 0; x < 16; x++) {
    18. for (int y = 0; y < 127; y++) {
    19. for (int z = 0; z < 16; z++) {
    20. Block block = q.getChunk().getBlock(x, y, z);
    21.  
    22. if (block.getType() == Material.BEDROCK) {
    23. block.setType(Material.STONE);
    24. }
    25. }
    26. }
    27. }
    28. }
    29. }
     
  15. Offline

    Garris0n

    Which are in the source.

    What you're doing will cause lag, just saying.
     
  16. Offline

    Conarnar

  17. Offline

    RawCode

    everything works, read code carefully and completely, not only lines you want.

    your code is invalid, care to read javadocs about method before using it?

    answer is "terrain control"
     
  18. Offline

    Conarnar

    I didn't just read that line, I just posted a line I noticed to be forcibly throwing an exception.

    Well of course it's invalid, why else would it not be working?

    This isn't the plugin requests section where I lazily wait for someone to make or find a plugin for me.
     
  19. Offline

    RawCode

    Lazily download terrain control and lazily read its source code, or lazily wait someone to lazily spoonfeed you.
     
    coasterman10 and Garris0n like this.
  20. Offline

    Conarnar

    Then I will just lazily requests a plugin and lazily wait until someone makes it.
     
  21. Offline

    RawCode

    you will lazily get same responce again, nobody will waste time on plugin that already exists.
     
  22. Offline

    Conarnar

    Yeah, you're right. TerrainControl is proving to be very useful (and fun). :p
     
Thread Status:
Not open for further replies.

Share This Page