geforkt von Mirrors/Paper
SPIGOT-4691: Fix custom world generator when placing tiles
Dieser Commit ist enthalten in:
Ursprung
0e1cea5a4a
Commit
f40143ef5e
@ -1,5 +1,8 @@
|
|||||||
package org.bukkit.craftbukkit.generator;
|
package org.bukkit.craftbukkit.generator;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import net.minecraft.server.BlockPosition;
|
||||||
import net.minecraft.server.Blocks;
|
import net.minecraft.server.Blocks;
|
||||||
import net.minecraft.server.ChunkSection;
|
import net.minecraft.server.ChunkSection;
|
||||||
import net.minecraft.server.IBlockData;
|
import net.minecraft.server.IBlockData;
|
||||||
@ -17,6 +20,7 @@ import org.bukkit.material.MaterialData;
|
|||||||
public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
||||||
private final int maxHeight;
|
private final int maxHeight;
|
||||||
private final ChunkSection[] sections;
|
private final ChunkSection[] sections;
|
||||||
|
private Set<BlockPosition> tiles;
|
||||||
|
|
||||||
public CraftChunkData(World world) {
|
public CraftChunkData(World world) {
|
||||||
this(world.getMaxHeight());
|
this(world.getMaxHeight());
|
||||||
@ -140,6 +144,14 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
|||||||
}
|
}
|
||||||
ChunkSection section = getChunkSection(y, true);
|
ChunkSection section = getChunkSection(y, true);
|
||||||
section.setType(x, y & 0xf, z, type);
|
section.setType(x, y & 0xf, z, type);
|
||||||
|
|
||||||
|
if (type.getBlock().isTileEntity()) {
|
||||||
|
if (tiles == null) {
|
||||||
|
tiles = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
tiles.add(new BlockPosition(x, y, z));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChunkSection getChunkSection(int y, boolean create) {
|
private ChunkSection getChunkSection(int y, boolean create) {
|
||||||
@ -153,4 +165,8 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
|||||||
ChunkSection[] getRawChunkData() {
|
ChunkSection[] getRawChunkData() {
|
||||||
return sections;
|
return sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<BlockPosition> getTiles() {
|
||||||
|
return tiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettin
|
|||||||
|
|
||||||
ChunkData data = generator.generateChunkData(this.world.getWorld(), random, x, z, biomegrid);
|
ChunkData data = generator.generateChunkData(this.world.getWorld(), random, x, z, biomegrid);
|
||||||
Preconditions.checkArgument(data instanceof CraftChunkData, "Plugins must use createChunkData(World) rather than implementing ChunkData: %s", data);
|
Preconditions.checkArgument(data instanceof CraftChunkData, "Plugins must use createChunkData(World) rather than implementing ChunkData: %s", data);
|
||||||
ChunkSection[] sections = ((CraftChunkData) data).getRawChunkData();
|
CraftChunkData craftData = (CraftChunkData) data;
|
||||||
|
ChunkSection[] sections = craftData.getRawChunkData();
|
||||||
|
|
||||||
ChunkSection[] csect = ichunkaccess.getSections();
|
ChunkSection[] csect = ichunkaccess.getSections();
|
||||||
int scnt = Math.min(csect.length, sections.length);
|
int scnt = Math.min(csect.length, sections.length);
|
||||||
@ -77,6 +78,20 @@ public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettin
|
|||||||
|
|
||||||
// Set biome grid
|
// Set biome grid
|
||||||
ichunkaccess.a(biomegrid.biome);
|
ichunkaccess.a(biomegrid.biome);
|
||||||
|
|
||||||
|
if (craftData.getTiles() != null) {
|
||||||
|
for (BlockPosition pos : craftData.getTiles()) {
|
||||||
|
int tx = pos.getX();
|
||||||
|
int ty = pos.getY();
|
||||||
|
int tz = pos.getZ();
|
||||||
|
Block block = craftData.getTypeId(tx, ty, tz).getBlock();
|
||||||
|
|
||||||
|
if (block.isTileEntity()) {
|
||||||
|
TileEntity tile = ((ITileEntity) block).a(world);
|
||||||
|
ichunkaccess.a(new BlockPosition((x << 4) + tx, ty, (z << 4) + tz), tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren