Update to Minecraft 1.18.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2022-03-01 02:00:00 +11:00
parent bd40300a4f
commit 9ee989ea81
184 changed files with 1785 additions and 1785 deletions

View File

@@ -11,6 +11,7 @@ import java.util.concurrent.locks.LockSupport;
import java.util.function.BooleanSupplier;
import java.util.function.Predicate;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.SectionPosition;
import net.minecraft.nbt.DynamicOpsNBT;
@@ -292,10 +293,10 @@ public class CraftChunk implements Chunk {
byte[][] sectionSkyLights = new byte[cs.length][];
byte[][] sectionEmitLights = new byte[cs.length][];
boolean[] sectionEmpty = new boolean[cs.length];
DataPaletteBlock<BiomeBase>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null;
DataPaletteBlock<Holder<BiomeBase>>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[cs.length] : null;
IRegistry<BiomeBase> iregistry = worldServer.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY);
Codec<DataPaletteBlock<BiomeBase>> biomeCodec = DataPaletteBlock.codec(iregistry, iregistry.byNameCodec(), DataPaletteBlock.e.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS));
Codec<DataPaletteBlock<Holder<BiomeBase>>> biomeCodec = DataPaletteBlock.codec(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.e.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
for (int i = 0; i < cs.length; i++) {
NBTTagCompound data = new NBTTagCompound();
@@ -333,7 +334,7 @@ public class CraftChunk implements Chunk {
}
World world = getWorld();
return new CraftChunkSnapshot(getX(), getZ(), chunk.getMinBuildHeight(), chunk.getMaxBuildHeight(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome);
return new CraftChunkSnapshot(getX(), getZ(), chunk.getMinBuildHeight(), chunk.getMaxBuildHeight(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, iregistry, biome);
}
@Override
@@ -350,7 +351,8 @@ public class CraftChunk implements Chunk {
byte[][] skyLight = new byte[hSection][];
byte[][] emitLight = new byte[hSection][];
boolean[] empty = new boolean[hSection];
DataPaletteBlock<BiomeBase>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null;
IRegistry<BiomeBase> iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY);
DataPaletteBlock<Holder<BiomeBase>>[] biome = (includeBiome || includeBiomeTempRain) ? new DataPaletteBlock[hSection] : null;
for (int i = 0; i < hSection; i++) {
blockIDs[i] = emptyBlockIDs;
@@ -359,12 +361,11 @@ public class CraftChunk implements Chunk {
empty[i] = true;
if (biome != null) {
IRegistry<BiomeBase> iregistry = world.getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY);
biome[i] = new DataPaletteBlock<>(iregistry, iregistry.getOrThrow(Biomes.PLAINS), DataPaletteBlock.e.SECTION_BIOMES);
biome[i] = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.e.SECTION_BIOMES);
}
}
return new CraftChunkSnapshot(x, z, world.getMinHeight(), world.getMaxHeight(), world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(actual, HeightMap.Type.MOTION_BLOCKING), biome);
return new CraftChunkSnapshot(x, z, world.getMinHeight(), world.getMaxHeight(), world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(actual, HeightMap.Type.MOTION_BLOCKING), iregistry, biome);
}
static void validateChunkCoordinates(int minY, int maxY, int x, int y, int z) {

View File

@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
import com.google.common.base.Predicates;
import java.util.function.Predicate;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.block.state.IBlockData;
@@ -31,9 +32,10 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
private final boolean[] empty;
private final HeightMap hmap; // Height map
private final long captureFulltime;
private final DataPaletteBlock<BiomeBase>[] biome;
private final IRegistry<BiomeBase> biomeRegistry;
private final DataPaletteBlock<Holder<BiomeBase>>[] biome;
CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, DataPaletteBlock<BiomeBase>[] biome) {
CraftChunkSnapshot(int x, int z, int minHeight, int maxHeight, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, IRegistry<BiomeBase> biomeRegistry, DataPaletteBlock<Holder<BiomeBase>>[] biome) {
this.x = x;
this.z = z;
this.minHeight = minHeight;
@@ -45,6 +47,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
this.emitlight = sectionEmitLights;
this.empty = sectionEmpty;
this.hmap = hmap;
this.biomeRegistry = biomeRegistry;
this.biome = biome;
}
@@ -132,8 +135,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
validateChunkCoordinates(x, y, z);
DataPaletteBlock<BiomeBase> biome = this.biome[getSectionIndex(y >> 2)];
return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.registry, biome.get(x >> 2, (y & 0xF) >> 2, z >> 2));
DataPaletteBlock<Holder<BiomeBase>> biome = this.biome[getSectionIndex(y >> 2)];
return CraftBlock.biomeBaseToBiome(biomeRegistry, biome.get(x >> 2, (y & 0xF) >> 2, z >> 2));
}
@Override
@@ -146,8 +149,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
validateChunkCoordinates(x, y, z);
DataPaletteBlock<BiomeBase> biome = this.biome[getSectionIndex(y >> 2)];
return biome.get(x >> 2, (y & 0xF) >> 2, z >> 2).getTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
DataPaletteBlock<Holder<BiomeBase>> biome = this.biome[getSectionIndex(y >> 2)];
return biome.get(x >> 2, (y & 0xF) >> 2, z >> 2).value().getTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
}
@Override

