Minor sponge fix

This commit is contained in:
Jesse Boyd 2016-07-31 09:16:58 +10:00
parent ffddf5c187
commit 409456e895
5 changed files with 34 additions and 25 deletions

View File

@ -114,7 +114,7 @@ public final class Flags {
} }
}; };
public static final BooleanFlag SLEEP = new BooleanFlag("sleep"); public static final BooleanFlag SLEEP = new BooleanFlag("sleep");
public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("teleport-deny"); public static final TeleportDenyFlag TELEPORT_DENY = new TeleportDenyFlag("teleport-deny");
private static final HashMap<String, Flag<?>> flags; private static final HashMap<String, Flag<?>> flags;

View File

@ -332,7 +332,7 @@ public class SpongeMain implements IPlotMain {
if (gen instanceof SpongePlotGenerator) { if (gen instanceof SpongePlotGenerator) {
PS.get().loadWorld(worldName, (SpongePlotGenerator) gen); PS.get().loadWorld(worldName, (SpongePlotGenerator) gen);
} else { } else {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!"); throw new UnsupportedOperationException("NOT IMPLEMENTED YET! " + worldName + " | " + gen);
} }
} }
@ -345,6 +345,8 @@ public class SpongeMain implements IPlotMain {
public PlotPlayer wrapPlayer(Object player) { public PlotPlayer wrapPlayer(Object player) {
if (player instanceof Player) { if (player instanceof Player) {
return SpongeUtil.getPlayer((Player) player); return SpongeUtil.getPlayer((Player) player);
} else if (UUIDHandler.implementation == null) {
return null;
} else if (player instanceof String) { } else if (player instanceof String) {
return UUIDHandler.getPlayer((String) player); return UUIDHandler.getPlayer((String) player);
} else if (player instanceof UUID) { } else if (player instanceof UUID) {

View File

@ -149,7 +149,7 @@ public class SpongeSetupUtils extends SetupUtils {
.generator(GeneratorTypes.OVERWORLD) .generator(GeneratorTypes.OVERWORLD)
.usesMapFeatures(false) .usesMapFeatures(false)
.enabled(true) .enabled(true)
//.generatorModifiers(wgm) .generatorModifiers(wgm)
.build("PS",object.world); .build("PS",object.world);
WorldProperties properties = null; WorldProperties properties = null;
try { try {

View File

@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.object.SpongePlayer; import com.plotsquared.sponge.object.SpongePlayer;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -52,7 +53,7 @@ import org.spongepowered.api.world.extent.Extent;
public class SpongeUtil extends WorldUtil { public class SpongeUtil extends WorldUtil {
public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared")); public static Cause CAUSE = Cause.of(NamedCause.source(Sponge.getPluginManager().fromInstance(SpongeMain.THIS).get()));
private static BiomeType[] biomes; private static BiomeType[] biomes;
private static HashMap<String, Integer> biomeMap; private static HashMap<String, Integer> biomeMap;
private static HashMap<BlockState, PlotBlock> stateMap; private static HashMap<BlockState, PlotBlock> stateMap;

View File

@ -17,6 +17,7 @@ import net.minecraft.entity.EntityTracker;
import net.minecraft.entity.EntityTrackerEntry; import net.minecraft.entity.EntityTrackerEntry;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.network.play.server.SPacketChunkData; import net.minecraft.network.play.server.SPacketChunkData;
import net.minecraft.network.play.server.SPacketDestroyEntities; import net.minecraft.network.play.server.SPacketDestroyEntities;
import net.minecraft.server.management.PlayerChunkMap; import net.minecraft.server.management.PlayerChunkMap;
@ -31,9 +32,6 @@ import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockTypes; import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeType;
import org.spongepowered.api.world.extent.UnmodifiableBlockVolume;
import org.spongepowered.api.world.extent.worker.MutableBlockVolumeWorker;
import org.spongepowered.api.world.extent.worker.procedure.BlockVolumeMapper;
public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> { public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
@ -59,7 +57,6 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
@Override @Override
public PlotBlock getBlock(int x, int y, int z) { public PlotBlock getBlock(int x, int y, int z) {
World worldObj = getSpongeWorld(); World worldObj = getSpongeWorld();
BlockState block = worldObj.getBlock(x, y, z); BlockState block = worldObj.getBlock(x, y, z);
if (block == null) { if (block == null) {
@ -440,24 +437,28 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
public void setBlocks(LocalChunk<char[]> lc) { public void setBlocks(LocalChunk<char[]> lc) {
World worldObj = getSpongeWorld(); World worldObj = getSpongeWorld();
org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ()); org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ());
Chunk nmsChunk = (Chunk) spongeChunk;
char[][] ids = ((CharLocalChunk) lc).blocks; char[][] ids = ((CharLocalChunk) lc).blocks;
MutableBlockVolumeWorker<? extends org.spongepowered.api.world.Chunk> blockWorker = spongeChunk.getBlockWorker(SpongeUtil.CAUSE); for (int layer = 0; layer < 16; layer++) {
blockWorker.map(new BlockVolumeMapper() { char[] array = ids[layer];
@Override
public BlockState map(UnmodifiableBlockVolume volume, int xx, int y, int zz) {
int x = xx & 15;
int z = zz & 15;
int i = MainUtil.CACHE_I[y][x][z];
char[] array = ids[i];
if (array == null) { if (array == null) {
return null; continue;
} }
int combinedId = array[MainUtil.CACHE_J[y][x][z]]; ExtendedBlockStorage section = nmsChunk.getBlockStorageArray()[layer];
short[] cacheX = MainUtil.x_loc[0];
short[] cacheY = MainUtil.y_loc[0];
short[] cacheZ = MainUtil.z_loc[0];
for (int j = 0; j < array.length; j++) {
int combinedId = array[j];
switch (combinedId) { switch (combinedId) {
case 0: case 0:
return null; continue;
case 1: case 1:
return AIR; int x = cacheX[j];
int y = cacheY[j];
int z = cacheZ[j];
section.set(x, y, z, Blocks.AIR.getDefaultState());
continue;
default: default:
int id = combinedId >> 4; int id = combinedId >> 4;
Block block = Block.getBlockById(id); Block block = Block.getBlockById(id);
@ -468,10 +469,15 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
} else { } else {
ibd = block.getDefaultState(); ibd = block.getDefaultState();
} }
return (BlockState) ibd; x = cacheX[j];
y = cacheY[j];
z = cacheZ[j];
section.set(x, y, z, ibd);
continue;
} }
} }
}); }
refreshChunk(nmsChunk.xPosition, nmsChunk.zPosition);
} }
public void setBiomes(LocalChunk<char[]> lc) { public void setBiomes(LocalChunk<char[]> lc) {