How to use Desht Mass Block Update

Discussion in 'Plugin Development' started by BurnerDiamond, Dec 16, 2015.

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

    BurnerDiamond

    This is just a quick question.

    How would I use @desht 's API, to completely reset all blocks in an arena.

    I'm not sure how to use both MassBlockUpdate and CraftMassBlockUpdate

    Furthermore how do I use the cuboid class to create a cuboid and then craft a mass block update using a cuboid object?
     
  2. Offline

    Zombie_Striker

    @BurnerDiamond
    This isn't really a problem with bukkit, this is with @desht 's plugin. It would be better if you message him your problem.
     
  3. Offline

    BurnerDiamond

    Okay but what about this? I decided to take out chunks of NMS and Block Update but I keep having this error:

    Code:
    [12:47:52] [Server thread/ERROR]: Could not pass event PlayerDeathEvent to Ladder v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[custom.jar:git-Spigot-1646]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[custom.jar:git-Spigot-1646]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:514) [custom.jar:git-Spigot-1646]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:499) [custom.jar:git-Spigot-1646]
        at org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory.callPlayerDeathEvent(CraftEventFactory.java:397) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.EntityPlayer.die(EntityPlayer.java:386) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.EntityLiving.damageEntity(EntityLiving.java:745) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.EntityHuman.damageEntity(EntityHuman.java:765) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.EntityPlayer.damageEntity(EntityPlayer.java:465) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.EntityHuman.attack(EntityHuman.java:950) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:1204) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.PacketPlayInUseEntity.a(PacketPlayInUseEntity.java:37) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.PacketPlayInUseEntity.handle(PacketPlayInUseEntity.java:49) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [custom.jar:git-Spigot-1646]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [custom.jar:git-Spigot-1646]
    Caused by: java.lang.NullPointerException
        at me.bladian.arena.CraftMassBlockUpdate.setBlock(CraftMassBlockUpdate.java:57) ~[?:?]
        at me.bladian.arena.Arena.resetArena(Arena.java:123) ~[?:?]
        at me.bladian.arena.Ladder.actionResetArena(Ladder.java:422) ~[?:?]
        at me.bladian.arena.Ladder.onDeath(Ladder.java:226) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_65]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_65]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[custom.jar:git-Spigot-1646]
    Which is this error here:

    Code:
    boolean res = nms.setBlockFast(world, x, y, z, blockId, (byte)data);
    Used here:

    Code:
    ublic boolean setBlock(int x, int y, int z, int blockId, int data) {
            minX = Math.min(minX, x);
            minZ = Math.min(minZ, z);
            maxX = Math.max(maxX, x);
            maxZ = Math.max(maxZ, z);
    
            blocksModified++;
            int oldBlockId = world.getBlockTypeIdAt(x, y, z);
    
            boolean res = nms.setBlockFast(world, x, y, z, blockId, (byte)data);
    
            if (relightingStrategy != RelightingStrategy.NEVER) {
                if (nms.getBlockLightBlocking(oldBlockId) != nms.getBlockLightBlocking(blockId)
                        || nms.getBlockLightEmission(oldBlockId) != nms.getBlockLightEmission(blockId)) {
                    // lighting or light blocking by this block has changed; force a recalculation
                    if (relightingStrategy == RelightingStrategy.IMMEDIATE) {
                        nms.recalculateBlockLighting(world, x, y, z);
                    } else if (relightingStrategy == RelightingStrategy.DEFERRED || relightingStrategy == RelightingStrategy.HYBRID) {
                        deferredBlocks.add(new DeferredBlock(x, y, z));
                    }
                }
            }
            return res;
        }
    From this code:

    Code:
    /**
         * Make a fast block change at the given coordinates.  Clients will
         * not see this change until {@link #notifyClients()} is called.
         *
         * @param x X-coordinate of the block
         * @param y Y-coordinate of the block
         * @param z Z-coordinate of the block
         * @param materialId the new material ID for the block
         * @return whether the block was actually changed
         */
        public boolean setBlock(int x, int y, int z, int materialId);
    
        /**
         * Make a fast block change at the given coordinates.  Clients will
         * not see this change until {@link #notifyClients()} is called.
         *
         * @param x X-coordinate of the block
         * @param y Y-coordinate of the block
         * @param z Z-coordinate of the block
         * @param materialId the new material ID for the block
         * @param data the new block data
         * @return whether the block was actually changed
         */
        public boolean setBlock(int x, int y, int z, int materialId, int data);
     
  4. Offline

    Gorbit99

    Are you sure, that world is not null? Do a null check before that line
     
  5. Offline

    Zombie_Striker

    Did you null check everything?
    1. world can be null
    2. x cannot be null.
    3. y cannot be null.
    4. z cannot be null.
    5. blockid cannot be null.
    6. data cannot be null.
     
  6. Offline

    mcdorli

    This can be null:
    nms

    world is definitely not null, because then the error would have happened 2 lines above here
    nt oldBlockId = world.getBlockTypeIdAt(x, y, z)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 16, 2015
  7. Offline

    BurnerDiamond

    It was that, now I'm having a different problem. It's not updating any of the blocks, even though I've done every method.

    Code:
    public void resetArena() {
            MassBlockUpdate massBlockUpdate = CraftMassBlockUpdate.createMassBlockUpdater(core, world);
            Iterator<Block> blockIterator = cuboid.iterator();
            while (blockIterator.hasNext()) {
                Block block = blockIterator.next();
                massBlockUpdate.setBlock(block.getX(), block.getY(), block.getZ(), block.getTypeId(), block.getData());
    
            }
    
    
        }
    Any ideas why the blocks aren't updating?
     
  8. Offline

    mcdorli

    I never worked with this library, so no, there aren't any.
     
  9. Offline

    BurnerDiamond

    Screw it I'm going back to a custom block logger.
     
  10. Offline

    mythbusterma

    @BurnerDiamond

    A NullPointerException is very simple to diagnose. Why would you give up that easily?
     
    Zombie_Striker likes this.
  11. Offline

    BurnerDiamond

    I was able to fix the null pointer. Was simple enough, NMS was returning null, but I had a problem with blocks not being place. I also think this wouldn't benefit greatly as the server isn't big enough, and the mass block update isn't currently required.

    If you have any idea on why blocks weren't being replaced feel free to tell me, otherwise I couldn't find a method that maybe update the client and worked at the same time.
     
Thread Status:
Not open for further replies.

Share This Page