View File

@@ -5,11 +5,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.function.Predicate;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.data.worldgen.features.TreeFeatures;
import net.minecraft.world.entity.EntityAreaEffectCloud;
@@ -49,7 +49,7 @@ import net.minecraft.world.level.block.BlockDiodeAbstract;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured;
import net.minecraft.world.phys.AxisAlignedBB;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -226,11 +226,11 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
@Override
public void setBiome(int x, int y, int z, Biome biome) {
Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot set the biome to %s", biome);
BiomeBase biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), biome);
Holder<BiomeBase> biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), biome);
setBiome(x, y, z, biomeBase);
}
public abstract void setBiome(int x, int y, int z, BiomeBase biomeBase);
public abstract void setBiome(int x, int y, int z, Holder<BiomeBase> biomeBase);
@Override
public BlockState getBlockState(Location location) {
@@ -321,7 +321,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
}
public boolean generateTree(GeneratorAccessSeed access, ChunkGenerator chunkGenerator, BlockPosition pos, Random random, TreeType treeType) {
net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured gen;
Holder<?> gen;
switch (treeType) {
case BIG_TREE:
gen = TreeFeatures.FANCY_OAK;
@@ -386,7 +386,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
break;
}
return gen.feature.place(new FeaturePlaceContext(Optional.empty(), access, chunkGenerator, random, pos, gen.config));
return ((WorldGenFeatureConfigured<?, ?>) gen.value()).place(access, chunkGenerator, random, pos);
}
@Override
@@ -558,7 +558,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
entity = new EntityBoat(world, x, y, z);
entity.moveTo(x, y, z, yaw, pitch);
} else if (FallingBlock.class.isAssignableFrom(clazz)) {
entity = new EntityFallingBlock(world, x, y, z, getHandle().getBlockState(new BlockPosition(x, y, z)));
BlockPosition pos = new BlockPosition(x, y, z);
entity = EntityFallingBlock.fall(world, pos, getHandle().getBlockState(pos));
} else if (Projectile.class.isAssignableFrom(clazz)) {
if (Snowball.class.isAssignableFrom(clazz)) {
entity = new EntitySnowball(world, x, y, z);

View File

@@ -37,7 +37,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
@@ -52,8 +51,8 @@ import net.minecraft.commands.CommandDispatcher;
import net.minecraft.commands.CommandListenerWrapper;
import net.minecraft.commands.arguments.ArgumentEntity;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.RegistryMaterials;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.ServerCommand;
@@ -71,11 +70,8 @@ import net.minecraft.server.players.IpBanEntry;
import net.minecraft.server.players.OpListEntry;
import net.minecraft.server.players.PlayerList;
import net.minecraft.server.players.WhiteListEntry;
import net.minecraft.tags.Tags;
import net.minecraft.tags.TagsBlock;
import net.minecraft.tags.TagsEntity;
import net.minecraft.tags.TagsFluid;
import net.minecraft.tags.TagsItem;
import net.minecraft.tags.TagKey;
import net.minecraft.util.ChatDeserializer;
import net.minecraft.util.datafix.DataConverterRegistry;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.effect.MobEffects;
@@ -461,7 +457,7 @@ public final class CraftServer implements Server {
public void syncCommands() {
// Clear existing commands
CommandDispatcher dispatcher = console.resources.commands = new CommandDispatcher();
CommandDispatcher dispatcher = console.resources.managers().commands = new CommandDispatcher();
// Register all commands, vanilla ones will be using the old dispatcher references
for (Map.Entry<String, Command> entry : commandMap.getKnownCommands().entrySet()) {
@@ -1033,16 +1029,12 @@ public final class CraftServer implements Server {
boolean hardcore = creator.hardcore();
WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(console.registryreadops, console.datapackconfiguration);
WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(console.registryreadops, console.datapackconfiguration, console.registryHolder.allElementsLifecycle());
WorldSettings worldSettings;
// See MinecraftServer.a(String, String, long, WorldType, JsonElement)
if (worlddata == null) {
Properties properties = new Properties();
properties.put("generator-settings", Objects.toString(creator.generatorSettings()));
properties.put("level-seed", Objects.toString(creator.seed()));
properties.put("generate-structures", Objects.toString(creator.generateStructures()));
properties.put("level-type", Objects.toString(creator.type().getName()));
DedicatedServerProperties.a properties = new DedicatedServerProperties.a(Objects.toString(creator.seed()), ChatDeserializer.parse(creator.generatorSettings()), creator.generateStructures(), creator.type().name().toLowerCase(Locale.ROOT));
GeneratorSettings generatorsettings = GeneratorSettings.create(console.registryAccess(), properties);
worldSettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
@@ -1059,28 +1051,28 @@ public final class CraftServer implements Server {
long j = BiomeManager.obfuscateSeed(creator.seed());
List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata));
RegistryMaterials<WorldDimension> registrymaterials = worlddata.worldGenSettings().dimensions();
WorldDimension worlddimension = (WorldDimension) registrymaterials.get(actualDimension);
DimensionManager dimensionmanager;
IRegistry<WorldDimension> iregistry = worlddata.worldGenSettings().dimensions();
WorldDimension worlddimension = (WorldDimension) iregistry.get(actualDimension);
Holder<DimensionManager> holder;
net.minecraft.world.level.chunk.ChunkGenerator chunkgenerator;
if (worlddimension == null) {
dimensionmanager = (DimensionManager) console.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION);
holder = console.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION);
chunkgenerator = GeneratorSettings.makeDefaultOverworld(console.registryHolder, (new Random()).nextLong());
} else {
dimensionmanager = worlddimension.type();
holder = worlddimension.typeHolder();
chunkgenerator = worlddimension.generator();
}
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), dimensionmanager);
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), holder.value());
if (biomeProvider == null && generator != null) {
biomeProvider = generator.getDefaultBiomeProvider(worldInfo);
}
if (biomeProvider != null) {
WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, console.registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY));
if (chunkgenerator instanceof ChunkGeneratorAbstract) {
chunkgenerator = new ChunkGeneratorAbstract(((ChunkGeneratorAbstract) chunkgenerator).noises, worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings);
if (chunkgenerator instanceof ChunkGeneratorAbstract cga) {
chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, cga.ringPlacementSeed, cga.settings);
}
}
@@ -1094,7 +1086,7 @@ public final class CraftServer implements Server {
worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH)));
}
WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, getServer().progressListenerFactory.create(11),
WorldServer internal = (WorldServer) new WorldServer(console, console.executor, worldSession, worlddata, worldKey, holder, getServer().progressListenerFactory.create(11),
chunkgenerator, worlddata.worldGenSettings().isDebug(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
@@ -2161,19 +2153,19 @@ public final class CraftServer implements Server {
case org.bukkit.Tag.REGISTRY_BLOCKS:
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type");
return (org.bukkit.Tag<T>) new CraftBlockTag(TagsBlock.getAllTags(), key);
return (org.bukkit.Tag<T>) new CraftBlockTag(IRegistry.BLOCK, TagKey.create(IRegistry.BLOCK_REGISTRY, key));
case org.bukkit.Tag.REGISTRY_ITEMS:
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type");
return (org.bukkit.Tag<T>) new CraftItemTag(TagsItem.getAllTags(), key);
return (org.bukkit.Tag<T>) new CraftItemTag(IRegistry.ITEM, TagKey.create(IRegistry.ITEM_REGISTRY, key));
case org.bukkit.Tag.REGISTRY_FLUIDS:
Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type");
return (org.bukkit.Tag<T>) new CraftFluidTag(TagsFluid.getAllTags(), key);
return (org.bukkit.Tag<T>) new CraftFluidTag(IRegistry.FLUID, TagKey.create(IRegistry.FLUID_REGISTRY, key));
case org.bukkit.Tag.REGISTRY_ENTITY_TYPES:
Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type");
return (org.bukkit.Tag<T>) new CraftEntityTag(TagsEntity.getAllTags(), key);
return (org.bukkit.Tag<T>) new CraftEntityTag(IRegistry.ENTITY_TYPE, TagKey.create(IRegistry.ENTITY_TYPE_REGISTRY, key));
default:
throw new IllegalArgumentException();
}
@@ -2186,23 +2178,23 @@ public final class CraftServer implements Server {
case org.bukkit.Tag.REGISTRY_BLOCKS:
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type");
Tags<Block> blockTags = TagsBlock.getAllTags();
return blockTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList());
IRegistry<Block> blockTags = IRegistry.BLOCK;
return blockTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftBlockTag(blockTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
case org.bukkit.Tag.REGISTRY_ITEMS:
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type");
Tags<Item> itemTags = TagsItem.getAllTags();
return itemTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList());
IRegistry<Item> itemTags = IRegistry.ITEM;
return itemTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
case org.bukkit.Tag.REGISTRY_FLUIDS:
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Fluid namespace must have fluid type");
Tags<FluidType> fluidTags = TagsFluid.getAllTags();
return fluidTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftFluidTag(fluidTags, key)).collect(ImmutableList.toImmutableList());
IRegistry<FluidType> fluidTags = IRegistry.FLUID;
return fluidTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftFluidTag(fluidTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
case org.bukkit.Tag.REGISTRY_ENTITY_TYPES:
Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type");
Tags<EntityTypes<?>> entityTags = TagsEntity.getAllTags();
return entityTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, key)).collect(ImmutableList.toImmutableList());
IRegistry<EntityTypes<?>> entityTags = IRegistry.ENTITY_TYPE;
return entityTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
default:
throw new IllegalArgumentException();
}

