Make Sponge compile

It doesn't work but it allows the project to compile.
This commit is contained in:
MattBDev 2016-06-02 19:38:35 -04:00
parent cee970e3d9
commit 0147690eba
10 changed files with 104 additions and 80 deletions

View File

@ -10,7 +10,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.ReflectionUtils; import com.intellectualcrafters.plot.util.ReflectionUtils;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
import org.spongepowered.api.data.DataContainer; import org.spongepowered.api.data.DataContainer;
import org.spongepowered.api.world.WorldCreationSettings;
import org.spongepowered.api.world.biome.BiomeGenerationSettings; import org.spongepowered.api.world.biome.BiomeGenerationSettings;
import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeType;
import org.spongepowered.api.world.biome.BiomeTypes; import org.spongepowered.api.world.biome.BiomeTypes;
@ -19,6 +18,7 @@ import org.spongepowered.api.world.gen.BiomeGenerator;
import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.GenerationPopulator;
import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGenerator;
import org.spongepowered.api.world.gen.WorldGeneratorModifier; import org.spongepowered.api.world.gen.WorldGeneratorModifier;
import org.spongepowered.api.world.storage.WorldProperties;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -69,10 +69,10 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
} }
@Override @Override
public void modifyWorldGenerator(WorldCreationSettings settings, DataContainer data, WorldGenerator wg) { public void modifyWorldGenerator(WorldProperties world, DataContainer settings, WorldGenerator worldGenerator) {
String worldName = settings.getWorldName(); String worldName = world.getWorldName();
wg.setBaseGenerationPopulator(new SpongeTerrainGen(this, this.plotGenerator)); worldGenerator.setBaseGenerationPopulator(new SpongeTerrainGen(this, this.plotGenerator));
wg.setBiomeGenerator(new BiomeGenerator() { worldGenerator.setBiomeGenerator(new BiomeGenerator() {
@Override @Override
public void generateBiomes(MutableBiomeArea buffer) { public void generateBiomes(MutableBiomeArea buffer) {
PlotArea area = PS.get().getPlotArea(worldName, null); PlotArea area = PS.get().getPlotArea(worldName, null);
@ -89,13 +89,13 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
} }
}); });
for (BiomeType type : ReflectionUtils.<BiomeType> getStaticFields(BiomeTypes.class)) { for (BiomeType type : ReflectionUtils.<BiomeType> getStaticFields(BiomeTypes.class)) {
BiomeGenerationSettings biomeSettings = wg.getBiomeSettings(type); BiomeGenerationSettings biomeSettings = worldGenerator.getBiomeSettings(type);
biomeSettings.getGenerationPopulators().clear(); biomeSettings.getGenerationPopulators().clear();
biomeSettings.getPopulators().clear(); biomeSettings.getPopulators().clear();
biomeSettings.getGroundCoverLayers().clear(); biomeSettings.getGroundCoverLayers().clear();
} }
wg.getGenerationPopulators().clear(); worldGenerator.getGenerationPopulators().clear();
wg.getPopulators().clear(); worldGenerator.getPopulators().clear();
PS.get().loadWorld(worldName, this); PS.get().loadWorld(worldName, this);
} }

View File

@ -41,7 +41,7 @@ import org.spongepowered.api.event.block.ChangeBlockEvent;
import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; import org.spongepowered.api.event.block.NotifyNeighborBlockEvent;
import org.spongepowered.api.event.command.SendCommandEvent; import org.spongepowered.api.event.command.SendCommandEvent;
import org.spongepowered.api.event.entity.BreedEntityEvent; import org.spongepowered.api.event.entity.BreedEntityEvent;
import org.spongepowered.api.event.entity.DisplaceEntityEvent; import org.spongepowered.api.event.entity.MoveEntityEvent;
import org.spongepowered.api.event.entity.SpawnEntityEvent; import org.spongepowered.api.event.entity.SpawnEntityEvent;
import org.spongepowered.api.event.message.MessageEvent; import org.spongepowered.api.event.message.MessageEvent;
import org.spongepowered.api.event.network.ClientConnectionEvent; import org.spongepowered.api.event.network.ClientConnectionEvent;
@ -643,12 +643,15 @@ public class MainListener {
} }
@Listener @Listener
public void onMove(DisplaceEntityEvent.TargetPlayer event) { public void onMove(MoveEntityEvent event) {
if (!(event.getTargetEntity() instanceof Player)) {
return;
}
org.spongepowered.api.world.Location<World> from = event.getFromTransform().getLocation(); org.spongepowered.api.world.Location<World> from = event.getFromTransform().getLocation();
org.spongepowered.api.world.Location<World> to = event.getToTransform().getLocation(); org.spongepowered.api.world.Location<World> to = event.getToTransform().getLocation();
int x2; int x2;
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) { if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
Player player = event.getTargetEntity(); Player player = (Player) event.getTargetEntity();
PlotPlayer pp = SpongeUtil.getPlayer(player); PlotPlayer pp = SpongeUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); TaskManager.TELEPORT_QUEUE.remove(pp.getName());
@ -697,7 +700,7 @@ public class MainListener {
} }
int z2; int z2;
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) { if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
Player player = event.getTargetEntity(); Player player = (Player) event.getTargetEntity();
PlotPlayer pp = SpongeUtil.getPlayer(player); PlotPlayer pp = SpongeUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); TaskManager.TELEPORT_QUEUE.remove(pp.getName());

