Migrations

This commit is contained in:
Sebastian Hartte
2020-06-27 16:18:20 +02:00
parent d638d083c2
commit ba71a82288
303 changed files with 1216 additions and 1210 deletions
@@ -29,7 +29,7 @@ import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MutableBoundingBox;
@@ -5,7 +5,7 @@ import java.util.Collection;
import javax.annotation.Nullable;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.INBT;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
@@ -45,21 +45,21 @@ public final class MeteoriteSpawnData {
}
@Nullable
private CompoundNBT getSpawnData(int chunkX, int chunkZ, boolean create) {
private CompoundTag getSpawnData(int chunkX, int chunkZ, boolean create) {
chunkX /= 16;
chunkZ /= 16;
String key = chunkX + "," + chunkZ;
INBT inbt = data.spawns.get(key);
if (!(inbt instanceof CompoundNBT)) {
if (!(inbt instanceof CompoundTag)) {
if (create) {
inbt = new CompoundNBT();
inbt = new CompoundTag();
data.spawns.put(key, inbt);
data.markDirty();
} else {
return null;
}
}
return (CompoundNBT) inbt;
return (CompoundTag) inbt;
}
/**
@@ -69,13 +69,13 @@ public final class MeteoriteSpawnData {
public boolean isMeteoriteSpawnInRange(BlockPos pos, int rangeSquared) {
synchronized (data) {
ChunkPos chunkPos = new ChunkPos(pos);
CompoundNBT spawnData = getSpawnData(chunkPos.x, chunkPos.z, false);
CompoundTag spawnData = getSpawnData(chunkPos.x, chunkPos.z, false);
if (spawnData == null) {
return false;
}
final int size = spawnData.getInt("num");
for (int i = 0; i < size; i++) {
CompoundNBT existingSettingsNbt = spawnData.getCompound(String.valueOf(i));
CompoundTag existingSettingsNbt = spawnData.getCompound(String.valueOf(i));
BlockPos existingPos = PlacedMeteoriteSettings.read(existingSettingsNbt).getPos();
int deltaX = (existingPos.getX() - pos.getX());
int deltaZ = (existingPos.getZ() - pos.getZ());
@@ -101,9 +101,9 @@ public final class MeteoriteSpawnData {
public void addSpawnedMeteorite(PlacedMeteoriteSettings settings) {
synchronized (data) {
ChunkPos chunkPos = new ChunkPos(settings.getPos());
CompoundNBT spawnData = getSpawnData(chunkPos.x, chunkPos.z, true);
CompoundTag spawnData = getSpawnData(chunkPos.x, chunkPos.z, true);
final int size = spawnData.getInt("num");
spawnData.put(String.valueOf(size), settings.write(new CompoundNBT()));
spawnData.put(String.valueOf(size), settings.write(new CompoundTag()));
spawnData.putInt("num", size + 1);
data.markDirty();
}
@@ -118,13 +118,13 @@ public final class MeteoriteSpawnData {
final int cx = x + (chunkX >> 4);
final int cz = z + (chunkZ >> 4);
final CompoundNBT data = getSpawnData(cx << 4, cz << 4, false);
final CompoundTag data = getSpawnData(cx << 4, cz << 4, false);
if (data != null) {
// edit.
final int size = data.getInt("num");
for (int s = 0; s < size; s++) {
CompoundNBT settingsNbt = data.getCompound(String.valueOf(s));
CompoundTag settingsNbt = data.getCompound(String.valueOf(s));
ll.add(PlacedMeteoriteSettings.read(settingsNbt));
}
}
@@ -151,22 +151,22 @@ public final class MeteoriteSpawnData {
private static class SavedData extends WorldSavedData {
private LongOpenHashSet generated;
private CompoundNBT spawns;
private CompoundTag spawns;
public SavedData() {
super(NAME);
this.generated = new LongOpenHashSet();
this.spawns = new CompoundNBT();
this.spawns = new CompoundTag();
}
@Override
public synchronized void read(CompoundNBT nbt) {
public synchronized void read(CompoundTag nbt) {
this.generated = new LongOpenHashSet(nbt.getLongArray("generated"));
this.spawns = nbt.getCompound("spawns");
}
@Override
public synchronized CompoundNBT write(CompoundNBT compound) {
public synchronized CompoundTag write(CompoundTag compound) {
compound.putLongArray("generated", generated.toLongArray());
compound.put("spawns", spawns);
return compound;
@@ -19,7 +19,7 @@ package appeng.worldgen.meteorite;
import java.util.Random;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MutableBoundingBox;
@@ -53,7 +53,7 @@ public class MeteoriteStructurePiece extends StructurePiece {
chunkPos.getZStart() - range, chunkPos.getXEnd() + range, center.getY(), chunkPos.getZEnd() + range);
}
public MeteoriteStructurePiece(TemplateManager templateManager, CompoundNBT tag) {
public MeteoriteStructurePiece(TemplateManager templateManager, CompoundTag tag) {
super(TYPE, tag);
BlockPos center = BlockPos.fromLong(tag.getLong(Constants.TAG_POS));
@@ -75,7 +75,7 @@ public class MeteoriteStructurePiece extends StructurePiece {
}
@Override
protected void readAdditional(CompoundNBT tag) {
protected void readAdditional(CompoundTag tag) {
tag.putFloat(Constants.TAG_RADIUS, settings.getMeteoriteRadius());
tag.putLong(Constants.TAG_POS, settings.getPos().toLong());
tag.putByte(Constants.TAG_CRATER, (byte) settings.getCraterType().ordinal());
@@ -18,7 +18,7 @@
package appeng.worldgen.meteorite;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.BlockPos;
import appeng.worldgen.meteorite.fallout.FalloutMode;
@@ -70,7 +70,7 @@ public final class PlacedMeteoriteSettings {
return craterLake;
}
public CompoundNBT write(CompoundNBT tag) {
public CompoundTag write(CompoundTag tag) {
tag.putLong(Constants.TAG_POS, pos.toLong());
tag.putFloat(Constants.TAG_RADIUS, meteoriteRadius);
@@ -81,7 +81,7 @@ public final class PlacedMeteoriteSettings {
return tag;
}
public static PlacedMeteoriteSettings read(CompoundNBT tag) {
public static PlacedMeteoriteSettings read(CompoundTag tag) {
BlockPos pos = BlockPos.fromLong(tag.getLong(Constants.TAG_POS));
float meteoriteRadius = tag.getFloat(Constants.TAG_RADIUS);
CraterType craterType = CraterType.values()[tag.getByte(Constants.TAG_CRATER)];
@@ -20,7 +20,7 @@ package appeng.worldgen.meteorite.debug;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.util.Direction;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldReader;