Update to Minecraft 1.16.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2020-08-12 07:00:00 +10:00
parent 5e5f7f19dc
commit 6a9e00d4b6
208 changed files with 2144 additions and 2455 deletions

View File

@@ -16,6 +16,7 @@ import net.minecraft.server.EnumSkyBlock;
import net.minecraft.server.GameProfileSerializer;
import net.minecraft.server.HeightMap;
import net.minecraft.server.IBlockData;
import net.minecraft.server.IRegistry;
import net.minecraft.server.LightEngine;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.NibbleArray;
@@ -288,7 +289,7 @@ public class CraftChunk implements Chunk {
BiomeStorage biome = null;
if (includeBiome || includeBiomeTempRain) {
biome = chunk.getBiomeIndex().b();
biome = chunk.getBiomeIndex();
}
World world = getWorld();
@@ -300,7 +301,7 @@ public class CraftChunk implements Chunk {
if (includeBiome || includeBiomeTempRain) {
WorldChunkManager wcm = world.getHandle().getChunkProvider().getChunkGenerator().getWorldChunkManager();
biome = new BiomeStorage(new ChunkCoordIntPair(x, z), wcm);
biome = new BiomeStorage(world.getHandle().r().b(IRegistry.ay), new ChunkCoordIntPair(x, z), wcm);
}
/* Fill with empty data */

View File

@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.DamageSource;
import net.minecraft.server.Entity;
import net.minecraft.server.EntityHuman;
@@ -14,6 +13,7 @@ import net.minecraft.server.LootContextParameterSet;
import net.minecraft.server.LootContextParameters;
import net.minecraft.server.LootTable;
import net.minecraft.server.LootTableInfo;
import net.minecraft.server.Vec3D;
import net.minecraft.server.WorldServer;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
@@ -82,7 +82,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle();
builder.set(LootContextParameters.THIS_ENTITY, nmsLootedEntity);
builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC);
builder.set(LootContextParameters.POSITION, nmsLootedEntity.getChunkCoordinates());
builder.set(LootContextParameters.ORIGIN, nmsLootedEntity.getPositionVector());
}
if (context.getKiller() != null) {
@@ -115,7 +115,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
}
public static LootContext convertContext(LootTableInfo info) {
BlockPosition position = info.getContextParameter(LootContextParameters.POSITION);
Vec3D position = info.getContextParameter(LootContextParameters.ORIGIN);
Location location = new Location(info.getWorld().getWorld(), position.getX(), position.getY(), position.getZ());
LootContext.Builder contextBuilder = new LootContext.Builder(location);

View File

@@ -92,9 +92,8 @@ import net.minecraft.server.PlayerList;
import net.minecraft.server.RegistryMaterials;
import net.minecraft.server.RegistryReadOps;
import net.minecraft.server.ResourceKey;
import net.minecraft.server.SaveData;
import net.minecraft.server.ServerCommand;
import net.minecraft.server.TagsServer;
import net.minecraft.server.Tags;
import net.minecraft.server.TicketType;
import net.minecraft.server.Vec3D;
import net.minecraft.server.VillageSiege;
@@ -752,7 +751,7 @@ public final class CraftServer implements Server {
configuration = YamlConfiguration.loadConfiguration(getConfigFile());
commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile());
console.propertyManager = new DedicatedServerSettings(console.options);
console.propertyManager = new DedicatedServerSettings(console.aX(), console.options);
DedicatedServerProperties config = console.propertyManager.getProperties();
console.setPVP(config.pvp);
@@ -986,7 +985,7 @@ public final class CraftServer implements Server {
IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b();
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), (IRegistryCustom) iregistrycustom_dimension);
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), iregistrycustom_dimension);
WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration);
WorldSettings worldSettings;
@@ -998,7 +997,7 @@ 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(properties);
GeneratorSettings generatorsettings = GeneratorSettings.a(console.aX(), properties);
worldSettings = new WorldSettings(name, EnumGamemode.getById(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
}
@@ -1008,32 +1007,29 @@ public final class CraftServer implements Server {
if (console.options.has("forceUpgrade")) {
net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), console.options.has("eraseCache"), () -> {
return true;
}, worlddata.getGeneratorSettings().e().c().stream().map((entry) -> {
return ResourceKey.a(IRegistry.ad, ((ResourceKey) entry.getKey()).a());
}, worlddata.getGeneratorSettings().d().d().stream().map((entry) -> {
return ResourceKey.a(IRegistry.K, ((ResourceKey) entry.getKey()).a());
}).collect(ImmutableSet.toImmutableSet()));
}
long j = BiomeManager.a(creator.seed());
List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata));
RegistryMaterials<WorldDimension> registrymaterials = worlddata.getGeneratorSettings().e();
RegistryMaterials<WorldDimension> registrymaterials = worlddata.getGeneratorSettings().d();
WorldDimension worlddimension = (WorldDimension) registrymaterials.a(actualDimension);
DimensionManager dimensionmanager;
net.minecraft.server.ChunkGenerator chunkgenerator;
if (worlddimension == null) {
dimensionmanager = DimensionManager.a();
chunkgenerator = GeneratorSettings.a((new Random()).nextLong());
dimensionmanager = (DimensionManager) console.f.a().d(DimensionManager.OVERWORLD);
chunkgenerator = GeneratorSettings.a(console.f.b(IRegistry.ay), console.f.b(IRegistry.ar), (new Random()).nextLong());
} else {
dimensionmanager = worlddimension.b();
chunkgenerator = worlddimension.c();
}
ResourceKey<DimensionManager> typeKey = (ResourceKey) console.f.a().c(dimensionmanager).orElseThrow(() -> {
return new IllegalStateException("Unregistered dimension type: " + dimensionmanager);
});
ResourceKey<net.minecraft.server.World> worldKey = ResourceKey.a(IRegistry.ae, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH)));
ResourceKey<net.minecraft.server.World> worldKey = ResourceKey.a(IRegistry.L, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH)));
WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, worldSession, worlddata, worldKey, typeKey, dimensionmanager, getServer().worldLoadListenerFactory.create(11),
WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, worldSession, worlddata, worldKey, dimensionmanager, getServer().worldLoadListenerFactory.create(11),
chunkgenerator, worlddata.getGeneratorSettings().isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator);
if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
@@ -1212,7 +1208,7 @@ public final class CraftServer implements Server {
public Recipe getRecipe(NamespacedKey recipeKey) {
Preconditions.checkArgument(recipeKey != null, "recipeKey == null");
return getServer().getCraftingManager().a(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null);
return getServer().getCraftingManager().getRecipe(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null);
}
@Override
@@ -1971,13 +1967,13 @@ 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");
TagsServer<Block> blockTags = console.getTagRegistry().getBlockTags();
return blockTags.b().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList());
Tags<Block> blockTags = console.getTagRegistry().getBlockTags();
return blockTags.a().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");
TagsServer<Item> itemTags = console.getTagRegistry().getItemTags();
return itemTags.b().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList());
Tags<Item> itemTags = console.getTagRegistry().getItemTags();
return itemTags.a().keySet().stream().map(key -> (org.bukkit.Tag<T>) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList());
default:
throw new IllegalArgumentException();
}