View File

@ -185,40 +185,40 @@ public class SpongePlayer extends PlotPlayer {
this.player.playSound(null, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(null, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2256: case 2256:
this.player.playSound(SoundTypes.RECORDS_11, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_11, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2257: case 2257:
this.player.playSound(SoundTypes.RECORDS_13, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_13, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2258: case 2258:
this.player.playSound(SoundTypes.RECORDS_BLOCKS, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_BLOCKS, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2259: case 2259:
this.player.playSound(SoundTypes.RECORDS_CAT, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_CAT, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2260: case 2260:
this.player.playSound(SoundTypes.RECORDS_CHIRP, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_CHIRP, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2261: case 2261:
this.player.playSound(SoundTypes.RECORDS_FAR, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_FAR, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2262: case 2262:
this.player.playSound(SoundTypes.RECORDS_MALL, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_MALL, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2263: case 2263:
this.player.playSound(SoundTypes.RECORDS_MELLOHI, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_MELLOHI, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2264: case 2264:
this.player.playSound(SoundTypes.RECORDS_STAL, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_STAL, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2265: case 2265:
this.player.playSound(SoundTypes.RECORDS_STRAD, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_STRAD, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2266: case 2266:
this.player.playSound(SoundTypes.RECORDS_WAIT, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_WAIT, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
case 2267: case 2267:
this.player.playSound(SoundTypes.RECORDS_WARD, SpongeUtil.getLocation(location).getPosition(), 1); this.player.playSound(SoundTypes.RECORD_WARD, SpongeUtil.getLocation(location).getPosition(), 1);
break; break;
} }
} }

View File

@ -22,33 +22,36 @@ import java.util.UUID;
public class SpongeCommand implements CommandCallable { public class SpongeCommand implements CommandCallable {
@Override @Override
public CommandResult process(CommandSource cmd, String string) throws CommandException { public CommandResult process(CommandSource source, String arguments) throws CommandException {
TaskManager.runTask(() -> { TaskManager.runTask(() -> {
String id = cmd.getIdentifier(); String id = source.getIdentifier();
PlotPlayer pp; PlotPlayer plotPlayer = null;
try { try {
UUID uuid = UUID.fromString(id); UUID uuid = UUID.fromString(id);
Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
pp = SpongeUtil.getPlayer(player); Optional<Player> player = SpongeMain.THIS.getServer().getPlayer(uuid);
if (player.isPresent()) {
plotPlayer = SpongeUtil.getPlayer(player.get());
}
} catch (Exception ignored) { } catch (Exception ignored) {
pp = ConsolePlayer.getConsole(); plotPlayer = ConsolePlayer.getConsole();
} }
MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" ")); MainCommand.onCommand(plotPlayer, arguments.isEmpty() ? new String[]{} : arguments.split(" "));
}); });
return CommandResult.success(); return CommandResult.success();
} }
@Override @Override
public List<String> getSuggestions(CommandSource source, String s) throws CommandException { public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException {
if (!(source instanceof Player)) { if (!(source instanceof Player)) {
return null; return null;
} }
PlotPlayer player = SpongeUtil.getPlayer((Player) source); PlotPlayer player = SpongeUtil.getPlayer((Player) source);
String[] args = s.split(" "); String[] args = arguments.split(" ");
if (args.length == 0) { if (args.length == 0) {
return Collections.singletonList(MainCommand.getInstance().toString()); return Collections.singletonList(MainCommand.getInstance().toString());
} }
Collection objects = MainCommand.getInstance().tab(player, args, s.endsWith(" ")); Collection objects = MainCommand.getInstance().tab(player, args, arguments.endsWith(" "));
if (objects == null) { if (objects == null) {
return null; return null;
} }
@ -60,22 +63,22 @@ public class SpongeCommand implements CommandCallable {
} }
@Override @Override
public boolean testPermission(CommandSource cmd) { public boolean testPermission(CommandSource source) {
return true; return true;
} }
@Override @Override
public Optional<? extends Text> getShortDescription(CommandSource cmd) { public Optional<Text> getShortDescription(CommandSource source) {
return Optional.of(Text.of("Shows plot help")); return Optional.of(Text.of("Shows plot help"));
} }
@Override @Override
public Optional<? extends Text> getHelp(CommandSource cmd) { public Optional<Text> getHelp(CommandSource source) {
return Optional.of(Text.of("/plot")); return Optional.of(Text.of("/plot"));
} }
@Override @Override
public Text getUsage(CommandSource cmd) { public Text getUsage(CommandSource source) {
return Text.of("/plot <command>"); return Text.of("/plot <command>");
} }

View File

@ -402,9 +402,7 @@ public class SpongeMetrics {
// Server software specific section // Server software specific section
final String pluginName = plugin.getName(); final String pluginName = plugin.getName();
final boolean onlineMode = game.getServer().getOnlineMode(); // TRUE if online mode is enabled final boolean onlineMode = game.getServer().getOnlineMode(); // TRUE if online mode is enabled
final String pluginVersion = plugin.getVersion().get(); final String pluginVersion = plugin.getVersion().orElse("unknown");
// TODO no visible way to get MC version at the moment
// TODO added by game.getPlatform().getMinecraftVersion() -- impl in 2.1
final String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion()); final String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion());
final int playersOnline = game.getServer().getOnlinePlayers().size(); final int playersOnline = game.getServer().getOnlinePlayers().size();

View File

@ -64,7 +64,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0)); schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0)); schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
// Arrays of data types // Arrays of data types
List<Tag> tileEntities = new ArrayList<Tag>(); List<Tag> tileEntities = new ArrayList<>();
byte[] blocks = new byte[width * height * length]; byte[] blocks = new byte[width * height * length];
byte[] blockData = new byte[width * height * length]; byte[] blockData = new byte[width * height * length];
// Queue // Queue
@ -78,7 +78,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
public void run() { public void run() {
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks)); schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
schematic.put("Data", new ByteArrayTag("Data", blockData)); schematic.put("Data", new ByteArrayTag("Data", blockData));
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>())); schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<>()));
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities)); schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
whenDone.value = new CompoundTag("Schematic", schematic); whenDone.value = new CompoundTag("Schematic", schematic);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -105,7 +105,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
int sy = pos1.getY(); int sy = pos1.getY();
int ey = pos2.getY(); int ey = pos2.getY();
// Generate list of chunks // Generate list of chunks
ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>(); ArrayList<ChunkLoc> chunks = new ArrayList<>();
for (int x = bcx; x <= tcx; x++) { for (int x = bcx; x <= tcx; x++) {
for (int z = bcz; z <= tcz; z++) { for (int z = bcz; z <= tcz; z++) {
chunks.add(new ChunkLoc(x, z)); chunks.add(new ChunkLoc(x, z));
@ -270,7 +270,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
rawTag = null; rawTag = null;
} }
if (rawTag != null) { if (rawTag != null) {
Map<String, Tag> values = new HashMap<String, Tag>(); Map<String, Tag> values = new HashMap<>();
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) { for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
values.put(entry.getKey(), entry.getValue()); values.put(entry.getKey(), entry.getValue());
} }

View File

@ -13,8 +13,7 @@ import org.spongepowered.api.Sponge;
import org.spongepowered.api.world.DimensionTypes; import org.spongepowered.api.world.DimensionTypes;
import org.spongepowered.api.world.GeneratorTypes; import org.spongepowered.api.world.GeneratorTypes;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import org.spongepowered.api.world.WorldCreationSettings; import org.spongepowered.api.world.WorldArchetype;
import org.spongepowered.api.world.WorldCreationSettings.Builder;
import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGenerator;
import org.spongepowered.api.world.gen.WorldGeneratorModifier; import org.spongepowered.api.world.gen.WorldGeneratorModifier;
import org.spongepowered.api.world.storage.WorldProperties; import org.spongepowered.api.world.storage.WorldProperties;
@ -24,6 +23,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
public class SpongeSetupUtils extends SetupUtils { public class SpongeSetupUtils extends SetupUtils {
@ -140,32 +140,44 @@ public class SpongeSetupUtils extends SetupUtils {
if (object.setupGenerator != null) { if (object.setupGenerator != null) {
// create world with generator // create world with generator
GeneratorWrapper<?> gw = SetupUtils.generators.get(object.setupGenerator); GeneratorWrapper<?> gw = SetupUtils.generators.get(object.setupGenerator);
WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator(); WorldArchetype wgm = (WorldArchetype) gw.getPlatformGenerator();
WorldCreationSettings settings = Sponge.getRegistry().createBuilder(Builder.class) WorldArchetype settings = WorldArchetype.builder()
.name(object.world)
.loadsOnStartup(true) .loadsOnStartup(true)
.keepsSpawnLoaded(true) .keepsSpawnLoaded(true)
.dimension(DimensionTypes.OVERWORLD) .dimension(DimensionTypes.OVERWORLD)
.generator(GeneratorTypes.OVERWORLD) .generator(GeneratorTypes.OVERWORLD)
.usesMapFeatures(false) .usesMapFeatures(false)
.enabled(true) .enabled(true)
.generatorModifiers(wgm) //.generatorModifiers(wgm)
.build(); .build("PS",object.world);
WorldProperties properties = Sponge.getServer().createWorldProperties(settings).get(); WorldProperties properties = null;
World worldObj = Sponge.getServer().loadWorld(properties).get(); try {
properties = Sponge.getServer().createWorldProperties(object.world, settings);
} catch (IOException e) {
e.printStackTrace();
}
World worldObj;
Optional<World> world1 = Sponge.getServer().loadWorld(properties);
if (world1.isPresent()) {
worldObj = world1.get();
}
} else { } else {
// create vanilla world // create vanilla world
WorldCreationSettings settings = Sponge.getRegistry().createBuilder(Builder.class) WorldArchetype settings = WorldArchetype.builder()
.name(object.world)
.loadsOnStartup(true) .loadsOnStartup(true)
.keepsSpawnLoaded(true) .keepsSpawnLoaded(true)
.dimension(DimensionTypes.OVERWORLD) .dimension(DimensionTypes.OVERWORLD)
.generator(GeneratorTypes.OVERWORLD) .generator(GeneratorTypes.OVERWORLD)
.usesMapFeatures(true) .usesMapFeatures(true)
.enabled(true) .enabled(true)
.build(); .build("PS",object.world);
WorldProperties properties = Sponge.getServer().createWorldProperties(settings).get(); WorldProperties properties = null;
try {
properties = Sponge.getServer().createWorldProperties(object.world, settings);
} catch (IOException e) {
e.printStackTrace();
}
World worldObj = Sponge.getServer().loadWorld(properties).get(); World worldObj = Sponge.getServer().loadWorld(properties).get();
} }
return object.world; return object.world;

View File

@ -18,8 +18,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.object.SpongePlayer; import com.plotsquared.sponge.object.SpongePlayer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.Biome;
import org.apache.commons.lang3.NotImplementedException;
import org.spongepowered.api.Sponge; import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType; import org.spongepowered.api.block.BlockType;
@ -42,6 +41,7 @@ import org.spongepowered.api.world.biome.BiomeType;
import org.spongepowered.api.world.biome.BiomeTypes; import org.spongepowered.api.world.biome.BiomeTypes;
import org.spongepowered.api.world.extent.Extent; import org.spongepowered.api.world.extent.Extent;
import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -113,7 +113,7 @@ public class SpongeUtil extends WorldUtil {
} }
public static BiomeType getBiome(int index) { public static BiomeType getBiome(int index) {
return (BiomeType) BiomeGenBase.getBiome(index); return (BiomeType) Biome.getBiome(index);
} }
public static Text getText(String m) { public static Text getText(String m) {
@ -349,9 +349,9 @@ public class SpongeUtil extends WorldUtil {
} }
@Override @Override
public Location getSpawn(PlotPlayer pp) { public Location getSpawn(PlotPlayer plotPlayer) {
throw new NotImplementedException("TODO IMPLEMENT THIS"); // TODO FIXME World world = getWorld(plotPlayer.getLocation().getWorld());
// Probably can call a respawn event and get the location from there return SpongeUtil.getLocation(world.getSpawnLocation());
} }
@Override @Override
@ -371,7 +371,12 @@ public class SpongeUtil extends WorldUtil {
@Override @Override
public void saveWorld(String worldName) { public void saveWorld(String worldName) {
throw new NotImplementedException("TODO WIP"); // TODO FIXME try {
SpongeUtil.getWorld(worldName).save();
} catch (IOException e) {
e.printStackTrace();
PS.debug("Failed to save world.");
}
} }
@Override @Override

View File

@ -8,11 +8,11 @@ import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.SpongeUtil;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ClassInheritanceMultiMap; import net.minecraft.util.ClassInheritanceMultiMap;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.BlockStateContainer;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import org.spongepowered.api.world.Chunk; import org.spongepowered.api.world.Chunk;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
@ -132,11 +132,11 @@ public class FastQueue extends SlowQueue {
ExtendedBlockStorage section = sections[j]; ExtendedBlockStorage section = sections[j];
if ((section == null) || (fs.getCount(j) >= 4096)) { if ((section == null) || (fs.getCount(j) >= 4096)) {
section = new ExtendedBlockStorage(j << 4, flag); section = new ExtendedBlockStorage(j << 4, flag);
section.setData(newArray); //section.setData(newArray); //todo
sections[j] = section; sections[j] = section;
continue; continue;
} }
char[] currentArray = section.getData(); BlockStateContainer currentArray = section.getData();
boolean fill = true; boolean fill = true;
for (int k = 0; k < newArray.length; k++) { for (int k = 0; k < newArray.length; k++) {
char n = newArray[k]; char n = newArray[k];
@ -146,10 +146,10 @@ public class FastQueue extends SlowQueue {
continue; continue;
case 1: case 1:
fill = false; fill = false;
currentArray[k] = 0; //currentArray[k] = 0; //todo
continue; continue;
default: default:
currentArray[k] = n; //currentArray[k] = n; //todo
continue; continue;
} }
} }
@ -226,10 +226,11 @@ public class FastQueue extends SlowQueue {
if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) { if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) {
continue; continue;
} }
char[] array = section.getData(); BlockStateContainer array = section.getData();
int l = PseudoRandom.random.random(2); int l = PseudoRandom.random.random(2);
for (int k = 0; k < array.length; k++) { for (int k = 0; k < array.getSerializedSize(); k++) {
int i = array[k]; int i = 0;
//i = array[k]; //todo
if (i < 16) { if (i < 16) {
continue; continue;
} }
@ -285,7 +286,8 @@ public class FastQueue extends SlowQueue {
} }
public boolean isSolid(int i) { public boolean isSolid(int i) {
return i != 0 && Block.getBlockById(i).isOpaqueCube(); //return i != 0 && Block.getBlockById(i).isOpaqueCube();
throw new UnsupportedOperationException("Unsupported");
} }
public int getId(ExtendedBlockStorage[] sections, int x, int y, int z) { public int getId(ExtendedBlockStorage[] sections, int x, int y, int z) {
@ -300,9 +302,10 @@ public class FastQueue extends SlowQueue {
if (section == null) { if (section == null) {
return 0; return 0;
} }
char[] array = section.getData(); BlockStateContainer array = section.getData();
int j = MainUtil.CACHE_J[y][x][z]; int j = MainUtil.CACHE_J[y][x][z];
return array[j] >> 4; //return array[j] >> 4; //todo: fix for 1.9.4
return 0;
} }
/** /**

View File

@ -13,7 +13,7 @@ import com.plotsquared.sponge.util.SpongeUtil;
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.network.NetHandlerPlayServer; import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.play.server.S21PacketChunkData; import net.minecraft.network.play.server.SPacketChunkData;
import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.world.Chunk; import org.spongepowered.api.world.Chunk;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
@ -81,9 +81,9 @@ public class SendChunk {
continue; continue;
} }
chunks.remove(chunk); chunks.remove(chunk);
NetHandlerPlayServer con = nmsPlayerMP.playerNetServerHandler; NetHandlerPlayServer con = nmsPlayerMP.connection;
net.minecraft.world.chunk.Chunk nmsChunk = (net.minecraft.world.chunk.Chunk) chunk; net.minecraft.world.chunk.Chunk nmsChunk = (net.minecraft.world.chunk.Chunk) chunk;
S21PacketChunkData packet = new S21PacketChunkData(nmsChunk, true, 65535); SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65535);
con.sendPacket(packet); con.sendPacket(packet);
} }
} }