Start handling Spout custom IDs (16 bit block IDs)
This commit is contained in:
parent
1bec851087
commit
8c97a6e681
3 changed files with 80 additions and 3 deletions
6
pom.xml
6
pom.xml
|
|
@ -157,5 +157,11 @@
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.getspout</groupId>
|
||||||
|
<artifactId>spoutpluginapi</artifactId>
|
||||||
|
<version>dev-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ import org.bukkit.event.world.SpawnChangeEvent;
|
||||||
import org.bukkit.event.world.WorldListener;
|
import org.bukkit.event.world.WorldListener;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
@ -74,6 +75,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||||
private String version;
|
private String version;
|
||||||
public BukkitEventProcessor bep;
|
public BukkitEventProcessor bep;
|
||||||
public SnapshotCache sscache;
|
public SnapshotCache sscache;
|
||||||
|
private boolean has_spout = false;
|
||||||
|
|
||||||
private MapManager mapManager;
|
private MapManager mapManager;
|
||||||
public static DynmapPlugin plugin;
|
public static DynmapPlugin plugin;
|
||||||
|
|
@ -337,6 +339,12 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||||
if(bep == null)
|
if(bep == null)
|
||||||
bep = new BukkitEventProcessor(this);
|
bep = new BukkitEventProcessor(this);
|
||||||
|
|
||||||
|
/* Check for Spout */
|
||||||
|
if(detectSpout()) {
|
||||||
|
has_spout = true;
|
||||||
|
Log.info("Detected Spout");
|
||||||
|
}
|
||||||
|
|
||||||
/* Set up player login/quit event handler */
|
/* Set up player login/quit event handler */
|
||||||
registerPlayerLoginListener();
|
registerPlayerLoginListener();
|
||||||
|
|
||||||
|
|
@ -870,4 +878,12 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||||
bep.registerEvent(Event.Type.WORLD_UNLOAD, worldTrigger);
|
bep.registerEvent(Event.Type.WORLD_UNLOAD, worldTrigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean detectSpout() {
|
||||||
|
Plugin p = this.getServer().getPluginManager().getPlugin("Spout");
|
||||||
|
return (p != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSpout() {
|
||||||
|
return has_spout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import org.bukkit.Chunk;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.ChunkSnapshot;
|
import org.bukkit.ChunkSnapshot;
|
||||||
|
import org.dynmap.DynmapAPI;
|
||||||
import org.dynmap.DynmapChunk;
|
import org.dynmap.DynmapChunk;
|
||||||
import org.dynmap.DynmapCore;
|
import org.dynmap.DynmapCore;
|
||||||
import org.dynmap.DynmapWorld;
|
import org.dynmap.DynmapWorld;
|
||||||
|
|
@ -22,6 +23,7 @@ import org.dynmap.common.BiomeMap;
|
||||||
import org.dynmap.utils.MapChunkCache;
|
import org.dynmap.utils.MapChunkCache;
|
||||||
import org.dynmap.utils.MapIterator;
|
import org.dynmap.utils.MapIterator;
|
||||||
import org.dynmap.utils.MapIterator.BlockStep;
|
import org.dynmap.utils.MapIterator.BlockStep;
|
||||||
|
import org.getspout.spoutapi.block.SpoutChunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
|
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
|
||||||
|
|
@ -35,6 +37,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||||
private static Field chunkbiome = null;
|
private static Field chunkbiome = null;
|
||||||
private static Field ticklist = null;
|
private static Field ticklist = null;
|
||||||
private static Method processticklist = null;
|
private static Method processticklist = null;
|
||||||
|
private static boolean use_spout = false;
|
||||||
|
|
||||||
private static final int MAX_PROCESSTICKS = 20;
|
private static final int MAX_PROCESSTICKS = 20;
|
||||||
private static final int MAX_TICKLIST = 20000;
|
private static final int MAX_TICKLIST = 20000;
|
||||||
|
|
@ -347,6 +350,42 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SpoutChunkSnapshot implements ChunkSnapshot {
|
||||||
|
private ChunkSnapshot chunk;
|
||||||
|
private short[] customids; /* (X << 11) | (Z << 7) | Y */
|
||||||
|
|
||||||
|
SpoutChunkSnapshot(ChunkSnapshot chunk, short[] customids) {
|
||||||
|
this.chunk = chunk;
|
||||||
|
this.customids = customids.clone();
|
||||||
|
}
|
||||||
|
/* Need these for interface, but not used */
|
||||||
|
public final int getX() { return chunk.getX(); }
|
||||||
|
public final int getZ() { return chunk.getZ(); }
|
||||||
|
public final String getWorldName() { return chunk.getWorldName(); }
|
||||||
|
public final Biome getBiome(int x, int z) { return chunk.getBiome(x, z); }
|
||||||
|
public final double getRawBiomeTemperature(int x, int z) { return chunk.getRawBiomeTemperature(x, z); }
|
||||||
|
public final double getRawBiomeRainfall(int x, int z) { return chunk.getRawBiomeRainfall(x, z); }
|
||||||
|
public final long getCaptureFullTime() { return chunk.getCaptureFullTime(); }
|
||||||
|
|
||||||
|
public final int getBlockTypeId(int x, int y, int z) {
|
||||||
|
int id = customids[(x << 11) | (z << 7) | y];
|
||||||
|
if(id != 0) return id;
|
||||||
|
return chunk.getBlockTypeId(x, y, z);
|
||||||
|
}
|
||||||
|
public final int getBlockData(int x, int y, int z) {
|
||||||
|
return chunk.getBlockData(x, y, z);
|
||||||
|
}
|
||||||
|
public final int getBlockSkyLight(int x, int y, int z) {
|
||||||
|
return chunk.getBlockSkyLight(x, y, z);
|
||||||
|
}
|
||||||
|
public final int getBlockEmittedLight(int x, int y, int z) {
|
||||||
|
return chunk.getBlockEmittedLight(x, y, z);
|
||||||
|
}
|
||||||
|
public final int getHighestBlockYAt(int x, int z) {
|
||||||
|
return chunk.getHighestBlockYAt(x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final EmptyChunk EMPTY = new EmptyChunk();
|
private static final EmptyChunk EMPTY = new EmptyChunk();
|
||||||
private static final PlainChunk STONE = new PlainChunk(1);
|
private static final PlainChunk STONE = new PlainChunk(1);
|
||||||
private static final PlainChunk OCEAN = new PlainChunk(9);
|
private static final PlainChunk OCEAN = new PlainChunk(9);
|
||||||
|
|
@ -405,6 +444,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||||
} catch (NoSuchFieldException nsmx) {
|
} catch (NoSuchFieldException nsmx) {
|
||||||
} catch (NoSuchMethodException nsmx) {
|
} catch (NoSuchMethodException nsmx) {
|
||||||
}
|
}
|
||||||
|
use_spout = DynmapPlugin.plugin.hasSpout();
|
||||||
|
|
||||||
init = true;
|
init = true;
|
||||||
}
|
}
|
||||||
|
|
@ -449,6 +489,17 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||||
snapbiomes = new BiomeMap[x_dim * (z_max-z_min+1)][];
|
snapbiomes = new BiomeMap[x_dim * (z_max-z_min+1)][];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ChunkSnapshot checkSpoutData(Chunk c, ChunkSnapshot ss) {
|
||||||
|
if(c instanceof SpoutChunk) {
|
||||||
|
SpoutChunk sc = (SpoutChunk)c;
|
||||||
|
short[] custids = sc.getCustomBlockIds();
|
||||||
|
if(custids != null) {
|
||||||
|
return new SpoutChunkSnapshot(ss, custids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
|
||||||
public int loadChunks(int max_to_load) {
|
public int loadChunks(int max_to_load) {
|
||||||
long t0 = System.nanoTime();
|
long t0 = System.nanoTime();
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
@ -513,8 +564,12 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Chunk c = w.getChunkAt(chunk.x, chunk.z);
|
Chunk c = w.getChunkAt(chunk.x, chunk.z);
|
||||||
if(blockdata || highesty)
|
if(blockdata || highesty) {
|
||||||
ss = c.getChunkSnapshot(highesty, biome, biomeraw);
|
ss = c.getChunkSnapshot(highesty, biome, biomeraw);
|
||||||
|
if(use_spout) {
|
||||||
|
ss = checkSpoutData(c, ss);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ss = w.getEmptyChunkSnapshot(chunk.x, chunk.z, biome, biomeraw);
|
ss = w.getEmptyChunkSnapshot(chunk.x, chunk.z, biome, biomeraw);
|
||||||
if(ss != null) {
|
if(ss != null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue