From aff7e490244ecdba823ff80949460f99fbfa82aa Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Tue, 27 Oct 2020 22:14:32 -0400 Subject: [PATCH] Hunk Slices! --- src/main/java/com/volmit/iris/Iris.java | 78 +++- .../scaffold/hunk/io/HunkCompoundRegion.java | 73 ++-- .../gen/v2/scaffold/hunk/io/HunkRegion.java | 116 +++--- .../v2/scaffold/hunk/io/HunkRegionSlice.java | 333 ++++++++++-------- .../v2/scaffold/parallax/ParallaxWorld.java | 232 ++++++------ .../com/volmit/iris/util/CompoundTag.java | 109 +++--- src/main/java/com/volmit/iris/util/KMap.java | 2 +- 7 files changed, 521 insertions(+), 422 deletions(-) diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index ccf4046c2..8149d6e09 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -117,23 +117,53 @@ public class Iris extends MortarPlugin private static boolean doesSupport3DBiomes() { - int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); + try + { + int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); - return v >= 15; + return v >= 15; + } + + catch(Throwable e) + { + + } + + return false; } private static boolean doesSupportCustomModels() { - int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); + try + { + int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); - return v >= 14; + return v >= 14; + } + + catch(Throwable e) + { + + } + + return false; } private static boolean doesSupportAwareness() { - int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); + try + { + int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]); - return v >= 15; + return v >= 15; + } + + catch(Throwable e) + { + + } + + return false; } @Override @@ -281,17 +311,22 @@ public class Iris extends MortarPlugin public static void msg(String string) { - lock.lock(); - if(instance == null) + try { - System.out.println("[Iris]: " + string); - lock.unlock(); - return; + if(instance == null) + { + System.out.println("[Iris]: " + string); + return; + } + + String msg = C.GRAY + "[" + C.GREEN + "Iris" + C.GRAY + "]: " + string; + Bukkit.getConsoleSender().sendMessage(msg); } - String msg = C.GRAY + "[" + C.GREEN + "Iris" + C.GRAY + "]: " + string; - Bukkit.getConsoleSender().sendMessage(msg); - lock.unlock(); + catch(Throwable e) + { + System.out.println("[Iris]: " + string); + } } public static File getCached(String name, String url) @@ -389,7 +424,20 @@ public class Iris extends MortarPlugin public static void verbose(String string) { - if(IrisSettings.get().verbose) + if(true) + { + System.out.println(string); + } + + try + { + if(IrisSettings.get().verbose) + { + msg(C.GRAY + string); + } + } + + catch(Throwable e) { msg(C.GRAY + string); } diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkCompoundRegion.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkCompoundRegion.java index 0075a40c6..9efe846cf 100644 --- a/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkCompoundRegion.java +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkCompoundRegion.java @@ -1,37 +1,58 @@ package com.volmit.iris.gen.v2.scaffold.hunk.io; -import com.volmit.iris.util.CompoundTag; -import lombok.Getter; +import java.io.File; +import java.io.IOException; + import org.bukkit.block.data.BlockData; -import java.io.File; +import com.volmit.iris.util.CompoundTag; -public class HunkCompoundRegion extends HunkRegion { +import lombok.Getter; - @Getter - private HunkRegionSlice parallaxSlice; - @Getter - private HunkRegionSlice objectSlice; - @Getter - private HunkRegionSlice updateSlice; +public class HunkCompoundRegion extends HunkRegion +{ + @Getter + private HunkRegionSlice blockSlice; + @Getter + private HunkRegionSlice objectSlice; + @Getter + private HunkRegionSlice updateSlice; - private final int height; + private final int height; - public HunkCompoundRegion(int height, File folder, int x, int z, CompoundTag compound) { - super(folder, x, z, compound); - this.height = height; - setupSlices(); - } + public HunkCompoundRegion(int height, File folder, int x, int z, CompoundTag compound) + { + super(folder, x, z, compound); + this.height = height; + setupSlices(); + } - public HunkCompoundRegion(int height, File folder, int x, int z) { - super(folder, x, z); - this.height = height; - setupSlices(); - } + public HunkCompoundRegion(int height, File folder, int x, int z) + { + super(folder, x, z); + this.height = height; + setupSlices(); + } - private void setupSlices() { - parallaxSlice = HunkRegionSlice.BLOCKDATA.apply(height, getCompound()); - objectSlice = HunkRegionSlice.STRING.apply(height, getCompound(), "objects"); - updateSlice = HunkRegionSlice.BOOLEAN.apply(height, getCompound(), "updates"); - } + private void setupSlices() + { + blockSlice = HunkRegionSlice.BLOCKDATA.apply(height, getCompound()); + objectSlice = HunkRegionSlice.STRING.apply(height, getCompound(), "objects"); + updateSlice = HunkRegionSlice.BOOLEAN.apply(height, getCompound(), "updates"); + } + + public void save() throws IOException + { + blockSlice.save(); + objectSlice.save(); + updateSlice.save(); + super.save(); + } + + public void unload() + { + blockSlice.unloadAll(); + objectSlice.unloadAll(); + updateSlice.unloadAll(); + } } diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkRegion.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkRegion.java index 414d3ec12..c8b30e7b6 100644 --- a/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkRegion.java +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkRegion.java @@ -1,67 +1,85 @@ package com.volmit.iris.gen.v2.scaffold.hunk.io; -import com.volmit.iris.gen.v2.scaffold.hunk.Hunk; -import com.volmit.iris.util.CompoundTag; -import com.volmit.iris.util.KMap; -import com.volmit.iris.util.NBTInputStream; -import com.volmit.iris.util.NBTOutputStream; -import lombok.Data; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.util.Map; + +import com.volmit.iris.Iris; +import com.volmit.iris.util.CompoundTag; +import com.volmit.iris.util.KMap; +import com.volmit.iris.util.NBTInputStream; +import com.volmit.iris.util.NBTOutputStream; +import com.volmit.iris.util.Tag; + +import lombok.Data; @Data public class HunkRegion { - private final File folder; - private CompoundTag compound; - private final int x; - private final int z; + private final File folder; + private CompoundTag compound; + private final int x; + private final int z; - public HunkRegion(File folder, int x, int z, CompoundTag compound) { - this.compound = compound; - this.folder = folder; - this.x = x; - this.z = z; - folder.mkdirs(); - } + public HunkRegion(File folder, int x, int z, CompoundTag compound) + { + this.compound = fix(compound); + this.folder = folder; + this.x = x; + this.z = z; + folder.mkdirs(); + } - public HunkRegion(File folder, int x, int z) { - this(folder, x, z, new CompoundTag(x + "." + z, new KMap<>())); - File f = getFile(); + public HunkRegion(File folder, int x, int z) + { + this(folder, x, z, new CompoundTag(x + "." + z, new KMap<>())); + File f = getFile(); - if(f.exists()) - { - try - { - NBTInputStream in = new NBTInputStream(new FileInputStream(f)); - compound = (CompoundTag) in.readTag(); - in.close(); - } + if(f.exists()) + { + try + { + NBTInputStream in = new NBTInputStream(new FileInputStream(f)); + compound = fix((CompoundTag) in.readTag()); + in.close(); + } - catch(Throwable e) - { + catch(Throwable e) + { - } - } - } + } + } + } - public File getFile() - { - return new File(folder, x + "." + z + ".dat"); - } + private CompoundTag fix(CompoundTag readTag) + { + Map v = readTag.getValue(); - public void save() throws IOException - { - synchronized (compound) - { - File f = getFile(); - FileOutputStream fos = new FileOutputStream(f); - NBTOutputStream out = new NBTOutputStream(fos); - out.writeTag(compound); - out.close(); - } - } + if(!(v instanceof KMap)) + { + return new CompoundTag(readTag.getName(), new KMap(v)); + } + + return readTag; + } + + public File getFile() + { + return new File(folder, x + "." + z + ".dat"); + } + + public void save() throws IOException + { + synchronized(compound) + { + File f = getFile(); + FileOutputStream fos = new FileOutputStream(f); + NBTOutputStream out = new NBTOutputStream(fos); + out.writeTag(compound); + out.close(); + Iris.verbose("Saved Region: " + getX() + " " + getZ()); + } + } } diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkRegionSlice.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkRegionSlice.java index 7ceea369a..cb85b9ced 100644 --- a/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkRegionSlice.java +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/hunk/io/HunkRegionSlice.java @@ -1,190 +1,215 @@ package com.volmit.iris.gen.v2.scaffold.hunk.io; -import com.volmit.iris.gen.v2.scaffold.hunk.Hunk; -import com.volmit.iris.manager.IrisDataManager; -import com.volmit.iris.object.IrisBiome; -import com.volmit.iris.object.IrisObject; -import com.volmit.iris.util.*; -import org.bukkit.block.Biome; +import java.io.IOException; + import org.bukkit.block.data.BlockData; -import java.io.IOException; -import java.util.function.Function; +import com.volmit.iris.Iris; +import com.volmit.iris.gen.v2.scaffold.hunk.Hunk; +import com.volmit.iris.util.ByteArrayTag; +import com.volmit.iris.util.CompoundTag; +import com.volmit.iris.util.Function2; +import com.volmit.iris.util.Function3; +import com.volmit.iris.util.KList; +import com.volmit.iris.util.KMap; +import com.volmit.iris.util.Tag; -public class HunkRegionSlice { - public static final Function2> BLOCKDATA = (h,c) -> new HunkRegionSlice<>(h,Hunk::newMappedHunk, new BlockDataHunkIOAdapter(), c, "blockdata"); - public static final Function3> STRING = (h,c,t) -> new HunkRegionSlice<>(h,Hunk::newMappedHunk, new StringHunkIOAdapter(), c, t); - public static final Function3> BOOLEAN = (h,c,t) -> new HunkRegionSlice<>(h,Hunk::newMappedHunk, new BooleanHunkIOAdapter(), c, t); - private final Function3> factory; - private final HunkIOAdapter adapter; - private final CompoundTag compound; - private final String key; - private final KMap> loadedChunks; - private final KList save; - private final int height; +public class HunkRegionSlice +{ + public static final Function2> BLOCKDATA = (h, c) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BlockDataHunkIOAdapter(), c, "blockdata"); + public static final Function3> STRING = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new StringHunkIOAdapter(), c, t); + public static final Function3> BOOLEAN = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BooleanHunkIOAdapter(), c, t); + private final Function3> factory; + private final HunkIOAdapter adapter; + private final CompoundTag compound; + private final String key; + private final KMap> loadedChunks; + private final KList save; + private final int height; - public HunkRegionSlice(int height, Function3> factory, HunkIOAdapter adapter, CompoundTag compound, String key) - { - this.height = height; - this.loadedChunks = new KMap<>(); - this.factory = factory; - this.adapter = adapter; - this.compound = compound; - this.save = new KList<>(); - this.key = key; - } + public HunkRegionSlice(int height, Function3> factory, HunkIOAdapter adapter, CompoundTag compound, String key) + { + this.height = height; + this.loadedChunks = new KMap<>(); + this.factory = factory; + this.adapter = adapter; + this.compound = compound; + this.save = new KList<>(); + this.key = key; + } - public void clear() - { - for(String i : new KList<>(compound.getValue().keySet())) - { - if(i.startsWith(key + ".")) - { - compound.getValue().remove(i); - } - } - } + public void clear() + { + synchronized(save) + { + for(String i : new KList<>(compound.getValue().keySet())) + { + if(i.startsWith(key + ".")) + { + compound.getValue().remove(i); + } + } + } + } - public boolean contains(int x, int z) - { - return compound.getValue().containsKey(key(x, z)); - } + public void save() + { + for(short i : save) + { + save((byte) (i & 0xFF), (byte) ((i >> 8) & 0xFF)); + } - public void delete(int x, int z) - { - compound.getValue().remove(key(x,z)); - } + save.clear(); + } - public Hunk read(int x, int z) throws IOException - { - Tag t = compound.getValue().get(key(x,z)); + public boolean contains(int x, int z) + { + return compound.getValue().containsKey(key(x, z)); + } - if(!(t instanceof ByteArrayTag)) - { - return null; - } + public void delete(int x, int z) + { + compound.getValue().remove(key(x, z)); + } - return adapter.read(factory, (ByteArrayTag) t); - } + public Hunk read(int x, int z) throws IOException + { + Tag t = compound.getValue().get(key(x, z)); - public void write(Hunk hunk, int x, int z) throws IOException - { - compound.getValue().put(key(x,z), hunk.writeByteArrayTag(adapter, key)); - } + if(!(t instanceof ByteArrayTag)) + { + Iris.verbose("NOT BYTE ARRAY!"); + return null; + } - public synchronized void close() - { - for(Short i : loadedChunks.k()) - { - unload((byte) (i & 0xFF), (byte) ((i >> 8) & 0xFF)); - } + return adapter.read(factory, (ByteArrayTag) t); + } - save.clear(); - loadedChunks.clear(); - } + public void write(Hunk hunk, int x, int z) throws IOException + { + compound.getValue().put(key(x, z), hunk.writeByteArrayTag(adapter, key(x, z))); + } - public synchronized void save(Hunk region, int x, int z) - { - try { - write(region, x, z); - } catch (IOException e) { - e.printStackTrace(); - } - } + public synchronized void unloadAll() + { + for(Short i : loadedChunks.k()) + { + unload((byte) (i & 0xFF), (byte) ((i >> 8) & 0xFF)); + } - public boolean isLoaded(int x, int z) - { - return loadedChunks.containsKey(ikey(x,z)); - } + save.clear(); + loadedChunks.clear(); + } - public synchronized void save(int x, int z) - { - if(isLoaded(x,z)) - { - save(get(x,z), x, z); - } - } + public synchronized void save(Hunk region, int x, int z) + { + try + { + write(region, x, z); + } + catch(IOException e) + { + e.printStackTrace(); + } + } - public synchronized void unload(int x, int z) - { - short key = ikey(x,z); + public boolean isLoaded(int x, int z) + { + return loadedChunks.containsKey(ikey(x, z)); + } - if(isLoaded(x, z)) - { - if(save.contains(key)) - { - save(x,z); - save.remove(key); - } + public synchronized void save(int x, int z) + { + if(isLoaded(x, z)) + { + save(get(x, z), x, z); + } + } - loadedChunks.remove(key); - } - } + public synchronized void unload(int x, int z) + { + short key = ikey(x, z); - public synchronized Hunk load(int x, int z) - { - if(isLoaded(x,z)) - { - return loadedChunks.get(ikey(x,z)); - } + if(isLoaded(x, z)) + { + if(save.contains(key)) + { + save(x, z); + save.remove(key); + } - Hunk v = null; + loadedChunks.remove(key); + } + } - if(contains(x ,z)) - { - try { - v = read(x,z); - } catch (IOException e) { - e.printStackTrace(); - } - } + public synchronized Hunk load(int x, int z) + { + if(isLoaded(x, z)) + { + return loadedChunks.get(ikey(x, z)); + } - if(v == null) - { - v = factory.apply(16, height, 16); - } - loadedChunks.put(ikey(x,z), v); + Hunk v = null; - return v; - } + if(contains(x, z)) + { + try + { + v = read(x, z); + } - public Hunk get(int x, int z) - { - short key = ikey(x,z); + catch(IOException e) + { + e.printStackTrace(); + } + } - Hunk c = loadedChunks.get(key); + if(v == null) + { + v = factory.apply(16, height, 16); + } + loadedChunks.put(ikey(x, z), v); - if(c == null) - { - c = load(x, z); - } + return v; + } - return c; - } + public Hunk get(int x, int z) + { + short key = ikey(x, z); - public Hunk getR(int x, int z) - { - return get(x,z).readOnly(); - } + Hunk c = loadedChunks.get(key); - public Hunk getRW(int x, int z) - { - save.addIfMissing(ikey(x,z)); - return get(x,z); - } + if(c == null) + { + c = load(x, z); + } - private short ikey(int x, int z) - { - return ((short)(((x & 0xFF) << 8) | (z & 0xFF))); - } + return c; + } - private String key(int x, int z) - { - if(x < 0 || x >=32 || z < 0 || z >= 32) - { - throw new IndexOutOfBoundsException("The chunk " + x + " " + z + " is out of bounds max is 31x31"); - } + public Hunk getR(int x, int z) + { + return get(x, z).readOnly(); + } - return key + "." + Integer.toString(((short)(((x & 0xFF) << 8) | (z & 0xFF))), 36); - } + public Hunk getRW(int x, int z) + { + save.addIfMissing(ikey(x, z)); + return get(x, z); + } + + private short ikey(int x, int z) + { + return ((short) (((x & 0xFF) << 8) | (z & 0xFF))); + } + + private String key(int x, int z) + { + if(x < 0 || x >= 32 || z < 0 || z >= 32) + { + throw new IndexOutOfBoundsException("The chunk " + x + " " + z + " is out of bounds max is 31x31"); + } + + return key + "." + Integer.toString(((short) (((x & 0xFF) << 8) | (z & 0xFF))), 36); + } } diff --git a/src/main/java/com/volmit/iris/gen/v2/scaffold/parallax/ParallaxWorld.java b/src/main/java/com/volmit/iris/gen/v2/scaffold/parallax/ParallaxWorld.java index 9a59a54d6..78f81e3c9 100644 --- a/src/main/java/com/volmit/iris/gen/v2/scaffold/parallax/ParallaxWorld.java +++ b/src/main/java/com/volmit/iris/gen/v2/scaffold/parallax/ParallaxWorld.java @@ -1,142 +1,154 @@ package com.volmit.iris.gen.v2.scaffold.parallax; +import java.io.File; +import java.io.IOException; + +import org.bukkit.block.data.BlockData; + import com.volmit.iris.gen.v2.scaffold.hunk.Hunk; import com.volmit.iris.gen.v2.scaffold.hunk.io.HunkCompoundRegion; import com.volmit.iris.util.KList; import com.volmit.iris.util.KMap; -import org.bukkit.block.data.BlockData; -import java.io.File; -import java.io.IOException; +public class ParallaxWorld implements ParallaxAccess +{ + private final KMap loadedRegions; + private final KList save; + private final File folder; + private final int height; -public class ParallaxWorld implements ParallaxAccess { - private final KMap loadedRegions; - private final KList save; - private final File folder; - private final int height; + public ParallaxWorld(int height, File folder) + { + this.height = height; + this.folder = folder; + save = new KList<>(); + loadedRegions = new KMap<>(); + folder.mkdirs(); + } - public ParallaxWorld(int height, File folder) - { - this.height = height; - this.folder = folder; - save = new KList<>(); - loadedRegions = new KMap<>(); - folder.mkdirs(); - } + public synchronized void close() + { + for(HunkCompoundRegion i : loadedRegions.v()) + { + unload(i.getX(), i.getZ()); + } - public synchronized void close() - { - for(HunkCompoundRegion i : loadedRegions.v()) - { - unload(i.getX(), i.getZ()); - } + save.clear(); + loadedRegions.clear(); + } - save.clear(); - loadedRegions.clear(); - } + public synchronized void save(HunkCompoundRegion region) + { + try + { + region.save(); + } - public synchronized void save(HunkCompoundRegion region) - { - try { - region.save(); - } catch (IOException e) { - e.printStackTrace(); - } - } + catch(IOException e) + { + e.printStackTrace(); + } + } - public boolean isLoaded(int x, int z) - { - return loadedRegions.containsKey(key(x,z)); - } + public boolean isLoaded(int x, int z) + { + return loadedRegions.containsKey(key(x, z)); + } - public synchronized void save(int x, int z) - { - if(isLoaded(x,z)) - { - save(getR(x,z)); - } - } + public synchronized void save(int x, int z) + { + if(isLoaded(x, z)) + { + save(getR(x, z)); + } + } - public synchronized void unload(int x, int z) - { - long key = key(x,z); + public synchronized void unload(int x, int z) + { + long key = key(x, z); - if(isLoaded(x, z)) - { - if(save.contains(key)) - { - save(x,z); - save.remove(key); - } + if(isLoaded(x, z)) + { + if(save.contains(key)) + { + save(x, z); + save.remove(key); + } - loadedRegions.remove(key); - } - } + loadedRegions.remove(key).unload(); + } + } - public synchronized HunkCompoundRegion load(int x, int z) - { - if(isLoaded(x,z)) - { - return loadedRegions.get(key(x,z)); - } + public synchronized HunkCompoundRegion load(int x, int z) + { + if(isLoaded(x, z)) + { + return loadedRegions.get(key(x, z)); + } - HunkCompoundRegion v = new HunkCompoundRegion(height, folder, x, z); - loadedRegions.put(key(x,z), v); - return v; - } + HunkCompoundRegion v = new HunkCompoundRegion(height, folder, x, z); + loadedRegions.put(key(x, z), v); + return v; + } - public HunkCompoundRegion getR(int x, int z) - { - long key = key(x,z); + public HunkCompoundRegion getR(int x, int z) + { + long key = key(x, z); - HunkCompoundRegion region = loadedRegions.get(key); + HunkCompoundRegion region = loadedRegions.get(key); - if(region == null) - { - region = load(x, z); - } + if(region == null) + { + region = load(x, z); + } - return region; - } + return region; + } - public HunkCompoundRegion getRW(int x, int z) - { - save.addIfMissing(key(x,z)); - return getR(x,z); - } + public HunkCompoundRegion getRW(int x, int z) + { + save.addIfMissing(key(x, z)); + return getR(x, z); + } - private long key(int x, int z) - { - return (((long)x) << 32) | (((long)z) & 0xffffffffL); - } + private long key(int x, int z) + { + return (((long) x) << 32) | (((long) z) & 0xffffffffL); + } - @Override - public Hunk getBlocksR(int x, int z) { - return getR(x>>5, z>>5).getParallaxSlice().getR(x & 31,z & 31); - } + @Override + public Hunk getBlocksR(int x, int z) + { + return getR(x >> 5, z >> 5).getBlockSlice().getR(x & 31, z & 31); + } - @Override - public synchronized Hunk getBlocksRW(int x, int z) { - return getRW(x>>5, z>>5).getParallaxSlice().getRW(x & 31,z & 31); - } + @Override + public synchronized Hunk getBlocksRW(int x, int z) + { + return getRW(x >> 5, z >> 5).getBlockSlice().getRW(x & 31, z & 31); + } - @Override - public Hunk getObjectsR(int x, int z) { - return getR(x>>5, z>>5).getObjectSlice().getR(x & 31,z & 31); - } + @Override + public Hunk getObjectsR(int x, int z) + { + return getR(x >> 5, z >> 5).getObjectSlice().getR(x & 31, z & 31); + } - @Override - public synchronized Hunk getObjectsRW(int x, int z) { - return getRW(x>>5, z>>5).getObjectSlice().getRW(x & 31,z & 31); - } + @Override + public synchronized Hunk getObjectsRW(int x, int z) + { + return getRW(x >> 5, z >> 5).getObjectSlice().getRW(x & 31, z & 31); + } - @Override - public Hunk getUpdatesR(int x, int z) { - return getR(x>>5, z>>5).getUpdateSlice().getR(x & 31,z & 31); - } + @Override + public Hunk getUpdatesR(int x, int z) + { + return getR(x >> 5, z >> 5).getUpdateSlice().getR(x & 31, z & 31); + } - @Override - public synchronized Hunk getUpdatesRW(int x, int z) { - return getRW(x>>5, z>>5).getUpdateSlice().getRW(x & 31,z & 31); - } + @Override + public synchronized Hunk getUpdatesRW(int x, int z) + { + return getRW(x >> 5, z >> 5).getUpdateSlice().getRW(x & 31, z & 31); + } } diff --git a/src/main/java/com/volmit/iris/util/CompoundTag.java b/src/main/java/com/volmit/iris/util/CompoundTag.java index f6df65522..c1802e9c3 100644 --- a/src/main/java/com/volmit/iris/util/CompoundTag.java +++ b/src/main/java/com/volmit/iris/util/CompoundTag.java @@ -1,38 +1,5 @@ package com.volmit.iris.util; -/* - * JNBT License - * - * Copyright (c) 2010 Graham Edgecombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of the JNBT team nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -import java.util.Collections; import java.util.Map; /** @@ -41,43 +8,51 @@ import java.util.Map; * @author Graham Edgecombe * */ -public final class CompoundTag extends Tag { +public final class CompoundTag extends Tag +{ - /** - * The value. - */ - private final Map value; + /** + * The value. + */ + private final Map value; - /** - * Creates the tag. - * - * @param name The name. - * @param value The value. - */ - public CompoundTag(String name, Map value) { - super(name); - this.value = Collections.unmodifiableMap(value); - } + /** + * Creates the tag. + * + * @param name + * The name. + * @param value + * The value. + */ + public CompoundTag(String name, Map value) + { + super(name); + this.value = value; + } - @Override - public Map getValue() { - return value; - } + @Override + public Map getValue() + { + return value; + } - @Override - public String toString() { - String name = getName(); - String append = ""; - if (name != null && !name.equals("")) { - append = "(\"" + this.getName() + "\")"; - } - StringBuilder bldr = new StringBuilder(); - bldr.append("TAG_Compound" + append + ": " + value.size() + " entries\r\n{\r\n"); - for (Map.Entry entry : value.entrySet()) { - bldr.append(" " + entry.getValue().toString().replaceAll("\r\n", "\r\n ") + "\r\n"); - } - bldr.append("}"); - return bldr.toString(); - } + @Override + public String toString() + { + String name = getName(); + String append = ""; + if(name != null && !name.equals("")) + { + append = "(\"" + this.getName() + "\")"; + } + StringBuilder bldr = new StringBuilder(); + bldr.append("TAG_Compound" + append + ": " + value.size() + " entries\r\n{\r\n"); + for(Map.Entry entry : value.entrySet()) + { + bldr.append(" " + entry.getValue().toString().replaceAll("\r\n", "\r\n ") + "\r\n"); + } + bldr.append("}"); + return bldr.toString(); + } } diff --git a/src/main/java/com/volmit/iris/util/KMap.java b/src/main/java/com/volmit/iris/util/KMap.java index f6dab9707..87aff4295 100644 --- a/src/main/java/com/volmit/iris/util/KMap.java +++ b/src/main/java/com/volmit/iris/util/KMap.java @@ -16,7 +16,7 @@ public class KMap extends ConcurrentHashMap super(); } - public KMap(KMap gMap) + public KMap(Map gMap) { this(); put(gMap);