From cfe47d25d27add475bc113f93db55a6e4e058500 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 20 Apr 2018 23:19:07 +1000 Subject: [PATCH] Fixes #910 --- .../fawe/bukkit/v1_10/BukkitChunk_1_10.java | 101 +++++++----------- .../fawe/bukkit/v1_11/BukkitChunk_1_11.java | 71 ++++++------ .../fawe/bukkit/v1_7/BukkitChunk_1_7.java | 85 ++++++--------- .../fawe/bukkit/v1_8/BukkitChunk_1_8.java | 82 ++++++-------- .../fawe/bukkit/v1_9/BukkitChunk_1_9.java | 95 +++++++--------- 5 files changed, 179 insertions(+), 255 deletions(-) diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java index c6e68ff9..7a555c7d 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java @@ -10,36 +10,13 @@ import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.ReflectionUtils; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.ListTag; -import com.sk89q.jnbt.LongTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; +import com.sk89q.jnbt.*; import com.sk89q.worldedit.internal.Constants; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import net.minecraft.server.v1_10_R1.Block; -import net.minecraft.server.v1_10_R1.BlockPosition; -import net.minecraft.server.v1_10_R1.DataBits; -import net.minecraft.server.v1_10_R1.DataPalette; -import net.minecraft.server.v1_10_R1.DataPaletteBlock; -import net.minecraft.server.v1_10_R1.DataPaletteGlobal; -import net.minecraft.server.v1_10_R1.Entity; -import net.minecraft.server.v1_10_R1.EntityPlayer; -import net.minecraft.server.v1_10_R1.EntityTypes; -import net.minecraft.server.v1_10_R1.IBlockData; -import net.minecraft.server.v1_10_R1.NBTTagCompound; -import net.minecraft.server.v1_10_R1.NBTTagInt; -import net.minecraft.server.v1_10_R1.TileEntity; +import java.util.*; +import net.minecraft.server.v1_10_R1.*; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -335,42 +312,6 @@ public class BukkitChunk_1_10 extends CharFaweChunk { } } } - // Trim tiles - Iterator> iterator = tiles.entrySet().iterator(); - HashMap toRemove = null; - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); - net.minecraft.server.v1_10_R1.BlockPosition pos = tile.getKey(); - int lx = pos.getX() & 15; - int ly = pos.getY(); - int lz = pos.getZ() & 15; - int j = FaweCache.CACHE_I[ly][lz][lx]; - char[] array = this.getIdArray(j); - if (array == null) { - continue; - } - int k = FaweCache.CACHE_J[ly][lz][lx]; - if (array[k] != 0) { - if (toRemove == null) { - toRemove = new HashMap<>(); - } - if (copy != null) { - copy.storeTile(tile.getValue(), tile.getKey()); - } - toRemove.put(tile.getKey(), tile.getValue()); - } - } - if (toRemove != null) { - for (Map.Entry entry : toRemove.entrySet()) { - net.minecraft.server.v1_10_R1.BlockPosition bp = entry.getKey(); - net.minecraft.server.v1_10_R1.TileEntity tile = entry.getValue(); - tiles.remove(bp); - nmsWorld.s(bp); - tile.y(); - tile.invalidateBlockCache(); - } - - } // Set blocks for (int j = 0; j < sections.length; j++) { int count = this.getCount(j); @@ -452,6 +393,42 @@ public class BukkitChunk_1_10 extends CharFaweChunk { } getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section); } + // Trim tiles + Iterator> iterator = tiles.entrySet().iterator(); + HashMap toRemove = null; + while (iterator.hasNext()) { + Map.Entry tile = iterator.next(); + net.minecraft.server.v1_10_R1.BlockPosition pos = tile.getKey(); + int lx = pos.getX() & 15; + int ly = pos.getY(); + int lz = pos.getZ() & 15; + int j = FaweCache.CACHE_I[ly][lz][lx]; + char[] array = this.getIdArray(j); + if (array == null) { + continue; + } + int k = FaweCache.CACHE_J[ly][lz][lx]; + if (array[k] != 0) { + if (toRemove == null) { + toRemove = new HashMap<>(); + } + if (copy != null) { + copy.storeTile(tile.getValue(), tile.getKey()); + } + toRemove.put(tile.getKey(), tile.getValue()); + } + } + if (toRemove != null) { + for (Map.Entry entry : toRemove.entrySet()) { + net.minecraft.server.v1_10_R1.BlockPosition bp = entry.getKey(); + net.minecraft.server.v1_10_R1.TileEntity tile = entry.getValue(); + tiles.remove(bp); + nmsWorld.s(bp); + tile.y(); + tile.invalidateBlockCache(); + } + + } // Set biomes if (this.biomes != null) { if (copy != null) { diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java index deec71b0..a72cd028 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java @@ -345,42 +345,7 @@ public class BukkitChunk_1_11 extends CharFaweChunk> iterator = tiles.entrySet().iterator(); - HashMap toRemove = null; - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); - BlockPosition pos = tile.getKey(); - int lx = pos.getX() & 15; - int ly = pos.getY(); - int lz = pos.getZ() & 15; - int j = FaweCache.CACHE_I[ly][lz][lx]; - char[] array = this.getIdArray(j); - if (array == null) { - continue; - } - int k = FaweCache.CACHE_J[ly][lz][lx]; - if (array[k] != 0) { - if (toRemove == null) { - toRemove = new HashMap<>(); - } - if (copy != null) { - copy.storeTile(tile.getValue(), tile.getKey()); - } - toRemove.put(tile.getKey(), tile.getValue()); - } - } - if (toRemove != null) { - for (Map.Entry entry : toRemove.entrySet()) { - BlockPosition bp = entry.getKey(); - TileEntity tile = entry.getValue(); - tiles.remove(bp); - nmsWorld.s(bp); - tile.z(); - tile.invalidateBlockCache(); - } - } // Set blocks for (int j = 0; j < sections.length; j++) { int count = this.getCount(j); @@ -462,6 +427,42 @@ public class BukkitChunk_1_11 extends CharFaweChunk> iterator = tiles.entrySet().iterator(); + HashMap toRemove = null; + while (iterator.hasNext()) { + Map.Entry tile = iterator.next(); + BlockPosition pos = tile.getKey(); + int lx = pos.getX() & 15; + int ly = pos.getY(); + int lz = pos.getZ() & 15; + int j = FaweCache.CACHE_I[ly][lz][lx]; + char[] array = this.getIdArray(j); + if (array == null) { + continue; + } + int k = FaweCache.CACHE_J[ly][lz][lx]; + if (array[k] != 0) { + if (toRemove == null) { + toRemove = new HashMap<>(); + } + if (copy != null) { + copy.storeTile(tile.getValue(), tile.getKey()); + } + toRemove.put(tile.getKey(), tile.getValue()); + } + } + if (toRemove != null) { + for (Map.Entry entry : toRemove.entrySet()) { + BlockPosition bp = entry.getKey(); + TileEntity tile = entry.getValue(); + tiles.remove(bp); + nmsWorld.s(bp); + tile.z(); + tile.invalidateBlockCache(); + } + + } // Set biomes if (this.biomes != null) { if (copy != null) { diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java index 4d5bd9f9..f3e69beb 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitChunk_1_7.java @@ -13,24 +13,8 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.internal.Constants; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import net.minecraft.server.v1_7_R4.ChunkPosition; -import net.minecraft.server.v1_7_R4.ChunkSection; -import net.minecraft.server.v1_7_R4.Entity; -import net.minecraft.server.v1_7_R4.EntityPlayer; -import net.minecraft.server.v1_7_R4.EntityTypes; -import net.minecraft.server.v1_7_R4.NBTTagCompound; -import net.minecraft.server.v1_7_R4.NBTTagInt; -import net.minecraft.server.v1_7_R4.NibbleArray; -import net.minecraft.server.v1_7_R4.TileEntity; +import java.util.*; +import net.minecraft.server.v1_7_R4.*; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; @@ -256,39 +240,6 @@ public class BukkitChunk_1_7 extends CharFaweChunk { CharFaweChunk previous = getParent().getPrevious(this, sections, tiles, entities, createdEntities, false); getParent().getChangeTask().run(previous, this); } - // Trim tiles - Iterator> iterator = tiles.entrySet().iterator(); - HashMap toRemove = null; - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); - ChunkPosition pos = tile.getKey(); - int lx = pos.x & 15; - int ly = pos.y; - int lz = pos.z & 15; - int j = FaweCache.CACHE_I[ly][lz][lx]; - char[] array = this.getIdArray(j); - if (array == null) { - continue; - } - int k = FaweCache.CACHE_J[ly][lz][lx]; - if (array[k] != 0) { - if (toRemove == null) { - toRemove = new HashMap<>(); - } - toRemove.put(tile.getKey(), tile.getValue()); - } - } - if (toRemove != null) { - for (Map.Entry entry : toRemove.entrySet()) { - ChunkPosition bp = entry.getKey(); - TileEntity tile = entry.getValue(); - tiles.remove(bp); - nmsWorld.p(bp.x, bp.y, bp.z); - tile.s(); - tile.u(); - } - - } // Set blocks for (int j = 0; j < sections.length; j++) { int count = this.getCount(j); @@ -423,7 +374,39 @@ public class BukkitChunk_1_7 extends CharFaweChunk { } getParent().setCount(0, solid, section); } + // Trim tiles + Iterator> iterator = tiles.entrySet().iterator(); + HashMap toRemove = null; + while (iterator.hasNext()) { + Map.Entry tile = iterator.next(); + ChunkPosition pos = tile.getKey(); + int lx = pos.x & 15; + int ly = pos.y; + int lz = pos.z & 15; + int j = FaweCache.CACHE_I[ly][lz][lx]; + char[] array = this.getIdArray(j); + if (array == null) { + continue; + } + int k = FaweCache.CACHE_J[ly][lz][lx]; + if (array[k] != 0) { + if (toRemove == null) { + toRemove = new HashMap<>(); + } + toRemove.put(tile.getKey(), tile.getValue()); + } + } + if (toRemove != null) { + for (Map.Entry entry : toRemove.entrySet()) { + ChunkPosition bp = entry.getKey(); + TileEntity tile = entry.getValue(); + tiles.remove(bp); + nmsWorld.p(bp.x, bp.y, bp.z); + tile.s(); + tile.u(); + } + } // Set biomes if (this.biomes != null) { byte[] currentBiomes = nmsChunk.m(); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java index aa9878f8..02d2b246 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java @@ -13,21 +13,8 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.internal.Constants; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import net.minecraft.server.v1_8_R3.BlockPosition; -import net.minecraft.server.v1_8_R3.ChunkSection; -import net.minecraft.server.v1_8_R3.Entity; -import net.minecraft.server.v1_8_R3.EntityPlayer; -import net.minecraft.server.v1_8_R3.EntityTypes; -import net.minecraft.server.v1_8_R3.NBTTagCompound; -import net.minecraft.server.v1_8_R3.NBTTagInt; -import net.minecraft.server.v1_8_R3.TileEntity; +import java.util.*; +import net.minecraft.server.v1_8_R3.*; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.World; @@ -186,39 +173,6 @@ public class BukkitChunk_1_8 extends CharFaweChunk { CharFaweChunk previous = getParent().getPrevious(this, sections, tiles, entities, createdEntities, false); getParent().getChangeTask().run(previous, this); } - // Trim tiles - Iterator> iterator = tiles.entrySet().iterator(); - HashMap toRemove = null; - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); - BlockPosition pos = tile.getKey(); - int lx = pos.getX() & 15; - int ly = pos.getY(); - int lz = pos.getZ() & 15; - int j = FaweCache.CACHE_I[ly][lz][lx]; - char[] array = this.getIdArray(j); - if (array == null) { - continue; - } - int k = FaweCache.CACHE_J[ly][lz][lx]; - if (array[k] != 0) { - if (toRemove == null) { - toRemove = new HashMap<>(); - } - toRemove.put(tile.getKey(), tile.getValue()); - } - } - if (toRemove != null) { - for (Map.Entry entry : toRemove.entrySet()) { - BlockPosition bp = entry.getKey(); - TileEntity tile = entry.getValue(); - tiles.remove(bp); - nmsWorld.t(bp); - tile.y(); - tile.E(); - } - - } // Set blocks for (int j = 0; j < sections.length; j++) { int count = this.getCount(j); @@ -287,7 +241,39 @@ public class BukkitChunk_1_8 extends CharFaweChunk { } getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + solid, section); } + // Trim tiles + Iterator> iterator = tiles.entrySet().iterator(); + HashMap toRemove = null; + while (iterator.hasNext()) { + Map.Entry tile = iterator.next(); + BlockPosition pos = tile.getKey(); + int lx = pos.getX() & 15; + int ly = pos.getY(); + int lz = pos.getZ() & 15; + int j = FaweCache.CACHE_I[ly][lz][lx]; + char[] array = this.getIdArray(j); + if (array == null) { + continue; + } + int k = FaweCache.CACHE_J[ly][lz][lx]; + if (array[k] != 0) { + if (toRemove == null) { + toRemove = new HashMap<>(); + } + toRemove.put(tile.getKey(), tile.getValue()); + } + } + if (toRemove != null) { + for (Map.Entry entry : toRemove.entrySet()) { + BlockPosition bp = entry.getKey(); + TileEntity tile = entry.getValue(); + tiles.remove(bp); + nmsWorld.t(bp); + tile.y(); + tile.E(); + } + } // Set biomes if (this.biomes != null) { byte[] currentBiomes = nmsChunk.getBiomeIndex(); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java index 37b4b5e5..71c8cccd 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java @@ -9,35 +9,12 @@ import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.ReflectionUtils; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.ListTag; -import com.sk89q.jnbt.LongTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; +import com.sk89q.jnbt.*; import com.sk89q.worldedit.internal.Constants; import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import net.minecraft.server.v1_9_R2.Block; -import net.minecraft.server.v1_9_R2.BlockPosition; -import net.minecraft.server.v1_9_R2.ChunkSection; -import net.minecraft.server.v1_9_R2.DataBits; -import net.minecraft.server.v1_9_R2.DataPalette; -import net.minecraft.server.v1_9_R2.DataPaletteBlock; -import net.minecraft.server.v1_9_R2.DataPaletteGlobal; -import net.minecraft.server.v1_9_R2.Entity; -import net.minecraft.server.v1_9_R2.EntityPlayer; -import net.minecraft.server.v1_9_R2.EntityTypes; -import net.minecraft.server.v1_9_R2.IBlockData; -import net.minecraft.server.v1_9_R2.NBTTagCompound; -import net.minecraft.server.v1_9_R2.NBTTagInt; -import net.minecraft.server.v1_9_R2.TileEntity; +import java.util.*; +import net.minecraft.server.v1_9_R2.*; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.craftbukkit.v1_9_R2.CraftChunk; @@ -289,39 +266,6 @@ public class BukkitChunk_1_9 extends CharFaweChunk { CharFaweChunk previous = getParent().getPrevious(this, sections, tiles, entities, createdEntities, false); getParent().getChangeTask().run(previous, this); } - // Trim tiles - Iterator> iterator = tiles.entrySet().iterator(); - HashMap toRemove = null; - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); - BlockPosition pos = tile.getKey(); - int lx = pos.getX() & 15; - int ly = pos.getY(); - int lz = pos.getZ() & 15; - int j = FaweCache.CACHE_I[ly][lz][lx]; - char[] array = this.getIdArray(j); - if (array == null) { - continue; - } - int k = FaweCache.CACHE_J[ly][lz][lx]; - if (array[k] != 0) { - if (toRemove == null) { - toRemove = new HashMap<>(); - } - toRemove.put(tile.getKey(), tile.getValue()); - } - } - if (toRemove != null) { - for (Map.Entry entry : toRemove.entrySet()) { - BlockPosition bp = entry.getKey(); - TileEntity tile = entry.getValue(); - tiles.remove(bp); - nmsWorld.s(bp); - tile.y(); - tile.invalidateBlockCache(); - } - - } // Set blocks for (int j = 0; j < sections.length; j++) { int count = this.getCount(j); @@ -405,6 +349,39 @@ public class BukkitChunk_1_9 extends CharFaweChunk { } getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section); } + // Trim tiles + Iterator> iterator = tiles.entrySet().iterator(); + HashMap toRemove = null; + while (iterator.hasNext()) { + Map.Entry tile = iterator.next(); + BlockPosition pos = tile.getKey(); + int lx = pos.getX() & 15; + int ly = pos.getY(); + int lz = pos.getZ() & 15; + int j = FaweCache.CACHE_I[ly][lz][lx]; + char[] array = this.getIdArray(j); + if (array == null) { + continue; + } + int k = FaweCache.CACHE_J[ly][lz][lx]; + if (array[k] != 0) { + if (toRemove == null) { + toRemove = new HashMap<>(); + } + toRemove.put(tile.getKey(), tile.getValue()); + } + } + if (toRemove != null) { + for (Map.Entry entry : toRemove.entrySet()) { + BlockPosition bp = entry.getKey(); + TileEntity tile = entry.getValue(); + tiles.remove(bp); + nmsWorld.s(bp); + tile.y(); + tile.invalidateBlockCache(); + } + + } // Set biomes byte[] biomes = this.biomes; if (biomes != null) {