View File

@@ -23,6 +23,8 @@ import java.util.UUID;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
@@ -39,6 +41,7 @@ import net.minecraft.server.level.Ticket;
import net.minecraft.server.level.TicketType;
import net.minecraft.server.level.WorldServer;
import net.minecraft.sounds.SoundCategory;
import net.minecraft.tags.TagKey;
import net.minecraft.util.ArraySetSorted;
import net.minecraft.util.Unit;
import net.minecraft.world.EnumDifficulty;
@@ -58,7 +61,6 @@ import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.IChunkAccess;
import net.minecraft.world.level.chunk.ProtoChunkExtension;
import net.minecraft.world.level.levelgen.feature.StructureGenerator;
import net.minecraft.world.level.storage.SavedFile;
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.MovingObjectPosition;
@@ -97,6 +99,7 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.util.CraftRayTraceResult;
import org.bukkit.craftbukkit.util.CraftSpawnCategory;
import org.bukkit.entity.AbstractArrow;
@@ -749,7 +752,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
@Override
public void setBiome(int x, int y, int z, BiomeBase bb) {
public void setBiome(int x, int y, int z, Holder<BiomeBase> bb) {
BlockPosition pos = new BlockPosition(x, 0, z);
if (this.world.hasChunkAt(pos)) {
net.minecraft.world.level.chunk.Chunk chunk = this.world.getChunkAt(pos);
@@ -770,7 +773,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public double getTemperature(int x, int y, int z) {
BlockPosition pos = new BlockPosition(x, y, z);
return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).getTemperature(pos);
return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).value().getTemperature(pos);
}
@Override
@@ -780,7 +783,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public double getHumidity(int x, int y, int z) {
return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).getDownfall();
return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).value().getDownfall();
}
@Override
@@ -1142,7 +1145,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Validate.notNull(material, "Material cannot be null");
Validate.isTrue(material.isBlock(), "Material must be a block");
EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState());
EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState());
entity.time = 1;
world.addFreshEntity(entity, SpawnReason.CUSTOM);
@@ -1154,7 +1157,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Validate.notNull(location, "Location cannot be null");
Validate.notNull(data, "Material cannot be null");
EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState());
EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState());
entity.time = 1;
world.addFreshEntity(entity, SpawnReason.CUSTOM);
@@ -1774,7 +1777,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) {
BlockPosition originPos = new BlockPosition(origin.getX(), origin.getY(), origin.getZ());
BlockPosition nearest = getHandle().getChunkSource().getGenerator().findNearestMapFeature(getHandle(), StructureGenerator.STRUCTURES_REGISTRY.get(structureType.getName()), originPos, radius, findUnexplored);
BlockPosition nearest = getHandle().findNearestMapFeature(TagKey.create(IRegistry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, CraftNamespacedKey.toMinecraft(structureType.getKey())), originPos, radius, findUnexplored);
return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
}

