Update to Minecraft 1.18-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-11-22 09:00:00 +11:00
parent a852b81a69
commit 43702a9e10
700 changed files with 10286 additions and 10098 deletions

View File

@@ -14,7 +14,7 @@ public class CraftArt {
static {
ImmutableBiMap.Builder<Paintings, Art> artworkBuilder = ImmutableBiMap.builder();
for (MinecraftKey key : IRegistry.MOTIVE.keySet()) {
artworkBuilder.put(IRegistry.MOTIVE.get(key), Art.getByName(key.getKey()));
artworkBuilder.put(IRegistry.MOTIVE.get(key), Art.getByName(key.getPath()));
}
artwork = artworkBuilder.build();

View File

@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicates;
import com.mojang.serialization.Codec;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Collection;
@@ -12,21 +13,22 @@ import java.util.function.Predicate;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.core.SectionPosition;
import net.minecraft.nbt.GameProfileSerializer;
import net.minecraft.nbt.DynamicOpsNBT;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.level.WorldServer;
import net.minecraft.util.thread.ThreadedMailbox;
import net.minecraft.world.level.ChunkCoordIntPair;
import net.minecraft.world.level.EnumSkyBlock;
import net.minecraft.world.level.biome.WorldChunkManager;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.BiomeStorage;
import net.minecraft.world.level.chunk.ChunkSection;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.DataPaletteBlock;
import net.minecraft.world.level.chunk.IChunkAccess;
import net.minecraft.world.level.chunk.NibbleArray;
import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
import net.minecraft.world.level.chunk.storage.EntityStorage;
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import net.minecraft.world.level.levelgen.HeightMap;
@@ -40,7 +42,6 @@ import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.entity.Entity;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.plugin.Plugin;
@@ -50,7 +51,7 @@ public class CraftChunk implements Chunk {
private final WorldServer worldServer;
private final int x;
private final int z;
private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new ChunkSection(0).getBlocks();
private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new DataPaletteBlock<>(net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.e.SECTION_STATES);
private static final byte[] emptyLight = new byte[2048];
public CraftChunk(net.minecraft.world.level.chunk.Chunk chunk) {
@@ -81,7 +82,7 @@ public class CraftChunk implements Chunk {
net.minecraft.world.level.chunk.Chunk c = weakChunk.get();
if (c == null) {
c = worldServer.getChunkAt(x, z);
c = worldServer.getChunk(x, z);
weakChunk = new WeakReference<net.minecraft.world.level.chunk.Chunk>(c);
}
@@ -117,7 +118,7 @@ public class CraftChunk implements Chunk {
@Override
public boolean isEntitiesLoaded() {
return getCraftWorld().getHandle().entityManager.a(ChunkCoordIntPair.pair(x, z)); // PAIL rename isEntitiesLoaded
return getCraftWorld().getHandle().entityManager.areEntitiesLoaded(ChunkCoordIntPair.asLong(x, z));
}
@Override
@@ -127,40 +128,40 @@ public class CraftChunk implements Chunk {
}
PersistentEntitySectionManager<net.minecraft.world.entity.Entity> entityManager = getCraftWorld().getHandle().entityManager;
long pair = ChunkCoordIntPair.pair(x, z);
long pair = ChunkCoordIntPair.asLong(x, z);
if (entityManager.a(pair)) { // PAIL rename isEntitiesLoaded
if (entityManager.areEntitiesLoaded(pair)) {
return entityManager.getEntities(new ChunkCoordIntPair(x, z)).stream()
.map(net.minecraft.world.entity.Entity::getBukkitEntity)
.filter(Objects::nonNull).toArray(Entity[]::new);
}
entityManager.b(pair); // Start entity loading
entityManager.ensureChunkQueuedForLoad(pair); // Start entity loading
// SPIGOT-6772: Use entity mailbox and re-schedule entities if they get unloaded
ThreadedMailbox<Runnable> mailbox = ((EntityStorage) entityManager.permanentStorage).entityDeserializerQueue;
BooleanSupplier supplier = () -> {
// only execute inbox if our entities are not present
if (entityManager.a(pair)) {
if (entityManager.areEntitiesLoaded(pair)) {
return true;
}
if (!entityManager.isPending(pair)) {
// Our entities got unloaded, this should normally not happen.
entityManager.b(pair); // Re-start entity loading
entityManager.ensureChunkQueuedForLoad(pair); // Re-start entity loading
}
// tick loading inbox, which loads the created entities to the world
// (if present)
entityManager.tick();
// check if our entities are loaded
return entityManager.a(pair);
return entityManager.areEntitiesLoaded(pair);
};
// now we wait until the entities are loaded,
// the converting from NBT to entity object is done on the main Thread which is why we wait
while (!supplier.getAsBoolean()) {
if (mailbox.b() != 0) { // PAIL rename size
if (mailbox.size() != 0) {
mailbox.run();
} else {
Thread.yield();
@@ -218,7 +219,7 @@ public class CraftChunk implements Chunk {
@Override
public boolean isSlimeChunk() {
// 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk
return SeededRandom.a(getX(), getZ(), getWorld().getSeed(), 987234911L).nextInt(10) == 0;
return SeededRandom.seedSlimeChunk(getX(), getZ(), getWorld().getSeed(), 987234911L).nextInt(10) == 0;
}
@Override
@@ -269,7 +270,7 @@ public class CraftChunk implements Chunk {
Predicate<IBlockData> nms = Predicates.equalTo(((CraftBlockData) block).getState());
for (ChunkSection section : getHandle().getSections()) {
if (section != null && section.getBlocks().contains(nms)) {
if (section != null && section.getStates().maybeHas(nms)) {
return true;
}
}
@@ -291,37 +292,36 @@ 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;
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));
for (int i = 0; i < cs.length; i++) {
if (ChunkSection.a(cs[i])) { // Section is empty? // PAIL rename isEmpty
sectionBlockIDs[i] = emptyBlockIDs;
NBTTagCompound data = new NBTTagCompound();
data.put("block_states", ChunkRegionLoader.BLOCK_STATE_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, cs[i].getStates()).get().left().get());
sectionBlockIDs[i] = ChunkRegionLoader.BLOCK_STATE_CODEC.parse(DynamicOpsNBT.INSTANCE, data.getCompound("block_states")).get().left().get();
LightEngine lightengine = chunk.level.getLightEngine();
NibbleArray skyLightArray = lightengine.getLayerListener(EnumSkyBlock.SKY).getDataLayerData(SectionPosition.of(x, i, z));
if (skyLightArray == null) {
sectionSkyLights[i] = emptyLight;
} else {
sectionSkyLights[i] = new byte[2048];
System.arraycopy(skyLightArray.getData(), 0, sectionSkyLights[i], 0, 2048);
}
NibbleArray emitLightArray = lightengine.getLayerListener(EnumSkyBlock.BLOCK).getDataLayerData(SectionPosition.of(x, i, z));
if (emitLightArray == null) {
sectionEmitLights[i] = emptyLight;
sectionEmpty[i] = true;
} else { // Not empty
NBTTagCompound data = new NBTTagCompound();
cs[i].getBlocks().a(data, "Palette", "BlockStates");
} else {
sectionEmitLights[i] = new byte[2048];
System.arraycopy(emitLightArray.getData(), 0, sectionEmitLights[i], 0, 2048);
}
DataPaletteBlock blockids = new DataPaletteBlock<>(ChunkSection.GLOBAL_BLOCKSTATE_PALETTE, net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, GameProfileSerializer::c, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // TODO: snapshot whole ChunkSection
blockids.a(data.getList("Palette", CraftMagicNumbers.NBT.TAG_COMPOUND), data.getLongArray("BlockStates"));
sectionBlockIDs[i] = blockids;
LightEngine lightengine = chunk.level.getChunkProvider().getLightEngine();
NibbleArray skyLightArray = lightengine.a(EnumSkyBlock.SKY).a(SectionPosition.a(x, i, z));
if (skyLightArray == null) {
sectionSkyLights[i] = emptyLight;
} else {
sectionSkyLights[i] = new byte[2048];
System.arraycopy(skyLightArray.asBytes(), 0, sectionSkyLights[i], 0, 2048);
}
NibbleArray emitLightArray = lightengine.a(EnumSkyBlock.BLOCK).a(SectionPosition.a(x, i, z));
if (emitLightArray == null) {
sectionEmitLights[i] = emptyLight;
} else {
sectionEmitLights[i] = new byte[2048];
System.arraycopy(emitLightArray.asBytes(), 0, sectionEmitLights[i], 0, 2048);
}
if (biome != null) {
data.put("biomes", biomeCodec.encodeStart(DynamicOpsNBT.INSTANCE, cs[i].getBiomes()).get().left().get());
biome[i] = biomeCodec.parse(DynamicOpsNBT.INSTANCE, data.getCompound("biomes")).get().left().get();
}
}
@@ -329,13 +329,7 @@ public class CraftChunk implements Chunk {
if (includeMaxBlockY) {
hmap = new HeightMap(chunk, HeightMap.Type.MOTION_BLOCKING);
hmap.a(chunk, HeightMap.Type.MOTION_BLOCKING, chunk.heightmaps.get(HeightMap.Type.MOTION_BLOCKING).a());
}
BiomeStorage biome = null;
if (includeBiome || includeBiomeTempRain) {
biome = chunk.getBiomeIndex();
hmap.setRawData(chunk, HeightMap.Type.MOTION_BLOCKING, chunk.heightmaps.get(HeightMap.Type.MOTION_BLOCKING).getRawData());
}
World world = getWorld();
@@ -348,13 +342,7 @@ public class CraftChunk implements Chunk {
}
public static ChunkSnapshot getEmptyChunkSnapshot(int x, int z, CraftWorld world, boolean includeBiome, boolean includeBiomeTempRain) {
BiomeStorage biome = null;
if (includeBiome || includeBiomeTempRain) {
WorldChunkManager wcm = world.getHandle().getChunkProvider().getChunkGenerator().getWorldChunkManager();
biome = new BiomeStorage(world.getHandle().t().d(IRegistry.BIOME_REGISTRY), world.getHandle(), new ChunkCoordIntPair(x, z), wcm);
}
IChunkAccess actual = world.getHandle().getChunkAt(x, z, ChunkStatus.EMPTY);
IChunkAccess actual = world.getHandle().getChunk(x, z, ChunkStatus.EMPTY);
/* Fill with empty data */
int hSection = actual.getSectionsCount();
@@ -362,12 +350,18 @@ 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;
for (int i = 0; i < hSection; i++) {
blockIDs[i] = emptyBlockIDs;
skyLight[i] = emptyLight;
emitLight[i] = emptyLight;
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);
}
}
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);

View File

@@ -7,7 +7,6 @@ import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.BiomeStorage;
import net.minecraft.world.level.chunk.DataPaletteBlock;
import net.minecraft.world.level.levelgen.HeightMap;
import org.bukkit.ChunkSnapshot;
@@ -32,9 +31,9 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
private final boolean[] empty;
private final HeightMap hmap; // Height map
private final long captureFulltime;
private final BiomeStorage biome;
private final 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, BiomeStorage 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) {
this.x = x;
this.z = z;
this.minHeight = minHeight;
@@ -70,7 +69,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
Predicate<IBlockData> nms = Predicates.equalTo(((CraftBlockData) block).getState());
for (DataPaletteBlock<IBlockData> palette : blockids) {
if (palette.contains(nms)) {
if (palette.maybeHas(nms)) {
return true;
}
}
@@ -82,21 +81,21 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
public Material getBlockType(int x, int y, int z) {
validateChunkCoordinates(x, y, z);
return CraftMagicNumbers.getMaterial(blockids[getSectionIndex(y)].a(x, y & 0xF, z).getBlock());
return CraftMagicNumbers.getMaterial(blockids[getSectionIndex(y)].get(x, y & 0xF, z).getBlock());
}
@Override
public final BlockData getBlockData(int x, int y, int z) {
validateChunkCoordinates(x, y, z);
return CraftBlockData.fromData(blockids[getSectionIndex(y)].a(x, y & 0xF, z));
return CraftBlockData.fromData(blockids[getSectionIndex(y)].get(x, y & 0xF, z));
}
@Override
public final int getData(int x, int y, int z) {
validateChunkCoordinates(x, y, z);
return CraftMagicNumbers.toLegacyData(blockids[getSectionIndex(y)].a(x, y & 0xF, z));
return CraftMagicNumbers.toLegacyData(blockids[getSectionIndex(y)].get(x, y & 0xF, z));
}
@Override
@@ -120,7 +119,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
Preconditions.checkState(hmap != null, "ChunkSnapshot created without height map. Please call getSnapshot with includeMaxblocky=true");
validateChunkCoordinates(x, 0, z);
return hmap.a(x, z);
return hmap.getFirstAvailable(x, z);
}
@Override
@@ -133,7 +132,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
validateChunkCoordinates(x, y, z);
return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.biomeRegistry, biome.getBiome(x >> 2, y >> 2, z >> 2));
DataPaletteBlock<BiomeBase> biome = this.biome[getSectionIndex(y)];
return CraftBlock.biomeBaseToBiome((IRegistry<BiomeBase>) biome.registry, biome.get(x >> 2, y >> 2, z >> 2));
}
@Override
@@ -146,7 +146,8 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
Preconditions.checkState(biome != null, "ChunkSnapshot created without biome. Please call getSnapshot with includeBiome=true");
validateChunkCoordinates(x, y, z);
return biome.getBiome(x >> 2, y >> 2, z >> 2).getAdjustedTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
DataPaletteBlock<BiomeBase> biome = this.biome[getSectionIndex(y)];
return biome.get(x >> 2, y >> 2, z >> 2).getTemperature(new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
}
@Override

View File

@@ -20,7 +20,7 @@ public class CraftCrashReport implements Supplier<String> {
public String get() {
StringWriter value = new StringWriter();
try {
value.append("\n Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(MinecraftServer.getServer().getOnlineMode()));
value.append("\n Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(MinecraftServer.getServer().usesAuthentication()));
value.append("\n Plugins: {");
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
PluginDescriptionFile description = plugin.getDescription();

View File

@@ -60,7 +60,7 @@ public class CraftEffect {
break;
case STEP_SOUND:
Validate.isTrue(((Material) data).isBlock(), "Material is not a block!");
datavalue = Block.getCombinedId(CraftMagicNumbers.getBlock((Material) data).getBlockData());
datavalue = Block.getId(CraftMagicNumbers.getBlock((Material) data).defaultBlockState());
break;
case COMPOSTER_FILL_ATTEMPT:
datavalue = ((Boolean) data) ? 1 : 0;

View File

@@ -53,7 +53,7 @@ public class CraftIpBanList implements org.bukkit.BanList {
@Override
public Set<org.bukkit.BanEntry> getBanEntries() {
ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder();
for (String target : list.getEntries()) {
for (String target : list.getUserList()) {
builder.add(new CraftIpBanEntry(target, (IpBanEntry) list.get(target), list));
}

View File

@@ -42,7 +42,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
@Override
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
LootTableInfo nmsContext = convertContext(context);
List<net.minecraft.world.item.ItemStack> nmsItems = handle.populateLoot(nmsContext);
List<net.minecraft.world.item.ItemStack> nmsItems = handle.getRandomItems(nmsContext);
Collection<ItemStack> bukkit = new ArrayList<>(nmsItems.size());
for (net.minecraft.world.item.ItemStack item : nmsItems) {
@@ -62,7 +62,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
IInventory handle = craftInventory.getInventory();
// TODO: When events are added, call event here w/ custom reason?
getHandle().fillInventory(handle, nmsContext);
getHandle().fill(handle, nmsContext);
}
@Override
@@ -83,7 +83,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle();
setMaybe(builder, LootContextParameters.THIS_ENTITY, nmsLootedEntity);
setMaybe(builder, LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC);
setMaybe(builder, LootContextParameters.ORIGIN, nmsLootedEntity.getPositionVector());
setMaybe(builder, LootContextParameters.ORIGIN, nmsLootedEntity.position());
}
if (context.getKiller() != null) {
@@ -102,46 +102,46 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
// SPIGOT-5603 - Avoid IllegalArgumentException in LootTableInfo#build()
LootContextParameterSet.Builder nmsBuilder = new LootContextParameterSet.Builder();
for (LootContextParameter<?> param : getHandle().getLootContextParameterSet().getRequired()) {
nmsBuilder.addRequired(param);
for (LootContextParameter<?> param : getHandle().getParamSet().getRequired()) {
nmsBuilder.required(param);
}
for (LootContextParameter<?> param : getHandle().getLootContextParameterSet().getOptional()) {
if (!getHandle().getLootContextParameterSet().getRequired().contains(param)) {
nmsBuilder.addOptional(param);
for (LootContextParameter<?> param : getHandle().getParamSet().getAllowed()) {
if (!getHandle().getParamSet().getRequired().contains(param)) {
nmsBuilder.optional(param);
}
}
nmsBuilder.addOptional(LootContextParameters.LOOTING_MOD);
nmsBuilder.optional(LootContextParameters.LOOTING_MOD);
return builder.build(nmsBuilder.build());
return builder.create(nmsBuilder.build());
}
private <T> void setMaybe(LootTableInfo.Builder builder, LootContextParameter<T> param, T value) {
if (getHandle().getLootContextParameterSet().getRequired().contains(param) || getHandle().getLootContextParameterSet().getOptional().contains(param)) {
builder.set(param, value);
if (getHandle().getParamSet().getRequired().contains(param) || getHandle().getParamSet().getAllowed().contains(param)) {
builder.withParameter(param, value);
}
}
public static LootContext convertContext(LootTableInfo info) {
Vec3D position = info.getContextParameter(LootContextParameters.ORIGIN);
Vec3D position = info.getParamOrNull(LootContextParameters.ORIGIN);
if (position == null) {
position = info.getContextParameter(LootContextParameters.THIS_ENTITY).getPositionVector(); // Every vanilla context has origin or this_entity, see LootContextParameterSets
position = info.getParamOrNull(LootContextParameters.THIS_ENTITY).position(); // Every vanilla context has origin or this_entity, see LootContextParameterSets
}
Location location = new Location(info.getWorld().getWorld(), position.getX(), position.getY(), position.getZ());
Location location = new Location(info.getLevel().getWorld(), position.x(), position.y(), position.z());
LootContext.Builder contextBuilder = new LootContext.Builder(location);
if (info.hasContextParameter(LootContextParameters.KILLER_ENTITY)) {
CraftEntity killer = info.getContextParameter(LootContextParameters.KILLER_ENTITY).getBukkitEntity();
if (info.hasParam(LootContextParameters.KILLER_ENTITY)) {
CraftEntity killer = info.getParamOrNull(LootContextParameters.KILLER_ENTITY).getBukkitEntity();
if (killer instanceof CraftHumanEntity) {
contextBuilder.killer((CraftHumanEntity) killer);
}
}
if (info.hasContextParameter(LootContextParameters.THIS_ENTITY)) {
contextBuilder.lootedEntity(info.getContextParameter(LootContextParameters.THIS_ENTITY).getBukkitEntity());
if (info.hasParam(LootContextParameters.THIS_ENTITY)) {
contextBuilder.lootedEntity(info.getParamOrNull(LootContextParameters.THIS_ENTITY).getBukkitEntity());
}
if (info.hasContextParameter(LootContextParameters.LOOTING_MOD)) {
contextBuilder.lootingModifier(info.getContextParameter(LootContextParameters.LOOTING_MOD));
if (info.hasParam(LootContextParameters.LOOTING_MOD)) {
contextBuilder.lootingModifier(info.getParamOrNull(LootContextParameters.LOOTING_MOD));
}
contextBuilder.luck(info.getLuck());

View File

@@ -61,7 +61,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
NBTTagCompound data = getBukkitData();
if (data != null) {
if (data.hasKey("lastKnownName")) {
if (data.contains("lastKnownName")) {
return data.getString("lastKnownName");
}
}
@@ -90,9 +90,9 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
}
if (value) {
server.getHandle().addOp(profile);
server.getHandle().op(profile);
} else {
server.getHandle().removeOp(profile);
server.getHandle().deop(profile);
}
}
@@ -119,15 +119,15 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
@Override
public boolean isWhitelisted() {
return server.getHandle().getWhitelist().isWhitelisted(profile);
return server.getHandle().getWhiteList().isWhiteListed(profile);
}
@Override
public void setWhitelisted(boolean value) {
if (value) {
server.getHandle().getWhitelist().add(new WhiteListEntry(profile));
server.getHandle().getWhiteList().add(new WhiteListEntry(profile));
} else {
server.getHandle().getWhitelist().remove(profile);
server.getHandle().getWhiteList().remove(profile);
}
}
@@ -188,8 +188,8 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
NBTTagCompound result = getData();
if (result != null) {
if (!result.hasKey("bukkit")) {
result.set("bukkit", new NBTTagCompound());
if (!result.contains("bukkit")) {
result.put("bukkit", new NBTTagCompound());
}
result = result.getCompound("bukkit");
}
@@ -209,7 +209,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
NBTTagCompound data = getBukkitData();
if (data != null) {
if (data.hasKey("firstPlayed")) {
if (data.contains("firstPlayed")) {
return data.getLong("firstPlayed");
} else {
File file = getDataFile();
@@ -228,7 +228,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
NBTTagCompound data = getBukkitData();
if (data != null) {
if (data.hasKey("lastPlayed")) {
if (data.contains("lastPlayed")) {
return data.getLong("lastPlayed");
} else {
File file = getDataFile();
@@ -249,7 +249,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
NBTTagCompound data = getData();
if (data == null) return null;
if (data.hasKey("SpawnX") && data.hasKey("SpawnY") && data.hasKey("SpawnZ")) {
if (data.contains("SpawnX") && data.contains("SpawnY") && data.contains("SpawnZ")) {
String spawnWorld = data.getString("SpawnWorld");
if (spawnWorld.equals("")) {
spawnWorld = server.getWorlds().get(0).getName();
@@ -276,7 +276,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
}
private ServerStatisticManager getStatisticManager() {
return server.getHandle().getStatisticManager(getUniqueId(), getName());
return server.getHandle().getPlayerStats(getUniqueId(), getName());
}
@Override

View File

@@ -67,7 +67,6 @@ public enum CraftParticle {
SNOW_SHOVEL("item_snowball"),
SLIME("item_slime"),
HEART("heart"),
BARRIER("barrier"),
ITEM_CRACK("item"),
BLOCK_CRACK("block"),
BLOCK_DUST("block"),
@@ -108,7 +107,6 @@ public enum CraftParticle {
LANDING_OBSIDIAN_TEAR("landing_obsidian_tear"),
REVERSE_PORTAL("reverse_portal"),
WHITE_ASH("white_ash"),
LIGHT("light"),
DUST_COLOR_TRANSITION("dust_color_transition"),
VIBRATION("vibration"),
FALLING_SPORE_BLOSSOM("falling_spore_blossom"),
@@ -125,6 +123,7 @@ public enum CraftParticle {
WAX_OFF("wax_off"),
ELECTRIC_SPARK("electric_spark"),
SCRAPE("scrape"),
BLOCK_MARKER("block_marker"),
// ----- Legacy Separator -----
LEGACY_BLOCK_CRACK("block"),
LEGACY_BLOCK_DUST("block"),
@@ -215,7 +214,7 @@ public enum CraftParticle {
}
public static Particle toBukkit(net.minecraft.core.particles.ParticleParam nms) {
return toBukkit(nms.getParticle());
return toBukkit(nms.getType());
}
public static Particle toBukkit(net.minecraft.core.particles.Particle nms) {

View File

@@ -68,7 +68,7 @@ public class CraftProfileBanList implements org.bukkit.BanList {
ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder();
for (JsonListEntry entry : list.getValues()) {
GameProfile profile = (GameProfile) entry.getKey();
GameProfile profile = (GameProfile) entry.getUser();
builder.add(new CraftProfileBanEntry(profile, (GameProfileBanEntry) entry, list));
}
@@ -104,6 +104,6 @@ public class CraftProfileBanList implements org.bukkit.BanList {
//
}
return ((uuid != null) ? MinecraftServer.getServer().getUserCache().getProfile(uuid) : MinecraftServer.getServer().getUserCache().getProfile(target)).orElse(null);
return ((uuid != null) ? MinecraftServer.getServer().getProfileCache().get(uuid) : MinecraftServer.getServer().getProfileCache().get(target)).orElse(null);
}
}

View File

@@ -48,7 +48,7 @@ public final class CraftRaid implements Raid {
@Override
public Location getLocation() {
BlockPosition pos = handle.getCenter();
World world = handle.getWorld();
World world = handle.getLevel();
return new Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ());
}
@@ -82,7 +82,7 @@ public final class CraftRaid implements Raid {
@Override
public float getTotalHealth() {
return handle.sumMobHealth();
return handle.getHealthOfLivingRaiders();
}
@Override

View File

@@ -5,11 +5,12 @@ 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 net.minecraft.core.BlockPosition;
import net.minecraft.core.EnumDirection;
import net.minecraft.core.IRegistry;
import net.minecraft.data.worldgen.BiomeDecoratorGroups;
import net.minecraft.data.worldgen.features.TreeFeatures;
import net.minecraft.world.entity.EntityAreaEffectCloud;
import net.minecraft.world.entity.EntityExperienceOrb;
import net.minecraft.world.entity.EntityInsentient;
@@ -213,7 +214,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
@Override
public Biome getBiome(int x, int y, int z) {
return CraftBlock.biomeBaseToBiome(getHandle().t().d(IRegistry.BIOME_REGISTRY), getHandle().getBiome(x >> 2, y >> 2, z >> 2));
return CraftBlock.biomeBaseToBiome(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), getHandle().getNoiseBiome(x, y, z));
}
@Override
@@ -224,7 +225,7 @@ 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().t().d(IRegistry.BIOME_REGISTRY), biome);
BiomeBase biomeBase = CraftBlock.biomeToBiomeBase(getHandle().registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY), biome);
setBiome(x, y, z, biomeBase);
}
@@ -261,7 +262,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
}
private IBlockData getData(int x, int y, int z) {
return getHandle().getType(new BlockPosition(x, y, z));
return getHandle().getBlockState(new BlockPosition(x, y, z));
}
@Override
@@ -287,14 +288,14 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
@Override
public boolean generateTree(Location location, Random random, TreeType treeType) {
BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
return generateTree(getHandle(), getHandle().getMinecraftWorld().getChunkProvider().generator, pos, random, treeType);
return generateTree(getHandle(), getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, random, treeType);
}
@Override
public boolean generateTree(Location location, Random random, TreeType treeType, Consumer<BlockState> consumer) {
BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
BlockStateListPopulator populator = new BlockStateListPopulator(getHandle());
boolean result = generateTree(populator, getHandle().getMinecraftWorld().getChunkProvider().generator, pos, random, treeType);
boolean result = generateTree(populator, getHandle().getMinecraftWorld().getChunkSource().getGenerator(), pos, random, treeType);
populator.refreshTiles();
for (BlockState blockState : populator.getList()) {
@@ -311,69 +312,69 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
net.minecraft.world.level.levelgen.feature.WorldGenFeatureConfigured gen;
switch (treeType) {
case BIG_TREE:
gen = BiomeDecoratorGroups.FANCY_OAK;
gen = TreeFeatures.FANCY_OAK;
break;
case BIRCH:
gen = BiomeDecoratorGroups.BIRCH;
gen = TreeFeatures.BIRCH;
break;
case REDWOOD:
gen = BiomeDecoratorGroups.SPRUCE;
gen = TreeFeatures.SPRUCE;
break;
case TALL_REDWOOD:
gen = BiomeDecoratorGroups.PINE;
gen = TreeFeatures.PINE;
break;
case JUNGLE:
gen = BiomeDecoratorGroups.MEGA_JUNGLE_TREE;
gen = TreeFeatures.MEGA_JUNGLE_TREE;
break;
case SMALL_JUNGLE:
gen = BiomeDecoratorGroups.JUNGLE_TREE_NO_VINE;
gen = TreeFeatures.JUNGLE_TREE_NO_VINE;
break;
case COCOA_TREE:
gen = BiomeDecoratorGroups.JUNGLE_TREE;
gen = TreeFeatures.JUNGLE_TREE;
break;
case JUNGLE_BUSH:
gen = BiomeDecoratorGroups.JUNGLE_BUSH;
gen = TreeFeatures.JUNGLE_BUSH;
break;
case RED_MUSHROOM:
gen = BiomeDecoratorGroups.HUGE_RED_MUSHROOM;
gen = TreeFeatures.HUGE_RED_MUSHROOM;
break;
case BROWN_MUSHROOM:
gen = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM;
gen = TreeFeatures.HUGE_BROWN_MUSHROOM;
break;
case SWAMP:
gen = BiomeDecoratorGroups.SWAMP_OAK;
gen = TreeFeatures.SWAMP_OAK;
break;
case ACACIA:
gen = BiomeDecoratorGroups.ACACIA;
gen = TreeFeatures.ACACIA;
break;
case DARK_OAK:
gen = BiomeDecoratorGroups.DARK_OAK;
gen = TreeFeatures.DARK_OAK;
break;
case MEGA_REDWOOD:
gen = BiomeDecoratorGroups.MEGA_PINE;
gen = TreeFeatures.MEGA_PINE;
break;
case TALL_BIRCH:
gen = BiomeDecoratorGroups.SUPER_BIRCH_BEES_0002;
gen = TreeFeatures.SUPER_BIRCH_BEES_0002;
break;
case CHORUS_PLANT:
((BlockChorusFlower) Blocks.CHORUS_FLOWER).a(access, pos, random, 8);
((BlockChorusFlower) Blocks.CHORUS_FLOWER).generatePlant(access, pos, random, 8);
return true;
case CRIMSON_FUNGUS:
gen = BiomeDecoratorGroups.CRIMSON_FUNGI_PLANTED;
gen = TreeFeatures.CRIMSON_FUNGUS_PLANTED;
break;
case WARPED_FUNGUS:
gen = BiomeDecoratorGroups.WARPED_FUNGI_PLANTED;
gen = TreeFeatures.WARPED_FUNGUS_PLANTED;
break;
case AZALEA:
gen = BiomeDecoratorGroups.AZALEA_TREE;
gen = TreeFeatures.AZALEA_TREE;
break;
case TREE:
default:
gen = BiomeDecoratorGroups.OAK;
gen = TreeFeatures.OAK;
break;
}
return gen.feature.generate(new FeaturePlaceContext(access, chunkGenerator, random, pos, gen.config));
return gen.feature.place(new FeaturePlaceContext(Optional.empty(), access, chunkGenerator, random, pos, gen.config));
}
@Override
@@ -503,7 +504,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
Preconditions.checkArgument(entity != null, "Cannot spawn null entity");
if (randomizeData && entity instanceof EntityInsentient) {
((EntityInsentient) entity).prepare(getHandle(), getHandle().getDamageScaler(entity.getChunkCoordinates()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, null);
((EntityInsentient) entity).finalizeSpawn(getHandle(), getHandle().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, null);
}
if (!isNormalWorld()) {
@@ -543,9 +544,9 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
// order is important for some of these
if (Boat.class.isAssignableFrom(clazz)) {
entity = new EntityBoat(world, x, y, z);
entity.setPositionRotation(x, y, z, yaw, pitch);
entity.moveTo(x, y, z, yaw, pitch);
} else if (FallingBlock.class.isAssignableFrom(clazz)) {
entity = new EntityFallingBlock(world, x, y, z, getHandle().getType(new BlockPosition(x, y, z)));
entity = new EntityFallingBlock(world, x, y, z, getHandle().getBlockState(new BlockPosition(x, y, z)));
} else if (Projectile.class.isAssignableFrom(clazz)) {
if (Snowball.class.isAssignableFrom(clazz)) {
entity = new EntitySnowball(world, x, y, z);
@@ -553,22 +554,22 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
entity = new EntityEgg(world, x, y, z);
} else if (AbstractArrow.class.isAssignableFrom(clazz)) {
if (TippedArrow.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ARROW.a(world);
((EntityTippedArrow) entity).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
entity = EntityTypes.ARROW.create(world);
((EntityTippedArrow) entity).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SPECTRAL_ARROW.a(world);
entity = EntityTypes.SPECTRAL_ARROW.create(world);
} else if (Trident.class.isAssignableFrom(clazz)) {
entity = EntityTypes.TRIDENT.a(world);
entity = EntityTypes.TRIDENT.create(world);
} else {
entity = EntityTypes.ARROW.a(world);
entity = EntityTypes.ARROW.create(world);
}
entity.setPositionRotation(x, y, z, 0, 0);
entity.moveTo(x, y, z, 0, 0);
} else if (ThrownExpBottle.class.isAssignableFrom(clazz)) {
entity = EntityTypes.EXPERIENCE_BOTTLE.a(world);
entity.setPositionRotation(x, y, z, 0, 0);
entity = EntityTypes.EXPERIENCE_BOTTLE.create(world);
entity.moveTo(x, y, z, 0, 0);
} else if (EnderPearl.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ENDER_PEARL.a(world);
entity.setPositionRotation(x, y, z, 0, 0);
entity = EntityTypes.ENDER_PEARL.create(world);
entity.moveTo(x, y, z, 0, 0);
} else if (ThrownPotion.class.isAssignableFrom(clazz)) {
if (LingeringPotion.class.isAssignableFrom(clazz)) {
entity = new EntityPotion(world, x, y, z);
@@ -579,23 +580,23 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
}
} else if (Fireball.class.isAssignableFrom(clazz)) {
if (SmallFireball.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SMALL_FIREBALL.a(world);
entity = EntityTypes.SMALL_FIREBALL.create(world);
} else if (WitherSkull.class.isAssignableFrom(clazz)) {
entity = EntityTypes.WITHER_SKULL.a(world);
entity = EntityTypes.WITHER_SKULL.create(world);
} else if (DragonFireball.class.isAssignableFrom(clazz)) {
entity = EntityTypes.DRAGON_FIREBALL.a(world);
entity = EntityTypes.DRAGON_FIREBALL.create(world);
} else {
entity = EntityTypes.FIREBALL.a(world);
entity = EntityTypes.FIREBALL.create(world);
}
entity.setPositionRotation(x, y, z, yaw, pitch);
entity.moveTo(x, y, z, yaw, pitch);
Vector direction = location.getDirection().multiply(10);
((EntityFireball) entity).setDirection(direction.getX(), direction.getY(), direction.getZ());
} else if (ShulkerBullet.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SHULKER_BULLET.a(world);
entity.setPositionRotation(x, y, z, yaw, pitch);
entity = EntityTypes.SHULKER_BULLET.create(world);
entity.moveTo(x, y, z, yaw, pitch);
} else if (LlamaSpit.class.isAssignableFrom(clazz)) {
entity = EntityTypes.LLAMA_SPIT.a(world);
entity.setPositionRotation(x, y, z, yaw, pitch);
entity = EntityTypes.LLAMA_SPIT.create(world);
entity.moveTo(x, y, z, yaw, pitch);
} else if (Firework.class.isAssignableFrom(clazz)) {
entity = new EntityFireworks(world, x, y, z, net.minecraft.world.item.ItemStack.EMPTY);
}
@@ -618,204 +619,204 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
} else if (EnderSignal.class.isAssignableFrom(clazz)) {
entity = new EntityEnderSignal(world, x, y, z);
} else if (EnderCrystal.class.isAssignableFrom(clazz)) {
entity = EntityTypes.END_CRYSTAL.a(world);
entity.setPositionRotation(x, y, z, 0, 0);
entity = EntityTypes.END_CRYSTAL.create(world);
entity.moveTo(x, y, z, 0, 0);
} else if (LivingEntity.class.isAssignableFrom(clazz)) {
if (Chicken.class.isAssignableFrom(clazz)) {
entity = EntityTypes.CHICKEN.a(world);
entity = EntityTypes.CHICKEN.create(world);
} else if (Cow.class.isAssignableFrom(clazz)) {
if (MushroomCow.class.isAssignableFrom(clazz)) {
entity = EntityTypes.MOOSHROOM.a(world);
entity = EntityTypes.MOOSHROOM.create(world);
} else {
entity = EntityTypes.COW.a(world);
entity = EntityTypes.COW.create(world);
}
} else if (Golem.class.isAssignableFrom(clazz)) {
if (Snowman.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SNOW_GOLEM.a(world);
entity = EntityTypes.SNOW_GOLEM.create(world);
} else if (IronGolem.class.isAssignableFrom(clazz)) {
entity = EntityTypes.IRON_GOLEM.a(world);
entity = EntityTypes.IRON_GOLEM.create(world);
} else if (Shulker.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SHULKER.a(world);
entity = EntityTypes.SHULKER.create(world);
}
} else if (Creeper.class.isAssignableFrom(clazz)) {
entity = EntityTypes.CREEPER.a(world);
entity = EntityTypes.CREEPER.create(world);
} else if (Ghast.class.isAssignableFrom(clazz)) {
entity = EntityTypes.GHAST.a(world);
entity = EntityTypes.GHAST.create(world);
} else if (Pig.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PIG.a(world);
entity = EntityTypes.PIG.create(world);
} else if (Player.class.isAssignableFrom(clazz)) {
// need a net server handler for this one
} else if (Sheep.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SHEEP.a(world);
entity = EntityTypes.SHEEP.create(world);
} else if (AbstractHorse.class.isAssignableFrom(clazz)) {
if (ChestedHorse.class.isAssignableFrom(clazz)) {
if (Donkey.class.isAssignableFrom(clazz)) {
entity = EntityTypes.DONKEY.a(world);
entity = EntityTypes.DONKEY.create(world);
} else if (Mule.class.isAssignableFrom(clazz)) {
entity = EntityTypes.MULE.a(world);
entity = EntityTypes.MULE.create(world);
} else if (Llama.class.isAssignableFrom(clazz)) {
if (TraderLlama.class.isAssignableFrom(clazz)) {
entity = EntityTypes.TRADER_LLAMA.a(world);
entity = EntityTypes.TRADER_LLAMA.create(world);
} else {
entity = EntityTypes.LLAMA.a(world);
entity = EntityTypes.LLAMA.create(world);
}
}
} else if (SkeletonHorse.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SKELETON_HORSE.a(world);
entity = EntityTypes.SKELETON_HORSE.create(world);
} else if (ZombieHorse.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ZOMBIE_HORSE.a(world);
entity = EntityTypes.ZOMBIE_HORSE.create(world);
} else {
entity = EntityTypes.HORSE.a(world);
entity = EntityTypes.HORSE.create(world);
}
} else if (AbstractSkeleton.class.isAssignableFrom(clazz)) {
if (Stray.class.isAssignableFrom(clazz)) {
entity = EntityTypes.STRAY.a(world);
entity = EntityTypes.STRAY.create(world);
} else if (WitherSkeleton.class.isAssignableFrom(clazz)) {
entity = EntityTypes.WITHER_SKELETON.a(world);
entity = EntityTypes.WITHER_SKELETON.create(world);
} else if (Skeleton.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SKELETON.a(world);
entity = EntityTypes.SKELETON.create(world);
}
} else if (Slime.class.isAssignableFrom(clazz)) {
if (MagmaCube.class.isAssignableFrom(clazz)) {
entity = EntityTypes.MAGMA_CUBE.a(world);
entity = EntityTypes.MAGMA_CUBE.create(world);
} else {
entity = EntityTypes.SLIME.a(world);
entity = EntityTypes.SLIME.create(world);
}
} else if (Spider.class.isAssignableFrom(clazz)) {
if (CaveSpider.class.isAssignableFrom(clazz)) {
entity = EntityTypes.CAVE_SPIDER.a(world);
entity = EntityTypes.CAVE_SPIDER.create(world);
} else {
entity = EntityTypes.SPIDER.a(world);
entity = EntityTypes.SPIDER.create(world);
}
} else if (Squid.class.isAssignableFrom(clazz)) {
if (GlowSquid.class.isAssignableFrom(clazz)) {
entity = EntityTypes.GLOW_SQUID.a(world);
entity = EntityTypes.GLOW_SQUID.create(world);
} else {
entity = EntityTypes.SQUID.a(world);
entity = EntityTypes.SQUID.create(world);
}
} else if (Tameable.class.isAssignableFrom(clazz)) {
if (Wolf.class.isAssignableFrom(clazz)) {
entity = EntityTypes.WOLF.a(world);
entity = EntityTypes.WOLF.create(world);
} else if (Parrot.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PARROT.a(world);
entity = EntityTypes.PARROT.create(world);
} else if (Cat.class.isAssignableFrom(clazz)) {
entity = EntityTypes.CAT.a(world);
entity = EntityTypes.CAT.create(world);
}
} else if (PigZombie.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ZOMBIFIED_PIGLIN.a(world);
entity = EntityTypes.ZOMBIFIED_PIGLIN.create(world);
} else if (Zombie.class.isAssignableFrom(clazz)) {
if (Husk.class.isAssignableFrom(clazz)) {
entity = EntityTypes.HUSK.a(world);
entity = EntityTypes.HUSK.create(world);
} else if (ZombieVillager.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ZOMBIE_VILLAGER.a(world);
entity = EntityTypes.ZOMBIE_VILLAGER.create(world);
} else if (Drowned.class.isAssignableFrom(clazz)) {
entity = EntityTypes.DROWNED.a(world);
entity = EntityTypes.DROWNED.create(world);
} else {
entity = new EntityZombie(world);
}
} else if (Giant.class.isAssignableFrom(clazz)) {
entity = EntityTypes.GIANT.a(world);
entity = EntityTypes.GIANT.create(world);
} else if (Silverfish.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SILVERFISH.a(world);
entity = EntityTypes.SILVERFISH.create(world);
} else if (Enderman.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ENDERMAN.a(world);
entity = EntityTypes.ENDERMAN.create(world);
} else if (Blaze.class.isAssignableFrom(clazz)) {
entity = EntityTypes.BLAZE.a(world);
entity = EntityTypes.BLAZE.create(world);
} else if (AbstractVillager.class.isAssignableFrom(clazz)) {
if (Villager.class.isAssignableFrom(clazz)) {
entity = EntityTypes.VILLAGER.a(world);
entity = EntityTypes.VILLAGER.create(world);
} else if (WanderingTrader.class.isAssignableFrom(clazz)) {
entity = EntityTypes.WANDERING_TRADER.a(world);
entity = EntityTypes.WANDERING_TRADER.create(world);
}
} else if (Witch.class.isAssignableFrom(clazz)) {
entity = EntityTypes.WITCH.a(world);
entity = EntityTypes.WITCH.create(world);
} else if (Wither.class.isAssignableFrom(clazz)) {
entity = EntityTypes.WITHER.a(world);
entity = EntityTypes.WITHER.create(world);
} else if (ComplexLivingEntity.class.isAssignableFrom(clazz)) {
if (EnderDragon.class.isAssignableFrom(clazz)) {
if (isNormalWorld()) {
entity = EntityTypes.ENDER_DRAGON.a(getHandle().getMinecraftWorld());
entity = EntityTypes.ENDER_DRAGON.create(getHandle().getMinecraftWorld());
} else {
throw new IllegalArgumentException("Cannot spawn entity " + clazz.getName() + " during world generation");
}
}
} else if (Ambient.class.isAssignableFrom(clazz)) {
if (Bat.class.isAssignableFrom(clazz)) {
entity = EntityTypes.BAT.a(world);
entity = EntityTypes.BAT.create(world);
}
} else if (Rabbit.class.isAssignableFrom(clazz)) {
entity = EntityTypes.RABBIT.a(world);
entity = EntityTypes.RABBIT.create(world);
} else if (Endermite.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ENDERMITE.a(world);
entity = EntityTypes.ENDERMITE.create(world);
} else if (Guardian.class.isAssignableFrom(clazz)) {
if (ElderGuardian.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ELDER_GUARDIAN.a(world);
entity = EntityTypes.ELDER_GUARDIAN.create(world);
} else {
entity = EntityTypes.GUARDIAN.a(world);
entity = EntityTypes.GUARDIAN.create(world);
}
} else if (ArmorStand.class.isAssignableFrom(clazz)) {
entity = new EntityArmorStand(world, x, y, z);
} else if (PolarBear.class.isAssignableFrom(clazz)) {
entity = EntityTypes.POLAR_BEAR.a(world);
entity = EntityTypes.POLAR_BEAR.create(world);
} else if (Vex.class.isAssignableFrom(clazz)) {
entity = EntityTypes.VEX.a(world);
entity = EntityTypes.VEX.create(world);
} else if (Illager.class.isAssignableFrom(clazz)) {
if (Spellcaster.class.isAssignableFrom(clazz)) {
if (Evoker.class.isAssignableFrom(clazz)) {
entity = EntityTypes.EVOKER.a(world);
entity = EntityTypes.EVOKER.create(world);
} else if (Illusioner.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ILLUSIONER.a(world);
entity = EntityTypes.ILLUSIONER.create(world);
}
} else if (Vindicator.class.isAssignableFrom(clazz)) {
entity = EntityTypes.VINDICATOR.a(world);
entity = EntityTypes.VINDICATOR.create(world);
} else if (Pillager.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PILLAGER.a(world);
entity = EntityTypes.PILLAGER.create(world);
}
} else if (Turtle.class.isAssignableFrom(clazz)) {
entity = EntityTypes.TURTLE.a(world);
entity = EntityTypes.TURTLE.create(world);
} else if (Phantom.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PHANTOM.a(world);
entity = EntityTypes.PHANTOM.create(world);
} else if (Fish.class.isAssignableFrom(clazz)) {
if (Cod.class.isAssignableFrom(clazz)) {
entity = EntityTypes.COD.a(world);
entity = EntityTypes.COD.create(world);
} else if (PufferFish.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PUFFERFISH.a(world);
entity = EntityTypes.PUFFERFISH.create(world);
} else if (Salmon.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SALMON.a(world);
entity = EntityTypes.SALMON.create(world);
} else if (TropicalFish.class.isAssignableFrom(clazz)) {
entity = EntityTypes.TROPICAL_FISH.a(world);
entity = EntityTypes.TROPICAL_FISH.create(world);
}
} else if (Dolphin.class.isAssignableFrom(clazz)) {
entity = EntityTypes.DOLPHIN.a(world);
entity = EntityTypes.DOLPHIN.create(world);
} else if (Ocelot.class.isAssignableFrom(clazz)) {
entity = EntityTypes.OCELOT.a(world);
entity = EntityTypes.OCELOT.create(world);
} else if (Ravager.class.isAssignableFrom(clazz)) {
entity = EntityTypes.RAVAGER.a(world);
entity = EntityTypes.RAVAGER.create(world);
} else if (Panda.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PANDA.a(world);
entity = EntityTypes.PANDA.create(world);
} else if (Fox.class.isAssignableFrom(clazz)) {
entity = EntityTypes.FOX.a(world);
entity = EntityTypes.FOX.create(world);
} else if (Bee.class.isAssignableFrom(clazz)) {
entity = EntityTypes.BEE.a(world);
entity = EntityTypes.BEE.create(world);
} else if (Hoglin.class.isAssignableFrom(clazz)) {
entity = EntityTypes.HOGLIN.a(world);
entity = EntityTypes.HOGLIN.create(world);
} else if (Piglin.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PIGLIN.a(world);
entity = EntityTypes.PIGLIN.create(world);
} else if (PiglinBrute.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PIGLIN_BRUTE.a(world);
entity = EntityTypes.PIGLIN_BRUTE.create(world);
} else if (Strider.class.isAssignableFrom(clazz)) {
entity = EntityTypes.STRIDER.a(world);
entity = EntityTypes.STRIDER.create(world);
} else if (Zoglin.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ZOGLIN.a(world);
entity = EntityTypes.ZOGLIN.create(world);
} else if (Axolotl.class.isAssignableFrom(clazz)) {
entity = EntityTypes.AXOLOTL.a(world);
entity = EntityTypes.AXOLOTL.create(world);
} else if (Goat.class.isAssignableFrom(clazz)) {
entity = EntityTypes.GOAT.a(world);
entity = EntityTypes.GOAT.create(world);
}
if (entity != null) {
entity.setLocation(x, y, z, yaw, pitch);
entity.setHeadRotation(yaw); // SPIGOT-3587
entity.absMoveTo(x, y, z, yaw, pitch);
entity.setYHeadRot(yaw); // SPIGOT-3587
}
} else if (Hanging.class.isAssignableFrom(clazz)) {
if (LeashHitch.class.isAssignableFrom(clazz)) {
@@ -836,12 +837,12 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
final BlockPosition pos = new BlockPosition(x, y, z);
for (BlockFace dir : faces) {
IBlockData nmsBlock = getHandle().getType(pos.shift(CraftBlock.blockFaceToNotch(dir)));
if (nmsBlock.getMaterial().isBuildable() || BlockDiodeAbstract.isDiode(nmsBlock)) {
IBlockData nmsBlock = getHandle().getBlockState(pos.relative(CraftBlock.blockFaceToNotch(dir)));
if (nmsBlock.getMaterial().isSolid() || BlockDiodeAbstract.isDiode(nmsBlock)) {
boolean taken = false;
AxisAlignedBB bb = (ItemFrame.class.isAssignableFrom(clazz))
? EntityItemFrame.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).opposite(), width, height)
: EntityHanging.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).opposite(), width, height);
? EntityItemFrame.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height)
: EntityHanging.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height);
List<net.minecraft.world.entity.Entity> list = (List<net.minecraft.world.entity.Entity>) getHandle().getEntities(null, bb);
for (Iterator<net.minecraft.world.entity.Entity> it = list.iterator(); !taken && it.hasNext(); ) {
net.minecraft.world.entity.Entity e = it.next();
@@ -864,13 +865,13 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
randomizeData = false; // Don't randomize if no valid face is found, prevents null painting
}
EnumDirection dir = CraftBlock.blockFaceToNotch(face).opposite();
EnumDirection dir = CraftBlock.blockFaceToNotch(face).getOpposite();
if (Painting.class.isAssignableFrom(clazz)) {
if (isNormalWorld() && randomizeData) {
entity = new EntityPainting(getHandle().getMinecraftWorld(), new BlockPosition(x, y, z), dir);
} else {
entity = new EntityPainting(EntityTypes.PAINTING, getHandle().getMinecraftWorld());
entity.setLocation(x, y, z, yaw, pitch);
entity.absMoveTo(x, y, z, yaw, pitch);
((EntityPainting) entity).setDirection(dir);
}
} else if (ItemFrame.class.isAssignableFrom(clazz)) {
@@ -886,15 +887,15 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
} else if (ExperienceOrb.class.isAssignableFrom(clazz)) {
entity = new EntityExperienceOrb(world, x, y, z, 0);
} else if (LightningStrike.class.isAssignableFrom(clazz)) {
entity = EntityTypes.LIGHTNING_BOLT.a(world);
entity.teleportAndSync(location.getX(), location.getY(), location.getZ());
entity = EntityTypes.LIGHTNING_BOLT.create(world);
entity.moveTo(location.getX(), location.getY(), location.getZ());
} else if (AreaEffectCloud.class.isAssignableFrom(clazz)) {
entity = new EntityAreaEffectCloud(world, x, y, z);
} else if (EvokerFangs.class.isAssignableFrom(clazz)) {
entity = new EntityEvokerFangs(world, x, y, z, (float) Math.toRadians(yaw), 0, null);
} else if (Marker.class.isAssignableFrom(clazz)) {
entity = EntityTypes.MARKER.a(world);
entity.setPosition(x, y, z);
entity = EntityTypes.MARKER.create(world);
entity.setPos(x, y, z);
}
if (entity != null) {

View File

@@ -46,6 +46,7 @@ import java.util.UUID;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import jline.console.ConsoleReader;
import net.minecraft.advancements.Advancement;
@@ -71,8 +72,12 @@ import net.minecraft.server.dedicated.DedicatedServerSettings;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.server.level.TicketType;
import net.minecraft.server.level.WorldServer;
import net.minecraft.server.players.GameProfileBanEntry;
import net.minecraft.server.players.IpBanEntry;
import net.minecraft.server.players.JsonListEntry;
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;
@@ -301,7 +306,7 @@ public final class CraftServer implements Server {
}
}));
this.serverVersion = CraftServer.class.getPackage().getImplementationVersion();
this.structureManager = new CraftStructureManager(console.getDefinedStructureManager());
this.structureManager = new CraftStructureManager(console.getStructureManager());
Bukkit.setServer(this);
@@ -453,7 +458,7 @@ public final class CraftServer implements Server {
CommandDispatcher dispatcher = console.vanillaCommandDispatcher;
// Build a list of all Vanilla commands and create wrappers
for (CommandNode<CommandListenerWrapper> cmd : dispatcher.a().getRoot().getChildren()) {
for (CommandNode<CommandListenerWrapper> cmd : dispatcher.getDispatcher().getRoot().getChildren()) {
commandMap.register("minecraft", new VanillaCommandWrapper(dispatcher, cmd));
}
}
@@ -478,15 +483,15 @@ public final class CraftServer implements Server {
node = clone;
}
dispatcher.a().getRoot().addChild(node);
dispatcher.getDispatcher().getRoot().addChild(node);
} else {
new BukkitCommandWrapper(this, entry.getValue()).register(dispatcher.a(), label);
new BukkitCommandWrapper(this, entry.getValue()).register(dispatcher.getDispatcher(), label);
}
}
// Refresh commands
for (EntityPlayer player : getHandle().players) {
dispatcher.a(player);
dispatcher.sendCommands(player);
}
}
@@ -516,7 +521,7 @@ public final class CraftServer implements Server {
@Override
public String getVersion() {
return serverVersion + " (MC: " + console.getVersion() + ")";
return serverVersion + " (MC: " + console.getServerVersion() + ")";
}
@Override
@@ -560,7 +565,7 @@ public final class CraftServer implements Server {
public Player getPlayerExact(String name) {
Validate.notNull(name, "Name cannot be null");
EntityPlayer player = playerList.getPlayer(name);
EntityPlayer player = playerList.getPlayerByName(name);
return (player != null) ? player.getBukkitEntity() : null;
}
@@ -622,9 +627,14 @@ public final class CraftServer implements Server {
return this.getProperties().viewDistance;
}
@Override
public int getSimulationDistance() {
return this.getProperties().simulationDistance;
}
@Override
public String getIp() {
return this.getServer().getServerIp();
return this.getServer().getLocalIp();
}
@Override
@@ -634,7 +644,7 @@ public final class CraftServer implements Server {
@Override
public boolean getGenerateStructures() {
return this.getProperties().a(this.getServer().getCustomRegistry()).shouldGenerateMapFeatures();
return this.getProperties().getWorldGenSettings(this.getServer().registryAccess()).generateFeatures();
}
@Override
@@ -649,7 +659,7 @@ public final class CraftServer implements Server {
@Override
public boolean getAllowNether() {
return this.getServer().getAllowNether();
return this.getServer().isNetherEnabled();
}
public boolean getWarnOnOverload() {
@@ -667,7 +677,7 @@ public final class CraftServer implements Server {
// NOTE: Temporary calls through to server.properies until its replaced
private DedicatedServerProperties getProperties() {
return this.console.getDedicatedServerProperties();
return this.console.getProperties();
}
// End Temporary calls
@@ -788,8 +798,8 @@ public final class CraftServer implements Server {
console.settings = new DedicatedServerSettings(console.options);
DedicatedServerProperties config = console.settings.getProperties();
console.setPVP(config.pvp);
console.setAllowFlight(config.allowFlight);
console.setPvpAllowed(config.pvp);
console.setFlightAllowed(config.allowFlight);
console.setMotd(config.motd);
monsterSpawn = configuration.getInt("spawn-limits.monsters");
animalSpawn = configuration.getInt("spawn-limits.animals");
@@ -805,19 +815,19 @@ public final class CraftServer implements Server {
loadIcon();
try {
playerList.getIPBans().load();
playerList.getIpBans().load();
} catch (IOException ex) {
logger.log(Level.WARNING, "Failed to load banned-ips.json, " + ex.getMessage());
}
try {
playerList.getProfileBans().load();
playerList.getBans().load();
} catch (IOException ex) {
logger.log(Level.WARNING, "Failed to load banned-players.json, " + ex.getMessage());
}
for (WorldServer world : console.getWorlds()) {
for (WorldServer world : console.getAllLevels()) {
world.serverLevelData.setDifficulty(config.difficulty);
world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals);
world.setSpawnSettings(config.spawnMonsters, config.spawnAnimals);
if (this.getTicksPerAnimalSpawns() < 0) {
world.ticksPerAnimalSpawns = 400;
} else {
@@ -953,7 +963,7 @@ public final class CraftServer implements Server {
@Override
public String toString() {
return "CraftServer{" + "serverName=" + serverName + ",serverVersion=" + serverVersion + ",minecraftVersion=" + console.getVersion() + '}';
return "CraftServer{" + "serverName=" + serverName + ",serverVersion=" + serverVersion + ",minecraftVersion=" + console.getServerVersion() + '}';
}
public World createWorld(String name, World.Environment environment) {
@@ -1016,16 +1026,15 @@ public final class CraftServer implements Server {
Convertable.ConversionSession worldSession;
try {
worldSession = Convertable.a(getWorldContainer().toPath()).c(name, actualDimension);
worldSession = Convertable.createDefault(getWorldContainer().toPath()).createAccess(name, actualDimension);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
MinecraftServer.convertWorld(worldSession); // Run conversion now
boolean hardcore = creator.hardcore();
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, console.resources.i(), console.registryHolder);
WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration);
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, console.resources.getResourceManager(), console.registryHolder);
WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag(registryreadops, console.datapackconfiguration);
WorldSettings worldSettings;
// See MinecraftServer.a(String, String, long, WorldType, JsonElement)
@@ -1036,34 +1045,32 @@ public final class CraftServer implements Server {
properties.put("generate-structures", Objects.toString(creator.generateStructures()));
properties.put("level-type", Objects.toString(creator.type().getName()));
GeneratorSettings generatorsettings = GeneratorSettings.a(console.getCustomRegistry(), properties);
worldSettings = new WorldSettings(name, EnumGamemode.getById(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
GeneratorSettings generatorsettings = GeneratorSettings.create(console.registryAccess(), properties);
worldSettings = new WorldSettings(name, EnumGamemode.byId(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
}
worlddata.checkName(name);
worlddata.a(console.getServerModName(), console.getModded().isPresent());
worlddata.setModdedInfo(console.getServerModName(), console.getModdedStatus().shouldReportAsModified());
if (console.options.has("forceUpgrade")) {
net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), console.options.has("eraseCache"), () -> {
net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), console.options.has("eraseCache"), () -> {
return true;
}, worlddata.getGeneratorSettings().d().d().stream().map((entry) -> {
return ResourceKey.a(IRegistry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry.getKey()).a());
}).collect(ImmutableSet.toImmutableSet()));
}, worlddata.worldGenSettings());
}
long j = BiomeManager.a(creator.seed());
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.getGeneratorSettings().d();
WorldDimension worlddimension = (WorldDimension) registrymaterials.a(actualDimension);
RegistryMaterials<WorldDimension> registrymaterials = worlddata.worldGenSettings().dimensions();
WorldDimension worlddimension = (WorldDimension) registrymaterials.get(actualDimension);
DimensionManager dimensionmanager;
net.minecraft.world.level.chunk.ChunkGenerator chunkgenerator;
if (worlddimension == null) {
dimensionmanager = (DimensionManager) console.registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).d(DimensionManager.OVERWORLD_LOCATION);
chunkgenerator = GeneratorSettings.a(console.registryHolder.d(IRegistry.BIOME_REGISTRY), console.registryHolder.d(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY), (new Random()).nextLong());
dimensionmanager = (DimensionManager) console.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION);
chunkgenerator = GeneratorSettings.makeDefaultOverworld(console.registryHolder, (new Random()).nextLong());
} else {
dimensionmanager = worlddimension.b();
chunkgenerator = worlddimension.c();
dimensionmanager = worlddimension.type();
chunkgenerator = worlddimension.generator();
}
WorldInfo worldInfo = new CraftWorldInfo(worlddata, worldSession, creator.environment(), dimensionmanager);
@@ -1072,35 +1079,35 @@ public final class CraftServer implements Server {
}
if (biomeProvider != null) {
WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, console.registryHolder.b(IRegistry.BIOME_REGISTRY));
WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, console.registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY));
if (chunkgenerator instanceof ChunkGeneratorAbstract) {
chunkgenerator = new ChunkGeneratorAbstract(worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings);
chunkgenerator = new ChunkGeneratorAbstract(((ChunkGeneratorAbstract) chunkgenerator).noises, worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings);
}
}
ResourceKey<net.minecraft.world.level.World> worldKey;
String levelName = this.getServer().getDedicatedServerProperties().levelName;
String levelName = this.getServer().getProperties().levelName;
if (name.equals(levelName + "_nether")) {
worldKey = net.minecraft.world.level.World.NETHER;
} else if (name.equals(levelName + "_the_end")) {
worldKey = net.minecraft.world.level.World.END;
} else {
worldKey = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH)));
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),
chunkgenerator, worlddata.getGeneratorSettings().isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator, biomeProvider);
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)))) {
return null;
}
console.initWorld(internal, worlddata, worlddata, worlddata.getGeneratorSettings());
console.initWorld(internal, worlddata, worlddata, worlddata.worldGenSettings());
internal.setSpawnFlags(true, true);
console.levels.put(internal.getDimensionKey(), internal);
internal.setSpawnSettings(true, true);
console.levels.put(internal.dimension(), internal);
getServer().loadSpawn(internal.getChunkProvider().chunkMap.progressListener, internal);
getServer().prepareLevels(internal.getChunkSource().chunkMap.progressListener, internal);
internal.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API
pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
@@ -1120,15 +1127,15 @@ public final class CraftServer implements Server {
WorldServer handle = ((CraftWorld) world).getHandle();
if (!(console.levels.containsKey(handle.getDimensionKey()))) {
if (!(console.levels.containsKey(handle.dimension()))) {
return false;
}
if (handle.getDimensionKey() == net.minecraft.world.level.World.OVERWORLD) {
if (handle.dimension() == net.minecraft.world.level.World.OVERWORLD) {
return false;
}
if (handle.getPlayers().size() > 0) {
if (handle.players().size() > 0) {
return false;
}
@@ -1144,7 +1151,7 @@ public final class CraftServer implements Server {
handle.save(null, true, true);
}
handle.getChunkProvider().close(save);
handle.getChunkSource().close(save);
handle.entityManager.close(save); // SPIGOT-6722: close entityManager
handle.convertable.close();
} catch (Exception ex) {
@@ -1152,7 +1159,7 @@ public final class CraftServer implements Server {
}
worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH));
console.levels.remove(handle.getDimensionKey());
console.levels.remove(handle.dimension());
return true;
}
@@ -1209,7 +1216,7 @@ public final class CraftServer implements Server {
@Override
public void savePlayers() {
checkSaveState();
playerList.savePlayers();
playerList.saveAll();
}
@Override
@@ -1267,7 +1274,7 @@ public final class CraftServer implements Server {
public Recipe getRecipe(NamespacedKey recipeKey) {
Preconditions.checkArgument(recipeKey != null, "recipeKey == null");
return getServer().getCraftingManager().getRecipe(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null);
return getServer().getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null);
}
@Override
@@ -1280,7 +1287,7 @@ public final class CraftServer implements Server {
}
@Override
public boolean canUse(EntityHuman entityhuman) {
public boolean stillValid(EntityHuman entityhuman) {
return false;
}
};
@@ -1310,7 +1317,7 @@ public final class CraftServer implements Server {
if (recipe.isPresent()) {
RecipeCrafting recipeCrafting = recipe.get();
if (craftResult.setRecipeUsed(craftWorld.getHandle(), craftPlayer.getHandle(), recipeCrafting)) {
itemstack = recipeCrafting.a(inventoryCrafting);
itemstack = recipeCrafting.assemble(inventoryCrafting);
}
}
@@ -1320,7 +1327,7 @@ public final class CraftServer implements Server {
// Set the resulting matrix items
for (int i = 0; i < craftingMatrix.length; i++) {
Item remaining = inventoryCrafting.getContents().get(i).getItem().getCraftingRemainingItem();
craftingMatrix[i] = (remaining != null) ? CraftItemStack.asBukkitCopy(remaining.createItemStack()) : null;
craftingMatrix[i] = (remaining != null) ? CraftItemStack.asBukkitCopy(remaining.getDefaultInstance()) : null;
}
return CraftItemStack.asBukkitCopy(result);
@@ -1335,7 +1342,7 @@ public final class CraftServer implements Server {
inventoryCrafting.setItem(i, CraftItemStack.asNMSCopy(craftingMatrix[i]));
}
return getServer().getCraftingManager().craft(Recipes.CRAFTING, inventoryCrafting, world.getHandle());
return getServer().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventoryCrafting, world.getHandle());
}
@Override
@@ -1345,7 +1352,7 @@ public final class CraftServer implements Server {
@Override
public void clearRecipes() {
console.getCraftingManager().clearRecipes();
console.getRecipeManager().clearRecipes();
}
@Override
@@ -1358,7 +1365,7 @@ public final class CraftServer implements Server {
Preconditions.checkArgument(recipeKey != null, "recipeKey == null");
MinecraftKey mcKey = CraftNamespacedKey.toMinecraft(recipeKey);
for (Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> recipes : getServer().getCraftingManager().recipes.values()) {
for (Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> recipes : getServer().getRecipeManager().recipes.values()) {
if (recipes.remove(mcKey) != null) {
return true;
}
@@ -1405,7 +1412,7 @@ public final class CraftServer implements Server {
@Override
public int getSpawnRadius() {
return this.getServer().getSpawnProtection();
return this.getServer().getSpawnProtectionRadius();
}
@Override
@@ -1416,12 +1423,12 @@ public final class CraftServer implements Server {
@Override
public boolean getOnlineMode() {
return console.getOnlineMode();
return console.usesAuthentication();
}
@Override
public boolean getAllowFlight() {
return console.getAllowFlight();
return console.isFlightAllowed();
}
@Override
@@ -1504,7 +1511,7 @@ public final class CraftServer implements Server {
@Override
@Deprecated
public CraftMapView getMap(int id) {
WorldMap worldmap = console.getWorldServer(net.minecraft.world.level.World.OVERWORLD).a("map_" + id);
WorldMap worldmap = console.getLevel(net.minecraft.world.level.World.OVERWORLD).getMapData("map_" + id);
if (worldmap == null) {
return null;
}
@@ -1517,8 +1524,8 @@ public final class CraftServer implements Server {
net.minecraft.world.level.World minecraftWorld = ((CraftWorld) world).getHandle();
// creates a new map at world spawn with the scale of 3, with out tracking position and unlimited tracking
int newId = ItemWorldMap.createNewSavedData(minecraftWorld, minecraftWorld.getWorldData().a(), minecraftWorld.getWorldData().c(), 3, false, false, minecraftWorld.getDimensionKey());
return minecraftWorld.a(ItemWorldMap.a(newId)).mapView;
int newId = ItemWorldMap.createNewSavedData(minecraftWorld, minecraftWorld.getLevelData().getXSpawn(), minecraftWorld.getLevelData().getZSpawn(), 3, false, false, minecraftWorld.dimension());
return minecraftWorld.getMapData(ItemWorldMap.makeKey(newId)).mapView;
}
@Override
@@ -1537,17 +1544,17 @@ public final class CraftServer implements Server {
BlockPosition structurePosition = new BlockPosition(structureLocation.getBlockX(), structureLocation.getBlockY(), structureLocation.getBlockZ());
// Create map with trackPlayer = true, unlimitedTracking = true
net.minecraft.world.item.ItemStack stack = ItemWorldMap.createFilledMapView(worldServer, structurePosition.getX(), structurePosition.getZ(), MapView.Scale.NORMAL.getValue(), true, true);
ItemWorldMap.applySepiaFilter(worldServer, stack);
net.minecraft.world.item.ItemStack stack = ItemWorldMap.create(worldServer, structurePosition.getX(), structurePosition.getZ(), MapView.Scale.NORMAL.getValue(), true, true);
ItemWorldMap.renderBiomePreviewMap(worldServer, stack);
// "+" map ID taken from EntityVillager
ItemWorldMap.getSavedMap(stack, worldServer).decorateMap(stack, structurePosition, "+", MapIcon.Type.a(structureType.getMapIcon().getValue()));
ItemWorldMap.getSavedData(stack, worldServer).addTargetDecoration(stack, structurePosition, "+", MapIcon.Type.byIcon(structureType.getMapIcon().getValue()));
return CraftItemStack.asBukkitCopy(stack);
}
@Override
public void shutdown() {
console.safeShutdown(false);
console.halt(false);
}
@Override
@@ -1584,7 +1591,7 @@ public final class CraftServer implements Server {
OfflinePlayer result = getPlayerExact(name);
if (result == null) {
// This is potentially blocking :(
GameProfile profile = console.getUserCache().getProfile(name).orElse(null);
GameProfile profile = console.getProfileCache().get(name).orElse(null);
if (profile == null) {
// Make an OfflinePlayer using an offline mode UUID since the name has no profile
result = getOfflinePlayer(new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name));
@@ -1626,7 +1633,7 @@ public final class CraftServer implements Server {
@Override
@SuppressWarnings("unchecked")
public Set<String> getIPBans() {
return new HashSet<String>(Arrays.asList(playerList.getIPBans().getEntries()));
return playerList.getIpBans().getEntries().stream().map(IpBanEntry::getUser).collect(Collectors.toSet());
}
@Override
@@ -1647,8 +1654,8 @@ public final class CraftServer implements Server {
public Set<OfflinePlayer> getBannedPlayers() {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (JsonListEntry entry : playerList.getProfileBans().getValues()) {
result.add(getOfflinePlayer((GameProfile) entry.getKey()));
for (GameProfileBanEntry entry : playerList.getBans().getValues()) {
result.add(getOfflinePlayer(entry.getUser()));
}
return result;
@@ -1660,17 +1667,17 @@ public final class CraftServer implements Server {
switch (type) {
case IP:
return new CraftIpBanList(playerList.getIPBans());
return new CraftIpBanList(playerList.getIpBans());
case NAME:
default:
return new CraftProfileBanList(playerList.getProfileBans());
return new CraftProfileBanList(playerList.getBans());
}
}
@Override
public void setWhitelist(boolean value) {
playerList.setHasWhitelist(value);
console.setHasWhitelist(value);
playerList.setUsingWhiteList(value);
console.storeUsingWhiteList(value);
}
@Override
@@ -1687,8 +1694,8 @@ public final class CraftServer implements Server {
public Set<OfflinePlayer> getWhitelistedPlayers() {
Set<OfflinePlayer> result = new LinkedHashSet<OfflinePlayer>();
for (JsonListEntry entry : playerList.getWhitelist().getValues()) {
result.add(getOfflinePlayer((GameProfile) entry.getKey()));
for (WhiteListEntry entry : playerList.getWhiteList().getValues()) {
result.add(getOfflinePlayer(entry.getUser()));
}
return result;
@@ -1698,8 +1705,8 @@ public final class CraftServer implements Server {
public Set<OfflinePlayer> getOperators() {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (JsonListEntry entry : playerList.getOPs().getValues()) {
result.add(getOfflinePlayer((GameProfile) entry.getKey()));
for (OpListEntry entry : playerList.getOps().getValues()) {
result.add(getOfflinePlayer(entry.getUser()));
}
return result;
@@ -1707,12 +1714,12 @@ public final class CraftServer implements Server {
@Override
public void reloadWhitelist() {
playerList.reloadWhitelist();
playerList.reloadWhiteList();
}
@Override
public GameMode getDefaultGameMode() {
return GameMode.getByValue(console.getWorldServer(net.minecraft.world.level.World.OVERWORLD).serverLevelData.getGameType().getId());
return GameMode.getByValue(console.getLevel(net.minecraft.world.level.World.OVERWORLD).serverLevelData.getGameType().getId());
}
@Override
@@ -1720,7 +1727,7 @@ public final class CraftServer implements Server {
Validate.notNull(mode, "Mode cannot be null");
for (World world : getWorlds()) {
((CraftWorld) world).getHandle().serverLevelData.setGameType(EnumGamemode.getById(mode.getValue()));
((CraftWorld) world).getHandle().serverLevelData.setGameType(EnumGamemode.byId(mode.getValue()));
}
}
@@ -1743,7 +1750,7 @@ public final class CraftServer implements Server {
@Override
public File getWorldContainer() {
return this.getServer().storageSource.a(net.minecraft.world.level.World.OVERWORLD).getParentFile();
return this.getServer().storageSource.getDimensionPath(net.minecraft.world.level.World.OVERWORLD).getParent().toFile();
}
@Override
@@ -1990,18 +1997,19 @@ public final class CraftServer implements Server {
@Override
public void setIdleTimeout(int threshold) {
console.setIdleTimeout(threshold);
console.setPlayerIdleTimeout(threshold);
}
@Override
public int getIdleTimeout() {
return console.getIdleTimeout();
return console.getPlayerIdleTimeout();
}
@Override
public ChunkGenerator.ChunkData createChunkData(World world) {
Validate.notNull(world, "World cannot be null");
return new OldCraftChunkData(world);
WorldServer handle = ((CraftWorld) world).getHandle();
return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY));
}
@Override
@@ -2013,7 +2021,7 @@ public final class CraftServer implements Server {
public KeyedBossBar createBossBar(NamespacedKey key, String title, BarColor barColor, BarStyle barStyle, BarFlag... barFlags) {
Preconditions.checkArgument(key != null, "key");
BossBattleCustom bossBattleCustom = getServer().getBossBattleCustomData().register(CraftNamespacedKey.toMinecraft(key), CraftChatMessage.fromString(title, true)[0]);
BossBattleCustom bossBattleCustom = getServer().getCustomBossEvents().create(CraftNamespacedKey.toMinecraft(key), CraftChatMessage.fromString(title, true)[0]);
CraftKeyedBossbar craftKeyedBossbar = new CraftKeyedBossbar(bossBattleCustom);
craftKeyedBossbar.setColor(barColor);
craftKeyedBossbar.setStyle(barStyle);
@@ -2026,7 +2034,7 @@ public final class CraftServer implements Server {
@Override
public Iterator<KeyedBossBar> getBossBars() {
return Iterators.unmodifiableIterator(Iterators.transform(getServer().getBossBattleCustomData().getBattles().iterator(), new Function<BossBattleCustom, org.bukkit.boss.KeyedBossBar>() {
return Iterators.unmodifiableIterator(Iterators.transform(getServer().getCustomBossEvents().getEvents().iterator(), new Function<BossBattleCustom, org.bukkit.boss.KeyedBossBar>() {
@Override
public org.bukkit.boss.KeyedBossBar apply(BossBattleCustom bossBattleCustom) {
return bossBattleCustom.getBukkitEntity();
@@ -2037,7 +2045,7 @@ public final class CraftServer implements Server {
@Override
public KeyedBossBar getBossBar(NamespacedKey key) {
Preconditions.checkArgument(key != null, "key");
net.minecraft.server.bossevents.BossBattleCustom bossBattleCustom = getServer().getBossBattleCustomData().a(CraftNamespacedKey.toMinecraft(key));
net.minecraft.server.bossevents.BossBattleCustom bossBattleCustom = getServer().getCustomBossEvents().get(CraftNamespacedKey.toMinecraft(key));
return (bossBattleCustom == null) ? null : bossBattleCustom.getBukkitEntity();
}
@@ -2045,8 +2053,8 @@ public final class CraftServer implements Server {
@Override
public boolean removeBossBar(NamespacedKey key) {
Preconditions.checkArgument(key != null, "key");
net.minecraft.server.bossevents.BossBattleCustomData bossBattleCustomData = getServer().getBossBattleCustomData();
net.minecraft.server.bossevents.BossBattleCustom bossBattleCustom = bossBattleCustomData.a(CraftNamespacedKey.toMinecraft(key));
net.minecraft.server.bossevents.BossBattleCustomData bossBattleCustomData = getServer().getCustomBossEvents();
net.minecraft.server.bossevents.BossBattleCustom bossBattleCustom = bossBattleCustomData.get(CraftNamespacedKey.toMinecraft(key));
if (bossBattleCustom != null) {
bossBattleCustomData.remove(bossBattleCustom);
@@ -2060,7 +2068,7 @@ public final class CraftServer implements Server {
public Entity getEntity(UUID uuid) {
Validate.notNull(uuid, "UUID cannot be null");
for (WorldServer world : getServer().getWorlds()) {
for (WorldServer world : getServer().getAllLevels()) {
net.minecraft.world.entity.Entity entity = world.getEntity(uuid);
if (entity != null) {
return entity.getBukkitEntity();
@@ -2074,13 +2082,13 @@ public final class CraftServer implements Server {
public org.bukkit.advancement.Advancement getAdvancement(NamespacedKey key) {
Preconditions.checkArgument(key != null, "key");
Advancement advancement = console.getAdvancementData().a(CraftNamespacedKey.toMinecraft(key));
Advancement advancement = console.getAdvancements().getAdvancement(CraftNamespacedKey.toMinecraft(key));
return (advancement == null) ? null : advancement.bukkit;
}
@Override
public Iterator<org.bukkit.advancement.Advancement> advancementIterator() {
return Iterators.unmodifiableIterator(Iterators.transform(console.getAdvancementData().getAdvancements().iterator(), new Function<Advancement, org.bukkit.advancement.Advancement>() {
return Iterators.unmodifiableIterator(Iterators.transform(console.getAdvancements().getAllAdvancements().iterator(), new Function<Advancement, org.bukkit.advancement.Advancement>() {
@Override
public org.bukkit.advancement.Advancement apply(Advancement advancement) {
return advancement.bukkit;
@@ -2129,19 +2137,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.a(), key);
return (org.bukkit.Tag<T>) new CraftBlockTag(TagsBlock.getAllTags(), 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.a(), key);
return (org.bukkit.Tag<T>) new CraftItemTag(TagsItem.getAllTags(), 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.a(), key);
return (org.bukkit.Tag<T>) new CraftFluidTag(TagsFluid.getAllTags(), 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.a(), key);
return (org.bukkit.Tag<T>) new CraftEntityTag(TagsEntity.getAllTags(), key);
default:
throw new IllegalArgumentException();
}
@@ -2154,23 +2162,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.a();
return blockTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList());
Tags<Block> blockTags = TagsBlock.getAllTags();
return blockTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftBlockTag(blockTags, key)).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.a();
return itemTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList());
Tags<Item> itemTags = TagsItem.getAllTags();
return itemTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, key)).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.a();
return fluidTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftFluidTag(fluidTags, key)).collect(ImmutableList.toImmutableList());
Tags<FluidType> fluidTags = TagsFluid.getAllTags();
return fluidTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftFluidTag(fluidTags, key)).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.a();
return entityTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, key)).collect(ImmutableList.toImmutableList());
Tags<EntityTypes<?>> entityTags = TagsEntity.getAllTags();
return entityTags.getAllTags().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, key)).collect(ImmutableList.toImmutableList());
default:
throw new IllegalArgumentException();
}
@@ -2180,8 +2188,8 @@ public final class CraftServer implements Server {
public LootTable getLootTable(NamespacedKey key) {
Validate.notNull(key, "NamespacedKey cannot be null");
LootTableRegistry registry = getServer().getLootTableRegistry();
return new CraftLootTable(key, registry.getLootTable(CraftNamespacedKey.toMinecraft(key)));
LootTableRegistry registry = getServer().getLootTables();
return new CraftLootTable(key, registry.get(CraftNamespacedKey.toMinecraft(key)));
}
@Override
@@ -2189,12 +2197,12 @@ public final class CraftServer implements Server {
Preconditions.checkArgument(selector != null, "Selector cannot be null");
Preconditions.checkArgument(sender != null, "Sender cannot be null");
ArgumentEntity arg = ArgumentEntity.multipleEntities();
ArgumentEntity arg = ArgumentEntity.entities();
List<? extends net.minecraft.world.entity.Entity> nms;
try {
StringReader reader = new StringReader(selector);
nms = arg.parse(reader, true).getEntities(VanillaCommandWrapper.getListener(sender));
nms = arg.parse(reader, true).findEntities(VanillaCommandWrapper.getListener(sender));
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data in selector: " + selector);
} catch (CommandSyntaxException ex) {
throw new IllegalArgumentException("Could not parse selector: " + selector, ex);

View File

@@ -122,11 +122,11 @@ public enum CraftStatistic {
}
public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.stats.Statistic<?> statistic) {
IRegistry statRegistry = statistic.getWrapper().getRegistry();
MinecraftKey nmsKey = IRegistry.STAT_TYPE.getKey(statistic.getWrapper());
IRegistry statRegistry = statistic.getType().getRegistry();
MinecraftKey nmsKey = IRegistry.STAT_TYPE.getKey(statistic.getType());
if (statRegistry == IRegistry.CUSTOM_STAT) {
nmsKey = (MinecraftKey) statistic.b();
nmsKey = (MinecraftKey) statistic.getValue();
}
return statistics.get(nmsKey);
@@ -135,7 +135,7 @@ public enum CraftStatistic {
public static net.minecraft.stats.Statistic getNMSStatistic(org.bukkit.Statistic bukkit) {
Preconditions.checkArgument(bukkit.getType() == Statistic.Type.UNTYPED, "This method only accepts untyped statistics");
net.minecraft.stats.Statistic<MinecraftKey> nms = StatisticList.CUSTOM.b(statistics.inverse().get(bukkit));
net.minecraft.stats.Statistic<MinecraftKey> nms = StatisticList.CUSTOM.get(statistics.inverse().get(bukkit));
Preconditions.checkArgument(nms != null, "NMS Statistic %s does not exist", bukkit);
return nms;
@@ -144,22 +144,22 @@ public enum CraftStatistic {
public static net.minecraft.stats.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
try {
if (stat == Statistic.MINE_BLOCK) {
return StatisticList.BLOCK_MINED.b(CraftMagicNumbers.getBlock(material));
return StatisticList.BLOCK_MINED.get(CraftMagicNumbers.getBlock(material));
}
if (stat == Statistic.CRAFT_ITEM) {
return StatisticList.ITEM_CRAFTED.b(CraftMagicNumbers.getItem(material));
return StatisticList.ITEM_CRAFTED.get(CraftMagicNumbers.getItem(material));
}
if (stat == Statistic.USE_ITEM) {
return StatisticList.ITEM_USED.b(CraftMagicNumbers.getItem(material));
return StatisticList.ITEM_USED.get(CraftMagicNumbers.getItem(material));
}
if (stat == Statistic.BREAK_ITEM) {
return StatisticList.ITEM_BROKEN.b(CraftMagicNumbers.getItem(material));
return StatisticList.ITEM_BROKEN.get(CraftMagicNumbers.getItem(material));
}
if (stat == Statistic.PICKUP) {
return StatisticList.ITEM_PICKED_UP.b(CraftMagicNumbers.getItem(material));
return StatisticList.ITEM_PICKED_UP.get(CraftMagicNumbers.getItem(material));
}
if (stat == Statistic.DROP) {
return StatisticList.ITEM_DROPPED.b(CraftMagicNumbers.getItem(material));
return StatisticList.ITEM_DROPPED.get(CraftMagicNumbers.getItem(material));
}
} catch (ArrayIndexOutOfBoundsException e) {
return null;
@@ -172,26 +172,26 @@ public enum CraftStatistic {
EntityTypes<?> nmsEntity = IRegistry.ENTITY_TYPE.get(new MinecraftKey(entity.getName()));
if (stat == org.bukkit.Statistic.KILL_ENTITY) {
return net.minecraft.stats.StatisticList.ENTITY_KILLED.b(nmsEntity);
return net.minecraft.stats.StatisticList.ENTITY_KILLED.get(nmsEntity);
}
if (stat == org.bukkit.Statistic.ENTITY_KILLED_BY) {
return net.minecraft.stats.StatisticList.ENTITY_KILLED_BY.b(nmsEntity);
return net.minecraft.stats.StatisticList.ENTITY_KILLED_BY.get(nmsEntity);
}
}
return null;
}
public static EntityType getEntityTypeFromStatistic(net.minecraft.stats.Statistic<EntityTypes<?>> statistic) {
MinecraftKey name = EntityTypes.getName(statistic.b());
return EntityType.fromName(name.getKey());
MinecraftKey name = EntityTypes.getKey(statistic.getValue());
return EntityType.fromName(name.getPath());
}
public static Material getMaterialFromStatistic(net.minecraft.stats.Statistic<?> statistic) {
if (statistic.b() instanceof Item) {
return CraftMagicNumbers.getMaterial((Item) statistic.b());
if (statistic.getValue() instanceof Item) {
return CraftMagicNumbers.getMaterial((Item) statistic.getValue());
}
if (statistic.b() instanceof Block) {
return CraftMagicNumbers.getMaterial((Block) statistic.b());
if (statistic.getValue() instanceof Block) {
return CraftMagicNumbers.getMaterial((Block) statistic.getValue());
}
return null;
}
@@ -207,7 +207,7 @@ public enum CraftStatistic {
public static int getStatistic(ServerStatisticManager manager, Statistic statistic) {
Validate.notNull(statistic, "Statistic cannot be null");
Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
return manager.getStatisticValue(CraftStatistic.getNMSStatistic(statistic));
return manager.getValue(CraftStatistic.getNMSStatistic(statistic));
}
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, int amount) {
@@ -225,7 +225,7 @@ public enum CraftStatistic {
Validate.isTrue(statistic.getType() == Type.UNTYPED, "Must supply additional paramater for this statistic");
Validate.isTrue(newValue >= 0, "Value must be greater than or equal to 0");
net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getNMSStatistic(statistic);
manager.setStatistic(null, nmsStatistic, newValue);;
manager.setValue(null, nmsStatistic, newValue);;
}
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, Material material) {
@@ -242,7 +242,7 @@ public enum CraftStatistic {
Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
return manager.getStatisticValue(nmsStatistic);
return manager.getValue(nmsStatistic);
}
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, Material material, int amount) {
@@ -262,7 +262,7 @@ public enum CraftStatistic {
Validate.isTrue(statistic.getType() == Type.BLOCK || statistic.getType() == Type.ITEM, "This statistic does not take a Material parameter");
net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getMaterialStatistic(statistic, material);
Validate.notNull(nmsStatistic, "The supplied Material does not have a corresponding statistic");
manager.setStatistic(null, nmsStatistic, newValue);
manager.setValue(null, nmsStatistic, newValue);
}
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType) {
@@ -279,7 +279,7 @@ public enum CraftStatistic {
Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
return manager.getStatisticValue(nmsStatistic);
return manager.getValue(nmsStatistic);
}
public static void incrementStatistic(ServerStatisticManager manager, Statistic statistic, EntityType entityType, int amount) {
@@ -299,6 +299,6 @@ public enum CraftStatistic {
Validate.isTrue(statistic.getType() == Type.ENTITY, "This statistic does not take an EntityType parameter");
net.minecraft.stats.Statistic nmsStatistic = CraftStatistic.getEntityStatistic(statistic, entityType);
Validate.notNull(nmsStatistic, "The supplied EntityType does not have a corresponding statistic");
manager.setStatistic(null, nmsStatistic, newValue);
manager.setValue(null, nmsStatistic, newValue);
}
}

View File

@@ -159,7 +159,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public Location getSpawnLocation() {
BlockPosition spawn = world.getSpawn();
BlockPosition spawn = world.getSharedSpawnPos();
return new Location(this, spawn.getX(), spawn.getY(), spawn.getZ());
}
@@ -193,7 +193,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public Chunk getChunkAt(int x, int z) {
return this.world.getChunkProvider().getChunkAt(x, z, true).bukkitChunk;
return this.world.getChunkSource().getChunk(x, z, true).bukkitChunk;
}
@Override
@@ -205,13 +205,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean isChunkLoaded(int x, int z) {
return world.getChunkProvider().isChunkLoaded(x, z);
return world.getChunkSource().isChunkLoaded(x, z);
}
@Override
public boolean isChunkGenerated(int x, int z) {
try {
return isChunkLoaded(x, z) || world.getChunkProvider().chunkMap.read(new ChunkCoordIntPair(x, z)) != null;
return isChunkLoaded(x, z) || world.getChunkSource().chunkMap.read(new ChunkCoordIntPair(x, z)) != null;
} catch (IOException ex) {
throw new RuntimeException(ex);
}
@@ -219,7 +219,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public Chunk[] getLoadedChunks() {
Long2ObjectLinkedOpenHashMap<PlayerChunk> chunks = world.getChunkProvider().chunkMap.visibleChunkMap;
Long2ObjectLinkedOpenHashMap<PlayerChunk> chunks = world.getChunkSource().chunkMap.visibleChunkMap;
return chunks.values().stream().map(PlayerChunk::getFullChunk).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.Chunk::getBukkitChunk).toArray(Chunk[]::new);
}
@@ -246,7 +246,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean unloadChunkRequest(int x, int z) {
if (isChunkLoaded(x, z)) {
world.getChunkProvider().removeTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
}
return true;
@@ -256,12 +256,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
if (!isChunkLoaded(x, z)) {
return true;
}
net.minecraft.world.level.chunk.Chunk chunk = world.getChunkAt(x, z);
net.minecraft.world.level.chunk.Chunk chunk = world.getChunk(x, z);
chunk.mustNotSave = !save;
unloadChunkRequest(x, z);
world.getChunkProvider().purgeUnload();
world.getChunkSource().purgeUnload();
return !isChunkLoaded(x, z);
}
@@ -304,9 +304,9 @@ public class CraftWorld extends CraftRegionAccessor implements World {
// This flags 65 blocks distributed across all the sections of the chunk, so that everything is sent, including biomes
int height = getMaxHeight() / 16;
for (int idx = 0; idx < 64; idx++) {
world.notify(new BlockPosition(px + (idx / height), ((idx % height) * 16), pz), Blocks.AIR.getBlockData(), Blocks.STONE.getBlockData(), 3);
world.sendBlockUpdated(new BlockPosition(px + (idx / height), ((idx % height) * 16), pz), Blocks.AIR.defaultBlockState(), Blocks.STONE.defaultBlockState(), 3);
}
world.notify(new BlockPosition(px + 15, (height * 16) - 1, pz + 15), Blocks.AIR.getBlockData(), Blocks.STONE.getBlockData(), 3);
world.sendBlockUpdated(new BlockPosition(px + 15, (height * 16) - 1, pz + 15), Blocks.AIR.defaultBlockState(), Blocks.STONE.defaultBlockState(), 3);
return true;
}
@@ -318,16 +318,16 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean loadChunk(int x, int z, boolean generate) {
IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, generate ? ChunkStatus.FULL : ChunkStatus.EMPTY, true);
IChunkAccess chunk = world.getChunkSource().getChunk(x, z, generate ? ChunkStatus.FULL : ChunkStatus.EMPTY, true);
// If generate = false, but the chunk already exists, we will get this back.
if (chunk instanceof ProtoChunkExtension) {
// We then cycle through again to get the full chunk immediately, rather than after the ticket addition
chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true);
chunk = world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
}
if (chunk instanceof net.minecraft.world.level.chunk.Chunk) {
world.getChunkProvider().addTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
return true;
}
@@ -354,7 +354,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Preconditions.checkArgument(plugin != null, "null plugin");
Preconditions.checkArgument(plugin.isEnabled(), "plugin is not enabled");
ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager;
ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager;
if (chunkDistanceManager.addTicketAtLevel(TicketType.PLUGIN_TICKET, new ChunkCoordIntPair(x, z), 31, plugin)) { // keep in-line with force loading, add at level 31
this.getChunkAt(x, z); // ensure loaded
@@ -368,7 +368,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
public boolean removePluginChunkTicket(int x, int z, Plugin plugin) {
Preconditions.checkNotNull(plugin, "null plugin");
ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager;
ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager;
return chunkDistanceManager.removeTicketAtLevel(TicketType.PLUGIN_TICKET, new ChunkCoordIntPair(x, z), 31, plugin); // keep in-line with force loading, remove at level 31
}
@@ -376,14 +376,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
public void removePluginChunkTickets(Plugin plugin) {
Preconditions.checkNotNull(plugin, "null plugin");
ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager;
ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager;
chunkDistanceManager.removeAllTicketsFor(TicketType.PLUGIN_TICKET, 31, plugin); // keep in-line with force loading, remove at level 31
}
@Override
public Collection<Plugin> getPluginChunkTickets(int x, int z) {
ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager;
ArraySetSorted<Ticket<?>> tickets = chunkDistanceManager.tickets.get(ChunkCoordIntPair.pair(x, z));
ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager;
ArraySetSorted<Ticket<?>> tickets = chunkDistanceManager.tickets.get(ChunkCoordIntPair.asLong(x, z));
if (tickets == null) {
return Collections.emptyList();
@@ -391,7 +391,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
ImmutableList.Builder<Plugin> ret = ImmutableList.builder();
for (Ticket<?> ticket : tickets) {
if (ticket.getTicketType() == TicketType.PLUGIN_TICKET) {
if (ticket.getType() == TicketType.PLUGIN_TICKET) {
ret.add((Plugin) ticket.key);
}
}
@@ -402,7 +402,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
Map<Plugin, ImmutableList.Builder<Chunk>> ret = new HashMap<>();
ChunkMapDistance chunkDistanceManager = this.world.getChunkProvider().chunkMap.distanceManager;
ChunkMapDistance chunkDistanceManager = this.world.getChunkSource().chunkMap.distanceManager;
for (Long2ObjectMap.Entry<ArraySetSorted<Ticket<?>>> chunkTickets : chunkDistanceManager.tickets.long2ObjectEntrySet()) {
long chunkKey = chunkTickets.getLongKey();
@@ -410,7 +410,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Chunk chunk = null;
for (Ticket<?> ticket : tickets) {
if (ticket.getTicketType() != TicketType.PLUGIN_TICKET) {
if (ticket.getType() != TicketType.PLUGIN_TICKET) {
continue;
}
@@ -427,19 +427,19 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean isChunkForceLoaded(int x, int z) {
return getHandle().getForceLoadedChunks().contains(ChunkCoordIntPair.pair(x, z));
return getHandle().getForcedChunks().contains(ChunkCoordIntPair.asLong(x, z));
}
@Override
public void setChunkForceLoaded(int x, int z, boolean forced) {
getHandle().setForceLoaded(x, z, forced);
getHandle().setChunkForced(x, z, forced);
}
@Override
public Collection<Chunk> getForceLoadedChunks() {
Set<Chunk> chunks = new HashSet<>();
for (long coord : getHandle().getForceLoadedChunks()) {
for (long coord : getHandle().getForcedChunks()) {
chunks.add(getChunkAt(ChunkCoordIntPair.getX(coord), ChunkCoordIntPair.getZ(coord)));
}
@@ -463,7 +463,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
if (function != null) {
function.accept((org.bukkit.entity.Item) entity.getBukkitEntity());
}
world.addEntity(entity, SpawnReason.CUSTOM);
world.addFreshEntity(entity, SpawnReason.CUSTOM);
return (org.bukkit.entity.Item) entity.getBukkitEntity();
}
@@ -497,35 +497,35 @@ public class CraftWorld extends CraftRegionAccessor implements World {
EntityArrow arrow;
if (TippedArrow.class.isAssignableFrom(clazz)) {
arrow = EntityTypes.ARROW.a(world);
((EntityTippedArrow) arrow).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
arrow = EntityTypes.ARROW.create(world);
((EntityTippedArrow) arrow).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
arrow = EntityTypes.SPECTRAL_ARROW.a(world);
arrow = EntityTypes.SPECTRAL_ARROW.create(world);
} else if (Trident.class.isAssignableFrom(clazz)) {
arrow = EntityTypes.TRIDENT.a(world);
arrow = EntityTypes.TRIDENT.create(world);
} else {
arrow = EntityTypes.ARROW.a(world);
arrow = EntityTypes.ARROW.create(world);
}
arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
arrow.moveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
arrow.shoot(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
world.addEntity(arrow);
world.addFreshEntity(arrow);
return (T) arrow.getBukkitEntity();
}
@Override
public LightningStrike strikeLightning(Location loc) {
EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.a(world);
lightning.teleportAndSync(loc.getX(), loc.getY(), loc.getZ());
EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.create(world);
lightning.moveTo(loc.getX(), loc.getY(), loc.getZ());
world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM);
return (LightningStrike) lightning.getBukkitEntity();
}
@Override
public LightningStrike strikeLightningEffect(Location loc) {
EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.a(world);
lightning.teleportAndSync(loc.getX(), loc.getY(), loc.getZ());
lightning.setEffect(true);
EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.create(world);
lightning.moveTo(loc.getX(), loc.getY(), loc.getZ());
lightning.setVisualOnly(true);
world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM);
return (LightningStrike) lightning.getBukkitEntity();
}
@@ -545,10 +545,10 @@ public class CraftWorld extends CraftRegionAccessor implements World {
if (grownTree) { // Copy block data to delegate
for (BlockState blockstate : world.capturedBlockStates.values()) {
BlockPosition position = ((CraftBlockState) blockstate).getPosition();
net.minecraft.world.level.block.state.IBlockData oldBlock = world.getType(position);
net.minecraft.world.level.block.state.IBlockData oldBlock = world.getBlockState(position);
int flag = ((CraftBlockState) blockstate).getFlag();
delegate.setBlockData(blockstate.getX(), blockstate.getY(), blockstate.getZ(), blockstate.getBlockData());
net.minecraft.world.level.block.state.IBlockData newBlock = world.getType(position);
net.minecraft.world.level.block.state.IBlockData newBlock = world.getBlockState(position);
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag, 512);
}
world.capturedBlockStates.clear();
@@ -561,7 +561,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public String getName() {
return world.serverLevelData.getName();
return world.serverLevelData.getLevelName();
}
@Override
@@ -609,13 +609,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
CraftPlayer cp = (CraftPlayer) p;
if (cp.getHandle().connection == null) continue;
cp.getHandle().connection.sendPacket(new PacketPlayOutUpdateTime(cp.getHandle().level.getTime(), cp.getHandle().getPlayerTime(), cp.getHandle().level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
cp.getHandle().connection.send(new PacketPlayOutUpdateTime(cp.getHandle().level.getGameTime(), cp.getHandle().getPlayerTime(), cp.getHandle().level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
}
}
@Override
public long getGameTime() {
return world.levelData.getTime();
return world.levelData.getGameTime();
}
@Override
@@ -635,7 +635,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) {
return !world.createExplosion(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled;
return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled;
}
@Override
@@ -709,7 +709,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) {
// Transient load for this tick
return world.getChunkAt(x >> 4, z >> 4).getHighestBlock(CraftHeightMap.toNMS(heightMap), x, z);
return world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z);
}
@Override
@@ -742,13 +742,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public void setBiome(int x, int y, int z, BiomeBase bb) {
BlockPosition pos = new BlockPosition(x, 0, z);
if (this.world.isLoaded(pos)) {
net.minecraft.world.level.chunk.Chunk chunk = this.world.getChunkAtWorldCoords(pos);
if (this.world.hasChunkAt(pos)) {
net.minecraft.world.level.chunk.Chunk chunk = this.world.getChunkAt(pos);
if (chunk != null) {
chunk.getBiomeIndex().setBiome(x >> 2, y >> 2, z >> 2, bb);
chunk.setBiome(x, y, z, bb);
chunk.markDirty(); // SPIGOT-2890
chunk.setUnsaved(true); // SPIGOT-2890
}
}
}
@@ -761,7 +761,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.getBiome(x >> 2, y >> 2, z >> 2).getAdjustedTemperature(pos);
return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).getTemperature(pos);
}
@Override
@@ -771,7 +771,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public double getHumidity(int x, int y, int z) {
return this.world.getBiome(x >> 2, y >> 2, z >> 2).getHumidity();
return this.world.getNoiseBiome(x >> 2, y >> 2, z >> 2).getDownfall();
}
@Override
@@ -783,12 +783,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public Iterable<net.minecraft.world.entity.Entity> getNMSEntities() {
return getHandle().getEntities().a();
return getHandle().getEntities().getAll();
}
@Override
public void addEntityToWorld(net.minecraft.world.entity.Entity entity, SpawnReason reason) {
getHandle().addEntity(entity, reason);
getHandle().addFreshEntity(entity, reason);
}
@Override
@@ -914,7 +914,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Vector dir = direction.clone().normalize().multiply(maxDistance);
Vec3D startPos = new Vec3D(start.getX(), start.getY(), start.getZ());
Vec3D endPos = new Vec3D(start.getX() + dir.getX(), start.getY() + dir.getY(), start.getZ() + dir.getZ());
MovingObjectPosition nmsHitResult = this.getHandle().rayTrace(new RayTrace(startPos, endPos, ignorePassableBlocks ? RayTrace.BlockCollisionOption.COLLIDER : RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null));
MovingObjectPosition nmsHitResult = this.getHandle().clip(new RayTrace(startPos, endPos, ignorePassableBlocks ? RayTrace.BlockCollisionOption.COLLIDER : RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null));
return CraftRayTraceResult.fromNMS(this, nmsHitResult);
}
@@ -951,9 +951,9 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public List<Player> getPlayers() {
List<Player> list = new ArrayList<Player>(world.getPlayers().size());
List<Player> list = new ArrayList<Player>(world.players().size());
for (EntityHuman human : world.getPlayers()) {
for (EntityHuman human : world.players()) {
HumanEntity bukkitEntity = human.getBukkitEntity();
if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) {
@@ -987,7 +987,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public void setDifficulty(Difficulty difficulty) {
this.getHandle().serverLevelData.setDifficulty(EnumDifficulty.getById(difficulty.getValue()));
this.getHandle().serverLevelData.setDifficulty(EnumDifficulty.byId(difficulty.getValue()));
}
@Override
@@ -1001,24 +1001,24 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean hasStorm() {
return world.levelData.hasStorm();
return world.levelData.isRaining();
}
@Override
public void setStorm(boolean hasStorm) {
world.levelData.setStorm(hasStorm);
world.levelData.setRaining(hasStorm);
setWeatherDuration(0); // Reset weather duration (legacy behaviour)
setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
}
@Override
public int getWeatherDuration() {
return world.serverLevelData.getWeatherDuration();
return world.serverLevelData.getRainTime();
}
@Override
public void setWeatherDuration(int duration) {
world.serverLevelData.setWeatherDuration(duration);
world.serverLevelData.setRainTime(duration);
}
@Override
@@ -1035,12 +1035,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public int getThunderDuration() {
return world.serverLevelData.getThunderDuration();
return world.serverLevelData.getThunderTime();
}
@Override
public void setThunderDuration(int duration) {
world.serverLevelData.setThunderDuration(duration);
world.serverLevelData.setThunderTime(duration);
}
@Override
@@ -1116,7 +1116,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
distance = (int) player.getLocation().distanceSquared(location);
if (distance <= radius) {
((CraftPlayer) player).getHandle().connection.sendPacket(packet);
((CraftPlayer) player).getHandle().connection.send(packet);
}
}
}
@@ -1133,10 +1133,10 @@ 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).getBlockData());
EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState());
entity.time = 1;
world.addEntity(entity, SpawnReason.CUSTOM);
world.addFreshEntity(entity, SpawnReason.CUSTOM);
return (FallingBlock) entity.getBukkitEntity();
}
@@ -1148,7 +1148,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState());
entity.time = 1;
world.addEntity(entity, SpawnReason.CUSTOM);
world.addFreshEntity(entity, SpawnReason.CUSTOM);
return (FallingBlock) entity.getBukkitEntity();
}
@@ -1159,17 +1159,17 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public void setSpawnFlags(boolean allowMonsters, boolean allowAnimals) {
world.setSpawnFlags(allowMonsters, allowAnimals);
world.setSpawnSettings(allowMonsters, allowAnimals);
}
@Override
public boolean getAllowAnimals() {
return world.getChunkProvider().spawnFriendlies;
return world.getChunkSource().spawnFriendlies;
}
@Override
public boolean getAllowMonsters() {
return world.getChunkProvider().spawnEnemies;
return world.getChunkSource().spawnEnemies;
}
@Override
@@ -1184,47 +1184,47 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public int getLogicalHeight() {
return world.getDimensionManager().getLogicalHeight();
return world.dimensionType().logicalHeight();
}
@Override
public boolean isNatural() {
return world.getDimensionManager().isNatural();
return world.dimensionType().natural();
}
@Override
public boolean isBedWorks() {
return world.getDimensionManager().isBedWorks();
return world.dimensionType().bedWorks();
}
@Override
public boolean hasSkyLight() {
return world.getDimensionManager().hasSkyLight();
return world.dimensionType().hasSkyLight();
}
@Override
public boolean hasCeiling() {
return world.getDimensionManager().hasCeiling();
return world.dimensionType().hasCeiling();
}
@Override
public boolean isPiglinSafe() {
return world.getDimensionManager().isPiglinSafe();
return world.dimensionType().piglinSafe();
}
@Override
public boolean isRespawnAnchorWorks() {
return world.getDimensionManager().isRespawnAnchorWorks();
return world.dimensionType().respawnAnchorWorks();
}
@Override
public boolean hasRaids() {
return world.getDimensionManager().hasRaids();
return world.dimensionType().hasRaids();
}
@Override
public boolean isUltraWarm() {
return world.getDimensionManager().isNether();
return world.dimensionType().ultraWarm();
}
@Override
@@ -1241,12 +1241,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
public void setKeepSpawnInMemory(boolean keepLoaded) {
world.keepSpawnInMemory = keepLoaded;
// Grab the worlds spawn chunk
BlockPosition chunkcoordinates = this.world.getSpawn();
BlockPosition chunkcoordinates = this.world.getSharedSpawnPos();
if (keepLoaded) {
world.getChunkProvider().addTicket(TicketType.START, new ChunkCoordIntPair(chunkcoordinates), 11, Unit.INSTANCE);
world.getChunkSource().addRegionTicket(TicketType.START, new ChunkCoordIntPair(chunkcoordinates), 11, Unit.INSTANCE);
} else {
// TODO: doesn't work well if spawn changed....
world.getChunkProvider().removeTicket(TicketType.START, new ChunkCoordIntPair(chunkcoordinates), 11, Unit.INSTANCE);
world.getChunkSource().removeRegionTicket(TicketType.START, new ChunkCoordIntPair(chunkcoordinates), 11, Unit.INSTANCE);
}
}
@@ -1271,7 +1271,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public File getWorldFolder() {
return world.convertable.getWorldFolder(SavedFile.ROOT).toFile().getParentFile();
return world.convertable.getLevelPath(SavedFile.ROOT).toFile().getParentFile();
}
@Override
@@ -1296,17 +1296,17 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public org.bukkit.WorldType getWorldType() {
return world.isFlatWorld() ? org.bukkit.WorldType.FLAT : org.bukkit.WorldType.NORMAL;
return world.isFlat() ? org.bukkit.WorldType.FLAT : org.bukkit.WorldType.NORMAL;
}
@Override
public boolean canGenerateStructures() {
return world.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures();
return world.serverLevelData.worldGenSettings().generateFeatures();
}
@Override
public boolean isHardcore() {
return world.getWorldData().isHardcore();
return world.getLevelData().isHardcore();
}
@Override
@@ -1508,7 +1508,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
double z = loc.getZ();
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch);
world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.getDimensionKey(), packet);
world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet);
}
private static Map<String, GameRules.GameRuleKey<?>> gamerules;
@@ -1518,10 +1518,10 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
Map<String, GameRules.GameRuleKey<?>> gamerules = new HashMap<>();
GameRules.a(new GameRules.GameRuleVisitor() {
GameRules.visitGameRuleTypes(new GameRules.GameRuleVisitor() {
@Override
public <T extends GameRules.GameRuleValue<T>> void a(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) {
gamerules.put(gamerules_gamerulekey.a(), gamerules_gamerulekey);
public <T extends GameRules.GameRuleValue<T>> void visit(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) {
gamerules.put(gamerules_gamerulekey.getId(), gamerules_gamerulekey);
}
});
@@ -1535,10 +1535,10 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
Map<String, GameRules.GameRuleDefinition<?>> gameruleDefinitions = new HashMap<>();
GameRules.a(new GameRules.GameRuleVisitor() {
GameRules.visitGameRuleTypes(new GameRules.GameRuleVisitor() {
@Override
public <T extends GameRules.GameRuleValue<T>> void a(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) {
gameruleDefinitions.put(gamerules_gamerulekey.a(), gamerules_gameruledefinition);
public <T extends GameRules.GameRuleValue<T>> void visit(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) {
gameruleDefinitions.put(gamerules_gamerulekey.getId(), gamerules_gameruledefinition);
}
});
@@ -1552,7 +1552,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
return null;
}
GameRules.GameRuleValue<?> value = getHandle().getGameRules().get(getGameRulesNMS().get(rule));
GameRules.GameRuleValue<?> value = getHandle().getGameRules().getRule(getGameRulesNMS().get(rule));
return value != null ? value.toString() : "";
}
@@ -1563,9 +1563,9 @@ public class CraftWorld extends CraftRegionAccessor implements World {
if (!isGameRule(rule)) return false;
GameRules.GameRuleValue<?> handle = getHandle().getGameRules().get(getGameRulesNMS().get(rule));
handle.setValue(value);
handle.onChange(getHandle().getMinecraftServer());
GameRules.GameRuleValue<?> handle = getHandle().getGameRules().getRule(getGameRulesNMS().get(rule));
handle.deserialize(value);
handle.onChanged(getHandle().getServer());
return true;
}
@@ -1583,13 +1583,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public <T> T getGameRuleValue(GameRule<T> rule) {
Validate.notNull(rule, "GameRule cannot be null");
return convert(rule, getHandle().getGameRules().get(getGameRulesNMS().get(rule.getName())));
return convert(rule, getHandle().getGameRules().getRule(getGameRulesNMS().get(rule.getName())));
}
@Override
public <T> T getGameRuleDefault(GameRule<T> rule) {
Validate.notNull(rule, "GameRule cannot be null");
return convert(rule, getGameRuleDefinitions().get(rule.getName()).getValue());
return convert(rule, getGameRuleDefinitions().get(rule.getName()).createRule());
}
@Override
@@ -1599,9 +1599,9 @@ public class CraftWorld extends CraftRegionAccessor implements World {
if (!isGameRule(rule.getName())) return false;
GameRules.GameRuleValue<?> handle = getHandle().getGameRules().get(getGameRulesNMS().get(rule.getName()));
handle.setValue(newValue.toString());
handle.onChange(getHandle().getMinecraftServer());
GameRules.GameRuleValue<?> handle = getHandle().getGameRules().getRule(getGameRulesNMS().get(rule.getName()));
handle.deserialize(newValue.toString());
handle.onChanged(getHandle().getServer());
return true;
}
@@ -1611,9 +1611,9 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
if (value instanceof GameRules.GameRuleBoolean) {
return rule.getType().cast(((GameRules.GameRuleBoolean) value).a());
return rule.getType().cast(((GameRules.GameRuleBoolean) value).get());
} else if (value instanceof GameRules.GameRuleInt) {
return rule.getType().cast(value.getIntValue());
return rule.getType().cast(value.getCommandResult());
} else {
throw new IllegalArgumentException("Invalid GameRule type (" + value + ") for GameRule " + rule.getName());
}
@@ -1713,7 +1713,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().getChunkProvider().getChunkGenerator().findNearestMapFeature(getHandle(), StructureGenerator.STRUCTURES_REGISTRY.get(structureType.getName()), originPos, radius, findUnexplored);
BlockPosition nearest = getHandle().getChunkSource().getGenerator().findNearestMapFeature(getHandle(), StructureGenerator.STRUCTURES_REGISTRY.get(structureType.getName()), originPos, radius, findUnexplored);
return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
}
@@ -1722,19 +1722,19 @@ public class CraftWorld extends CraftRegionAccessor implements World {
Validate.notNull(location, "Location cannot be null");
Validate.isTrue(radius >= 0, "Radius cannot be negative");
PersistentRaid persistentRaid = world.getPersistentRaid();
PersistentRaid persistentRaid = world.getRaids();
net.minecraft.world.entity.raid.Raid raid = persistentRaid.getNearbyRaid(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), radius * radius);
return (raid == null) ? null : new CraftRaid(raid);
}
@Override
public List<Raid> getRaids() {
PersistentRaid persistentRaid = world.getPersistentRaid();
PersistentRaid persistentRaid = world.getRaids();
return persistentRaid.raidMap.values().stream().map(CraftRaid::new).collect(Collectors.toList());
}
@Override
public DragonBattle getEnderDragonBattle() {
return (getHandle().getDragonBattle() == null) ? null : new CraftDragonBattle(getHandle().getDragonBattle());
return (getHandle().dragonFight() == null) ? null : new CraftDragonBattle(getHandle().dragonFight());
}
}

View File

@@ -43,7 +43,7 @@ public class CraftWorldBorder implements WorldBorder {
time = Math.min(9223372036854775L, Math.max(0L, time));
if (time > 0L) {
this.handle.transitionSizeBetween(this.handle.getSize(), newSize, time * 1000L);
this.handle.lerpSizeBetween(this.handle.getSize(), newSize, time * 1000L);
} else {
this.handle.setSize(newSize);
}
@@ -73,22 +73,22 @@ public class CraftWorldBorder implements WorldBorder {
@Override
public double getDamageBuffer() {
return this.handle.getDamageBuffer();
return this.handle.getDamageSafeZone();
}
@Override
public void setDamageBuffer(double blocks) {
this.handle.setDamageBuffer(blocks);
this.handle.setDamageSafeZone(blocks);
}
@Override
public double getDamageAmount() {
return this.handle.getDamageAmount();
return this.handle.getDamagePerBlock();
}
@Override
public void setDamageAmount(double damage) {
this.handle.setDamageAmount(damage);
this.handle.setDamagePerBlock(damage);
}
@Override
@@ -103,18 +103,18 @@ public class CraftWorldBorder implements WorldBorder {
@Override
public int getWarningDistance() {
return this.handle.getWarningDistance();
return this.handle.getWarningBlocks();
}
@Override
public void setWarningDistance(int distance) {
this.handle.setWarningDistance(distance);
this.handle.setWarningBlocks(distance);
}
@Override
public boolean isInside(Location location) {
Preconditions.checkArgument(location != null, "location");
return location.getWorld().equals(this.world) && this.handle.a(new BlockPosition(location.getX(), location.getY(), location.getZ()));
return location.getWorld().equals(this.world) && this.handle.isWithinBounds(new BlockPosition(location.getX(), location.getY(), location.getZ()));
}
}

View File

@@ -149,8 +149,8 @@ public class Main {
}
float javaVersion = Float.parseFloat(System.getProperty("java.class.version"));
if (javaVersion < 60.0) {
System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 16. Check your Java version with the command 'java -version'.");
if (javaVersion < 61.0) {
System.err.println("Unsupported Java detected (" + javaVersion + "). This version of Minecraft requires at least Java 11. Check your Java version with the command 'java -version'.");
return;
}
if (javaVersion > 61.0) {
@@ -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, -7);
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

@@ -20,7 +20,7 @@ public class CraftAdvancement implements org.bukkit.advancement.Advancement {
@Override
public NamespacedKey getKey() {
return CraftNamespacedKey.fromMinecraft(handle.getName());
return CraftNamespacedKey.fromMinecraft(handle.getId());
}
@Override

View File

@@ -33,18 +33,18 @@ public class CraftAdvancementProgress implements AdvancementProgress {
@Override
public boolean awardCriteria(String criteria) {
return playerData.grantCriteria(advancement.getHandle(), criteria);
return playerData.award(advancement.getHandle(), criteria);
}
@Override
public boolean revokeCriteria(String criteria) {
return playerData.revokeCritera(advancement.getHandle(), criteria);
return playerData.revoke(advancement.getHandle(), criteria);
}
@Override
public Date getDateAwarded(String criteria) {
CriterionProgress criterion = handle.getCriterionProgress(criteria);
return (criterion == null) ? null : criterion.getDate();
CriterionProgress criterion = handle.getCriterion(criteria);
return (criterion == null) ? null : criterion.getObtained();
}
@Override
@@ -54,6 +54,6 @@ public class CraftAdvancementProgress implements AdvancementProgress {
@Override
public Collection<String> getAwardedCriteria() {
return Collections.unmodifiableCollection(Lists.newArrayList(handle.getAwardedCriteria()));
return Collections.unmodifiableCollection(Lists.newArrayList(handle.getCompletedCriteria()));
}
}

View File

@@ -30,7 +30,7 @@ public class CraftAttributeInstance implements AttributeInstance {
@Override
public void setBaseValue(double d) {
handle.setValue(d);
handle.setBaseValue(d);
}
@Override
@@ -46,7 +46,7 @@ public class CraftAttributeInstance implements AttributeInstance {
@Override
public void addModifier(AttributeModifier modifier) {
Preconditions.checkArgument(modifier != null, "modifier");
handle.addModifier(convert(modifier));
handle.addPermanentModifier(convert(modifier));
}
@Override
@@ -62,7 +62,7 @@ public class CraftAttributeInstance implements AttributeInstance {
@Override
public double getDefaultValue() {
return handle.getAttribute().getDefault();
return handle.getAttribute().getDefaultValue();
}
public static net.minecraft.world.entity.ai.attributes.AttributeModifier convert(AttributeModifier bukkit) {
@@ -70,6 +70,6 @@ public class CraftAttributeInstance implements AttributeInstance {
}
public static AttributeModifier convert(net.minecraft.world.entity.ai.attributes.AttributeModifier nms) {
return new AttributeModifier(nms.getUniqueId(), nms.getName(), nms.getAmount(), AttributeModifier.Operation.values()[nms.getOperation().ordinal()]);
return new AttributeModifier(nms.getId(), nms.getName(), nms.getAmount(), AttributeModifier.Operation.values()[nms.getOperation().ordinal()]);
}
}

View File

@@ -21,7 +21,7 @@ public class CraftAttributeMap implements Attributable {
@Override
public AttributeInstance getAttribute(Attribute attribute) {
Preconditions.checkArgument(attribute != null, "attribute");
net.minecraft.world.entity.ai.attributes.AttributeModifiable nms = handle.a(toMinecraft(attribute));
net.minecraft.world.entity.ai.attributes.AttributeModifiable nms = handle.getInstance(toMinecraft(attribute));
return (nms == null) ? null : new CraftAttributeInstance(nms, attribute);
}

View File

@@ -32,7 +32,7 @@ public final class CapturedBlockState extends CraftBlockState {
Random random = generatoraccessseed.getRandom();
// Begin copied block from WorldGenFeatureTreeBeehive
TileEntity tileentity = generatoraccessseed.getTileEntity(blockposition1);
TileEntity tileentity = generatoraccessseed.getBlockEntity(blockposition1);
if (tileentity instanceof TileEntityBeehive) {
TileEntityBeehive tileentitybeehive = (TileEntityBeehive) tileentity;
@@ -41,7 +41,7 @@ public final class CapturedBlockState extends CraftBlockState {
for (int k = 0; k < j; ++k) {
EntityBee entitybee = new EntityBee(EntityTypes.BEE, generatoraccessseed.getMinecraftWorld());
tileentitybeehive.a(entitybee, false, random.nextInt(599));
tileentitybeehive.addOccupantWithPresetTicks(entitybee, false, random.nextInt(599));
}
}
// End copied block

View File

@@ -27,7 +27,7 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
public void load(TileEntityBanner banner) {
super.load(banner);
base = DyeColor.getByWoolData((byte) ((BlockBannerAbstract) this.data.getBlock()).getColor().getColorIndex());
base = DyeColor.getByWoolData((byte) ((BlockBannerAbstract) this.data.getBlock()).getColor().getId());
patterns = new ArrayList<Pattern>();
if (banner.itemPatterns != null) {
@@ -88,14 +88,14 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
public void applyTo(TileEntityBanner banner) {
super.applyTo(banner);
banner.baseColor = EnumColor.fromColorIndex(base.getWoolData());
banner.baseColor = EnumColor.byId(base.getWoolData());
NBTTagList newPatterns = new NBTTagList();
for (Pattern p : patterns) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInt("Color", p.getColor().getWoolData());
compound.setString("Pattern", p.getPattern().getIdentifier());
compound.putInt("Color", p.getColor().getWoolData());
compound.putString("Pattern", p.getPattern().getIdentifier());
newPatterns.add(compound);
}
banner.itemPatterns = newPatterns;

View File

@@ -33,13 +33,13 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr
public void open() {
requirePlaced();
if (!getTileEntity().openersCounter.opened) {
IBlockData blockData = getTileEntity().getBlock();
boolean open = blockData.get(BlockBarrel.OPEN);
IBlockData blockData = getTileEntity().getBlockState();
boolean open = blockData.getValue(BlockBarrel.OPEN);
if (!open) {
getTileEntity().setOpenFlag(blockData, true);
getTileEntity().updateBlockState(blockData, true);
if (getWorldHandle() instanceof net.minecraft.world.level.World) {
getTileEntity().playOpenSound(blockData, SoundEffects.BARREL_OPEN);
getTileEntity().playSound(blockData, SoundEffects.BARREL_OPEN);
}
}
}
@@ -50,10 +50,10 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr
public void close() {
requirePlaced();
if (getTileEntity().openersCounter.opened) {
IBlockData blockData = getTileEntity().getBlock();
getTileEntity().setOpenFlag(blockData, false);
IBlockData blockData = getTileEntity().getBlockState();
getTileEntity().updateBlockState(blockData, false);
if (getWorldHandle() instanceof net.minecraft.world.level.World) {
getTileEntity().playOpenSound(blockData, SoundEffects.BARREL_CLOSE);
getTileEntity().playSound(blockData, SoundEffects.BARREL_CLOSE);
}
}
getTileEntity().openersCounter.opened = false;

View File

@@ -29,7 +29,7 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme
if (tileEntity instanceof TileEntityBeacon) {
TileEntityBeacon beacon = (TileEntityBeacon) tileEntity;
Collection<EntityHuman> nms = TileEntityBeacon.getHumansInRange(beacon.getWorld(), beacon.getPosition(), beacon.levels);
Collection<EntityHuman> nms = TileEntityBeacon.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels);
Collection<LivingEntity> bukkit = new ArrayList<LivingEntity>(nms.size());
for (EntityHuman human : nms) {
@@ -55,7 +55,7 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme
@Override
public void setPrimaryEffect(PotionEffectType effect) {
this.getSnapshot().primaryPower = (effect != null) ? MobEffectList.fromId(effect.getId()) : null;
this.getSnapshot().primaryPower = (effect != null) ? MobEffectList.byId(effect.getId()) : null;
}
@Override
@@ -65,7 +65,7 @@ public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> impleme
@Override
public void setSecondaryEffect(PotionEffectType effect) {
this.getSnapshot().secondaryPower = (effect != null) ? MobEffectList.fromId(effect.getId()) : null;
this.getSnapshot().secondaryPower = (effect != null) ? MobEffectList.byId(effect.getId()) : null;
}
@Override

View File

@@ -43,7 +43,7 @@ public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> imple
@Override
public int getEntityCount() {
return getSnapshot().getBeeCount();
return getSnapshot().getOccupantCount();
}
@Override
@@ -78,6 +78,6 @@ public class CraftBeehive extends CraftBlockEntityState<TileEntityBeehive> imple
public void addEntity(Bee entity) {
Preconditions.checkArgument(entity != null, "Entity must not be null");
getSnapshot().addBee(((CraftBee) entity).getHandle(), false);
getSnapshot().addOccupant(((CraftBee) entity).getHandle(), false);
}
}

View File

@@ -65,7 +65,7 @@ public class CraftBlock implements Block {
public CraftBlock(GeneratorAccess world, BlockPosition position) {
this.world = world;
this.position = position.immutableCopy();
this.position = position.immutable();
}
public static CraftBlock at(GeneratorAccess world, BlockPosition position) {
@@ -73,7 +73,7 @@ public class CraftBlock implements Block {
}
public net.minecraft.world.level.block.state.IBlockData getNMS() {
return world.getType(position);
return world.getBlockState(position);
}
public BlockPosition getPosition() {
@@ -149,12 +149,12 @@ public class CraftBlock implements Block {
}
private void setData(final byte data, int flag) {
world.setTypeAndData(position, CraftMagicNumbers.getBlock(getType(), data), flag);
world.setBlock(position, CraftMagicNumbers.getBlock(getType(), data), flag);
}
@Override
public byte getData() {
IBlockData blockData = world.getType(position);
IBlockData blockData = world.getBlockState(position);
return CraftMagicNumbers.toLegacyData(blockData);
}
@@ -188,21 +188,21 @@ public class CraftBlock implements Block {
public boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) {
IBlockData old = getNMS();
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
if (old.isTileEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
// SPIGOT-4612: faster - just clear tile
if (world instanceof net.minecraft.world.level.World) {
((net.minecraft.world.level.World) world).removeTileEntity(position);
((net.minecraft.world.level.World) world).removeBlockEntity(position);
} else {
world.setTypeAndData(position, Blocks.AIR.getBlockData(), 0);
world.setBlock(position, Blocks.AIR.defaultBlockState(), 0);
}
}
if (applyPhysics) {
return world.setTypeAndData(position, blockData, 3);
return world.setBlock(position, blockData, 3);
} else {
boolean success = world.setTypeAndData(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
boolean success = world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
if (success && world instanceof net.minecraft.world.level.World) {
world.getMinecraftWorld().notify(
world.getMinecraftWorld().sendBlockUpdated(
position,
old,
blockData,
@@ -215,12 +215,12 @@ public class CraftBlock implements Block {
@Override
public Material getType() {
return CraftMagicNumbers.getMaterial(world.getType(position).getBlock());
return CraftMagicNumbers.getMaterial(world.getBlockState(position).getBlock());
}
@Override
public byte getLightLevel() {
return (byte) world.getMinecraftWorld().getLightLevel(position);
return (byte) world.getMinecraftWorld().getMaxLocalRawBrightness(position);
}
@Override
@@ -271,7 +271,7 @@ public class CraftBlock implements Block {
@Override
public String toString() {
return "CraftBlock{pos=" + position + ",type=" + getType() + ",data=" + getNMS() + ",fluid=" + world.getFluid(position) + '}';
return "CraftBlock{pos=" + position + ",type=" + getType() + ",data=" + getNMS() + ",fluid=" + world.getFluidState(position) + '}';
}
public static BlockFace notchToBlockFace(EnumDirection notch) {
@@ -349,7 +349,7 @@ public class CraftBlock implements Block {
@Override
public double getTemperature() {
return world.getBiome(position).getAdjustedTemperature(position);
return world.getBiome(position).getTemperature(position);
}
@Override
@@ -359,12 +359,12 @@ public class CraftBlock implements Block {
@Override
public boolean isBlockPowered() {
return world.getMinecraftWorld().getBlockPower(position) > 0;
return world.getMinecraftWorld().getDirectSignalTo(position) > 0;
}
@Override
public boolean isBlockIndirectlyPowered() {
return world.getMinecraftWorld().isBlockIndirectlyPowered(position);
return world.getMinecraftWorld().hasNeighborSignal(position);
}
@Override
@@ -387,12 +387,12 @@ public class CraftBlock implements Block {
@Override
public boolean isBlockFacePowered(BlockFace face) {
return world.getMinecraftWorld().isBlockFacePowered(position, blockFaceToNotch(face));
return world.getMinecraftWorld().hasSignal(position, blockFaceToNotch(face));
}
@Override
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
int power = world.getMinecraftWorld().getBlockFacePower(position, blockFaceToNotch(face));
int power = world.getMinecraftWorld().getSignal(position, blockFaceToNotch(face));
Block relative = getRelative(face);
if (relative.getType() == Material.REDSTONE_WIRE) {
@@ -409,20 +409,20 @@ public class CraftBlock implements Block {
int x = getX();
int y = getY();
int z = getZ();
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = getPower(power, world.getType(new BlockPosition(x, y - 1, z)));
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = getPower(power, world.getType(new BlockPosition(x, y + 1, z)));
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = getPower(power, world.getType(new BlockPosition(x + 1, y, z)));
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = getPower(power, world.getType(new BlockPosition(x - 1, y, z)));
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = getPower(power, world.getType(new BlockPosition(x, y, z - 1)));
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = getPower(power, world.getType(new BlockPosition(x, y, z + 1)));
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = getPower(power, world.getBlockState(new BlockPosition(x, y - 1, z)));
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = getPower(power, world.getBlockState(new BlockPosition(x, y + 1, z)));
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = getPower(power, world.getBlockState(new BlockPosition(x + 1, y, z)));
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = getPower(power, world.getBlockState(new BlockPosition(x - 1, y, z)));
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = getPower(power, world.getBlockState(new BlockPosition(x, y, z - 1)));
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.hasSignal(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = getPower(power, world.getBlockState(new BlockPosition(x, y, z + 1)));
return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
}
private static int getPower(int i, IBlockData iblockdata) {
if (!iblockdata.a(Blocks.REDSTONE_WIRE)) {
if (!iblockdata.is(Blocks.REDSTONE_WIRE)) {
return i;
} else {
int j = iblockdata.get(BlockRedstoneWire.POWER);
int j = iblockdata.getValue(BlockRedstoneWire.POWER);
return j > i ? j : i;
}
@@ -445,7 +445,7 @@ public class CraftBlock implements Block {
@Override
public PistonMoveReaction getPistonMoveReaction() {
return PistonMoveReaction.getById(getNMS().getPushReaction().ordinal());
return PistonMoveReaction.getById(getNMS().getPistonPushReaction().ordinal());
}
@Override
@@ -462,18 +462,18 @@ public class CraftBlock implements Block {
boolean result = false;
// Modelled off EntityHuman#hasBlock
if (block != Blocks.AIR && (item == null || !iblockdata.isRequiresSpecialTool() || nmsItem.canDestroySpecialBlock(iblockdata))) {
net.minecraft.world.level.block.Block.dropItems(iblockdata, world.getMinecraftWorld(), position, world.getTileEntity(position), null, nmsItem);
if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) {
net.minecraft.world.level.block.Block.dropResources(iblockdata, world.getMinecraftWorld(), position, world.getBlockEntity(position), null, nmsItem);
result = true;
}
return setTypeAndData(Blocks.AIR.getBlockData(), true) && result;
return setTypeAndData(Blocks.AIR.defaultBlockState(), true) && result;
}
@Override
public boolean applyBoneMeal(BlockFace face) {
EnumDirection direction = blockFaceToNotch(face);
ItemActionContext context = new ItemActionContext(getCraftWorld().getHandle(), null, EnumHand.MAIN_HAND, Items.BONE_MEAL.createItemStack(), new MovingObjectPositionBlock(Vec3D.ZERO, direction, getPosition(), false));
ItemActionContext context = new ItemActionContext(getCraftWorld().getHandle(), null, EnumHand.MAIN_HAND, Items.BONE_MEAL.getDefaultInstance(), new MovingObjectPositionBlock(Vec3D.ZERO, direction, getPosition(), false));
return ItemBoneMeal.applyBonemeal(context) == EnumInteractionResult.SUCCESS;
}
@@ -495,7 +495,7 @@ public class CraftBlock implements Block {
// Modelled off EntityHuman#hasBlock
if (item == null || isPreferredTool(iblockdata, nms)) {
return net.minecraft.world.level.block.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)
return net.minecraft.world.level.block.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getBlockEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)
.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList());
} else {
return Collections.emptyList();
@@ -512,11 +512,11 @@ public class CraftBlock implements Block {
@Override
public float getBreakSpeed(Player player) {
Preconditions.checkArgument(player != null, "player cannot be null");
return getNMS().getDamage(((CraftPlayer) player).getHandle(), world, position);
return getNMS().getDestroyProgress(((CraftPlayer) player).getHandle(), world, position);
}
private boolean isPreferredTool(IBlockData iblockdata, net.minecraft.world.item.ItemStack nmsItem) {
return !iblockdata.isRequiresSpecialTool() || nmsItem.canDestroySpecialBlock(iblockdata);
return !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata);
}
@Override
@@ -563,7 +563,7 @@ public class CraftBlock implements Block {
Vec3D startPos = new Vec3D(start.getX(), start.getY(), start.getZ());
Vec3D endPos = new Vec3D(start.getX() + dir.getX(), start.getY() + dir.getY(), start.getZ() + dir.getZ());
MovingObjectPosition nmsHitResult = world.rayTraceBlock(new RayTrace(startPos, endPos, RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null), position);
MovingObjectPosition nmsHitResult = world.clip(new RayTrace(startPos, endPos, RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null), position);
return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult);
}
@@ -575,7 +575,7 @@ public class CraftBlock implements Block {
return new BoundingBox(); // Return an empty bounding box if the block has no dimension
}
AxisAlignedBB aabb = shape.getBoundingBox();
AxisAlignedBB aabb = shape.bounds();
return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ);
}

View File

@@ -12,7 +12,7 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB
private final T snapshot;
public CraftBlockEntityState(World world, T tileEntity) {
super(world, tileEntity.getPosition(), tileEntity.getBlock());
super(world, tileEntity.getBlockPos(), tileEntity.getBlockState());
this.tileEntity = tileEntity;
@@ -30,15 +30,15 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB
return null;
}
NBTTagCompound nbtTagCompound = tileEntity.save(new NBTTagCompound());
T snapshot = (T) TileEntity.create(getPosition(), getHandle(), nbtTagCompound);
NBTTagCompound nbtTagCompound = tileEntity.saveWithFullMetadata();
T snapshot = (T) TileEntity.loadStatic(getPosition(), getHandle(), nbtTagCompound);
return snapshot;
}
// copies the TileEntity-specific data, retains the position
private void copyData(T from, T to) {
NBTTagCompound nbtTagCompound = from.save(new NBTTagCompound());
NBTTagCompound nbtTagCompound = from.saveWithFullMetadata();
to.load(nbtTagCompound);
}
@@ -56,7 +56,7 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB
protected TileEntity getTileEntityFromWorld() {
requirePlaced();
return getWorldHandle().getTileEntity(this.getPosition());
return getWorldHandle().getBlockEntity(this.getPosition());
}
// gets the NBT data of the TileEntity represented by this block state
@@ -64,7 +64,7 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB
// update snapshot
applyTo(snapshot);
return snapshot.save(new NBTTagCompound());
return snapshot.saveWithFullMetadata();
}
// copies the data of the given tile entity to this block state
@@ -94,7 +94,7 @@ public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftB
if (isApplicable(tile)) {
applyTo((T) tile);
tile.update();
tile.setChanged();
}
}

View File

@@ -161,7 +161,7 @@ public class CraftBlockState implements BlockState {
Preconditions.checkArgument(type.isBlock(), "Material must be a block!");
if (this.getType() != type) {
this.data = CraftMagicNumbers.getBlock(type).getBlockData();
this.data = CraftMagicNumbers.getBlock(type).defaultBlockState();
}
}
@@ -216,7 +216,7 @@ public class CraftBlockState implements BlockState {
IBlockData newBlock = this.data;
block.setTypeAndData(newBlock, applyPhysics);
if (access instanceof net.minecraft.world.level.World) {
world.getHandle().notify(
world.getHandle().sendBlockUpdated(
position,
block.getNMS(),
newBlock,
@@ -226,7 +226,7 @@ public class CraftBlockState implements BlockState {
// Update levers etc
if (false && applyPhysics && getData() instanceof Attachable) { // Call does not map to new API
world.getHandle().applyPhysics(position.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock());
world.getHandle().updateNeighborsAt(position.relative(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock());
}
return true;

View File

@@ -326,7 +326,7 @@ public final class CraftBlockStates {
CraftWorld world = (CraftWorld) block.getWorld();
BlockPosition blockPosition = craftBlock.getPosition();
IBlockData blockData = craftBlock.getNMS();
TileEntity tileEntity = craftBlock.getHandle().getTileEntity(blockPosition);
TileEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition);
CraftBlockState blockState = getBlockState(world, blockPosition, blockData, tileEntity);
blockState.setWorldHandle(craftBlock.getHandle()); // Inject the block's generator access
return blockState;
@@ -338,7 +338,7 @@ public final class CraftBlockStates {
public static BlockState getBlockState(BlockPosition blockPosition, Material material, @Nullable NBTTagCompound blockEntityTag) {
Preconditions.checkNotNull(material, "material is null");
IBlockData blockData = CraftMagicNumbers.getBlock(material).getBlockData();
IBlockData blockData = CraftMagicNumbers.getBlock(material).defaultBlockState();
return getBlockState(blockPosition, blockData, blockEntityTag);
}
@@ -349,7 +349,7 @@ public final class CraftBlockStates {
public static BlockState getBlockState(BlockPosition blockPosition, IBlockData blockData, @Nullable NBTTagCompound blockEntityTag) {
Preconditions.checkNotNull(blockPosition, "blockPosition is null");
Preconditions.checkNotNull(blockData, "blockData is null");
TileEntity tileEntity = (blockEntityTag == null) ? null : TileEntity.create(blockPosition, blockData, blockEntityTag);
TileEntity tileEntity = (blockEntityTag == null) ? null : TileEntity.loadStatic(blockPosition, blockData, blockEntityTag);
return getBlockState(null, blockPosition, blockData, tileEntity);
}

View File

@@ -45,7 +45,7 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
CraftWorld world = (CraftWorld) this.getWorld();
BlockChest blockChest = (BlockChest) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST);
ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition(), true);
ITileInventory nms = blockChest.getMenuProvider(data, world.getHandle(), this.getPosition(), true);
if (nms instanceof BlockChest.DoubleInventory) {
inventory = new CraftInventoryDoubleChest((BlockChest.DoubleInventory) nms);
@@ -57,9 +57,9 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
public void open() {
requirePlaced();
if (!getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
IBlockData block = getTileEntity().getBlock();
getTileEntity().getWorld().playBlockAction(getPosition(), block.getBlock(), 1, getTileEntity().openersCounter.getOpenerCount() + 1);
TileEntityChest.playOpenSound(getTileEntity().getWorld(), getPosition(), block, SoundEffects.CHEST_OPEN);
IBlockData block = getTileEntity().getBlockState();
getTileEntity().getLevel().blockEvent(getPosition(), block.getBlock(), 1, getTileEntity().openersCounter.getOpenerCount() + 1);
TileEntityChest.playSound(getTileEntity().getLevel(), getPosition(), block, SoundEffects.CHEST_OPEN);
}
getTileEntity().openersCounter.opened = true;
}
@@ -68,9 +68,9 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
public void close() {
requirePlaced();
if (getTileEntity().openersCounter.opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
IBlockData block = getTileEntity().getBlock();
getTileEntity().getWorld().playBlockAction(getPosition(), block.getBlock(), 1, 0);
TileEntityChest.playOpenSound(getTileEntity().getWorld(), getPosition(), block, SoundEffects.CHEST_CLOSE);
IBlockData block = getTileEntity().getBlockState();
getTileEntity().getLevel().blockEvent(getPosition(), block.getBlock(), 1, 0);
TileEntityChest.playSound(getTileEntity().getLevel(), getPosition(), block, SoundEffects.CHEST_CLOSE);
}
getTileEntity().openersCounter.opened = false;
}

View File

@@ -1,8 +1,7 @@
package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import net.minecraft.core.BlockPosition;
import net.minecraft.resources.MinecraftKey;
import java.util.Optional;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
import org.bukkit.World;
@@ -17,8 +16,8 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
@Override
public EntityType getSpawnedType() {
MinecraftKey key = this.getSnapshot().getSpawner().getMobName(null, BlockPosition.ZERO);
return (key == null) ? EntityType.PIG : EntityType.fromName(key.getKey());
Optional<EntityTypes<?>> type = EntityTypes.by(this.getSnapshot().getSpawner().nextSpawnData.getEntityToSpawn());
return (type.isEmpty()) ? EntityType.PIG : EntityType.fromName(EntityTypes.getKey(type.get()).getPath());
}
@Override
@@ -27,12 +26,13 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
throw new IllegalArgumentException("Can't spawn EntityType " + entityType + " from mobspawners!");
}
this.getSnapshot().getSpawner().setMobName(EntityTypes.a(entityType.getName()).get());
this.getSnapshot().getSpawner().setEntityId(EntityTypes.byString(entityType.getName()).get());
}
@Override
public String getCreatureTypeName() {
return this.getSnapshot().getSpawner().getMobName(null, BlockPosition.ZERO).getKey();
Optional<EntityTypes<?>> type = EntityTypes.by(this.getSnapshot().getSpawner().nextSpawnData.getEntityToSpawn());
return (type.isEmpty()) ? "" : EntityTypes.getKey(type.get()).getPath();
}
@Override

View File

@@ -53,7 +53,7 @@ public class CraftDispenser extends CraftLootable<TileEntityDispenser> implement
CraftWorld world = (CraftWorld) this.getWorld();
BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER;
dispense.dispense(world.getHandle(), this.getPosition());
dispense.dispenseFrom(world.getHandle(), this.getPosition());
return true;
} else {
return false;

View File

@@ -40,7 +40,7 @@ public class CraftDropper extends CraftLootable<TileEntityDropper> implements Dr
CraftWorld world = (CraftWorld) this.getWorld();
BlockDropper drop = (BlockDropper) Blocks.DROPPER;
drop.dispense(world.getHandle(), this.getPosition());
drop.dispenseFrom(world.getHandle(), this.getPosition());
}
}
}

View File

@@ -36,7 +36,7 @@ public abstract class CraftFurnace<T extends TileEntityFurnace> extends CraftCon
public void setBurnTime(short burnTime) {
this.getSnapshot().litTime = burnTime;
// SPIGOT-844: Allow lighting and relighting using this API
this.data = this.data.set(BlockFurnace.LIT, burnTime > 0);
this.data = this.data.setValue(BlockFurnace.LIT, burnTime > 0);
}
@Override

View File

@@ -28,9 +28,9 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
CraftWorld world = (CraftWorld) this.getWorld();
Material record = this.getPlaying();
if (record == Material.AIR) {
getWorldHandle().setTypeAndData(this.getPosition(), Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, false), 3);
getWorldHandle().setBlock(this.getPosition(), Blocks.JUKEBOX.defaultBlockState().setValue(BlockJukeBox.HAS_RECORD, false), 3);
} else {
getWorldHandle().setTypeAndData(this.getPosition(), Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, true), 3);
getWorldHandle().setBlock(this.getPosition(), Blocks.JUKEBOX.defaultBlockState().setValue(BlockJukeBox.HAS_RECORD, true), 3);
}
world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record);
}
@@ -63,15 +63,15 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
ItemStack nms = CraftItemStack.asNMSCopy(record);
this.getSnapshot().setRecord(nms);
if (nms.isEmpty()) {
this.data = this.data.set(BlockJukeBox.HAS_RECORD, false);
this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, false);
} else {
this.data = this.data.set(BlockJukeBox.HAS_RECORD, true);
this.data = this.data.setValue(BlockJukeBox.HAS_RECORD, true);
}
}
@Override
public boolean isPlaying() {
return getHandle().get(BlockJukeBox.HAS_RECORD);
return getHandle().getValue(BlockJukeBox.HAS_RECORD);
}
@Override
@@ -89,7 +89,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> imple
TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity;
boolean result = !jukebox.getRecord().isEmpty();
CraftWorld world = (CraftWorld) this.getWorld();
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), getPosition());
((BlockJukeBox) Blocks.JUKEBOX).dropRecording(world.getHandle(), getPosition());
return result;
}
}

View File

@@ -43,7 +43,7 @@ public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> imple
boolean result = super.update(force, applyPhysics);
if (result && this.getType() == Material.LECTERN && getWorldHandle() instanceof net.minecraft.world.level.World) {
BlockLectern.a(this.world.getHandle(), this.getPosition(), this.getHandle());
BlockLectern.signalPageChange(this.world.getHandle(), this.getPosition(), this.getHandle());
}
return result;

View File

@@ -36,15 +36,15 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme
public DyeColor getColor() {
EnumColor color = ((BlockShulkerBox) CraftMagicNumbers.getBlock(this.getType())).color;
return (color == null) ? null : DyeColor.getByWoolData((byte) color.getColorIndex());
return (color == null) ? null : DyeColor.getByWoolData((byte) color.getId());
}
@Override
public void open() {
requirePlaced();
if (!getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
net.minecraft.world.level.World world = getTileEntity().getWorld();
world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 1);
net.minecraft.world.level.World world = getTileEntity().getLevel();
world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 1);
world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
}
getTileEntity().opened = true;
@@ -54,8 +54,8 @@ public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> impleme
public void close() {
requirePlaced();
if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.World) {
net.minecraft.world.level.World world = getTileEntity().getWorld();
world.playBlockAction(getPosition(), getTileEntity().getBlock().getBlock(), 1, 0);
net.minecraft.world.level.World world = getTileEntity().getLevel();
world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 0);
world.playSound(null, getPosition(), SoundEffects.SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
}
getTileEntity().opened = false;

View File

@@ -64,12 +64,12 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
@Override
public DyeColor getColor() {
return DyeColor.getByWoolData((byte) getSnapshot().getColor().getColorIndex());
return DyeColor.getByWoolData((byte) getSnapshot().getColor().getId());
}
@Override
public void setColor(DyeColor color) {
getSnapshot().setColor(EnumColor.fromColorIndex(color.getWoolData()));
getSnapshot().setColor(EnumColor.byId(color.getWoolData()));
}
@Override
@@ -82,7 +82,7 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
if (line.equals(originalLines[i])) {
continue; // The line contents are still the same, skip.
}
sign.a(i, CraftChatMessage.fromString(line)[0]);
sign.setMessage(i, CraftChatMessage.fromString(line)[0]);
}
}
}

View File

@@ -65,7 +65,7 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
return false;
}
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(name).orElse(null);
GameProfile profile = MinecraftServer.getServer().getProfileCache().get(name).orElse(null);
if (profile == null) {
return false;
}
@@ -153,7 +153,7 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
super.applyTo(skull);
if (getSkullType() == SkullType.PLAYER) {
skull.setGameProfile(profile);
skull.setOwner(profile);
}
}
}

View File

@@ -49,7 +49,7 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
@Override
public void setAuthor(LivingEntity entity) {
Preconditions.checkArgument(entity != null, "Structure Block author entity cannot be null");
getSnapshot().setAuthor(((CraftLivingEntity) entity).getHandle());
getSnapshot().createdBy(((CraftLivingEntity) entity).getHandle());
}
@Override
@@ -105,7 +105,7 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
@Override
public UsageMode getUsageMode() {
return UsageMode.valueOf(getSnapshot().getUsageMode().name());
return UsageMode.valueOf(getSnapshot().getMode().name());
}
@Override
@@ -179,13 +179,13 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
// Ensure block type is correct
if (access instanceof net.minecraft.world.level.World) {
tileEntity.setUsageMode(tileEntity.getUsageMode());
tileEntity.setMode(tileEntity.getMode());
} else if (access != null) {
// Custom handle during world generation
// From TileEntityStructure#setUsageMode(BlockPropertyStructureMode)
net.minecraft.world.level.block.state.IBlockData data = access.getType(this.getPosition());
if (data.a(net.minecraft.world.level.block.Blocks.STRUCTURE_BLOCK)) {
access.setTypeAndData(this.getPosition(), data.set(net.minecraft.world.level.block.BlockStructure.MODE, tileEntity.getUsageMode()), 2);
net.minecraft.world.level.block.state.IBlockData data = access.getBlockState(this.getPosition());
if (data.is(net.minecraft.world.level.block.Blocks.STRUCTURE_BLOCK)) {
access.setBlock(this.getPosition(), data.setValue(net.minecraft.world.level.block.BlockStructure.MODE, tileEntity.getMode()), 2);
}
}
}

View File

@@ -60,7 +60,7 @@ public class CraftBlockData implements BlockData {
* @return the matching Bukkit type
*/
protected <B extends Enum<B>> B get(BlockStateEnum<?> nms, Class<B> bukkit) {
return toBukkit(state.get(nms), bukkit);
return toBukkit(state.getValue(nms), bukkit);
}
/**
@@ -76,7 +76,7 @@ public class CraftBlockData implements BlockData {
protected <B extends Enum<B>> Set<B> getValues(BlockStateEnum<?> nms, Class<B> bukkit) {
ImmutableSet.Builder<B> values = ImmutableSet.builder();
for (Enum<?> e : nms.getValues()) {
for (Enum<?> e : nms.getPossibleValues()) {
values.add(toBukkit(e, bukkit));
}
@@ -93,7 +93,7 @@ public class CraftBlockData implements BlockData {
*/
protected <B extends Enum<B>, N extends Enum<N> & INamable> void set(BlockStateEnum<N> nms, Enum<B> bukkit) {
this.parsedStates = null;
this.state = this.state.set(nms, toNMS(bukkit, nms.getType()));
this.state = this.state.setValue(nms, toNMS(bukkit, nms.getValueClass()));
}
@Override
@@ -106,7 +106,7 @@ public class CraftBlockData implements BlockData {
clone.parsedStates = null;
for (IBlockState parsed : craft.parsedStates.keySet()) {
clone.state = clone.state.set(parsed, craft.state.get(parsed));
clone.state = clone.state.setValue(parsed, craft.state.getValue(parsed));
}
return clone;
@@ -178,7 +178,7 @@ public class CraftBlockData implements BlockData {
*/
protected <T extends Comparable<T>> T get(IBlockState<T> ibs) {
// Straight integer or boolean getter
return this.state.get(ibs);
return this.state.getValue(ibs);
}
/**
@@ -192,12 +192,12 @@ public class CraftBlockData implements BlockData {
public <T extends Comparable<T>, V extends T> void set(IBlockState<T> ibs, V v) {
// Straight integer or boolean setter
this.parsedStates = null;
this.state = this.state.set(ibs, v);
this.state = this.state.setValue(ibs, v);
}
@Override
public String getAsString() {
return toString(state.getStateMap());
return toString(state.getValues());
}
@Override
@@ -235,10 +235,10 @@ public class CraftBlockData implements BlockData {
public NBTTagCompound toStates() {
NBTTagCompound compound = new NBTTagCompound();
for (Map.Entry<IBlockState<?>, Comparable<?>> entry : state.getStateMap().entrySet()) {
for (Map.Entry<IBlockState<?>, Comparable<?>> entry : state.getValues().entrySet()) {
IBlockState iblockstate = (IBlockState) entry.getKey();
compound.setString(iblockstate.getName(), iblockstate.a(entry.getValue()));
compound.putString(iblockstate.getName(), iblockstate.getName(entry.getValue()));
}
return compound;
@@ -303,9 +303,9 @@ public class CraftBlockData implements BlockData {
for (Block instance : IRegistry.BLOCK) {
if (instance.getClass() == block) {
if (state == null) {
state = instance.getStates().a(name);
state = instance.getStateDefinition().getProperty(name);
} else {
IBlockState<?> newState = instance.getStates().a(name);
IBlockState<?> newState = instance.getStateDefinition().getProperty(name);
Preconditions.checkState(state == newState, "State mistmatch %s,%s", state, newState);
}
@@ -510,16 +510,16 @@ public class CraftBlockData implements BlockData {
}
StringReader reader = new StringReader(data);
ArgumentBlock arg = new ArgumentBlock(reader, false).a(false);
ArgumentBlock arg = new ArgumentBlock(reader, false).parse(false);
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data: " + data);
blockData = arg.getBlockData();
parsed = arg.getStateMap();
blockData = arg.getState();
parsed = arg.getProperties();
} catch (CommandSyntaxException ex) {
throw new IllegalArgumentException("Could not parse data: " + data, ex);
}
} else {
blockData = block.getBlockData();
blockData = block.defaultBlockState();
}
CraftBlockData craft = fromData(blockData);
@@ -533,6 +533,6 @@ public class CraftBlockData implements BlockData {
@Override
public SoundGroup getSoundGroup() {
return CraftSoundGroup.getSoundGroup(state.getStepSound());
return CraftSoundGroup.getSoundGroup(state.getSoundType());
}
}

View File

@@ -3,6 +3,8 @@
*/
package org.bukkit.craftbukkit.block.impl;
import org.bukkit.block.data.type.BigDripleaf.Tilt;
public final class CraftBigDripleaf extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.BigDripleaf, org.bukkit.block.data.type.Dripleaf, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged {
public CraftBigDripleaf() {

View File

@@ -0,0 +1,168 @@
// Based on net.minecraft.bundler.Main
package org.bukkit.craftbukkit.bootstrap;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] argv) {
new Main().run(argv);
}
private void run(String[] argv) {
try {
String defaultMainClassName = readResource("main-class", BufferedReader::readLine);
String mainClassName = System.getProperty("bundlerMainClass", defaultMainClassName);
String repoDir = System.getProperty("bundlerRepoDir", "bundler");
Path outputDir = Paths.get(repoDir).toAbsolutePath();
Files.createDirectories(outputDir);
System.out.println("Unbundling libraries to " + outputDir);
boolean readOnly = Boolean.getBoolean("bundlerReadOnly");
List<URL> extractedUrls = new ArrayList<>();
readAndExtractDir("versions", outputDir, extractedUrls, readOnly);
readAndExtractDir("libraries", outputDir, extractedUrls, readOnly);
if (mainClassName == null || mainClassName.isEmpty()) {
System.out.println("Empty main class specified, exiting");
System.exit(0);
}
ClassLoader maybePlatformClassLoader = getClass().getClassLoader().getParent();
URLClassLoader classLoader = new URLClassLoader(extractedUrls.toArray(new URL[0]), maybePlatformClassLoader);
System.out.println("Starting server");
Thread runThread = new Thread(() -> {
try {
Class<?> mainClass = Class.forName(mainClassName, true, classLoader);
MethodHandle mainHandle = MethodHandles.lookup().findStatic(mainClass, "main", MethodType.methodType(void.class, String[].class)).asFixedArity();
mainHandle.invoke(argv);
} catch (Throwable t) {
Thrower.INSTANCE.sneakyThrow(t);
}
}, "ServerMain");
runThread.setContextClassLoader(classLoader);
runThread.start();
} catch (Exception e) {
e.printStackTrace(System.out);
System.out.println("Failed to extract server libraries, exiting");
}
}
private <T> T readResource(String resource, ResourceParser<T> parser) throws Exception {
String fullPath = "/META-INF/" + resource;
try (InputStream is = getClass().getResourceAsStream(fullPath)) {
if (is == null) {
throw new IllegalStateException("Resource " + fullPath + " not found");
}
return parser.parse(new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)));
}
}
private void readAndExtractDir(String subdir, Path outputDir, List<URL> extractedUrls, boolean readOnly) throws Exception {
List<FileEntry> entries = readResource(subdir + ".list", reader -> reader.lines().map(FileEntry::parseLine).toList());
Path subdirPath = outputDir.resolve(subdir);
for (FileEntry entry : entries) {
if (entry.path.startsWith("minecraft-server")) {
continue;
}
Path outputFile = subdirPath.resolve(entry.path);
if (!readOnly) {
checkAndExtractJar(subdir, entry, outputFile);
}
extractedUrls.add(outputFile.toUri().toURL());
}
}
private void checkAndExtractJar(String subdir, FileEntry entry, Path outputFile) throws Exception {
if (!Files.exists(outputFile) || !checkIntegrity(outputFile, entry.hash())) {
System.out.printf("Unpacking %s (%s:%s) to %s%n", entry.path, subdir, entry.id, outputFile);
extractJar(subdir, entry.path, outputFile);
}
}
private void extractJar(String subdir, String jarPath, Path outputFile) throws IOException {
Files.createDirectories(outputFile.getParent());
try (InputStream input = getClass().getResourceAsStream("/META-INF/" + subdir + "/" + jarPath)) {
if (input == null) {
throw new IllegalStateException("Declared library " + jarPath + " not found");
}
Files.copy(input, outputFile, StandardCopyOption.REPLACE_EXISTING);
}
}
private static boolean checkIntegrity(Path file, String expectedHash) throws Exception {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
try (InputStream output = Files.newInputStream(file)) {
output.transferTo(new DigestOutputStream(OutputStream.nullOutputStream(), digest));
String actualHash = byteToHex(digest.digest());
if (actualHash.equalsIgnoreCase(expectedHash)) {
return true;
}
System.out.printf("Expected file %s to have hash %s, but got %s%n", new Object[]{file, expectedHash, actualHash});
}
return false;
}
private static String byteToHex(byte[] bytes) {
StringBuilder result = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
result.append(Character.forDigit(b >> 4 & 0xF, 16));
result.append(Character.forDigit(b >> 0 & 0xF, 16));
}
return result.toString();
}
@FunctionalInterface
private static interface ResourceParser<T> {
T parse(BufferedReader param1BufferedReader) throws Exception;
}
private static final record FileEntry(String hash, String id, String path) {
public static FileEntry parseLine(String line) {
String[] fields = line.split(" ");
if (fields.length != 2) {
throw new IllegalStateException("Malformed library entry: " + line);
}
String path = fields[1].substring(1);
return new FileEntry(fields[0], path, path);
}
}
private static class Thrower<T extends Throwable> {
private static final Thrower<RuntimeException> INSTANCE = new Thrower();
public void sneakyThrow(Throwable exception) throws T {
throw (T) exception;
}
}
}

View File

@@ -48,9 +48,9 @@ public class CraftBossBar implements BossBar {
private void initialize() {
this.flags = new HashMap<>();
this.flags.put(BarFlag.DARKEN_SKY, new FlagContainer(handle::isDarkenSky, handle::setDarkenSky));
this.flags.put(BarFlag.PLAY_BOSS_MUSIC, new FlagContainer(handle::isPlayMusic, handle::setPlayMusic));
this.flags.put(BarFlag.CREATE_FOG, new FlagContainer(handle::isCreateFog, handle::setCreateFog));
this.flags.put(BarFlag.DARKEN_SKY, new FlagContainer(handle::shouldDarkenScreen, handle::setDarkenScreen));
this.flags.put(BarFlag.PLAY_BOSS_MUSIC, new FlagContainer(handle::shouldPlayBossMusic, handle::setPlayBossMusic));
this.flags.put(BarFlag.CREATE_FOG, new FlagContainer(handle::shouldCreateWorldFog, handle::setCreateWorldFog));
}
private BarColor convertColor(BossBattle.BarColor color) {
@@ -103,7 +103,7 @@ public class CraftBossBar implements BossBar {
@Override
public void setTitle(String title) {
handle.name = CraftChatMessage.fromString(title, true)[0];
handle.sendUpdate(PacketPlayOutBoss::createUpdateNamePacket);
handle.broadcast(PacketPlayOutBoss::createUpdateNamePacket);
}
@Override
@@ -114,7 +114,7 @@ public class CraftBossBar implements BossBar {
@Override
public void setColor(BarColor color) {
handle.color = convertColor(color);
handle.sendUpdate(PacketPlayOutBoss::createUpdateStylePacket);
handle.broadcast(PacketPlayOutBoss::createUpdateStylePacket);
}
@Override
@@ -125,7 +125,7 @@ public class CraftBossBar implements BossBar {
@Override
public void setStyle(BarStyle style) {
handle.overlay = convertStyle(style);
handle.sendUpdate(PacketPlayOutBoss::createUpdateStylePacket);
handle.broadcast(PacketPlayOutBoss::createUpdateStylePacket);
}
@Override

View File

@@ -40,22 +40,22 @@ public class CraftDragonBattle implements DragonBattle {
@Override
public boolean generateEndPortal(boolean withPortals) {
if (handle.portalLocation != null || handle.getExitPortalShape() != null) {
if (handle.portalLocation != null || handle.findExitPortal() != null) {
return false;
}
this.handle.generateExitPortal(withPortals);
this.handle.spawnExitPortal(withPortals);
return true;
}
@Override
public boolean hasBeenPreviouslyKilled() {
return handle.isPreviouslyKilled();
return handle.hasPreviouslyKilledDragon();
}
@Override
public void initiateRespawn() {
this.handle.initiateRespawn();
this.handle.tryRespawn();
}
@Override
@@ -71,13 +71,13 @@ public class CraftDragonBattle implements DragonBattle {
return false;
}
this.handle.setRespawnPhase(toNMSRespawnPhase(phase));
this.handle.setRespawnStage(toNMSRespawnPhase(phase));
return true;
}
@Override
public void resetCrystals() {
this.handle.resetCrystals();
this.handle.resetSpikeCrystals();
}
@Override

View File

@@ -13,7 +13,7 @@ public class CraftKeyedBossbar extends CraftBossBar implements KeyedBossBar {
@Override
public NamespacedKey getKey() {
return CraftNamespacedKey.fromMinecraft(getHandle().getKey());
return CraftNamespacedKey.fromMinecraft(getHandle().getTextId());
}
@Override

View File

@@ -46,7 +46,7 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command<Comman
@Override
public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandListenerWrapper> context, SuggestionsBuilder builder) throws CommandSyntaxException {
List<String> results = server.tabComplete(context.getSource().getBukkitSender(), builder.getInput(), context.getSource().getWorld(), context.getSource().getPosition(), true);
List<String> results = server.tabComplete(context.getSource().getBukkitSender(), builder.getInput(), context.getSource().getLevel(), context.getSource().getPosition(), true);
// Defaults to sub nodes, but we have just one giant args node, so offset accordingly
builder = builder.createOffset(builder.getInput().lastIndexOf(' ') + 1);

View File

@@ -24,7 +24,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
@Override
public Block getBlock() {
return CraftBlock.at(tile.getWorld(), tile.getPosition());
return CraftBlock.at(tile.getLevel(), tile.getBlockPos());
}
@Override
@@ -43,7 +43,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
@Override
public String getName() {
return block.getName();
return block.getTextName();
}
@Override

View File

@@ -42,7 +42,7 @@ public final class VanillaCommandWrapper extends BukkitCommand {
if (!testPermission(sender)) return true;
CommandListenerWrapper icommandlistener = getListener(sender);
dispatcher.a(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel), true);
dispatcher.performCommand(icommandlistener, toDispatcher(args, getName()), toDispatcher(args, commandLabel), true);
return true;
}
@@ -53,10 +53,10 @@ public final class VanillaCommandWrapper extends BukkitCommand {
Validate.notNull(alias, "Alias cannot be null");
CommandListenerWrapper icommandlistener = getListener(sender);
ParseResults<CommandListenerWrapper> parsed = dispatcher.a().parse(toDispatcher(args, getName()), icommandlistener);
ParseResults<CommandListenerWrapper> parsed = dispatcher.getDispatcher().parse(toDispatcher(args, getName()), icommandlistener);
List<String> results = new ArrayList<>();
dispatcher.a().getCompletionSuggestions(parsed).thenAccept((suggestions) -> {
dispatcher.getDispatcher().getCompletionSuggestions(parsed).thenAccept((suggestions) -> {
suggestions.getList().forEach((s) -> results.add(s.getText()));
});
@@ -65,19 +65,19 @@ public final class VanillaCommandWrapper extends BukkitCommand {
public static CommandListenerWrapper getListener(CommandSender sender) {
if (sender instanceof Player) {
return ((CraftPlayer) sender).getHandle().getCommandListener();
return ((CraftPlayer) sender).getHandle().createCommandSourceStack();
}
if (sender instanceof BlockCommandSender) {
return ((CraftBlockCommandSender) sender).getWrapper();
}
if (sender instanceof CommandMinecart) {
return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().getWrapper();
return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().createCommandSourceStack();
}
if (sender instanceof RemoteConsoleCommandSender) {
return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource.getWrapper();
return ((DedicatedServer) MinecraftServer.getServer()).rconConsoleSource.createCommandSourceStack();
}
if (sender instanceof ConsoleCommandSender) {
return ((CraftServer) sender.getServer()).getServer().getServerCommandListener();
return ((CraftServer) sender.getServer()).getServer().createCommandSourceStack();
}
if (sender instanceof ProxiedCommandSender) {
return ((ProxiedNativeCommandSender) sender).getHandle();

View File

@@ -25,7 +25,7 @@ public class CraftEnchantment extends Enchantment {
@Override
public int getStartLevel() {
return target.getStartLevel();
return target.getMinLevel();
}
@Override
@@ -66,7 +66,7 @@ public class CraftEnchantment extends Enchantment {
@Override
public boolean isTreasure() {
return target.isTreasure();
return target.isTreasureOnly();
}
@Override
@@ -185,7 +185,7 @@ public class CraftEnchantment extends Enchantment {
return false;
}
CraftEnchantment ench = (CraftEnchantment) other;
return !target.isCompatible(ench.target);
return !target.isCompatibleWith(ench.target);
}
public net.minecraft.world.item.enchantment.Enchantment getHandle() {

View File

@@ -41,7 +41,7 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
@Override
public int getMaxDomestication() {
return getHandle().getMaxDomestication();
return getHandle().getMaxTemper();
}
@Override
@@ -52,13 +52,13 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
@Override
public double getJumpStrength() {
return getHandle().getJumpStrength();
return getHandle().getCustomJump();
}
@Override
public void setJumpStrength(double strength) {
Validate.isTrue(strength >= 0, "Jump strength cannot be less than zero");
getHandle().getAttributeInstance(GenericAttributes.JUMP_STRENGTH).setValue(strength);
getHandle().getAttribute(GenericAttributes.JUMP_STRENGTH).setBaseValue(strength);
}
@Override
@@ -81,7 +81,7 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
public void setOwner(AnimalTamer owner) {
if (owner != null) {
setTamed(true);
getHandle().setGoalTarget(null, null, false);
getHandle().setTarget(null, null, false);
setOwnerUUID(owner.getUniqueId());
} else {
setTamed(false);

View File

@@ -16,7 +16,7 @@ public class CraftAgeable extends CraftCreature implements Ageable {
@Override
public void setAge(int age) {
getHandle().setAgeRaw(age);
getHandle().setAge(age);
}
@Override

View File

@@ -43,7 +43,7 @@ public class CraftAnimals extends CraftAgeable implements Animals {
@Override
public void setLoveModeTicks(int ticks) {
Preconditions.checkArgument(ticks >= 0, "Love mode ticks must be positive or 0");
getHandle().setLoveTicks(ticks);
getHandle().setInLoveTime(ticks);
}
@Override
@@ -53,7 +53,7 @@ public class CraftAnimals extends CraftAgeable implements Animals {
@Override
public boolean isBreedItem(ItemStack itemStack) {
return getHandle().isBreedItem(CraftItemStack.asNMSCopy(itemStack));
return getHandle().isFood(CraftItemStack.asNMSCopy(itemStack));
}
@Override

View File

@@ -133,7 +133,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
@Override
public void setColor(Color color) {
getHandle().setColor(color.asRGB());
getHandle().setFixedColor(color.asRGB());
}
@Override
@@ -141,7 +141,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
int effectId = effect.getType().getId();
MobEffect existing = null;
for (MobEffect mobEffect : getHandle().effects) {
if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
if (MobEffectList.getId(mobEffect.getEffect()) == effectId) {
existing = mobEffect;
}
}
@@ -174,7 +174,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
@Override
public boolean hasCustomEffect(PotionEffectType type) {
for (MobEffect effect : getHandle().effects) {
if (CraftPotionUtil.equals(effect.getMobEffect(), type)) {
if (CraftPotionUtil.equals(effect.getEffect(), type)) {
return true;
}
}
@@ -191,7 +191,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
int effectId = effect.getId();
MobEffect existing = null;
for (MobEffect mobEffect : getHandle().effects) {
if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
if (MobEffectList.getId(mobEffect.getEffect()) == effectId) {
existing = mobEffect;
}
}
@@ -206,26 +206,26 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
@Override
public void setBasePotionData(PotionData data) {
Validate.notNull(data, "PotionData cannot be null");
getHandle().setType(CraftPotionUtil.fromBukkit(data));
getHandle().setPotionType(CraftPotionUtil.fromBukkit(data));
}
@Override
public PotionData getBasePotionData() {
return CraftPotionUtil.toBukkit(getHandle().getType());
return CraftPotionUtil.toBukkit(getHandle().getPotionType());
}
@Override
public ProjectileSource getSource() {
EntityLiving source = getHandle().getSource();
EntityLiving source = getHandle().getOwner();
return (source == null) ? null : (LivingEntity) source.getBukkitEntity();
}
@Override
public void setSource(ProjectileSource shooter) {
if (shooter instanceof CraftLivingEntity) {
getHandle().setSource((EntityLiving) ((CraftLivingEntity) shooter).getHandle());
getHandle().setOwner((EntityLiving) ((CraftLivingEntity) shooter).getHandle());
} else {
getHandle().setSource((EntityLiving) null);
getHandle().setOwner((EntityLiving) null);
}
}
}

View File

@@ -144,12 +144,12 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@Override
public boolean hasBasePlate() {
return !getHandle().hasBasePlate();
return !getHandle().isNoBasePlate();
}
@Override
public void setBasePlate(boolean basePlate) {
getHandle().setBasePlate(!basePlate);
getHandle().setNoBasePlate(!basePlate);
}
@Override
@@ -171,12 +171,12 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@Override
public boolean hasArms() {
return getHandle().hasArms();
return getHandle().isShowArms();
}
@Override
public void setArms(boolean arms) {
getHandle().setArms(arms);
getHandle().setShowArms(arms);
}
@Override
@@ -217,16 +217,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@Override
public void addEquipmentLock(EquipmentSlot equipmentSlot, LockType lockType) {
getHandle().disabledSlots |= (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getSlotFlag() + lockType.ordinal() * 8);
getHandle().disabledSlots |= (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getFilterFlag() + lockType.ordinal() * 8);
}
@Override
public void removeEquipmentLock(EquipmentSlot equipmentSlot, LockType lockType) {
getHandle().disabledSlots &= ~(1 << CraftEquipmentSlot.getNMS(equipmentSlot).getSlotFlag() + lockType.ordinal() * 8);
getHandle().disabledSlots &= ~(1 << CraftEquipmentSlot.getNMS(equipmentSlot).getFilterFlag() + lockType.ordinal() * 8);
}
@Override
public boolean hasEquipmentLock(EquipmentSlot equipmentSlot, LockType lockType) {
return (getHandle().disabledSlots & (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getSlotFlag() + lockType.ordinal() * 8)) != 0;
return (getHandle().disabledSlots & (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getFilterFlag() + lockType.ordinal() * 8)) != 0;
}
}

View File

@@ -21,7 +21,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
@Override
public void setKnockbackStrength(int knockbackStrength) {
Validate.isTrue(knockbackStrength >= 0, "Knockback cannot be negative");
getHandle().setKnockbackStrength(knockbackStrength);
getHandle().setKnockback(knockbackStrength);
}
@Override
@@ -31,13 +31,13 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
@Override
public double getDamage() {
return getHandle().getDamage();
return getHandle().getBaseDamage();
}
@Override
public void setDamage(double damage) {
Preconditions.checkArgument(damage >= 0, "Damage must be positive");
getHandle().setDamage(damage);
getHandle().setBaseDamage(damage);
}
@Override
@@ -54,12 +54,12 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
@Override
public boolean isCritical() {
return getHandle().isCritical();
return getHandle().isCritArrow();
}
@Override
public void setCritical(boolean critical) {
getHandle().setCritical(critical);
getHandle().setCritArrow(critical);
}
@Override
@@ -70,9 +70,9 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
@Override
public void setShooter(ProjectileSource shooter) {
if (shooter instanceof Entity) {
getHandle().setShooter(((CraftEntity) shooter).getHandle());
getHandle().setOwner(((CraftEntity) shooter).getHandle());
} else {
getHandle().setShooter(null);
getHandle().setOwner(null);
}
getHandle().projectileSource = shooter;
}
@@ -88,7 +88,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
return null;
}
BlockPosition pos = getHandle().getChunkCoordinates();
BlockPosition pos = getHandle().blockPosition();
return getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
}
@@ -100,7 +100,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
@Override
public void setPickupStatus(PickupStatus status) {
Preconditions.checkNotNull(status, "status");
getHandle().pickup = EntityArrow.PickupStatus.a(status.ordinal());
getHandle().pickup = EntityArrow.PickupStatus.byOrdinal(status.ordinal());
}
@Override
@@ -113,7 +113,7 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow {
@Override
public boolean isShotFromCrossbow() {
return getHandle().isShotFromCrossbow();
return getHandle().shotFromCrossbow();
}
@Override

View File

@@ -27,11 +27,11 @@ public class CraftBat extends CraftAmbient implements Bat {
@Override
public boolean isAwake() {
return !getHandle().isAsleep();
return !getHandle().isResting();
}
@Override
public void setAwake(boolean state) {
getHandle().setAsleep(!state);
getHandle().setResting(!state);
}
}

View File

@@ -43,14 +43,14 @@ public class CraftBee extends CraftAnimals implements Bee {
@Override
public Location getFlower() {
BlockPosition flower = getHandle().getFlowerPos();
BlockPosition flower = getHandle().getSavedFlowerPos();
return (flower == null) ? null : new Location(getWorld(), flower.getX(), flower.getY(), flower.getZ());
}
@Override
public void setFlower(Location location) {
Preconditions.checkArgument(location == null || this.getWorld().equals(location.getWorld()), "Flower must be in same world");
getHandle().setFlowerPos(location == null ? null : new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
getHandle().setSavedFlowerPos(location == null ? null : new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
}
@Override
@@ -75,12 +75,12 @@ public class CraftBee extends CraftAnimals implements Bee {
@Override
public int getAnger() {
return getHandle().getAnger();
return getHandle().getRemainingPersistentAngerTime();
}
@Override
public void setAnger(int anger) {
getHandle().setAnger(anger);
getHandle().setRemainingPersistentAngerTime(anger);
}
@Override
@@ -90,6 +90,6 @@ public class CraftBee extends CraftAnimals implements Bee {
@Override
public void setCannotEnterHiveTicks(int ticks) {
getHandle().setCannotEnterHiveTicks(ticks);
getHandle().setStayOutOfHiveCountdown(ticks);
}
}

View File

@@ -14,7 +14,7 @@ public class CraftBoat extends CraftVehicle implements Boat {
@Override
public TreeSpecies getWoodType() {
return getTreeSpecies(getHandle().getType());
return getTreeSpecies(getHandle().getBoatType());
}
@Override

View File

@@ -44,11 +44,11 @@ public class CraftCat extends CraftTameableAnimal implements Cat {
@Override
public DyeColor getCollarColor() {
return DyeColor.getByWoolData((byte) getHandle().getCollarColor().getColorIndex());
return DyeColor.getByWoolData((byte) getHandle().getCollarColor().getId());
}
@Override
public void setCollarColor(DyeColor color) {
getHandle().setCollarColor(EnumColor.fromColorIndex(color.getWoolData()));
getHandle().setCollarColor(EnumColor.byId(color.getWoolData()));
}
}

View File

@@ -17,13 +17,13 @@ public abstract class CraftChestedHorse extends CraftAbstractHorse implements Ch
@Override
public boolean isCarryingChest() {
return getHandle().isCarryingChest();
return getHandle().hasChest();
}
@Override
public void setCarryingChest(boolean chest) {
if (chest == isCarryingChest()) return;
getHandle().setCarryingChest(chest);
getHandle().loadChest();
getHandle().setChest(chest);
getHandle().createInventory();
}
}

View File

@@ -73,7 +73,7 @@ public class CraftCreeper extends CraftMonster implements Creeper {
@Override
public void explode() {
getHandle().explode();
getHandle().explodeCreeper();
}
@Override

View File

@@ -14,12 +14,12 @@ public class CraftEnderCrystal extends CraftEntity implements EnderCrystal {
@Override
public boolean isShowingBottom() {
return getHandle().isShowingBottom();
return getHandle().showsBottom();
}
@Override
public void setShowingBottom(boolean showing) {
getHandle().setShowingBottom(showing);
getHandle().setShowBottom(showing);
}
@Override

View File

@@ -49,16 +49,16 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD
@Override
public Phase getPhase() {
return Phase.values()[getHandle().getDataWatcher().get(EntityEnderDragon.DATA_PHASE)];
return Phase.values()[getHandle().getEntityData().get(EntityEnderDragon.DATA_PHASE)];
}
@Override
public void setPhase(Phase phase) {
getHandle().getDragonControllerManager().setControllerPhase(getMinecraftPhase(phase));
getHandle().getPhaseManager().setPhase(getMinecraftPhase(phase));
}
public static Phase getBukkitPhase(DragonControllerPhase phase) {
return Phase.values()[phase.b()];
return Phase.values()[phase.getId()];
}
public static DragonControllerPhase getMinecraftPhase(Phase phase) {
@@ -73,7 +73,7 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD
@Override
public DragonBattle getDragonBattle() {
return getHandle().getEnderDragonBattle() != null ? new CraftDragonBattle(getHandle().getEnderDragonBattle()) : null;
return getHandle().getDragonFight() != null ? new CraftDragonBattle(getHandle().getDragonFight()) : null;
}
@Override

View File

@@ -39,7 +39,7 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
@Override
public void setTargetLocation(Location location) {
Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds");
getHandle().a(new BlockPosition(location.getX(), location.getY(), location.getZ()));
getHandle().signalTo(new BlockPosition(location.getX(), location.getY(), location.getZ()));
}
@Override
@@ -54,12 +54,12 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
@Override
public ItemStack getItem() {
return CraftItemStack.asBukkitCopy(getHandle().getSuppliedItem());
return CraftItemStack.asBukkitCopy(getHandle().getItem());
}
@Override
public void setItem(ItemStack item) {
getHandle().setItem(item != null ? CraftItemStack.asNMSCopy(item) : Items.ENDER_EYE.createItemStack());
getHandle().setItem(item != null ? CraftItemStack.asNMSCopy(item) : Items.ENDER_EYE.getDefaultInstance());
}
@Override

View File

@@ -18,24 +18,24 @@ public class CraftEnderman extends CraftMonster implements Enderman {
@Override
public MaterialData getCarriedMaterial() {
IBlockData blockData = getHandle().getCarried();
IBlockData blockData = getHandle().getCarriedBlock();
return (blockData == null) ? Material.AIR.getNewData((byte) 0) : CraftMagicNumbers.getMaterial(blockData);
}
@Override
public BlockData getCarriedBlock() {
IBlockData blockData = getHandle().getCarried();
IBlockData blockData = getHandle().getCarriedBlock();
return (blockData == null) ? null : CraftBlockData.fromData(blockData);
}
@Override
public void setCarriedMaterial(MaterialData data) {
getHandle().setCarried(CraftMagicNumbers.getBlock(data));
getHandle().setCarriedBlock(CraftMagicNumbers.getBlock(data));
}
@Override
public void setCarriedBlock(BlockData blockData) {
getHandle().setCarried(blockData == null ? null : ((CraftBlockData) blockData).getState());
getHandle().setCarriedBlock(blockData == null ? null : ((CraftBlockData) blockData).getState());
}
@Override

View File

@@ -408,16 +408,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public Location getLocation() {
return new Location(getWorld(), entity.locX(), entity.locY(), entity.locZ(), entity.getBukkitYaw(), entity.getXRot());
return new Location(getWorld(), entity.getX(), entity.getY(), entity.getZ(), entity.getBukkitYaw(), entity.getXRot());
}
@Override
public Location getLocation(Location loc) {
if (loc != null) {
loc.setWorld(getWorld());
loc.setX(entity.locX());
loc.setY(entity.locY());
loc.setZ(entity.locZ());
loc.setX(entity.getX());
loc.setY(entity.getY());
loc.setZ(entity.getZ());
loc.setYaw(entity.getBukkitYaw());
loc.setPitch(entity.getXRot());
}
@@ -427,25 +427,25 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public Vector getVelocity() {
return CraftVector.toBukkit(entity.getMot());
return CraftVector.toBukkit(entity.getDeltaMovement());
}
@Override
public void setVelocity(Vector velocity) {
Preconditions.checkArgument(velocity != null, "velocity");
velocity.checkFinite();
entity.setMot(CraftVector.toNMS(velocity));
entity.setDeltaMovement(CraftVector.toNMS(velocity));
entity.hurtMarked = true;
}
@Override
public double getHeight() {
return getHandle().getHeight();
return getHandle().getBbHeight();
}
@Override
public double getWidth() {
return getHandle().getWidth();
return getHandle().getBbWidth();
}
@Override
@@ -484,7 +484,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
entity.setXRot(pitch);
entity.yRotO = yaw;
entity.xRotO = pitch;
entity.setHeadRotation(yaw);
entity.setYHeadRot(yaw);
}
@Override
@@ -513,9 +513,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
// entity.setLocation() throws no event, and so cannot be cancelled
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
entity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
// SPIGOT-619: Force sync head rotation also
entity.setHeadRotation(location.getYaw());
entity.setYHeadRot(location.getYaw());
return true;
}
@@ -534,7 +534,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
Preconditions.checkState(!entity.generation, "Cannot get nearby entities during world generation");
List<Entity> notchEntityList = entity.level.getEntities(entity, entity.getBoundingBox().grow(x, y, z), Predicates.alwaysTrue());
List<Entity> notchEntityList = entity.level.getEntities(entity, entity.getBoundingBox().inflate(x, y, z), Predicates.alwaysTrue());
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());
for (Entity e : notchEntityList) {
@@ -555,7 +555,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public int getMaxFireTicks() {
return entity.getMaxFireTicks();
return entity.getFireImmuneTicks();
}
@Override
@@ -597,7 +597,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public void remove() {
entity.die();
entity.discard();
}
@Override
@@ -663,7 +663,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public boolean addPassenger(org.bukkit.entity.Entity passenger) {
Preconditions.checkArgument(passenger != null, "passenger == null");
return ((CraftEntity) passenger).getHandle().a(getHandle(), true);
return ((CraftEntity) passenger).getHandle().startRiding(getHandle(), true);
}
@Override
@@ -711,7 +711,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public UUID getUniqueId() {
return getHandle().getUniqueID();
return getHandle().getUUID();
}
@Override
@@ -737,7 +737,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
Preconditions.checkState(!entity.generation, "Cannot play effect during world generation");
if (type.getApplicable().isInstance(this)) {
this.getHandle().level.broadcastEntityEffect(getHandle(), type.getData());
this.getHandle().level.broadcastEntityEvent(getHandle(), type.getData());
}
}
@@ -841,7 +841,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public boolean isCustomNameVisible() {
return getHandle().getCustomNameVisible();
return getHandle().isCustomNameVisible();
}
@Override
@@ -866,7 +866,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public String getName() {
return CraftChatMessage.fromComponent(getHandle().getDisplayName());
return CraftChatMessage.fromComponent(getHandle().getName());
}
@Override
@@ -951,7 +951,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public boolean isInvulnerable() {
return getHandle().isInvulnerable(DamageSource.GENERIC);
return getHandle().isInvulnerableTo(DamageSource.GENERIC);
}
@Override
@@ -986,28 +986,28 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@Override
public Set<String> getScoreboardTags() {
return getHandle().getScoreboardTags();
return getHandle().getTags();
}
@Override
public boolean addScoreboardTag(String tag) {
return getHandle().addScoreboardTag(tag);
return getHandle().addTag(tag);
}
@Override
public boolean removeScoreboardTag(String tag) {
return getHandle().removeScoreboardTag(tag);
return getHandle().removeTag(tag);
}
@Override
public PistonMoveReaction getPistonMoveReaction() {
return PistonMoveReaction.getById(getHandle().getPushReaction().ordinal());
return PistonMoveReaction.getById(getHandle().getPistonPushReaction().ordinal());
}
@Override
public BlockFace getFacing() {
// Use this method over getDirection because it handles boats and minecarts.
return CraftBlock.notchToBlockFace(getHandle().getAdjustedDirection());
return CraftBlock.notchToBlockFace(getHandle().getMotionDirection());
}
@Override
@@ -1022,7 +1022,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public void storeBukkitValues(NBTTagCompound c) {
if (!this.persistentDataContainer.isEmpty()) {
c.set("BukkitValues", this.persistentDataContainer.toTagCompound());
c.put("BukkitValues", this.persistentDataContainer.toTagCompound());
}
}
@@ -1036,8 +1036,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
protected NBTTagCompound save() {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("id", getHandle().getSaveID());
getHandle().save(nbttagcompound);
nbttagcompound.putString("id", getHandle().getEncodeId());
getHandle().saveWithoutId(nbttagcompound);
return nbttagcompound;
}
@@ -1049,13 +1049,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
WorldServer world = ((CraftWorld) getWorld()).getHandle();
PlayerChunkMap.EntityTracker entityTracker = world.getChunkProvider().chunkMap.entityMap.get(getEntityId());
PlayerChunkMap.EntityTracker entityTracker = world.getChunkSource().chunkMap.entityMap.get(getEntityId());
if (entityTracker == null) {
return;
}
entityTracker.broadcast(getHandle().getPacket());
entityTracker.broadcast(getHandle().getAddEntityPacket());
}
private static PermissibleBase getPermissibleBase() {

View File

@@ -29,11 +29,11 @@ public class CraftEvoker extends CraftSpellcaster implements Evoker {
@Override
public Evoker.Spell getCurrentSpell() {
return Evoker.Spell.values()[getHandle().getSpell().ordinal()];
return Evoker.Spell.values()[getHandle().getCurrentSpell().ordinal()];
}
@Override
public void setCurrentSpell(Evoker.Spell spell) {
getHandle().setSpell(spell == null ? EntityIllagerWizard.Spell.NONE : EntityIllagerWizard.Spell.a(spell.ordinal()));
getHandle().setIsCastingSpell(spell == null ? EntityIllagerWizard.Spell.NONE : EntityIllagerWizard.Spell.byId(spell.ordinal()));
}
}

View File

@@ -37,6 +37,6 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs {
@Override
public void setOwner(LivingEntity owner) {
getHandle().a(owner == null ? null : ((CraftLivingEntity) owner).getHandle());
getHandle().setOwner(owner == null ? null : ((CraftLivingEntity) owner).getHandle());
}
}

View File

@@ -36,7 +36,7 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
@Override
public BlockData getBlockData() {
return CraftBlockData.fromData(getHandle().getBlock());
return CraftBlockData.fromData(getHandle().getBlockState());
}
@Override

View File

@@ -41,9 +41,9 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
@Override
public void setShooter(ProjectileSource shooter) {
if (shooter instanceof CraftLivingEntity) {
getHandle().setShooter(((CraftLivingEntity) shooter).getHandle());
getHandle().setOwner(((CraftLivingEntity) shooter).getHandle());
} else {
getHandle().setShooter(null);
getHandle().setOwner(null);
}
getHandle().projectileSource = shooter;
}

View File

@@ -19,11 +19,11 @@ public class CraftFirework extends CraftProjectile implements Firework {
public CraftFirework(CraftServer server, EntityFireworks entity) {
super(server, entity);
ItemStack item = getHandle().getDataWatcher().get(EntityFireworks.DATA_ID_FIREWORKS_ITEM);
ItemStack item = getHandle().getEntityData().get(EntityFireworks.DATA_ID_FIREWORKS_ITEM);
if (item.isEmpty()) {
item = new ItemStack(Items.FIREWORK_ROCKET);
getHandle().getDataWatcher().set(EntityFireworks.DATA_ID_FIREWORKS_ITEM, item);
getHandle().getEntityData().set(EntityFireworks.DATA_ID_FIREWORKS_ITEM, item);
}
this.item = CraftItemStack.asCraftMirror(item);
@@ -61,7 +61,7 @@ public class CraftFirework extends CraftProjectile implements Firework {
// Copied from EntityFireworks constructor, update firework lifetime/power
getHandle().lifetime = 10 * (1 + meta.getPower()) + random.nextInt(6) + random.nextInt(7);
getHandle().getDataWatcher().markDirty(EntityFireworks.DATA_ID_FIREWORKS_ITEM);
getHandle().getEntityData().markDirty(EntityFireworks.DATA_ID_FIREWORKS_ITEM);
}
@Override
@@ -76,6 +76,6 @@ public class CraftFirework extends CraftProjectile implements Firework {
@Override
public void setShotAtAngle(boolean shotAtAngle) {
getHandle().getDataWatcher().set(EntityFireworks.DATA_SHOT_AT_ANGLE, shotAtAngle);
getHandle().getEntityData().set(EntityFireworks.DATA_SHOT_AT_ANGLE, shotAtAngle);
}
}

View File

@@ -71,7 +71,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook {
EntityFishingHook hook = getHandle();
if (this.biteChance == -1) {
if (hook.level.isRainingAt(new BlockPosition(MathHelper.floor(hook.locX()), MathHelper.floor(hook.locY()) + 1, MathHelper.floor(hook.locZ())))) {
if (hook.level.isRainingAt(new BlockPosition(MathHelper.floor(hook.getX()), MathHelper.floor(hook.getY()) + 1, MathHelper.floor(hook.getZ())))) {
return 1 / 300.0;
}
return 1 / 500.0;
@@ -87,7 +87,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook {
@Override
public boolean isInOpenWater() {
return getHandle().isInOpenWater();
return getHandle().isOpenWaterFishing();
}
@Override
@@ -101,7 +101,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook {
EntityFishingHook hook = getHandle();
hook.hookedIn = (entity != null) ? ((CraftEntity) entity).getHandle() : null;
hook.getDataWatcher().set(EntityFishingHook.DATA_HOOKED_ENTITY, hook.hookedIn != null ? hook.hookedIn.getId() + 1 : 0);
hook.getEntityData().set(EntityFishingHook.DATA_HOOKED_ENTITY, hook.hookedIn != null ? hook.hookedIn.getId() + 1 : 0);
}
@Override
@@ -111,7 +111,7 @@ public class CraftFishHook extends CraftProjectile implements FishHook {
return false;
}
hook.reel(hook.hookedIn);
hook.pullEntity(hook.hookedIn);
return true;
}

View File

@@ -50,7 +50,7 @@ public class CraftFox extends CraftAnimals implements Fox {
@Override
public void setCrouching(boolean crouching) {
getHandle().setCrouching(crouching);
getHandle().setIsCrouching(crouching);
}
@Override
@@ -70,7 +70,7 @@ public class CraftFox extends CraftAnimals implements Fox {
@Override
public AnimalTamer getFirstTrustedPlayer() {
UUID uuid = getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_0).orElse(null);
UUID uuid = getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_0).orElse(null);
if (uuid == null) {
return null;
}
@@ -85,16 +85,16 @@ public class CraftFox extends CraftAnimals implements Fox {
@Override
public void setFirstTrustedPlayer(AnimalTamer player) {
if (player == null && getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_1).isPresent()) {
if (player == null && getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_1).isPresent()) {
throw new IllegalStateException("Must remove second trusted player first");
}
getHandle().getDataWatcher().set(EntityFox.DATA_TRUSTED_ID_0, player == null ? Optional.empty() : Optional.of(player.getUniqueId()));
getHandle().getEntityData().set(EntityFox.DATA_TRUSTED_ID_0, player == null ? Optional.empty() : Optional.of(player.getUniqueId()));
}
@Override
public AnimalTamer getSecondTrustedPlayer() {
UUID uuid = getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_1).orElse(null);
UUID uuid = getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_1).orElse(null);
if (uuid == null) {
return null;
}
@@ -109,10 +109,10 @@ public class CraftFox extends CraftAnimals implements Fox {
@Override
public void setSecondTrustedPlayer(AnimalTamer player) {
if (player != null && !getHandle().getDataWatcher().get(EntityFox.DATA_TRUSTED_ID_0).isPresent()) {
if (player != null && !getHandle().getEntityData().get(EntityFox.DATA_TRUSTED_ID_0).isPresent()) {
throw new IllegalStateException("Must add first trusted player first");
}
getHandle().getDataWatcher().set(EntityFox.DATA_TRUSTED_ID_1, player == null ? Optional.empty() : Optional.of(player.getUniqueId()));
getHandle().getEntityData().set(EntityFox.DATA_TRUSTED_ID_1, player == null ? Optional.empty() : Optional.of(player.getUniqueId()));
}
}

View File

@@ -34,6 +34,6 @@ public class CraftGlowSquid extends CraftSquid implements GlowSquid {
@Override
public void setDarkTicksRemaining(int darkTicksRemaining) {
Preconditions.checkArgument(darkTicksRemaining >= 0, "darkTicksRemaining must be >= 0");
getHandle().setDarkTicksRemaining(darkTicksRemaining);
getHandle().setDarkTicks(darkTicksRemaining);
}
}

View File

@@ -33,7 +33,7 @@ public class CraftGuardian extends CraftMonster implements Guardian {
// clean up laser target, when target is removed
if (target == null) {
getHandle().a(0); // PAIL rename setLaserTarget
getHandle().setActiveAttackTarget(0);
}
}
@@ -45,9 +45,9 @@ public class CraftGuardian extends CraftMonster implements Guardian {
return false;
}
getHandle().a(target.getEntityId()); // PAIL rename setLaserTarget
getHandle().setActiveAttackTarget(target.getEntityId());
} else {
getHandle().a(0); // PAIL rename setLaserTarget
getHandle().setActiveAttackTarget(0);
}
return true;
@@ -55,7 +55,7 @@ public class CraftGuardian extends CraftMonster implements Guardian {
@Override
public boolean hasLaser() {
return getHandle().fy(); // PAIL rename hasLaserTarget
return getHandle().hasActiveAttackTarget();
}
@Override

View File

@@ -31,24 +31,24 @@ public class CraftHorse extends CraftAbstractHorse implements Horse {
@Override
public Color getColor() {
return Color.values()[getHandle().getColor().a()];
return Color.values()[getHandle().getVariant().getId()];
}
@Override
public void setColor(Color color) {
Validate.notNull(color, "Color cannot be null");
getHandle().setVariant(HorseColor.a(color.ordinal()), getHandle().getStyle());
getHandle().setVariantAndMarkings(HorseColor.byId(color.ordinal()), getHandle().getMarkings());
}
@Override
public Style getStyle() {
return Style.values()[getHandle().getStyle().a()];
return Style.values()[getHandle().getMarkings().getId()];
}
@Override
public void setStyle(Style style) {
Validate.notNull(style, "Style cannot be null");
getHandle().setVariant(getHandle().getColor(), HorseStyle.a(style.ordinal()));
getHandle().setVariantAndMarkings(getHandle().getVariant(), HorseStyle.byId(style.ordinal()));
}
@Override

View File

@@ -74,7 +74,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
super(server, entity);
mode = server.getDefaultGameMode();
this.inventory = new CraftInventoryPlayer(entity.getInventory());
enderChest = new CraftInventory(entity.getEnderChest());
enderChest = new CraftInventory(entity.getEnderChestInventory());
}
@Override
@@ -94,7 +94,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public MainHand getMainHand() {
return getHandle().getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT;
return getHandle().getMainArm() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT;
}
@Override
@@ -133,18 +133,18 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
Preconditions.checkArgument(location.getWorld().equals(getWorld()), "Cannot sleep across worlds");
BlockPosition blockposition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
IBlockData iblockdata = getHandle().level.getType(blockposition);
IBlockData iblockdata = getHandle().level.getBlockState(blockposition);
if (!(iblockdata.getBlock() instanceof BlockBed)) {
return false;
}
if (getHandle().sleep(blockposition, force).left().isPresent()) {
if (getHandle().startSleepInBed(blockposition, force).left().isPresent()) {
return false;
}
// From BlockBed
iblockdata = (IBlockData) iblockdata.set(BlockBed.OCCUPIED, true);
getHandle().level.setTypeAndData(blockposition, iblockdata, 4);
iblockdata = (IBlockData) iblockdata.setValue(BlockBed.OCCUPIED, true);
getHandle().level.setBlock(blockposition, iblockdata, 4);
return true;
}
@@ -153,20 +153,20 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
public void wakeup(boolean setSpawnLocation) {
Preconditions.checkState(isSleeping(), "Cannot wakeup if not sleeping");
getHandle().wakeup(true, setSpawnLocation);
getHandle().stopSleepInBed(true, setSpawnLocation);
}
@Override
public Location getBedLocation() {
Preconditions.checkState(isSleeping(), "Not sleeping");
BlockPosition bed = getHandle().getBedPosition().get();
BlockPosition bed = getHandle().getSleepingPos().get();
return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ());
}
@Override
public String getName() {
return getHandle().getName();
return getHandle().getScoreboardName();
}
@Override
@@ -290,15 +290,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
if (iinventory instanceof ITileInventory) {
if (iinventory instanceof TileEntity) {
TileEntity te = (TileEntity) iinventory;
if (!te.hasWorld()) {
te.setWorld(getHandle().level);
if (!te.hasLevel()) {
te.setLevel(getHandle().level);
}
}
}
Containers<?> container = CraftContainer.getNotchInventoryType(inventory);
if (iinventory instanceof ITileInventory) {
getHandle().openContainer(iinventory);
getHandle().openMenu(iinventory);
} else {
openCustomInventory(inventory, player, container);
}
@@ -320,7 +320,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
String title = container.getBukkitView().getTitle();
player.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0]));
player.connection.send(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0]));
player.containerMenu = container;
player.initMenu(container);
}
@@ -336,7 +336,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
return null;
}
}
getHandle().openContainer(((BlockWorkbench) Blocks.CRAFTING_TABLE).getInventory(null, getHandle().level, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
getHandle().openMenu(((BlockWorkbench) Blocks.CRAFTING_TABLE).getMenuProvider(null, getHandle().level, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
if (force) {
getHandle().containerMenu.checkReachable = false;
}
@@ -357,7 +357,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// If there isn't an enchant table we can force create one, won't be very useful though.
BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
getHandle().openContainer(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getInventory(null, getHandle().level, pos));
getHandle().openMenu(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getMenuProvider(null, getHandle().level, pos));
if (force) {
getHandle().containerMenu.checkReachable = false;
@@ -371,7 +371,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
if (((EntityPlayer) getHandle()).connection == null) return;
if (getHandle().containerMenu != getHandle().inventoryMenu) {
// fire INVENTORY_CLOSE if one already open
((EntityPlayer) getHandle()).connection.a(new PacketPlayInCloseWindow(getHandle().containerMenu.containerId));
((EntityPlayer) getHandle()).connection.handleContainerClose(new PacketPlayInCloseWindow(getHandle().containerMenu.containerId));
}
EntityPlayer player = (EntityPlayer) getHandle();
Container container;
@@ -390,7 +390,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// Now open the window
Containers<?> windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory());
String title = inventory.getTitle();
player.connection.sendPacket(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0]));
player.connection.send(new PacketPlayOutOpenWindow(container.containerId, windowType, CraftChatMessage.fromString(title)[0]));
player.containerMenu = container;
player.initMenu(container);
}
@@ -418,7 +418,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
int level = 1; // note: using level 0 with active 'is-regular-villager'-flag allows hiding the name suffix
if (merchant instanceof CraftAbstractVillager) {
mcMerchant = ((CraftAbstractVillager) merchant).getHandle();
name = ((CraftAbstractVillager) merchant).getHandle().getScoreboardDisplayName();
name = ((CraftAbstractVillager) merchant).getHandle().getDisplayName();
if (merchant instanceof CraftVillager) {
level = ((CraftVillager) merchant).getHandle().getVillagerData().getLevel();
}
@@ -430,14 +430,14 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
}
mcMerchant.setTradingPlayer(this.getHandle());
mcMerchant.openTrade(this.getHandle(), name, level);
mcMerchant.openTradingScreen(this.getHandle(), name, level);
return this.getHandle().containerMenu.getBukkitView();
}
@Override
public void closeInventory() {
getHandle().closeInventory();
getHandle().closeContainer();
}
@Override
@@ -447,12 +447,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public boolean isHandRaised() {
return getHandle().isHandRaised();
return getHandle().isUsingItem();
}
@Override
public ItemStack getItemInUse() {
net.minecraft.world.item.ItemStack item = getHandle().getActiveItem();
net.minecraft.world.item.ItemStack item = getHandle().getUseItem();
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
@@ -463,27 +463,27 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public int getExpToLevel() {
return getHandle().getExpToLevel();
return getHandle().getXpNeededForNextLevel();
}
@Override
public float getAttackCooldown() {
return getHandle().getAttackCooldown(0.5f);
return getHandle().getAttackStrengthScale(0.5f);
}
@Override
public boolean hasCooldown(Material material) {
Preconditions.checkArgument(material != null, "material");
return getHandle().getCooldownTracker().hasCooldown(CraftMagicNumbers.getItem(material));
return getHandle().getCooldowns().isOnCooldown(CraftMagicNumbers.getItem(material));
}
@Override
public int getCooldown(Material material) {
Preconditions.checkArgument(material != null, "material");
ItemCooldown.Info cooldown = getHandle().getCooldownTracker().cooldowns.get(CraftMagicNumbers.getItem(material));
return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime - getHandle().getCooldownTracker().tickCount);
ItemCooldown.Info cooldown = getHandle().getCooldowns().cooldowns.get(CraftMagicNumbers.getItem(material));
return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime - getHandle().getCooldowns().tickCount);
}
@Override
@@ -491,7 +491,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
Preconditions.checkArgument(material != null, "material");
Preconditions.checkArgument(ticks >= 0, "Cannot have negative cooldown");
getHandle().getCooldownTracker().setCooldown(CraftMagicNumbers.getItem(material), ticks);
getHandle().getCooldowns().addCooldown(CraftMagicNumbers.getItem(material), ticks);
}
@Override
@@ -501,7 +501,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public int discoverRecipes(Collection<NamespacedKey> recipes) {
return getHandle().discoverRecipes(bukkitKeysToMinecraftRecipes(recipes));
return getHandle().awardRecipes(bukkitKeysToMinecraftRecipes(recipes));
}
@Override
@@ -511,7 +511,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public int undiscoverRecipes(Collection<NamespacedKey> recipes) {
return getHandle().undiscoverRecipes(bukkitKeysToMinecraftRecipes(recipes));
return getHandle().resetRecipes(bukkitKeysToMinecraftRecipes(recipes));
}
@Override
@@ -526,10 +526,10 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private Collection<IRecipe<?>> bukkitKeysToMinecraftRecipes(Collection<NamespacedKey> recipeKeys) {
Collection<IRecipe<?>> recipes = new ArrayList<>();
CraftingManager manager = getHandle().level.getMinecraftServer().getCraftingManager();
CraftingManager manager = getHandle().level.getServer().getRecipeManager();
for (NamespacedKey recipeKey : recipeKeys) {
Optional<? extends IRecipe<?>> recipe = manager.getRecipe(CraftNamespacedKey.toMinecraft(recipeKey));
Optional<? extends IRecipe<?>> recipe = manager.byKey(CraftNamespacedKey.toMinecraft(recipeKey));
if (!recipe.isPresent()) {
continue;
}
@@ -543,7 +543,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public org.bukkit.entity.Entity getShoulderEntityLeft() {
if (!getHandle().getShoulderEntityLeft().isEmpty()) {
Optional<Entity> shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().level);
Optional<Entity> shoulder = EntityTypes.create(getHandle().getShoulderEntityLeft(), getHandle().level);
return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity();
}
@@ -562,7 +562,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public org.bukkit.entity.Entity getShoulderEntityRight() {
if (!getHandle().getShoulderEntityRight().isEmpty()) {
Optional<Entity> shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().level);
Optional<Entity> shoulder = EntityTypes.create(getHandle().getShoulderEntityRight(), getHandle().level);
return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity();
}
@@ -581,7 +581,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public boolean dropItem(boolean dropAll) {
if (!(getHandle() instanceof EntityPlayer)) return false;
return ((EntityPlayer) getHandle()).dropItem(dropAll);
return ((EntityPlayer) getHandle()).drop(dropAll);
}
@Override

View File

@@ -23,12 +23,12 @@ public class CraftItem extends CraftEntity implements Item {
@Override
public ItemStack getItemStack() {
return CraftItemStack.asCraftMirror(item.getItemStack());
return CraftItemStack.asCraftMirror(item.getItem());
}
@Override
public void setItemStack(ItemStack stack) {
item.setItemStack(CraftItemStack.asNMSCopy(stack));
item.setItem(CraftItemStack.asNMSCopy(stack));
}
@Override

View File

@@ -44,13 +44,13 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
super.update();
// mark dirty, so that the client gets updated with item and rotation
for (DataWatcher.Item<?> dataItem : getHandle().getDataWatcher().getAll()) {
getHandle().getDataWatcher().markDirty(dataItem.a());
for (DataWatcher.Item<?> dataItem : getHandle().getEntityData().getAll()) {
getHandle().getEntityData().markDirty(dataItem.getAccessor());
}
// update redstone
if (!getHandle().generation) {
getHandle().getWorld().updateAdjacentComparators(getHandle().pos, Blocks.AIR);
getHandle().getLevel().updateNeighbourForOutputSignal(getHandle().pos, Blocks.AIR);
}
}

View File

@@ -116,7 +116,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
// during world generation, we don't want to run logic for dropping items and xp
if (getHandle().generation && health == 0) {
getHandle().die();
getHandle().discard();
return;
}
@@ -129,14 +129,14 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public double getAbsorptionAmount() {
return getHandle().getAbsorptionHearts();
return getHandle().getAbsorptionAmount();
}
@Override
public void setAbsorptionAmount(double amount) {
Preconditions.checkArgument(amount >= 0 && Double.isFinite(amount), "amount < 0 or non-finite");
getHandle().setAbsorptionHearts((float) amount);
getHandle().setAbsorptionAmount((float) amount);
}
@Override
@@ -148,7 +148,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setMaxHealth(double amount) {
Validate.isTrue(amount > 0, "Max health must be greater than 0");
getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(amount);
getHandle().getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(amount);
if (getHealth() > amount) {
setHealth(amount);
@@ -157,12 +157,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public void resetMaxHealth() {
setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).getAttribute().getDefault());
setMaxHealth(getHandle().getAttribute(GenericAttributes.MAX_HEALTH).getAttribute().getDefaultValue());
}
@Override
public double getEyeHeight() {
return getHandle().getHeadHeight();
return getHandle().getEyeHeight();
}
@Override
@@ -238,12 +238,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public int getRemainingAir() {
return getHandle().getAirTicks();
return getHandle().getAirSupply();
}
@Override
public void setRemainingAir(int ticks) {
getHandle().setAirTicks(ticks);
getHandle().setAirSupply(ticks);
}
@Override
@@ -274,7 +274,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public void setArrowsInBody(int count) {
Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0");
getHandle().getDataWatcher().set(EntityLiving.DATA_ARROW_COUNT_ID, count);
getHandle().getEntityData().set(EntityLiving.DATA_ARROW_COUNT_ID, count);
}
@Override
@@ -294,7 +294,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
}
entity.damageEntity(reason, (float) amount);
entity.hurt(reason, (float) amount);
}
@Override
@@ -360,7 +360,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public boolean addPotionEffect(PotionEffect effect, boolean force) {
getHandle().addEffect(new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()), EntityPotionEffectEvent.Cause.PLUGIN);
getHandle().addEffect(new MobEffect(MobEffectList.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()), EntityPotionEffectEvent.Cause.PLUGIN);
return true;
}
@@ -375,25 +375,25 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public boolean hasPotionEffect(PotionEffectType type) {
return getHandle().hasEffect(MobEffectList.fromId(type.getId()));
return getHandle().hasEffect(MobEffectList.byId(type.getId()));
}
@Override
public PotionEffect getPotionEffect(PotionEffectType type) {
MobEffect handle = getHandle().getEffect(MobEffectList.fromId(type.getId()));
return (handle == null) ? null : new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles());
MobEffect handle = getHandle().getEffect(MobEffectList.byId(type.getId()));
return (handle == null) ? null : new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible());
}
@Override
public void removePotionEffect(PotionEffectType type) {
getHandle().removeEffect(MobEffectList.fromId(type.getId()), EntityPotionEffectEvent.Cause.PLUGIN);
getHandle().removeEffect(MobEffectList.byId(type.getId()), EntityPotionEffectEvent.Cause.PLUGIN);
}
@Override
public Collection<PotionEffect> getActivePotionEffects() {
List<PotionEffect> effects = new ArrayList<PotionEffect>();
for (MobEffect handle : getHandle().activeEffects.values()) {
effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()));
effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isVisible()));
}
return effects;
}
@@ -413,17 +413,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
if (Snowball.class.isAssignableFrom(projectile)) {
launch = new EntitySnowball(world, getHandle());
((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemSnowball
((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemSnowball
} else if (Egg.class.isAssignableFrom(projectile)) {
launch = new EntityEgg(world, getHandle());
((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEgg
((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEgg
} else if (EnderPearl.class.isAssignableFrom(projectile)) {
launch = new EntityEnderPearl(world, getHandle());
((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEnderPearl
((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 1.5F, 1.0F); // ItemEnderPearl
} else if (AbstractArrow.class.isAssignableFrom(projectile)) {
if (TippedArrow.class.isAssignableFrom(projectile)) {
launch = new EntityTippedArrow(world, getHandle());
((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
((EntityTippedArrow) launch).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(projectile)) {
launch = new EntitySpectralArrow(world, getHandle());
} else if (Trident.class.isAssignableFrom(projectile)) {
@@ -431,7 +431,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} else {
launch = new EntityTippedArrow(world, getHandle());
}
((EntityArrow) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 3.0F, 1.0F); // ItemBow
((EntityArrow) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), 0.0F, 3.0F, 1.0F); // ItemBow
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
if (LingeringPotion.class.isAssignableFrom(projectile)) {
launch = new EntityPotion(world, getHandle());
@@ -440,10 +440,10 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
launch = new EntityPotion(world, getHandle());
((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
}
((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.5F, 1.0F); // ItemSplashPotion
((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.5F, 1.0F); // ItemSplashPotion
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
launch = new EntityThrownExpBottle(world, getHandle());
((EntityProjectile) launch).a(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.7F, 1.0F); // ItemExpBottle
((EntityProjectile) launch).shootFromRotation(getHandle(), getHandle().getXRot(), getHandle().getYRot(), -20.0F, 0.7F, 1.0F); // ItemExpBottle
} else if (FishHook.class.isAssignableFrom(projectile) && getHandle() instanceof EntityHuman) {
launch = new EntityFishingHook((EntityHuman) getHandle(), world, 0, 0);
} else if (Fireball.class.isAssignableFrom(projectile)) {
@@ -461,26 +461,26 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
((EntityFireball) launch).projectileSource = this;
launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
} else if (LlamaSpit.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
Vector direction = location.getDirection();
launch = EntityTypes.LLAMA_SPIT.a(world);
launch = EntityTypes.LLAMA_SPIT.create(world);
((EntityLlamaSpit) launch).setShooter(getHandle());
((EntityLlamaSpit) launch).setOwner(getHandle());
((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F); // EntityLlama
launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
} else if (ShulkerBullet.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
launch = new EntityShulkerBullet(world, getHandle(), null, null);
launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
} else if (Firework.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
launch = new EntityFireworks(world, net.minecraft.world.item.ItemStack.EMPTY, getHandle());
launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
}
Validate.notNull(launch, "Projectile not supported");
@@ -489,7 +489,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
((T) launch.getBukkitEntity()).setVelocity(velocity);
}
world.addEntity(launch);
world.addFreshEntity(launch);
return (T) launch.getBukkitEntity();
}
@@ -507,7 +507,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public boolean getRemoveWhenFarAway() {
return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).isPersistent();
return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).isPersistenceRequired();
}
@Override
@@ -525,7 +525,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public void setCanPickupItems(boolean pickup) {
if (getHandle() instanceof EntityInsentient) {
((EntityInsentient) getHandle()).setCanPickupLoot(pickup);
((EntityInsentient) getHandle()).setCanPickUpLoot(pickup);
} else {
getHandle().bukkitPickUpLoot = pickup;
}
@@ -534,7 +534,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public boolean getCanPickupItems() {
if (getHandle() instanceof EntityInsentient) {
return ((EntityInsentient) getHandle()).canPickupLoot();
return ((EntityInsentient) getHandle()).canPickUpLoot();
} else {
return getHandle().bukkitPickUpLoot;
}
@@ -569,7 +569,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
if (!isLeashed()) {
return false;
}
((EntityInsentient) getHandle()).unleash(true, false);
((EntityInsentient) getHandle()).dropLeash(true, false);
return true;
}
@@ -588,18 +588,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
unleash();
((EntityInsentient) getHandle()).setLeashHolder(((CraftEntity) holder).getHandle(), true);
((EntityInsentient) getHandle()).setLeashedTo(((CraftEntity) holder).getHandle(), true);
return true;
}
@Override
public boolean isGliding() {
return getHandle().getFlag(7);
return getHandle().getSharedFlag(7);
}
@Override
public void setGliding(boolean gliding) {
getHandle().setFlag(7, gliding);
getHandle().setSharedFlag(7, gliding);
}
@Override
@@ -614,7 +614,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public boolean isRiptiding() {
return getHandle().isRiptiding();
return getHandle().isAutoSpinAttack();
}
@Override
@@ -626,7 +626,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public boolean isClimbing() {
Preconditions.checkState(!getHandle().generation, "Cannot check if climbing during world generation");
return getHandle().isClimbing();
return getHandle().onClimbable();
}
@Override
@@ -637,13 +637,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public void setAI(boolean ai) {
if (this.getHandle() instanceof EntityInsentient) {
((EntityInsentient) this.getHandle()).setNoAI(!ai);
((EntityInsentient) this.getHandle()).setNoAi(!ai);
}
}
@Override
public boolean hasAI() {
return (this.getHandle() instanceof EntityInsentient) ? !((EntityInsentient) this.getHandle()).isNoAI() : false;
return (this.getHandle() instanceof EntityInsentient) ? !((EntityInsentient) this.getHandle()).isNoAi() : false;
}
@Override
@@ -654,7 +654,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
if (getHandle() instanceof EntityHuman) {
((EntityHuman) getHandle()).attack(((CraftEntity) target).getHandle());
} else {
getHandle().attackEntity(((CraftEntity) target).getHandle());
getHandle().doHurtTarget(((CraftEntity) target).getHandle());
}
}
@@ -662,14 +662,14 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void swingMainHand() {
Preconditions.checkState(!getHandle().generation, "Cannot swing hand during world generation");
getHandle().swingHand(EnumHand.MAIN_HAND, true);
getHandle().swing(EnumHand.MAIN_HAND, true);
}
@Override
public void swingOffHand() {
Preconditions.checkState(!getHandle().generation, "Cannot swing hand during world generation");
getHandle().swingHand(EnumHand.OFF_HAND, true);
getHandle().swing(EnumHand.OFF_HAND, true);
}
@Override
@@ -689,17 +689,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public <T> T getMemory(MemoryKey<T> memoryKey) {
return (T) getHandle().getBehaviorController().getMemory(CraftMemoryKey.fromMemoryKey(memoryKey)).map(CraftMemoryMapper::fromNms).orElse(null);
return (T) getHandle().getBrain().getMemory(CraftMemoryKey.fromMemoryKey(memoryKey)).map(CraftMemoryMapper::fromNms).orElse(null);
}
@Override
public <T> void setMemory(MemoryKey<T> memoryKey, T t) {
getHandle().getBehaviorController().setMemory(CraftMemoryKey.fromMemoryKey(memoryKey), CraftMemoryMapper.toNms(t));
getHandle().getBrain().setMemory(CraftMemoryKey.fromMemoryKey(memoryKey), CraftMemoryMapper.toNms(t));
}
@Override
public EntityCategory getCategory() {
EnumMonsterType type = getHandle().getMonsterType(); // Not actually an enum?
EnumMonsterType type = getHandle().getMobType(); // Not actually an enum?
if (type == EnumMonsterType.UNDEFINED) {
return EntityCategory.NONE;
@@ -724,6 +724,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override
public void setInvisible(boolean invisible) {
getHandle().persistentInvisibility = invisible;
getHandle().setFlag(5, invisible);
getHandle().setSharedFlag(5, invisible);
}
}

View File

@@ -48,7 +48,7 @@ public class CraftLlama extends CraftChestedHorse implements Llama {
Preconditions.checkArgument(1 <= strength && strength <= 5, "strength must be [1,5]");
if (strength == getStrength()) return;
getHandle().setStrength(strength);
getHandle().loadChest();
getHandle().createInventory();
}
@Override

View File

@@ -29,11 +29,11 @@ public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit {
@Override
public ProjectileSource getShooter() {
return (getHandle().getShooter() != null) ? (ProjectileSource) getHandle().getShooter().getBukkitEntity() : null;
return (getHandle().getOwner() != null) ? (ProjectileSource) getHandle().getOwner().getBukkitEntity() : null;
}
@Override
public void setShooter(ProjectileSource source) {
getHandle().setShooter((source != null) ? ((CraftLivingEntity) source).getHandle() : null);
getHandle().setOwner((source != null) ? ((CraftLivingEntity) source).getHandle() : null);
}
}

View File

@@ -77,11 +77,11 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
public void setDisplayBlock(MaterialData material) {
if (material != null) {
IBlockData block = CraftMagicNumbers.getBlock(material);
this.getHandle().setDisplayBlock(block);
this.getHandle().setDisplayBlockState(block);
} else {
// Set block to air (default) and set the flag to not have a display block.
this.getHandle().setDisplayBlock(Blocks.AIR.getBlockData());
this.getHandle().a(false);
this.getHandle().setDisplayBlockState(Blocks.AIR.defaultBlockState());
this.getHandle().setCustomDisplay(false);
}
}
@@ -89,33 +89,33 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
public void setDisplayBlockData(BlockData blockData) {
if (blockData != null) {
IBlockData block = ((CraftBlockData) blockData).getState();
this.getHandle().setDisplayBlock(block);
this.getHandle().setDisplayBlockState(block);
} else {
// Set block to air (default) and set the flag to not have a display block.
this.getHandle().setDisplayBlock(Blocks.AIR.getBlockData());
this.getHandle().a(false);
this.getHandle().setDisplayBlockState(Blocks.AIR.defaultBlockState());
this.getHandle().setCustomDisplay(false);
}
}
@Override
public MaterialData getDisplayBlock() {
IBlockData blockData = getHandle().getDisplayBlock();
IBlockData blockData = getHandle().getDisplayBlockState();
return CraftMagicNumbers.getMaterial(blockData);
}
@Override
public BlockData getDisplayBlockData() {
IBlockData blockData = getHandle().getDisplayBlock();
IBlockData blockData = getHandle().getDisplayBlockState();
return CraftBlockData.fromData(blockData);
}
@Override
public void setDisplayBlockOffset(int offset) {
getHandle().setDisplayBlockOffset(offset);
getHandle().setDisplayOffset(offset);
}
@Override
public int getDisplayBlockOffset() {
return getHandle().getDisplayBlockOffset();
return getHandle().getDisplayOffset();
}
}

View File

@@ -34,7 +34,7 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
@Override
public void setCommand(String command) {
getHandle().getCommandBlock().setCommand(command != null ? command : "");
getHandle().getDataWatcher().set(EntityMinecartCommandBlock.DATA_ID_COMMAND_NAME, getHandle().getCommandBlock().getCommand());
getHandle().getEntityData().set(EntityMinecartCommandBlock.DATA_ID_COMMAND_NAME, getHandle().getCommandBlock().getCommand());
}
@Override

View File

@@ -21,17 +21,17 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
EntityInsentient entity = getHandle();
if (target == null) {
entity.setGoalTarget(null, null, false);
entity.setTarget(null, null, false);
} else if (target instanceof CraftLivingEntity) {
entity.setGoalTarget(((CraftLivingEntity) target).getHandle(), null, false);
entity.setTarget(((CraftLivingEntity) target).getHandle(), null, false);
}
}
@Override
public CraftLivingEntity getTarget() {
if (getHandle().getGoalTarget() == null) return null;
if (getHandle().getTarget() == null) return null;
return (CraftLivingEntity) getHandle().getGoalTarget().getBukkitEntity();
return (CraftLivingEntity) getHandle().getTarget().getBukkitEntity();
}
@Override

View File

@@ -19,14 +19,14 @@ public class CraftMushroomCow extends CraftCow implements MushroomCow {
@Override
public Variant getVariant() {
return Variant.values()[getHandle().getVariant().ordinal()];
return Variant.values()[getHandle().getMushroomType().ordinal()];
}
@Override
public void setVariant(Variant variant) {
Preconditions.checkArgument(variant != null, "variant");
getHandle().setVariant(EntityMushroomCow.Type.values()[variant.ordinal()]);
getHandle().setMushroomType(EntityMushroomCow.Type.values()[variant.ordinal()]);
}
@Override

View File

@@ -18,12 +18,12 @@ public class CraftPhantom extends CraftFlying implements Phantom {
@Override
public int getSize() {
return getHandle().getSize();
return getHandle().getPhantomSize();
}
@Override
public void setSize(int sz) {
getHandle().setSize(sz);
getHandle().setPhantomSize(sz);
}
@Override

View File

@@ -15,7 +15,7 @@ public class CraftPig extends CraftAnimals implements Pig {
@Override
public boolean hasSaddle() {
return getHandle().hasSaddle();
return getHandle().isSaddled();
}
@Override

View File

@@ -13,12 +13,12 @@ public class CraftPigZombie extends CraftZombie implements PigZombie {
@Override
public int getAnger() {
return getHandle().getAnger();
return getHandle().getRemainingPersistentAngerTime();
}
@Override
public void setAnger(int level) {
getHandle().setAnger(level);
getHandle().setRemainingPersistentAngerTime(level);
}
@Override

View File

@@ -149,7 +149,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public GameProfile getProfile() {
return getHandle().getProfile();
return getHandle().getGameProfile();
}
@Override
@@ -162,9 +162,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (value == isOp()) return;
if (value) {
server.getHandle().addOp(getProfile());
server.getHandle().op(getProfile());
} else {
server.getHandle().removeOp(getProfile());
server.getHandle().deop(getProfile());
}
perm.recalculatePermissions();
@@ -179,7 +179,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public InetSocketAddress getAddress() {
if (getHandle().connection == null) return null;
SocketAddress addr = getHandle().connection.connection.getSocketAddress();
SocketAddress addr = getHandle().connection.connection.getRemoteAddress();
if (addr instanceof InetSocketAddress) {
return (InetSocketAddress) addr;
} else {
@@ -201,7 +201,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (getHandle().connection == null) return;
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
getHandle().connection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
getHandle().connection.send(new PacketPlayOutChat(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
}
}
@@ -210,7 +210,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (getHandle().connection == null) return;
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
getHandle().connection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.CHAT, (sender == null) ? SystemUtils.NIL_UUID : sender));
getHandle().connection.send(new PacketPlayOutChat(component, ChatMessageType.CHAT, (sender == null) ? SystemUtils.NIL_UUID : sender));
}
}
@@ -265,7 +265,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromStringOrNull(name);
for (EntityPlayer player : (List<EntityPlayer>) server.getHandle().players) {
if (player.getBukkitEntity().canSee(this)) {
player.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle()));
player.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle()));
}
}
}
@@ -306,7 +306,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (getHandle().connection == null) return;
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter((this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader, (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter);
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Override
@@ -341,7 +341,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (getHandle().connection == null) return;
// Do not directly assign here, from the packethandler we'll assign it.
getHandle().connection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), loc.getYaw()));
getHandle().connection.send(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), loc.getYaw()));
}
@Override
@@ -400,7 +400,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);
getHandle().connection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
}
@Override
@@ -462,7 +462,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
break;
}
float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
getHandle().connection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
getHandle().connection.send(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.sounds.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
}
@Override
@@ -480,7 +480,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch);
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Override
@@ -488,7 +488,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (loc == null || sound == null || category == null || getHandle().connection == null) return;
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch);
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Override
@@ -510,14 +510,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void stopSound(String sound, org.bukkit.SoundCategory category) {
if (getHandle().connection == null) return;
getHandle().connection.sendPacket(new PacketPlayOutStopSound(new MinecraftKey(sound), category == null ? net.minecraft.sounds.SoundCategory.MASTER : net.minecraft.sounds.SoundCategory.valueOf(category.name())));
getHandle().connection.send(new PacketPlayOutStopSound(new MinecraftKey(sound), category == null ? net.minecraft.sounds.SoundCategory.MASTER : net.minecraft.sounds.SoundCategory.valueOf(category.name())));
}
@Override
public void stopAllSounds() {
if (getHandle().connection == null) return;
getHandle().connection.sendPacket(new PacketPlayOutStopSound(null, null));
getHandle().connection.send(new PacketPlayOutStopSound(null, null));
}
@Override
@@ -526,7 +526,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
int packetData = effect.getId();
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), data, false);
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Override
@@ -547,7 +547,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Preconditions.checkArgument(block != null, "Block cannot be null");
Preconditions.checkArgument(block.getWorld().equals(getWorld()), "Cannot break blocks across worlds");
return getHandle().gameMode.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
return getHandle().gameMode.destroyBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()));
}
@Override
@@ -555,7 +555,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (getHandle().connection == null) return;
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), CraftMagicNumbers.getBlock(material, data));
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Override
@@ -563,7 +563,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (getHandle().connection == null) return;
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), ((CraftBlockData) block).getState());
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Override
@@ -575,7 +575,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
int stage = (int) (9 * progress); // There are 0 - 9 damage states
PacketPlayOutBlockBreakAnimation packet = new PacketPlayOutBlockBreakAnimation(getHandle().getId(), new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), stage);
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Override
@@ -605,14 +605,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
IChatBaseComponent[] components = CraftSign.sanitizeLines(lines);
TileEntitySign sign = new TileEntitySign(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), Blocks.OAK_SIGN.getBlockData());
sign.setColor(EnumColor.fromColorIndex(dyeColor.getWoolData()));
TileEntitySign sign = new TileEntitySign(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), Blocks.OAK_SIGN.defaultBlockState());
sign.setColor(EnumColor.byId(dyeColor.getWoolData()));
sign.setHasGlowingText(hasGlowingText);
for (int i = 0; i < components.length; i++) {
sign.a(i, components[i]);
sign.setMessage(i, components[i]);
}
getHandle().connection.sendPacket(sign.getUpdatePacket());
getHandle().connection.send(sign.getUpdatePacket());
}
@Override
@@ -657,12 +657,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Collection<MapIcon> icons = new ArrayList<MapIcon>();
for (MapCursor cursor : data.cursors) {
if (cursor.isVisible()) {
icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption())));
icons.add(new MapIcon(MapIcon.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption())));
}
}
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), map.isLocked(), icons, new WorldMap.b(0, 0, 128, 128, data.buffer));
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Override
@@ -721,26 +721,26 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Close any foreign inventory
if (getHandle().containerMenu != getHandle().inventoryMenu) {
getHandle().closeInventory();
getHandle().closeContainer();
}
// Check if the fromWorld and toWorld are the same.
if (fromWorld == toWorld) {
entity.connection.teleport(to);
} else {
server.getHandle().moveToWorld(entity, toWorld, true, to, true);
server.getHandle().respawn(entity, toWorld, true, to, true);
}
return true;
}
@Override
public void setSneaking(boolean sneak) {
getHandle().setSneaking(sneak);
getHandle().setShiftKeyDown(sneak);
}
@Override
public boolean isSneaking() {
return getHandle().isSneaking();
return getHandle().isShiftKeyDown();
}
@Override
@@ -766,13 +766,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Deprecated
@Override
public void updateInventory() {
getHandle().containerMenu.updateInventory();
getHandle().containerMenu.sendAllDataToRemote();
}
@Override
public void setSleepingIgnored(boolean isSleeping) {
getHandle().fauxSleeping = isSleeping;
((CraftWorld) getWorld()).getHandle().everyoneSleeping();
((CraftWorld) getWorld()).getHandle().updateSleepingPlayerList();
}
@Override
@@ -782,14 +782,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public Location getBedSpawnLocation() {
WorldServer world = getHandle().server.getWorldServer(getHandle().getSpawnDimension());
BlockPosition bed = getHandle().getSpawn();
WorldServer world = getHandle().server.getLevel(getHandle().getRespawnDimension());
BlockPosition bed = getHandle().getRespawnPosition();
if (world != null && bed != null) {
Optional<Vec3D> spawnLoc = EntityHuman.getBed(world, bed, getHandle().getSpawnAngle(), getHandle().isSpawnForced(), true);
Optional<Vec3D> spawnLoc = EntityHuman.findRespawnPositionAndUseSpawnBlock(world, bed, getHandle().getRespawnAngle(), getHandle().isRespawnForced(), true);
if (spawnLoc.isPresent()) {
Vec3D vec = spawnLoc.get();
return new Location(world.getWorld(), vec.x, vec.y, vec.z, getHandle().getSpawnAngle(), 0);
return new Location(world.getWorld(), vec.x, vec.y, vec.z, getHandle().getRespawnAngle(), 0);
}
}
return null;
@@ -805,7 +805,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (location == null) {
getHandle().setRespawnPosition(null, null, 0.0F, override, false);
} else {
getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false);
getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false);
}
}
@@ -813,14 +813,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public Location getBedLocation() {
Preconditions.checkState(isSleeping(), "Not sleeping");
BlockPosition bed = getHandle().getSpawn();
BlockPosition bed = getHandle().getRespawnPosition();
return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ());
}
@Override
public boolean hasDiscoveredRecipe(NamespacedKey recipe) {
Preconditions.checkArgument(recipe != null, "recipe cannot be null");
return getHandle().getRecipeBook().hasDiscoveredRecipe(CraftNamespacedKey.toMinecraft(recipe));
return getHandle().getRecipeBook().contains(CraftNamespacedKey.toMinecraft(recipe));
}
@Override
@@ -832,92 +832,92 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void incrementStatistic(Statistic statistic) {
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic);
CraftStatistic.incrementStatistic(getHandle().getStats(), statistic);
}
@Override
public void decrementStatistic(Statistic statistic) {
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic);
CraftStatistic.decrementStatistic(getHandle().getStats(), statistic);
}
@Override
public int getStatistic(Statistic statistic) {
return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic);
return CraftStatistic.getStatistic(getHandle().getStats(), statistic);
}
@Override
public void incrementStatistic(Statistic statistic, int amount) {
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, amount);
CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, amount);
}
@Override
public void decrementStatistic(Statistic statistic, int amount) {
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, amount);
CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, amount);
}
@Override
public void setStatistic(Statistic statistic, int newValue) {
CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, newValue);
CraftStatistic.setStatistic(getHandle().getStats(), statistic, newValue);
}
@Override
public void incrementStatistic(Statistic statistic, Material material) {
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, material);
CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, material);
}
@Override
public void decrementStatistic(Statistic statistic, Material material) {
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, material);
CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, material);
}
@Override
public int getStatistic(Statistic statistic, Material material) {
return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic, material);
return CraftStatistic.getStatistic(getHandle().getStats(), statistic, material);
}
@Override
public void incrementStatistic(Statistic statistic, Material material, int amount) {
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, material, amount);
CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, material, amount);
}
@Override
public void decrementStatistic(Statistic statistic, Material material, int amount) {
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, material, amount);
CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, material, amount);
}
@Override
public void setStatistic(Statistic statistic, Material material, int newValue) {
CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, material, newValue);
CraftStatistic.setStatistic(getHandle().getStats(), statistic, material, newValue);
}
@Override
public void incrementStatistic(Statistic statistic, EntityType entityType) {
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, entityType);
CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, entityType);
}
@Override
public void decrementStatistic(Statistic statistic, EntityType entityType) {
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, entityType);
CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, entityType);
}
@Override
public int getStatistic(Statistic statistic, EntityType entityType) {
return CraftStatistic.getStatistic(getHandle().getStatisticManager(), statistic, entityType);
return CraftStatistic.getStatistic(getHandle().getStats(), statistic, entityType);
}
@Override
public void incrementStatistic(Statistic statistic, EntityType entityType, int amount) {
CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic, entityType, amount);
CraftStatistic.incrementStatistic(getHandle().getStats(), statistic, entityType, amount);
}
@Override
public void decrementStatistic(Statistic statistic, EntityType entityType, int amount) {
CraftStatistic.decrementStatistic(getHandle().getStatisticManager(), statistic, entityType, amount);
CraftStatistic.decrementStatistic(getHandle().getStats(), statistic, entityType, amount);
}
@Override
public void setStatistic(Statistic statistic, EntityType entityType, int newValue) {
CraftStatistic.setStatistic(getHandle().getStatisticManager(), statistic, entityType, newValue);
CraftStatistic.setStatistic(getHandle().getStats(), statistic, entityType, newValue);
}
@Override
@@ -968,15 +968,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public boolean isWhitelisted() {
return server.getHandle().getWhitelist().isWhitelisted(getProfile());
return server.getHandle().getWhiteList().isWhiteListed(getProfile());
}
@Override
public void setWhitelisted(boolean value) {
if (value) {
server.getHandle().getWhitelist().add(new WhiteListEntry(getProfile()));
server.getHandle().getWhiteList().add(new WhiteListEntry(getProfile()));
} else {
server.getHandle().getWhitelist().remove(getProfile());
server.getHandle().getWhiteList().remove(getProfile());
}
}
@@ -988,22 +988,22 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
throw new IllegalArgumentException("Mode cannot be null");
}
getHandle().a(EnumGamemode.getById(mode.getValue()));
getHandle().setGameMode(EnumGamemode.byId(mode.getValue()));
}
@Override
public GameMode getGameMode() {
return GameMode.getByValue(getHandle().gameMode.getGameMode().getId());
return GameMode.getByValue(getHandle().gameMode.getGameModeForPlayer().getId());
}
@Override
public void giveExp(int exp) {
getHandle().giveExp(exp);
getHandle().giveExperiencePoints(exp);
}
@Override
public void giveExpLevels(int levels) {
getHandle().levelDown(levels);
getHandle().giveExperienceLevels(levels);
}
@Override
@@ -1056,7 +1056,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
PacketPlayOutExperience packet = new PacketPlayOutExperience(progress, getTotalExperience(), level);
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
@Nullable
@@ -1095,16 +1095,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
hiddenPlayers.put(player.getUniqueId(), hidingPlugins);
// Remove this player from the hidden player's EntityTrackerEntry
PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkProvider().chunkMap;
PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkSource().chunkMap;
EntityPlayer other = ((CraftPlayer) player).getHandle();
PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId());
if (entry != null) {
entry.clear(getHandle());
entry.removePlayer(getHandle());
}
// Remove the hidden player from this player user list, if they're on it
if (other.sentListPacket) {
getHandle().connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other));
getHandle().connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other));
}
}
@@ -1137,10 +1137,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
hiddenPlayers.remove(player.getUniqueId());
PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkProvider().chunkMap;
PlayerChunkMap tracker = ((WorldServer) entity.level).getChunkSource().chunkMap;
EntityPlayer other = ((CraftPlayer) player).getHandle();
getHandle().connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other));
getHandle().connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other));
PlayerChunkMap.EntityTracker entry = tracker.entityMap.get(other.getId());
if (entry != null && !entry.seenBy.contains(getHandle())) {
@@ -1214,15 +1214,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void readExtraData(NBTTagCompound nbttagcompound) {
hasPlayedBefore = true;
if (nbttagcompound.hasKey("bukkit")) {
if (nbttagcompound.contains("bukkit")) {
NBTTagCompound data = nbttagcompound.getCompound("bukkit");
if (data.hasKey("firstPlayed")) {
if (data.contains("firstPlayed")) {
firstPlayed = data.getLong("firstPlayed");
lastPlayed = data.getLong("lastPlayed");
}
if (data.hasKey("newExp")) {
if (data.contains("newExp")) {
EntityPlayer handle = getHandle();
handle.newExp = data.getInt("newExp");
handle.newTotalExp = data.getInt("newTotalExp");
@@ -1234,20 +1234,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void setExtraData(NBTTagCompound nbttagcompound) {
if (!nbttagcompound.hasKey("bukkit")) {
nbttagcompound.set("bukkit", new NBTTagCompound());
if (!nbttagcompound.contains("bukkit")) {
nbttagcompound.put("bukkit", new NBTTagCompound());
}
NBTTagCompound data = nbttagcompound.getCompound("bukkit");
EntityPlayer handle = getHandle();
data.setInt("newExp", handle.newExp);
data.setInt("newTotalExp", handle.newTotalExp);
data.setInt("newLevel", handle.newLevel);
data.setInt("expToDrop", handle.expToDrop);
data.setBoolean("keepLevel", handle.keepLevel);
data.setLong("firstPlayed", getFirstPlayed());
data.setLong("lastPlayed", System.currentTimeMillis());
data.setString("lastKnownName", handle.getName());
data.putInt("newExp", handle.newExp);
data.putInt("newTotalExp", handle.newTotalExp);
data.putInt("newLevel", handle.newLevel);
data.putInt("expToDrop", handle.expToDrop);
data.putBoolean("keepLevel", handle.keepLevel);
data.putLong("firstPlayed", getFirstPlayed());
data.putLong("lastPlayed", System.currentTimeMillis());
data.putString("lastKnownName", handle.getScoreboardName());
}
@Override
@@ -1283,7 +1283,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (channels.contains(channel)) {
channel = StandardMessenger.validateAndCorrectChannel(channel);
PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(new MinecraftKey(channel), new PacketDataSerializer(Unpooled.wrappedBuffer(message)));
getHandle().connection.sendPacket(packet);
getHandle().connection.send(packet);
}
}
@@ -1296,7 +1296,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void setResourcePack(String url) {
Validate.notNull(url, "Resource pack URL cannot be null");
getHandle().setResourcePack(url, "null", false, null);
getHandle().sendTexturePack(url, "null", false, null);
}
@Override
@@ -1305,7 +1305,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Validate.notNull(hash, "Resource pack hash cannot be null");
Validate.isTrue(hash.length == 20, "Resource pack hash should be 20 bytes long but was " + hash.length);
getHandle().setResourcePack(url, BaseEncoding.base16().lowerCase().encode(hash), false, null);
getHandle().sendTexturePack(url, BaseEncoding.base16().lowerCase().encode(hash), false, null);
}
public void addChannel(String channel) {
@@ -1344,7 +1344,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
getHandle().connection.sendPacket(new PacketPlayOutCustomPayload(new MinecraftKey("register"), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray()))));
getHandle().connection.send(new PacketPlayOutCustomPayload(new MinecraftKey("register"), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray()))));
}
}
@@ -1379,7 +1379,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (container.getBukkitView().getType() != prop.getType()) {
return false;
}
container.setContainerData(prop.getId(), value);
container.setData(prop.getId(), value);
return true;
}
@@ -1400,7 +1400,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
getHandle().getAbilities().flying = value;
getHandle().updateAbilities();
getHandle().onUpdateAbilities();
}
@Override
@@ -1415,7 +1415,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
getHandle().getAbilities().mayfly = value;
getHandle().updateAbilities();
getHandle().onUpdateAbilities();
}
@Override
@@ -1438,7 +1438,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
validateSpeed(value);
EntityPlayer player = getHandle();
player.getAbilities().flyingSpeed = value / 2f;
player.updateAbilities();
player.onUpdateAbilities();
}
@@ -1447,8 +1447,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
validateSpeed(value);
EntityPlayer player = getHandle();
player.getAbilities().walkingSpeed = value / 2f;
player.updateAbilities();
getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(player.getAbilities().walkingSpeed); // SPIGOT-5833: combination of the two in 1.16+
player.onUpdateAbilities();
getHandle().getAttribute(GenericAttributes.MOVEMENT_SPEED).setBaseValue(player.getAbilities().walkingSpeed); // SPIGOT-5833: combination of the two in 1.16+
}
@Override
@@ -1477,13 +1477,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void setMaxHealth(double amount) {
super.setMaxHealth(amount);
this.health = Math.min(this.health, health);
getHandle().triggerHealthUpdate();
getHandle().resetSentInfo();
}
@Override
public void resetMaxHealth() {
super.resetMaxHealth();
getHandle().triggerHealthUpdate();
getHandle().resetSentInfo();
}
@Override
@@ -1548,25 +1548,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void updateScaledHealth(boolean sendHealth) {
AttributeMapBase attributemapserver = getHandle().getAttributeMap();
Collection<AttributeModifiable> set = attributemapserver.b(); // PAIL: Rename
AttributeMapBase attributemapserver = getHandle().getAttributes();
Collection<AttributeModifiable> set = attributemapserver.getSyncableAttributes();
injectScaledMaxHealth(set, true);
// SPIGOT-3813: Attributes before health
if (getHandle().connection != null) {
getHandle().connection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set));
getHandle().connection.send(new PacketPlayOutUpdateAttributes(getHandle().getId(), set));
if (sendHealth) {
sendHealthUpdate();
}
}
getHandle().getDataWatcher().set(EntityLiving.DATA_HEALTH_ID, (float) getScaledHealth());
getHandle().getEntityData().set(EntityLiving.DATA_HEALTH_ID, (float) getScaledHealth());
getHandle().maxHealthCache = getMaxHealth();
}
public void sendHealthUpdate() {
getHandle().connection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel()));
getHandle().connection.send(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel()));
}
public void injectScaledMaxHealth(Collection<AttributeModifiable> collection, boolean force) {
@@ -1580,20 +1580,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
AttributeModifiable dummy = new AttributeModifiable(GenericAttributes.MAX_HEALTH, (attribute) -> { });
dummy.setValue(scaledHealth ? healthScale : getMaxHealth());
dummy.setBaseValue(scaledHealth ? healthScale : getMaxHealth());
collection.add(dummy);
}
@Override
public org.bukkit.entity.Entity getSpectatorTarget() {
Entity followed = getHandle().getSpecatorTarget();
Entity followed = getHandle().getCamera();
return followed == getHandle() ? null : followed.getBukkitEntity();
}
@Override
public void setSpectatorTarget(org.bukkit.entity.Entity entity) {
Preconditions.checkArgument(getGameMode() == GameMode.SPECTATOR, "Player must be in spectator mode");
getHandle().setSpectatorTarget((entity == null) ? null : ((CraftEntity) entity).getHandle());
getHandle().setCamera((entity == null) ? null : ((CraftEntity) entity).getHandle());
}
@Override
@@ -1604,23 +1604,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) {
ClientboundSetTitlesAnimationPacket times = new ClientboundSetTitlesAnimationPacket(fadeIn, stay, fadeOut);
getHandle().connection.sendPacket(times);
getHandle().connection.send(times);
if (title != null) {
ClientboundSetTitleTextPacket packetTitle = new ClientboundSetTitleTextPacket(CraftChatMessage.fromStringOrNull(title));
getHandle().connection.sendPacket(packetTitle);
getHandle().connection.send(packetTitle);
}
if (subtitle != null) {
ClientboundSetSubtitleTextPacket packetSubtitle = new ClientboundSetSubtitleTextPacket(CraftChatMessage.fromStringOrNull(subtitle));
getHandle().connection.sendPacket(packetSubtitle);
getHandle().connection.send(packetSubtitle);
}
}
@Override
public void resetTitle() {
ClientboundClearTitlesPacket packetReset = new ClientboundClearTitlesPacket(true);
getHandle().connection.sendPacket(packetReset);
getHandle().connection.send(packetReset);
}
@Override
@@ -1684,7 +1684,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
}
PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.toNMS(particle, data), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count);
getHandle().connection.sendPacket(packetplayoutworldparticles);
getHandle().connection.send(packetplayoutworldparticles);
}
@@ -1693,8 +1693,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Preconditions.checkArgument(advancement != null, "advancement");
CraftAdvancement craft = (CraftAdvancement) advancement;
AdvancementDataPlayer data = getHandle().getAdvancementData();
AdvancementProgress progress = data.getProgress(craft.getHandle());
AdvancementDataPlayer data = getHandle().getAdvancements();
AdvancementProgress progress = data.getOrStartProgress(craft.getHandle());
return new CraftAdvancementProgress(craft, data, progress);
}
@@ -1718,7 +1718,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void updateCommands() {
if (getHandle().connection == null) return;
getHandle().server.getCommandDispatcher().a(getHandle());
getHandle().server.getCommands().sendCommands(getHandle());
}
@Override
@@ -1728,7 +1728,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
ItemStack hand = getInventory().getItemInMainHand();
getInventory().setItemInMainHand(book);
getHandle().openBook(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(book), net.minecraft.world.EnumHand.MAIN_HAND);
getHandle().openItemGui(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(book), net.minecraft.world.EnumHand.MAIN_HAND);
getInventory().setItemInMainHand(hand);
}
}

View File

@@ -19,9 +19,9 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj
@Override
public void setShooter(ProjectileSource shooter) {
if (shooter instanceof CraftLivingEntity) {
getHandle().setShooter((EntityLiving) ((CraftLivingEntity) shooter).entity);
getHandle().setOwner((EntityLiving) ((CraftLivingEntity) shooter).entity);
} else {
getHandle().setShooter(null);
getHandle().setOwner(null);
}
getHandle().projectileSource = shooter;
}

View File

@@ -42,9 +42,9 @@ public class CraftRabbit extends CraftAnimals implements Rabbit {
if (getRabbitType() == Type.THE_KILLER_BUNNY) {
// Reset goals and target finders.
World world = ((CraftWorld) this.getWorld()).getHandle();
entity.goalSelector = new PathfinderGoalSelector(world.getMethodProfilerSupplier());
entity.targetSelector = new PathfinderGoalSelector(world.getMethodProfilerSupplier());
entity.initPathfinder();
entity.goalSelector = new PathfinderGoalSelector(world.getProfilerSupplier());
entity.targetSelector = new PathfinderGoalSelector(world.getProfilerSupplier());
entity.registerGoals();
entity.initializePathFinderGoals();
}

View File

@@ -52,7 +52,7 @@ public abstract class CraftRaider extends CraftMonster implements Raider {
@Override
public boolean isCanJoinRaid() {
return getHandle().isCanJoinRaid();
return getHandle().canJoinRaid();
}
@Override

View File

@@ -14,12 +14,12 @@ public class CraftSheep extends CraftAnimals implements Sheep {
@Override
public DyeColor getColor() {
return DyeColor.getByWoolData((byte) getHandle().getColor().getColorIndex());
return DyeColor.getByWoolData((byte) getHandle().getColor().getId());
}
@Override
public void setColor(DyeColor color) {
getHandle().setColor(EnumColor.fromColorIndex(color.getWoolData()));
getHandle().setColor(EnumColor.byId(color.getWoolData()));
}
@Override

View File

@@ -32,23 +32,23 @@ public class CraftShulker extends CraftGolem implements Shulker {
@Override
public DyeColor getColor() {
return DyeColor.getByWoolData(getHandle().getDataWatcher().get(EntityShulker.DATA_COLOR_ID));
return DyeColor.getByWoolData(getHandle().getEntityData().get(EntityShulker.DATA_COLOR_ID));
}
@Override
public void setColor(DyeColor color) {
getHandle().getDataWatcher().set(EntityShulker.DATA_COLOR_ID, (color == null) ? 16 : color.getWoolData());
getHandle().getEntityData().set(EntityShulker.DATA_COLOR_ID, (color == null) ? 16 : color.getWoolData());
}
@Override
public float getPeek() {
return (float) getHandle().getPeek() / 100;
return (float) getHandle().getRawPeekAmount() / 100;
}
@Override
public void setPeek(float value) {
Preconditions.checkArgument(value >= 0 && value <= 1, "value needs to be in between or equal to 0 and 1");
getHandle().setPeek((int) (value * 100));
getHandle().setRawPeekAmount((int) (value * 100));
}
@Override

View File

@@ -22,9 +22,9 @@ public class CraftShulkerBullet extends AbstractProjectile implements ShulkerBul
@Override
public void setShooter(ProjectileSource shooter) {
if (shooter instanceof Entity) {
getHandle().setShooter(((CraftEntity) shooter).getHandle());
getHandle().setOwner(((CraftEntity) shooter).getHandle());
} else {
getHandle().setShooter(null);
getHandle().setOwner(null);
}
getHandle().projectileSource = shooter;
}

View File

@@ -15,10 +15,10 @@ public class CraftSizedFireball extends CraftFireball implements SizedFireball {
@Override
public ItemStack getDisplayItem() {
if (getHandle().getItem().isEmpty()) {
if (getHandle().getItemRaw().isEmpty()) {
return new ItemStack(Material.FIRE_CHARGE);
} else {
return CraftItemStack.asBukkitCopy(getHandle().getItem());
return CraftItemStack.asBukkitCopy(getHandle().getItemRaw());
}
}

View File

@@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.world.entity.monster.EntitySkeleton;
import net.minecraft.world.entity.monster.EntitySkeletonAbstract;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Skeleton;
@@ -15,7 +14,7 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton {
@Override
public boolean isConverting() {
return this.getHandle().fw(); // PAIL rename isStrayConverting
return this.getHandle().isFreezeConverting();
}
@Override
@@ -28,9 +27,9 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton {
public void setConversionTime(int time) {
if (time < 0) {
this.getHandle().conversionTime = -1;
this.getHandle().getDataWatcher().set(EntitySkeleton.DATA_STRAY_CONVERSION_ID, false);
this.getHandle().getEntityData().set(EntitySkeleton.DATA_STRAY_CONVERSION_ID, false);
} else {
this.getHandle().a(time); // PAIL rename startStrayConversion
this.getHandle().startFreezeConversion(time);
}
}

Some files were not shown because too many files have changed in this diff Show More