View File

@@ -635,6 +635,7 @@ public enum CraftSound {
ENTITY_PARROT_IMITATE_MAGMA_CUBE("entity.parrot.imitate.magma_cube"),
ENTITY_PARROT_IMITATE_PHANTOM("entity.parrot.imitate.phantom"),
ENTITY_PARROT_IMITATE_PIGLIN("entity.parrot.imitate.piglin"),
ENTITY_PARROT_IMITATE_PIGLIN_BRUTE("entity.parrot.imitate.piglin_brute"),
ENTITY_PARROT_IMITATE_PILLAGER("entity.parrot.imitate.pillager"),
ENTITY_PARROT_IMITATE_RAVAGER("entity.parrot.imitate.ravager"),
ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"),
@@ -661,6 +662,12 @@ public enum CraftSound {
ENTITY_PIGLIN_ADMIRING_ITEM("entity.piglin.admiring_item"),
ENTITY_PIGLIN_AMBIENT("entity.piglin.ambient"),
ENTITY_PIGLIN_ANGRY("entity.piglin.angry"),
ENTITY_PIGLIN_BRUTE_AMBIENT("entity.piglin_brute.ambient"),
ENTITY_PIGLIN_BRUTE_ANGRY("entity.piglin_brute.angry"),
ENTITY_PIGLIN_BRUTE_CONVERTED_TO_ZOMBIFIED("entity.piglin_brute.converted_to_zombified"),
ENTITY_PIGLIN_BRUTE_DEATH("entity.piglin_brute.death"),
ENTITY_PIGLIN_BRUTE_HURT("entity.piglin_brute.hurt"),
ENTITY_PIGLIN_BRUTE_STEP("entity.piglin_brute.step"),
ENTITY_PIGLIN_CELEBRATE("entity.piglin.celebrate"),
ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED("entity.piglin.converted_to_zombified"),
ENTITY_PIGLIN_DEATH("entity.piglin.death"),

View File

@@ -88,6 +88,7 @@ import net.minecraft.server.Ticket;
import net.minecraft.server.TicketType;
import net.minecraft.server.Unit;
import net.minecraft.server.Vec3D;
import net.minecraft.server.WorldGenFeatureConfigured;
import net.minecraft.server.WorldGenFeatureHugeFungiConfiguration;
import net.minecraft.server.WorldGenerator;
import net.minecraft.server.WorldServer;
@@ -196,6 +197,7 @@ import org.bukkit.entity.Phantom;
import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Piglin;
import org.bukkit.entity.PiglinBrute;
import org.bukkit.entity.Pillager;
import org.bukkit.entity.Player;
import org.bukkit.entity.PolarBear;
@@ -317,7 +319,7 @@ public class CraftWorld implements World {
public boolean setSpawnLocation(int x, int y, int z) {
try {
Location previousLocation = getSpawnLocation();
world.worldData.setSpawn(new BlockPosition(x, y, z));
world.worldData.setSpawn(new BlockPosition(x, y, z), 0.0F);
// Notify anyone who's listening.
SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
@@ -664,88 +666,69 @@ public class CraftWorld implements World {
public boolean generateTree(Location loc, TreeType type) {
BlockPosition pos = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
net.minecraft.server.WorldGenerator gen;
net.minecraft.server.WorldGenFeatureConfiguration conf;
net.minecraft.server.WorldGenFeatureConfigured gen;
switch (type) {
case BIG_TREE:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.FANCY_TREE;
gen = BiomeDecoratorGroups.FANCY_OAK;
break;
case BIRCH:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.BIRCH_TREE;
gen = BiomeDecoratorGroups.BIRCH;
break;
case REDWOOD:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.SPRUCE_TREE;
gen = BiomeDecoratorGroups.SPRUCE;
break;
case TALL_REDWOOD:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.PINE_TREE;
gen = BiomeDecoratorGroups.PINE;
break;
case JUNGLE:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.MEGA_JUNGLE_TREE;
gen = BiomeDecoratorGroups.MEGA_JUNGLE_TREE;
break;
case SMALL_JUNGLE:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.JUNGLE_TREE_NOVINE;
gen = BiomeDecoratorGroups.JUNGLE_TREE_NO_VINE;
break;
case COCOA_TREE:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.JUNGLE_TREE;
gen = BiomeDecoratorGroups.JUNGLE_TREE;
break;
case JUNGLE_BUSH:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.JUNGLE_BUSH;
gen = BiomeDecoratorGroups.JUNGLE_BUSH;
break;
case RED_MUSHROOM:
gen = WorldGenerator.HUGE_RED_MUSHROOM;
conf = BiomeDecoratorGroups.HUGE_RED_MUSHROOM;
gen = BiomeDecoratorGroups.HUGE_RED_MUSHROOM;
break;
case BROWN_MUSHROOM:
gen = WorldGenerator.HUGE_BROWN_MUSHROOM;
conf = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM;
gen = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM;
break;
case SWAMP:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.SWAMP_TREE;
gen = BiomeDecoratorGroups.SWAMP_TREE;
break;
case ACACIA:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.ACACIA_TREE;
gen = BiomeDecoratorGroups.ACACIA;
break;
case DARK_OAK:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.DARK_OAK_TREE;
gen = BiomeDecoratorGroups.DARK_OAK;
break;
case MEGA_REDWOOD:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.MEGA_PINE_TREE;
gen = BiomeDecoratorGroups.MEGA_PINE;
break;
case TALL_BIRCH:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.TALL_BIRCH_TREE_BEES_0002;
gen = BiomeDecoratorGroups.SUPER_BIRCH_BEES_0002;
break;
case CHORUS_PLANT:
((BlockChorusFlower) Blocks.CHORUS_FLOWER).a(world, pos, rand, 8);
return true;
case CRIMSON_FUNGUS:
gen = WorldGenerator.HUGE_FUNGUS;
conf = WorldGenFeatureHugeFungiConfiguration.b;
gen = BiomeDecoratorGroups.CRIMSON_FUNGI;
break;
case WARPED_FUNGUS:
gen = WorldGenerator.HUGE_FUNGUS;
conf = WorldGenFeatureHugeFungiConfiguration.d;
gen = BiomeDecoratorGroups.WARPED_FUNGI;
break;
case TREE:
default:
gen = WorldGenerator.TREE;
conf = BiomeDecoratorGroups.NORMAL_TREE;
gen = BiomeDecoratorGroups.OAK;
break;
}
return gen.generate(world, world.getStructureManager(), world.getChunkProvider().getChunkGenerator(), rand, pos, conf);
return gen.e.generate(world, world.getChunkProvider().getChunkGenerator(), rand, pos, gen.f);
}
@Override
@@ -1700,6 +1683,8 @@ public class CraftWorld implements World {
entity = EntityTypes.HOGLIN.a(world);
} else if (Piglin.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PIGLIN.a(world);
} else if (PiglinBrute.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PIGLIN_BRUTE.a(world);
} else if (Strider.class.isAssignableFrom(clazz)) {
entity = EntityTypes.STRIDER.a(world);
} else if (Zoglin.class.isAssignableFrom(clazz)) {

View File

@@ -177,11 +177,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, -21);
deadline.add(Calendar.DAY_OF_YEAR, -2);
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

@@ -4,7 +4,7 @@ import java.util.Random;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.EntityBee;
import net.minecraft.server.EntityTypes;
import net.minecraft.server.GeneratorAccess;
import net.minecraft.server.GeneratorAccessSeed;
import net.minecraft.server.TileEntity;
import net.minecraft.server.TileEntityBeehive;
import net.minecraft.server.World;
@@ -27,19 +27,19 @@ public final class CapturedBlockState extends CraftBlockState {
// SPIGOT-5537: Horrible hack to manually add bees given World.captureTreeGeneration does not support tiles
if (this.treeBlock && getType() == Material.BEE_NEST) {
GeneratorAccess generatoraccess = this.world.getHandle();
GeneratorAccessSeed generatoraccessseed = this.world.getHandle();
BlockPosition blockposition1 = this.getPosition();
Random random = generatoraccess.getRandom();
Random random = generatoraccessseed.getRandom();
// Begin copied block from WorldGenFeatureTreeBeehive
TileEntity tileentity = generatoraccess.getTileEntity(blockposition1);
TileEntity tileentity = generatoraccessseed.getTileEntity(blockposition1);
if (tileentity instanceof TileEntityBeehive) {
TileEntityBeehive tileentitybeehive = (TileEntityBeehive) tileentity;
int j = 2 + random.nextInt(2);
for (int k = 0; k < j; ++k) {
EntityBee entitybee = new EntityBee(EntityTypes.BEE, generatoraccess.getMinecraftWorld());
EntityBee entitybee = new EntityBee(EntityTypes.BEE, generatoraccessseed.getMinecraftWorld());
tileentitybeehive.a(entitybee, false, random.nextInt(599));
}

View File

@@ -38,8 +38,8 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr
requirePlaced();
if (!getTileEntity().opened) {
IBlockData blockData = getTileEntity().getBlock();
getTileEntity().a(blockData, true);
getTileEntity().a(blockData, SoundEffects.BLOCK_BARREL_OPEN);
getTileEntity().setOpenFlag(blockData, true);
getTileEntity().playOpenSound(blockData, SoundEffects.BLOCK_BARREL_OPEN);
}
getTileEntity().opened = true;
}
@@ -49,8 +49,8 @@ public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barr
requirePlaced();
if (getTileEntity().opened) {
IBlockData blockData = getTileEntity().getBlock();
getTileEntity().a(blockData, false);
getTileEntity().a(blockData, SoundEffects.BLOCK_BARREL_CLOSE);
getTileEntity().setOpenFlag(blockData, false);
getTileEntity().playOpenSound(blockData, SoundEffects.BLOCK_BARREL_CLOSE);
}
getTileEntity().opened = false;
}

View File

@@ -19,6 +19,7 @@ import net.minecraft.server.IRegistry;
import net.minecraft.server.MinecraftKey;
import net.minecraft.server.MovingObjectPosition;
import net.minecraft.server.RayTrace;
import net.minecraft.server.RegistryGeneration;
import net.minecraft.server.TileEntity;
import net.minecraft.server.Vec3D;
import net.minecraft.server.VoxelShape;
@@ -152,7 +153,7 @@ public class CraftBlock implements Block {
@Override
public BlockData getBlockData() {
return CraftBlockData.fromData(getNMS());
return CraftBlockData.fromData(getNMS());
}
@Override
@@ -225,7 +226,6 @@ public class CraftBlock implements Block {
return (byte) world.getBrightness(EnumSkyBlock.BLOCK, position);
}
public Block getFace(final BlockFace face) {
return getRelative(face, 1);
}
@@ -268,41 +268,43 @@ public class CraftBlock implements Block {
}
public static BlockFace notchToBlockFace(EnumDirection notch) {
if (notch == null) return BlockFace.SELF;
switch (notch) {
case DOWN:
return BlockFace.DOWN;
case UP:
return BlockFace.UP;
case NORTH:
return BlockFace.NORTH;
case SOUTH:
return BlockFace.SOUTH;
case WEST:
return BlockFace.WEST;
case EAST:
return BlockFace.EAST;
default:
if (notch == null) {
return BlockFace.SELF;
}
switch (notch) {
case DOWN:
return BlockFace.DOWN;
case UP:
return BlockFace.UP;
case NORTH:
return BlockFace.NORTH;
case SOUTH:
return BlockFace.SOUTH;
case WEST:
return BlockFace.WEST;
case EAST:
return BlockFace.EAST;
default:
return BlockFace.SELF;
}
}
public static EnumDirection blockFaceToNotch(BlockFace face) {
switch (face) {
case DOWN:
return EnumDirection.DOWN;
case UP:
return EnumDirection.UP;
case NORTH:
return EnumDirection.NORTH;
case SOUTH:
return EnumDirection.SOUTH;
case WEST:
return EnumDirection.WEST;
case EAST:
return EnumDirection.EAST;
default:
return null;
case DOWN:
return EnumDirection.DOWN;
case UP:
return EnumDirection.UP;
case NORTH:
return EnumDirection.NORTH;
case SOUTH:
return EnumDirection.SOUTH;
case WEST:
return EnumDirection.WEST;
case EAST:
return EnumDirection.EAST;
default:
return null;
}
}
@@ -311,168 +313,168 @@ public class CraftBlock implements Block {
Material material = getType();
switch (material) {
case ACACIA_SIGN:
case ACACIA_WALL_SIGN:
case BIRCH_SIGN:
case BIRCH_WALL_SIGN:
case CRIMSON_SIGN:
case CRIMSON_WALL_SIGN:
case DARK_OAK_SIGN:
case DARK_OAK_WALL_SIGN:
case JUNGLE_SIGN:
case JUNGLE_WALL_SIGN:
case OAK_SIGN:
case OAK_WALL_SIGN:
case SPRUCE_SIGN:
case SPRUCE_WALL_SIGN:
case WARPED_SIGN:
case WARPED_WALL_SIGN:
return new CraftSign(this);
case CHEST:
case TRAPPED_CHEST:
return new CraftChest(this);
case FURNACE:
return new CraftFurnaceFurnace(this);
case DISPENSER:
return new CraftDispenser(this);
case DROPPER:
return new CraftDropper(this);
case END_GATEWAY:
return new CraftEndGateway(this);
case HOPPER:
return new CraftHopper(this);
case SPAWNER:
return new CraftCreatureSpawner(this);
case JUKEBOX:
return new CraftJukebox(this);
case BREWING_STAND:
return new CraftBrewingStand(this);
case CREEPER_HEAD:
case CREEPER_WALL_HEAD:
case DRAGON_HEAD:
case DRAGON_WALL_HEAD:
case PLAYER_HEAD:
case PLAYER_WALL_HEAD:
case SKELETON_SKULL:
case SKELETON_WALL_SKULL:
case WITHER_SKELETON_SKULL:
case WITHER_SKELETON_WALL_SKULL:
case ZOMBIE_HEAD:
case ZOMBIE_WALL_HEAD:
return new CraftSkull(this);
case COMMAND_BLOCK:
case CHAIN_COMMAND_BLOCK:
case REPEATING_COMMAND_BLOCK:
return new CraftCommandBlock(this);
case BEACON:
return new CraftBeacon(this);
case BLACK_BANNER:
case BLACK_WALL_BANNER:
case BLUE_BANNER:
case BLUE_WALL_BANNER:
case BROWN_BANNER:
case BROWN_WALL_BANNER:
case CYAN_BANNER:
case CYAN_WALL_BANNER:
case GRAY_BANNER:
case GRAY_WALL_BANNER:
case GREEN_BANNER:
case GREEN_WALL_BANNER:
case LIGHT_BLUE_BANNER:
case LIGHT_BLUE_WALL_BANNER:
case LIGHT_GRAY_BANNER:
case LIGHT_GRAY_WALL_BANNER:
case LIME_BANNER:
case LIME_WALL_BANNER:
case MAGENTA_BANNER:
case MAGENTA_WALL_BANNER:
case ORANGE_BANNER:
case ORANGE_WALL_BANNER:
case PINK_BANNER:
case PINK_WALL_BANNER:
case PURPLE_BANNER:
case PURPLE_WALL_BANNER:
case RED_BANNER:
case RED_WALL_BANNER:
case WHITE_BANNER:
case WHITE_WALL_BANNER:
case YELLOW_BANNER:
case YELLOW_WALL_BANNER:
return new CraftBanner(this);
case STRUCTURE_BLOCK:
return new CraftStructureBlock(this);
case SHULKER_BOX:
case WHITE_SHULKER_BOX:
case ORANGE_SHULKER_BOX:
case MAGENTA_SHULKER_BOX:
case LIGHT_BLUE_SHULKER_BOX:
case YELLOW_SHULKER_BOX:
case LIME_SHULKER_BOX:
case PINK_SHULKER_BOX:
case GRAY_SHULKER_BOX:
case LIGHT_GRAY_SHULKER_BOX:
case CYAN_SHULKER_BOX:
case PURPLE_SHULKER_BOX:
case BLUE_SHULKER_BOX:
case BROWN_SHULKER_BOX:
case GREEN_SHULKER_BOX:
case RED_SHULKER_BOX:
case BLACK_SHULKER_BOX:
return new CraftShulkerBox(this);
case ENCHANTING_TABLE:
return new CraftEnchantingTable(this);
case ENDER_CHEST:
return new CraftEnderChest(this);
case DAYLIGHT_DETECTOR:
return new CraftDaylightDetector(this);
case COMPARATOR:
return new CraftComparator(this);
case BLACK_BED:
case BLUE_BED:
case BROWN_BED:
case CYAN_BED:
case GRAY_BED:
case GREEN_BED:
case LIGHT_BLUE_BED:
case LIGHT_GRAY_BED:
case LIME_BED:
case MAGENTA_BED:
case ORANGE_BED:
case PINK_BED:
case PURPLE_BED:
case RED_BED:
case WHITE_BED:
case YELLOW_BED:
return new CraftBed(this);
case CONDUIT:
return new CraftConduit(this);
case BARREL:
return new CraftBarrel(this);
case BELL:
return new CraftBell(this);
case BLAST_FURNACE:
return new CraftBlastFurnace(this);
case CAMPFIRE:
case SOUL_CAMPFIRE:
return new CraftCampfire(this);
case JIGSAW:
return new CraftJigsaw(this);
case LECTERN:
return new CraftLectern(this);
case SMOKER:
return new CraftSmoker(this);
case BEEHIVE:
case BEE_NEST:
return new CraftBeehive(this);
default:
TileEntity tileEntity = world.getTileEntity(position);
if (tileEntity != null) {
// block with unhandled TileEntity:
return new CraftBlockEntityState<TileEntity>(this, (Class<TileEntity>) tileEntity.getClass());
} else {
// Block without TileEntity:
return new CraftBlockState(this);
}
case ACACIA_SIGN:
case ACACIA_WALL_SIGN:
case BIRCH_SIGN:
case BIRCH_WALL_SIGN:
case CRIMSON_SIGN:
case CRIMSON_WALL_SIGN:
case DARK_OAK_SIGN:
case DARK_OAK_WALL_SIGN:
case JUNGLE_SIGN:
case JUNGLE_WALL_SIGN:
case OAK_SIGN:
case OAK_WALL_SIGN:
case SPRUCE_SIGN:
case SPRUCE_WALL_SIGN:
case WARPED_SIGN:
case WARPED_WALL_SIGN:
return new CraftSign(this);
case CHEST:
case TRAPPED_CHEST:
return new CraftChest(this);
case FURNACE:
return new CraftFurnaceFurnace(this);
case DISPENSER:
return new CraftDispenser(this);
case DROPPER:
return new CraftDropper(this);
case END_GATEWAY:
return new CraftEndGateway(this);
case HOPPER:
return new CraftHopper(this);
case SPAWNER:
return new CraftCreatureSpawner(this);
case JUKEBOX:
return new CraftJukebox(this);
case BREWING_STAND:
return new CraftBrewingStand(this);
case CREEPER_HEAD:
case CREEPER_WALL_HEAD:
case DRAGON_HEAD:
case DRAGON_WALL_HEAD:
case PLAYER_HEAD:
case PLAYER_WALL_HEAD:
case SKELETON_SKULL:
case SKELETON_WALL_SKULL:
case WITHER_SKELETON_SKULL:
case WITHER_SKELETON_WALL_SKULL:
case ZOMBIE_HEAD:
case ZOMBIE_WALL_HEAD:
return new CraftSkull(this);
case COMMAND_BLOCK:
case CHAIN_COMMAND_BLOCK:
case REPEATING_COMMAND_BLOCK:
return new CraftCommandBlock(this);
case BEACON:
return new CraftBeacon(this);
case BLACK_BANNER:
case BLACK_WALL_BANNER:
case BLUE_BANNER:
case BLUE_WALL_BANNER:
case BROWN_BANNER:
case BROWN_WALL_BANNER:
case CYAN_BANNER:
case CYAN_WALL_BANNER:
case GRAY_BANNER:
case GRAY_WALL_BANNER:
case GREEN_BANNER:
case GREEN_WALL_BANNER:
case LIGHT_BLUE_BANNER:
case LIGHT_BLUE_WALL_BANNER:
case LIGHT_GRAY_BANNER:
case LIGHT_GRAY_WALL_BANNER:
case LIME_BANNER:
case LIME_WALL_BANNER:
case MAGENTA_BANNER:
case MAGENTA_WALL_BANNER:
case ORANGE_BANNER:
case ORANGE_WALL_BANNER:
case PINK_BANNER:
case PINK_WALL_BANNER:
case PURPLE_BANNER:
case PURPLE_WALL_BANNER:
case RED_BANNER:
case RED_WALL_BANNER:
case WHITE_BANNER:
case WHITE_WALL_BANNER:
case YELLOW_BANNER:
case YELLOW_WALL_BANNER:
return new CraftBanner(this);
case STRUCTURE_BLOCK:
return new CraftStructureBlock(this);
case SHULKER_BOX:
case WHITE_SHULKER_BOX:
case ORANGE_SHULKER_BOX:
case MAGENTA_SHULKER_BOX:
case LIGHT_BLUE_SHULKER_BOX:
case YELLOW_SHULKER_BOX:
case LIME_SHULKER_BOX:
case PINK_SHULKER_BOX:
case GRAY_SHULKER_BOX:
case LIGHT_GRAY_SHULKER_BOX:
case CYAN_SHULKER_BOX:
case PURPLE_SHULKER_BOX:
case BLUE_SHULKER_BOX:
case BROWN_SHULKER_BOX:
case GREEN_SHULKER_BOX:
case RED_SHULKER_BOX:
case BLACK_SHULKER_BOX:
return new CraftShulkerBox(this);
case ENCHANTING_TABLE:
return new CraftEnchantingTable(this);
case ENDER_CHEST:
return new CraftEnderChest(this);
case DAYLIGHT_DETECTOR:
return new CraftDaylightDetector(this);
case COMPARATOR:
return new CraftComparator(this);
case BLACK_BED:
case BLUE_BED:
case BROWN_BED:
case CYAN_BED:
case GRAY_BED:
case GREEN_BED:
case LIGHT_BLUE_BED:
case LIGHT_GRAY_BED:
case LIME_BED:
case MAGENTA_BED:
case ORANGE_BED:
case PINK_BED:
case PURPLE_BED:
case RED_BED:
case WHITE_BED:
case YELLOW_BED:
return new CraftBed(this);
case CONDUIT:
return new CraftConduit(this);
case BARREL:
return new CraftBarrel(this);
case BELL:
return new CraftBell(this);
case BLAST_FURNACE:
return new CraftBlastFurnace(this);
case CAMPFIRE:
case SOUL_CAMPFIRE:
return new CraftCampfire(this);
case JIGSAW:
return new CraftJigsaw(this);
case LECTERN:
return new CraftLectern(this);
case SMOKER:
return new CraftSmoker(this);
case BEEHIVE:
case BEE_NEST:
return new CraftBeehive(this);
default:
TileEntity tileEntity = world.getTileEntity(position);
if (tileEntity != null) {
// block with unhandled TileEntity:
return new CraftBlockEntityState<TileEntity>(this, (Class<TileEntity>) tileEntity.getClass());
} else {
// Block without TileEntity:
return new CraftBlockState(this);
}
}
}
@@ -491,7 +493,7 @@ public class CraftBlock implements Block {
return null;
}
return Biome.valueOf(IRegistry.BIOME.getKey(base).getKey().toUpperCase(java.util.Locale.ENGLISH));
return Biome.valueOf(RegistryGeneration.WORLDGEN_BIOME.getKey(base).getKey().toUpperCase(java.util.Locale.ENGLISH));
}
public static BiomeBase biomeToBiomeBase(Biome bio) {
@@ -499,7 +501,7 @@ public class CraftBlock implements Block {
return null;
}
return IRegistry.BIOME.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH)));
return RegistryGeneration.WORLDGEN_BIOME.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH)));
}
@Override
@@ -524,8 +526,12 @@ public class CraftBlock implements Block {
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof CraftBlock)) return false;
if (o == this) {
return true;
}
if (!(o instanceof CraftBlock)) {
return false;
}
CraftBlock other = (CraftBlock) o;
return this.position.equals(other.position) && this.getWorld().equals(other.getWorld());
@@ -613,7 +619,7 @@ public class CraftBlock implements Block {
boolean result = false;
// Modelled off EntityHuman#hasBlock
if (block != Blocks.AIR && (item == null || !iblockdata.isAlwaysDestroyable() || nmsItem.canDestroySpecialBlock(iblockdata))) {
if (block != Blocks.AIR && (item == null || !iblockdata.isRequiresSpecialTool() || nmsItem.canDestroySpecialBlock(iblockdata))) {
net.minecraft.server.Block.dropItems(iblockdata, world.getMinecraftWorld(), position, world.getTileEntity(position), null, nmsItem);
result = true;
}
@@ -637,7 +643,7 @@ public class CraftBlock implements Block {
net.minecraft.server.ItemStack nms = CraftItemStack.asNMSCopy(item);
// Modelled off EntityHuman#hasBlock
if (item == null || !iblockdata.isAlwaysDestroyable() || nms.canDestroySpecialBlock(iblockdata)) {
if (item == null || !iblockdata.isRequiresSpecialTool() || nms.canDestroySpecialBlock(iblockdata)) {
return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms)
.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList());
} else {

View File

@@ -12,7 +12,6 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.CraftChunk;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;

View File

@@ -62,7 +62,7 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
if (!getTileEntity().opened) {
net.minecraft.server.Block block = getTileEntity().getBlock().getBlock();
getTileEntity().getWorld().playBlockAction(getTileEntity().getPosition(), block, 1, getTileEntity().viewingCount + 1);
getTileEntity().a(SoundEffects.BLOCK_CHEST_OPEN);
getTileEntity().playOpenSound(SoundEffects.BLOCK_CHEST_OPEN);
}
getTileEntity().opened = true;
}
@@ -73,7 +73,7 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
if (getTileEntity().opened) {
net.minecraft.server.Block block = getTileEntity().getBlock().getBlock();
getTileEntity().getWorld().playBlockAction(getTileEntity().getPosition(), block, 1, 0);
getTileEntity().a(SoundEffects.BLOCK_CHEST_CLOSE);
getTileEntity().playOpenSound(SoundEffects.BLOCK_CHEST_CLOSE);
}
getTileEntity().opened = false;
}

View File

@@ -3,7 +3,7 @@
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftChain extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged {
public final class CraftChain extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Chain, org.bukkit.block.data.Orientable, org.bukkit.block.data.Waterlogged {
public CraftChain() {
super();
@@ -13,6 +13,25 @@ public final class CraftChain extends org.bukkit.craftbukkit.block.data.CraftBlo
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftOrientable
private static final net.minecraft.server.BlockStateEnum<?> AXIS = getEnum(net.minecraft.server.BlockChain.class, "axis");
@Override
public org.bukkit.Axis getAxis() {
return get(AXIS, org.bukkit.Axis.class);
}
@Override
public void setAxis(org.bukkit.Axis axis) {
set(AXIS, axis);
}
@Override
public java.util.Set<org.bukkit.Axis> getAxes() {
return getValues(AXIS, org.bukkit.Axis.class);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockChain.class, "waterlogged");

View File

@@ -3,7 +3,7 @@
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lantern {
public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lantern, org.bukkit.block.data.Waterlogged {
public CraftLantern() {
super();
@@ -26,4 +26,18 @@ public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftB
public void setHanging(boolean hanging) {
set(HANGING, hanging);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockLantern.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

@@ -39,11 +39,11 @@ public class CraftDragonBattle implements DragonBattle {
@Override
public boolean generateEndPortal(boolean withPortals) {
if (handle.exitPortalLocation != null || handle.j() != null) {
if (handle.exitPortalLocation != null || handle.getExitPortalShape() != null) {
return false;
}
this.handle.a(withPortals);
this.handle.generateExitPortal(withPortals);
return true;
}

View File

@@ -94,6 +94,8 @@ import net.minecraft.server.EntityPhantom;
import net.minecraft.server.EntityPig;
import net.minecraft.server.EntityPigZombie;
import net.minecraft.server.EntityPiglin;
import net.minecraft.server.EntityPiglinAbstract;
import net.minecraft.server.EntityPiglinBrute;
import net.minecraft.server.EntityPillager;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityPolarBear;
@@ -284,7 +286,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else { return new CraftIllager(server, (EntityIllagerAbstract) entity); }
}
else if (entity instanceof EntityRavager) { return new CraftRavager(server, (EntityRavager) entity); }
else if (entity instanceof EntityPiglin) { return new CraftPiglin(server, (EntityPiglin) entity); }
else if (entity instanceof EntityPiglinAbstract) {
if (entity instanceof EntityPiglin) return new CraftPiglin(server, (EntityPiglin) entity);
else if (entity instanceof EntityPiglinBrute) { return new CraftPiglinBrute(server, (EntityPiglinBrute) entity); }
else { return new CraftPiglinAbstract(server, (EntityPiglinAbstract) entity); }
}
else if (entity instanceof EntityZoglin) { return new CraftZoglin(server, (EntityZoglin) entity); }
else { return new CraftMonster(server, (EntityMonster) entity); }

View File

@@ -14,43 +14,43 @@ public class CraftHoglin extends CraftAnimals implements Hoglin {
@Override
public boolean isImmuneToZombification() {
return getHandle().eW();
return getHandle().isImmuneToZombification();
}
@Override
public void setImmuneToZombification(boolean flag) {
getHandle().t(flag);
getHandle().setImmuneToZombification(flag);
}
@Override
public boolean isAbleToBeHunted() {
return getHandle().bA;
return getHandle().cannotBeHunted;
}
@Override
public void setIsAbleToBeHunted(boolean flag) {
getHandle().bA = flag;
getHandle().cannotBeHunted = flag;
}
@Override
public int getConversionTime() {
Preconditions.checkState(isConverting(), "Entity not converting");
return getHandle().bz;
return getHandle().conversionTicks;
}
@Override
public void setConversionTime(int time) {
if (time < 0) {
getHandle().bz = -1;
getHandle().t(false);
getHandle().conversionTicks = -1;
getHandle().setImmuneToZombification(false);
} else {
getHandle().bz = time;
getHandle().conversionTicks = time;
}
}
@Override
public boolean isConverting() {
return getHandle().eO(); // PAIL rename isConverting()
return getHandle().isConverting();
}
@Override

View File

@@ -522,7 +522,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
CraftingManager manager = getHandle().world.getMinecraftServer().getCraftingManager();
for (NamespacedKey recipeKey : recipeKeys) {
Optional<? extends IRecipe<?>> recipe = manager.a(CraftNamespacedKey.toMinecraft(recipeKey));
Optional<? extends IRecipe<?>> recipe = manager.getRecipe(CraftNamespacedKey.toMinecraft(recipeKey));
if (!recipe.isPresent()) {
continue;
}

View File

@@ -140,12 +140,12 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
@Override
public boolean isFixed() {
return getHandle().ao;
return getHandle().fixed;
}
@Override
public void setFixed(boolean fixed) {
getHandle().ao = fixed;
getHandle().fixed = fixed;
}
@Override

View File

@@ -25,7 +25,7 @@ public class CraftPig extends CraftAnimals implements Pig {
@Override
public int getBoostTicks() {
return getHandle().saddleStorage.a ? getHandle().saddleStorage.c : 0;
return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.boostTicks : 0;
}
@Override
@@ -37,19 +37,19 @@ public class CraftPig extends CraftAnimals implements Pig {
@Override
public int getCurrentBoostTicks() {
return getHandle().saddleStorage.a ? getHandle().saddleStorage.b : 0;
return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.currentBoostTicks : 0;
}
@Override
public void setCurrentBoostTicks(int ticks) {
if (!getHandle().saddleStorage.a) {
if (!getHandle().saddleStorage.boosting) {
return;
}
int max = getHandle().saddleStorage.c;
int max = getHandle().saddleStorage.boostTicks;
Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max);
this.getHandle().saddleStorage.b = ticks;
this.getHandle().saddleStorage.currentBoostTicks = ticks;
}
@Override

View File

@@ -1,66 +1,24 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.EntityPiglin;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Piglin;
public class CraftPiglin extends CraftMonster implements Piglin {
public class CraftPiglin extends CraftPiglinAbstract implements Piglin {
public CraftPiglin(CraftServer server, EntityPiglin entity) {
super(server, entity);
}
@Override
public boolean isImmuneToZombification() {
return getHandle().eT();
}
@Override
public void setImmuneToZombification(boolean flag) {
getHandle().t(flag);
}
@Override
public boolean isAbleToHunt() {
return getHandle().bC;
return getHandle().cannotHunt;
}
@Override
public void setIsAbleToHunt(boolean flag) {
getHandle().bC = flag;
}
@Override
public int getConversionTime() {
Preconditions.checkState(isConverting(), "Entity not converting");
return getHandle().bA;
}
@Override
public void setConversionTime(int time) {
if (time < 0) {
getHandle().bA = -1;
getHandle().t(false);
} else {
getHandle().bA = time;
}
}
@Override
public boolean isConverting() {
return getHandle().eO(); // PAIL rename isConverting()
}
@Override
public boolean isBaby() {
return getHandle().isBaby();
}
@Override
public void setBaby(boolean flag) {
getHandle().a(flag);
getHandle().cannotHunt = flag;
}
@Override

View File

@@ -0,0 +1,59 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.EntityPiglinAbstract;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.PiglinAbstract;
public class CraftPiglinAbstract extends CraftMonster implements PiglinAbstract {
public CraftPiglinAbstract(CraftServer server, EntityPiglinAbstract entity) {
super(server, entity);
}
@Override
public boolean isImmuneToZombification() {
return getHandle().isImmuneToZombification();
}
@Override
public void setImmuneToZombification(boolean flag) {
getHandle().setImmuneToZombification(flag);
}
@Override
public int getConversionTime() {
Preconditions.checkState(isConverting(), "Entity not converting");
return getHandle().conversionTicks;
}
@Override
public void setConversionTime(int time) {
if (time < 0) {
getHandle().conversionTicks = -1;
getHandle().setImmuneToZombification(false);
} else {
getHandle().conversionTicks = time;
}
}
@Override
public boolean isConverting() {
return getHandle().isConverting();
}
@Override
public boolean isBaby() {
return getHandle().isBaby();
}
@Override
public void setBaby(boolean flag) {
getHandle().setBaby(flag);
}
@Override
public EntityPiglinAbstract getHandle() {
return (EntityPiglinAbstract) super.getHandle();
}
}

View File

@@ -0,0 +1,28 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityPiglinBrute;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.PiglinBrute;
public class CraftPiglinBrute extends CraftPiglinAbstract implements PiglinBrute {
public CraftPiglinBrute(CraftServer server, EntityPiglinBrute entity) {
super(server, entity);
}
@Override
public EntityPiglinBrute getHandle() {
return (EntityPiglinBrute) super.getHandle();
}
@Override
public EntityType getType() {
return EntityType.PIGLIN_BRUTE;
}
@Override
public String toString() {
return "CraftPiglinBrute";
}
}

View File

@@ -314,7 +314,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (getHandle().playerConnection == null) return;
// Do not directly assign here, from the packethandler we'll assign it.
getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));
getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), loc.getYaw()));
}
@Override
@@ -728,7 +728,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
BlockPosition bed = getHandle().getSpawn();
if (world != null && bed != null) {
Optional<Vec3D> spawnLoc = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isSpawnForced(), true);
Optional<Vec3D> spawnLoc = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().getSpawnAngle(), getHandle().isSpawnForced(), true);
if (spawnLoc.isPresent()) {
Vec3D vec = spawnLoc.get();
return new Location(world, vec.x, vec.y, vec.z);
@@ -745,9 +745,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void setBedSpawnLocation(Location location, boolean override) {
if (location == null) {
getHandle().setRespawnPosition(null, null, override, false);
getHandle().setRespawnPosition(null, null, location.getYaw(), override, false);
} else {
getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), override, false);
getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false);
}
}
@@ -762,13 +762,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public boolean hasDiscoveredRecipe(NamespacedKey recipe) {
Preconditions.checkArgument(recipe != null, "recipe cannot be null");
return getHandle().B().b(CraftNamespacedKey.toMinecraft(recipe));
return getHandle().getRecipeBook().hasDiscoveredRecipe(CraftNamespacedKey.toMinecraft(recipe));
}
@Override
public Set<NamespacedKey> getDiscoveredRecipes() {
ImmutableSet.Builder<NamespacedKey> bukkitRecipeKeys = ImmutableSet.builder();
getHandle().B().a.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key)));
getHandle().getRecipeBook().recipes.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key)));
return bukkitRecipeKeys.build();
}

View File

@@ -15,12 +15,12 @@ public class CraftStrider extends CraftAnimals implements Strider {
@Override
public boolean isShivering() {
return getHandle().eL(); // PAIL rename isShivering
return getHandle().isShivering();
}
@Override
public void setShivering(boolean shivering) {
this.getHandle().t(shivering); // PAIL rename setShivering
this.getHandle().setShivering(shivering);
}
@Override
@@ -30,36 +30,36 @@ public class CraftStrider extends CraftAnimals implements Strider {
@Override
public void setSaddle(boolean saddled) {
getHandle().bA.setSaddle(saddled);
getHandle().saddleStorage.setSaddle(saddled);
}
@Override
public int getBoostTicks() {
return getHandle().bA.a ? getHandle().bA.c : 0;
return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.boostTicks : 0;
}
@Override
public void setBoostTicks(int ticks) {
Preconditions.checkArgument(ticks >= 0, "ticks must be >= 0");
getHandle().bA.setBoostTicks(ticks);
getHandle().saddleStorage.setBoostTicks(ticks);
}
@Override
public int getCurrentBoostTicks() {
return getHandle().bA.a ? getHandle().bA.b : 0;
return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.currentBoostTicks : 0;
}
@Override
public void setCurrentBoostTicks(int ticks) {
if (!getHandle().bA.a) {
if (!getHandle().saddleStorage.boosting) {
return;
}
int max = getHandle().bA.c;
int max = getHandle().saddleStorage.boostTicks;
Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max);
this.getHandle().bA.b = ticks;
this.getHandle().saddleStorage.currentBoostTicks = ticks;
}
@Override

View File

@@ -18,7 +18,7 @@ public class CraftZoglin extends CraftMonster implements Zoglin {
@Override
public void setBaby(boolean flag) {
getHandle().a(flag);
getHandle().setBaby(flag);
}
@Override

View File

@@ -1460,7 +1460,7 @@ public class CraftEventFactory {
BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getBlockData());
// Suppress during worldgen
if (world instanceof World) {
world.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
((World) world).getMinecraftServer().server.getPluginManager().callEvent(event);
}
return event;
}

View File

@@ -14,9 +14,12 @@ import net.minecraft.server.DefinedStructureManager;
import net.minecraft.server.DimensionManager;
import net.minecraft.server.EnumCreatureType;
import net.minecraft.server.GeneratorAccess;
import net.minecraft.server.GeneratorAccessSeed;
import net.minecraft.server.HeightMap;
import net.minecraft.server.IBlockAccess;
import net.minecraft.server.IChunkAccess;
import net.minecraft.server.IRegistry;
import net.minecraft.server.IRegistryCustom;
import net.minecraft.server.ITileEntity;
import net.minecraft.server.ProtoChunk;
import net.minecraft.server.RegionLimitedWorldAccess;
@@ -36,6 +39,7 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
public class CustomChunkGenerator extends InternalChunkGenerator {
private final net.minecraft.server.ChunkGenerator delegate;
private final ChunkGenerator generator;
private final WorldServer world;
@@ -81,7 +85,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
@Override
public void createBiomes(IChunkAccess ichunkaccess) {
public void createBiomes(IRegistry<BiomeBase> iregistry, IChunkAccess ichunkaccess) {
// Don't allow the server to override any custom biomes that have been set
}
@@ -91,8 +95,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
@Override
public void storeStructures(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess) {
delegate.storeStructures(generatoraccess, structuremanager, ichunkaccess);
public void storeStructures(GeneratorAccessSeed generatoraccessseed, StructureManager structuremanager, IChunkAccess ichunkaccess) {
delegate.storeStructures(generatoraccessseed, structuremanager, ichunkaccess);
}
@Override
@@ -108,7 +112,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
// Get default biome data for chunk
CustomBiomeGrid biomegrid = new CustomBiomeGrid(new BiomeStorage(ichunkaccess.getPos(), this.getWorldChunkManager()));
CustomBiomeGrid biomegrid = new CustomBiomeGrid(new BiomeStorage(world.r().b(IRegistry.ay), ichunkaccess.getPos(), this.getWorldChunkManager()));
ChunkData data;
if (generator.isParallelCapable()) {
@@ -155,12 +159,13 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
@Override
public void createStructures(StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i) {
public void createStructures(IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i) {
if (generator.shouldGenerateStructures()) {
// Still need a way of getting the biome of this chunk to pass to createStructures
// Using default biomes for now.
delegate.createStructures(structuremanager, ichunkaccess, definedstructuremanager, i);
delegate.createStructures(iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i);
}
}
@Override
@@ -180,11 +185,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
return delegate.getBaseHeight(i, j, heightmap_type);
}
@Override
public List<BiomeBase.BiomeMeta> getMobsFor(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
return delegate.getMobsFor(biomebase, structuremanager, enumcreaturetype, blockposition);
}
@Override
public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager) {
if (generator.shouldGenerateDecorations()) {

View File

@@ -20,6 +20,7 @@ import net.minecraft.server.IProjectile;
import net.minecraft.server.MathHelper;
import net.minecraft.server.SourceBlock;
import net.minecraft.server.TileEntityDispenser;
import net.minecraft.server.WorldServer;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -65,7 +66,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
Validate.isTrue(getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
// Copied from BlockDispenser.dispense()
SourceBlock isourceblock = new SourceBlock(dispenserBlock.getWorld(), dispenserBlock.getPosition());
SourceBlock isourceblock = new SourceBlock((WorldServer) dispenserBlock.getWorld(), dispenserBlock.getPosition());
// Copied from DispenseBehaviorProjectile
IPosition iposition = BlockDispenser.a(isourceblock);
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);

View File

@@ -5,13 +5,13 @@ import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.server.Block;
import net.minecraft.server.MinecraftKey;
import net.minecraft.server.TagsServer;
import net.minecraft.server.Tags;
import org.bukkit.Material;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftBlockTag extends CraftTag<Block, Material> {
public CraftBlockTag(TagsServer<Block> registry, MinecraftKey tag) {
public CraftBlockTag(Tags<Block> registry, MinecraftKey tag) {
super(registry, tag);
}

View File

@@ -5,13 +5,13 @@ import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.server.Item;
import net.minecraft.server.MinecraftKey;
import net.minecraft.server.TagsServer;
import net.minecraft.server.Tags;
import org.bukkit.Material;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftItemTag extends CraftTag<Item, Material> {
public CraftItemTag(TagsServer<Item> registry, MinecraftKey tag) {
public CraftItemTag(Tags<Item> registry, MinecraftKey tag) {
super(registry, tag);
}

View File

@@ -1,7 +1,7 @@
package org.bukkit.craftbukkit.tag;
import net.minecraft.server.MinecraftKey;
import net.minecraft.server.TagsServer;
import net.minecraft.server.Tags;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Tag;
@@ -9,23 +9,17 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
public abstract class CraftTag<N, B extends Keyed> implements Tag<B> {
private final net.minecraft.server.TagsServer<N> registry;
private final net.minecraft.server.Tags<N> registry;
private final MinecraftKey tag;
//
private int version = -1;
private net.minecraft.server.Tag<N> handle;
public CraftTag(TagsServer<N> registry, MinecraftKey tag) {
public CraftTag(Tags<N> registry, MinecraftKey tag) {
this.registry = registry;
this.tag = tag;
}
protected net.minecraft.server.Tag<N> getHandle() {
if (version != registry.version) {
handle = registry.b(tag);
version = registry.version;
}
return handle;
}

View File

@@ -45,11 +45,11 @@ public final class CraftChatMessage {
// Separate pattern with no group 3, new lines are part of previous string
private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE);
// ChatColor.b does not explicitly reset, its more of empty
private static final ChatModifier RESET = ChatModifier.b.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false);
private static final ChatModifier RESET = ChatModifier.a.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false);
private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>();
private IChatMutableComponent currentChatComponent = new ChatComponentText("");
private ChatModifier modifier = ChatModifier.b;
private ChatModifier modifier = ChatModifier.a;
private final IChatBaseComponent[] output;
private int currentIndex;
private StringBuilder hex;

View File

@@ -204,7 +204,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
* @return string
*/
public String getMappingsVersion() {
return "25afc67716a170ea965092c1067ff439";
return "c2d5d7871edcc4fb0f81d18959c647af";
}
@Override
@@ -240,7 +240,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
JsonElement jsonelement = AdvancementDataWorld.DESERIALIZER.fromJson(advancement, JsonElement.class);
JsonObject jsonobject = ChatDeserializer.m(jsonelement, "advancement");
net.minecraft.server.Advancement.SerializedAdvancement nms = net.minecraft.server.Advancement.SerializedAdvancement.a(jsonobject, new LootDeserializationContext(minecraftkey, MinecraftServer.getServer().aI()));
net.minecraft.server.Advancement.SerializedAdvancement nms = net.minecraft.server.Advancement.SerializedAdvancement.a(jsonobject, new LootDeserializationContext(minecraftkey, MinecraftServer.getServer().getLootPredicateManager()));
if (nms != null) {
MinecraftServer.getServer().getAdvancementData().REGISTRY.a(Maps.newHashMap(Collections.singletonMap(minecraftkey, nms)));
Advancement bukkit = Bukkit.getAdvancement(key);

View File

@@ -20,16 +20,16 @@ import net.minecraft.server.HeightMap;
import net.minecraft.server.IBlockData;
import net.minecraft.server.IChunkAccess;
import net.minecraft.server.IChunkProvider;
import net.minecraft.server.IRegistryCustom;
import net.minecraft.server.LightEngine;
import net.minecraft.server.ParticleParam;
import net.minecraft.server.SoundCategory;
import net.minecraft.server.SoundEffect;
import net.minecraft.server.TickList;
import net.minecraft.server.TickListEmpty;
import net.minecraft.server.TileEntity;
import net.minecraft.server.World;
import net.minecraft.server.WorldBorder;
import net.minecraft.server.WorldData;
import net.minecraft.server.WorldServer;
public class DummyGeneratorAccess implements GeneratorAccess {
@@ -40,16 +40,11 @@ public class DummyGeneratorAccess implements GeneratorAccess {
@Override
public TickList<Block> getBlockTickList() {
return TickListEmpty.b();
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public TickList<FluidType> getFluidTickList() {
return TickListEmpty.b();
}
@Override
public World getMinecraftWorld() {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -59,7 +54,7 @@ public class DummyGeneratorAccess implements GeneratorAccess {
}
@Override
public DifficultyDamageScaler getDamageScaler(BlockPosition bp) {
public DifficultyDamageScaler getDamageScaler(BlockPosition blockposition) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -74,17 +69,27 @@ public class DummyGeneratorAccess implements GeneratorAccess {
}
@Override
public void playSound(EntityHuman eh, BlockPosition bp, SoundEffect se, SoundCategory sc, float f, float f1) {
public void playSound(EntityHuman entityhuman, BlockPosition blockposition, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void addParticle(ParticleParam pp, double d, double d1, double d2, double d3, double d4, double d5) {
public void addParticle(ParticleParam particleparam, double d0, double d1, double d2, double d3, double d4, double d5) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void a(EntityHuman eh, int i, BlockPosition bp, int i1) {
public void a(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public WorldServer getMinecraftWorld() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public IRegistryCustom r() {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -187,4 +192,9 @@ public class DummyGeneratorAccess implements GeneratorAccess {
public boolean a(BlockPosition blockposition, boolean flag, Entity entity, int i) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long ab() {
throw new UnsupportedOperationException("Not supported yet.");
}
}