View File

@@ -181,11 +181,11 @@ public class Main {
useConsole = false;
}
if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -28);
deadline.add(Calendar.DAY_OF_YEAR, -3);
if (buildDate.before(deadline.getTime())) {
System.err.println("*** Error, this build is outdated ***");
System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***");

View File

@@ -7,7 +7,9 @@ import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.EnumHand;
import net.minecraft.world.EnumInteractionResult;
@@ -333,6 +335,10 @@ public class CraftBlock implements Block {
getWorld().setBiome(getX(), getY(), getZ(), bio);
}
public static Biome biomeBaseToBiome(IRegistry<BiomeBase> registry, Holder<BiomeBase> base) {
return biomeBaseToBiome(registry, base.value());
}
public static Biome biomeBaseToBiome(IRegistry<BiomeBase> registry, BiomeBase base) {
if (base == null) {
return null;
@@ -342,17 +348,17 @@ public class CraftBlock implements Block {
return (biome == null) ? Biome.CUSTOM : biome;
}
public static BiomeBase biomeToBiomeBase(IRegistry<BiomeBase> registry, Biome bio) {
public static Holder<BiomeBase> biomeToBiomeBase(IRegistry<BiomeBase> registry, Biome bio) {
if (bio == null || bio == Biome.CUSTOM) {
return null;
}
return registry.get(CraftNamespacedKey.toMinecraft(bio.getKey()));
return registry.getHolderOrThrow(ResourceKey.create(IRegistry.BIOME_REGISTRY, CraftNamespacedKey.toMinecraft(bio.getKey())));
}
@Override
public double getTemperature() {
return world.getBiome(position).getTemperature(position);
return world.getBiome(position).value().getTemperature(position);
}
@Override

View File

@@ -7,6 +7,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Random;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.level.ChunkCoordIntPair;
@@ -167,7 +168,7 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe
}
@Override
public void setBiome(int x, int y, int z, BiomeBase biomeBase) {
public void setBiome(int x, int y, int z, Holder<BiomeBase> biomeBase) {
Preconditions.checkArgument(isInRegion(x, y, z), "Coordinates %s, %s, %s are not in the region", x, y, z);
IChunkAccess chunk = getHandle().getChunk(x >> 4, z >> 4, ChunkStatus.EMPTY);
chunk.setBiome(x >> 2, y >> 2, z >> 2, biomeBase);

View File

@@ -2,10 +2,12 @@ package org.bukkit.craftbukkit.generator;
import com.google.common.base.Preconditions;
import com.mojang.serialization.Codec;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.server.level.RegionLimitedWorldAccess;
@@ -73,18 +75,18 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
@Override
public Biome getBiome(int x, int y, int z) {
return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.biomeRegistry, biome.getNoiseBiome(x >> 2, y >> 2, z >> 2));
return CraftBlock.biomeBaseToBiome(biome.biomeRegistry, biome.getNoiseBiome(x >> 2, y >> 2, z >> 2));
}
@Override
public void setBiome(int x, int y, int z, Biome bio) {
Preconditions.checkArgument(bio != Biome.CUSTOM, "Cannot set the biome to %s", bio);
biome.setBiome(x >> 2, y >> 2, z >> 2, CraftBlock.biomeToBiomeBase((IRegistry<BiomeBase>) biome.biomeRegistry, bio));
biome.setBiome(x >> 2, y >> 2, z >> 2, CraftBlock.biomeToBiomeBase(biome.biomeRegistry, bio));
}
}
public CustomChunkGenerator(WorldServer world, net.minecraft.world.level.chunk.ChunkGenerator delegate, ChunkGenerator generator) {
super(delegate.getBiomeSource(), delegate.getSettings());
super(delegate.structureSets, delegate.structureOverrides, delegate.getBiomeSource());
this.world = world;
this.delegate = delegate;
@@ -279,8 +281,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
@Override
public WeightedRandomList<BiomeSettingsMobs.c> getMobsAt(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
return delegate.getMobsAt(biomebase, structuremanager, enumcreaturetype, blockposition);
public WeightedRandomList<BiomeSettingsMobs.c> getMobsAt(Holder<BiomeBase> holder, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
return delegate.getMobsAt(holder, structuremanager, enumcreaturetype, blockposition);
}
@Override
@@ -288,6 +290,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
super.applyBiomeDecoration(generatoraccessseed, ichunkaccess, structuremanager, generator.shouldGenerateDecorations());
}
@Override
public void addDebugScreenInfo(List<String> list, BlockPosition blockposition) {
delegate.addDebugScreenInfo(list, blockposition);
}
@Override
public void spawnOriginalMobs(RegionLimitedWorldAccess regionlimitedworldaccess) {
if (generator.shouldGenerateMobs()) {

View File

@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
import com.mojang.serialization.Codec;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.Climate;
@@ -19,8 +20,8 @@ public class CustomWorldChunkManager extends WorldChunkManager {
private final BiomeProvider biomeProvider;
private final IRegistry<BiomeBase> registry;
private static List<BiomeBase> biomeListToBiomeBaseList(List<Biome> biomes, IRegistry<BiomeBase> registry) {
List<BiomeBase> biomeBases = new ArrayList<>();
private static List<Holder<BiomeBase>> biomeListToBiomeBaseList(List<Biome> biomes, IRegistry<BiomeBase> registry) {
List<Holder<BiomeBase>> biomeBases = new ArrayList<>();
for (Biome biome : biomes) {
Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot use the biome %s", biome);
@@ -50,7 +51,7 @@ public class CustomWorldChunkManager extends WorldChunkManager {
}
@Override
public BiomeBase getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) {
public Holder<BiomeBase> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) {
Biome biome = biomeProvider.getBiome(worldInfo, x << 2, y << 2, z << 2);
Preconditions.checkArgument(biome != Biome.CUSTOM, "Cannot set the biome to %s", biome);

View File

@@ -1,12 +1,15 @@
package org.bukkit.craftbukkit.generator;
import java.util.Optional;
import net.minecraft.core.HolderSet;
import net.minecraft.core.IRegistry;
import net.minecraft.world.level.biome.WorldChunkManager;
import net.minecraft.world.level.levelgen.StructureSettings;
import net.minecraft.world.level.levelgen.structure.StructureSet;
// Do not implement functions to this class, add to NormalChunkGenerator
public abstract class InternalChunkGenerator extends net.minecraft.world.level.chunk.ChunkGenerator {
public InternalChunkGenerator(WorldChunkManager worldchunkmanager, StructureSettings structuresettings) {
super(worldchunkmanager, structuresettings);
public InternalChunkGenerator(IRegistry<StructureSet> iregistry, Optional<HolderSet<StructureSet>> optional, WorldChunkManager worldchunkmanager) {
super(iregistry, optional, worldchunkmanager);
}
}

View File

@@ -3,25 +3,25 @@ package org.bukkit.craftbukkit.tag;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.tags.Tags;
import net.minecraft.core.IRegistry;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import org.bukkit.Material;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftBlockTag extends CraftTag<Block, Material> {
public CraftBlockTag(Tags<Block> registry, MinecraftKey tag) {
public CraftBlockTag(IRegistry<Block> registry, TagKey<Block> tag) {
super(registry, tag);
}
@Override
public boolean isTagged(Material item) {
return getHandle().contains(CraftMagicNumbers.getBlock(item));
return CraftMagicNumbers.getBlock(item).builtInRegistryHolder().is(tag);
}
@Override
public Set<Material> getValues() {
return Collections.unmodifiableSet(getHandle().getValues().stream().map((block) -> CraftMagicNumbers.getMaterial(block)).collect(Collectors.toSet()));
return Collections.unmodifiableSet(getHandle().stream().map((block) -> CraftMagicNumbers.getMaterial(block.value())).collect(Collectors.toSet()));
}
}

View File

@@ -4,8 +4,8 @@ import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.core.IRegistry;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.tags.Tags;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityTypes;
import org.bukkit.Registry;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
@@ -13,17 +13,17 @@ import org.bukkit.entity.EntityType;
public class CraftEntityTag extends CraftTag<EntityTypes<?>, EntityType> {
public CraftEntityTag(Tags<EntityTypes<?>> registry, MinecraftKey tag) {
public CraftEntityTag(IRegistry<EntityTypes<?>> registry, TagKey<EntityTypes<?>> tag) {
super(registry, tag);
}
@Override
public boolean isTagged(EntityType entity) {
return getHandle().contains(IRegistry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(entity.getKey())));
return registry.getHolderOrThrow(ResourceKey.create(IRegistry.ENTITY_TYPE_REGISTRY, CraftNamespacedKey.toMinecraft(entity.getKey()))).is(tag);
}
@Override
public Set<EntityType> getValues() {
return Collections.unmodifiableSet(getHandle().getValues().stream().map((nms) -> Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(EntityTypes.getKey(nms)))).collect(Collectors.toSet()));
return Collections.unmodifiableSet(getHandle().stream().map((nms) -> Registry.ENTITY_TYPE.get(CraftNamespacedKey.fromMinecraft(EntityTypes.getKey(nms.value())))).collect(Collectors.toSet()));
}
}

View File

@@ -3,25 +3,25 @@ package org.bukkit.craftbukkit.tag;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.tags.Tags;
import net.minecraft.core.IRegistry;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.material.FluidType;
import org.bukkit.Fluid;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftFluidTag extends CraftTag<FluidType, Fluid> {
public CraftFluidTag(Tags<FluidType> registry, MinecraftKey tag) {
public CraftFluidTag(IRegistry<FluidType> registry, TagKey<FluidType> tag) {
super(registry, tag);
}
@Override
public boolean isTagged(Fluid fluid) {
return getHandle().contains(CraftMagicNumbers.getFluid(fluid));
return CraftMagicNumbers.getFluid(fluid).is(tag);
}
@Override
public Set<Fluid> getValues() {
return Collections.unmodifiableSet(getHandle().getValues().stream().map(CraftMagicNumbers::getFluid).collect(Collectors.toSet()));
return Collections.unmodifiableSet(getHandle().stream().map((fluid) -> CraftMagicNumbers.getFluid(fluid.value())).collect(Collectors.toSet()));
}
}

View File

@@ -3,25 +3,25 @@ package org.bukkit.craftbukkit.tag;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.tags.Tags;
import net.minecraft.core.IRegistry;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import org.bukkit.Material;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftItemTag extends CraftTag<Item, Material> {
public CraftItemTag(Tags<Item> registry, MinecraftKey tag) {
public CraftItemTag(IRegistry<Item> registry, TagKey<Item> tag) {
super(registry, tag);
}
@Override
public boolean isTagged(Material item) {
return getHandle().contains(CraftMagicNumbers.getItem(item));
return CraftMagicNumbers.getItem(item).builtInRegistryHolder().is(tag);
}
@Override
public Set<Material> getValues() {
return Collections.unmodifiableSet(getHandle().getValues().stream().map((item) -> CraftMagicNumbers.getMaterial(item)).collect(Collectors.toSet()));
return Collections.unmodifiableSet(getHandle().stream().map((item) -> CraftMagicNumbers.getMaterial(item.value())).collect(Collectors.toSet()));
}
}

View File

@@ -1,7 +1,8 @@
package org.bukkit.craftbukkit.tag;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.tags.Tags;
import net.minecraft.core.HolderSet;
import net.minecraft.core.IRegistry;
import net.minecraft.tags.TagKey;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Tag;
@@ -9,19 +10,19 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
public abstract class CraftTag<N, B extends Keyed> implements Tag<B> {
private final net.minecraft.tags.Tags<N> registry;
private final MinecraftKey tag;
protected final IRegistry<N> registry;
protected final TagKey<N> tag;
//
private net.minecraft.tags.Tag<N> handle;
private HolderSet.Named<N> handle;
public CraftTag(Tags<N> registry, MinecraftKey tag) {
public CraftTag(IRegistry<N> registry, TagKey<N> tag) {
this.registry = registry;
this.tag = tag;
}
protected net.minecraft.tags.Tag<N> getHandle() {
protected HolderSet.Named<N> getHandle() {
if (handle == null) {
handle = registry.getTagOrEmpty(tag);
handle = registry.getTag(tag).get();
}
return handle;
@@ -29,6 +30,6 @@ public abstract class CraftTag<N, B extends Keyed> implements Tag<B> {
@Override
public NamespacedKey getKey() {
return CraftNamespacedKey.fromMinecraft(tag);
return CraftNamespacedKey.fromMinecraft(tag.location());
}
}

View File

@@ -234,7 +234,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
* @return string
*/
public String getMappingsVersion() {
return "20b026e774dbf715e40a0b2afe114792";
return "eaeedbff51b16ead3170906872fda334";
}
@Override

View File

@@ -5,8 +5,8 @@ import java.util.Random;
import java.util.function.Predicate;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistryCustom;
import net.minecraft.core.SectionPosition;
import net.minecraft.core.particles.ParticleParam;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.WorldServer;
@@ -30,8 +30,6 @@ import net.minecraft.world.level.dimension.DimensionManager;
import net.minecraft.world.level.entity.EntityTypeTest;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.level.levelgen.feature.StructureGenerator;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidType;
@@ -53,11 +51,6 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<? extends StructureStart<?>> startsForFeature(SectionPosition sp, StructureGenerator<?> sg) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public WorldServer getLevel() {
throw new UnsupportedOperationException("Not supported yet.");
@@ -169,7 +162,7 @@ public class DummyGeneratorAccess implements GeneratorAccessSeed {
}
@Override
public BiomeBase getUncachedNoiseBiome(int i, int i1, int i2) {
public Holder<BiomeBase> getUncachedNoiseBiome(int i, int i1, int i2) {
throw new UnsupportedOperationException("Not supported yet.");
}

View File

@@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.util;
import com.mojang.util.QueueLogAppender;
import com.mojang.logging.LogQueues;
import java.io.IOException;
import java.io.OutputStream;
import java.util.logging.Level;
@@ -28,7 +28,7 @@ public class TerminalConsoleWriterThread extends Thread {
// Using name from log4j config in vanilla jar
while (true) {
message = QueueLogAppender.getNextLogEvent("TerminalConsole");
message = LogQueues.getNextLogEvent("TerminalConsole");
if (message == null) {
continue;
}