diff options
Diffstat (limited to 'src')
48 files changed, 334 insertions, 208 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/src/main/java/org/bukkit/craftbukkit/CraftArt.java index 1b17fd2b..378cd360 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; +import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import net.minecraft.server.Paintings; import org.bukkit.Art; @@ -12,8 +13,8 @@ public class CraftArt { static { ImmutableBiMap.Builder<Paintings, Art> artworkBuilder = ImmutableBiMap.builder(); - for (MinecraftKey key : Paintings.a.keySet()) { - artworkBuilder.put(Paintings.a.get(key), Art.getByName(key.getKey())); + for (MinecraftKey key : IRegistry.MOTIVE.keySet()) { + artworkBuilder.put(IRegistry.MOTIVE.get(key), Art.getByName(key.getKey())); } artwork = artworkBuilder.build(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index 0740c565..8822e6b9 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -12,7 +12,6 @@ import net.minecraft.server.IInventory; import net.minecraft.server.LootTable; import net.minecraft.server.LootTableInfo; import net.minecraft.server.WorldServer; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.NamespacedKey; import org.bukkit.craftbukkit.entity.CraftEntity; @@ -72,24 +71,24 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { Location loc = context.getLocation(); WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle(); - LootTableInfo.a builder = new LootTableInfo.a(handle); // PAIL rename Builder - builder.a(context.getLuck()); // PAIL rename withLuck, luck + LootTableInfo.Builder builder = new LootTableInfo.Builder(handle); + builder.luck(context.getLuck()); if (context.getLootedEntity() != null) { Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle(); - builder.a(nmsLootedEntity); // PAIL Rename withLootedEntity, lootedEntity - builder.a(DamageSource.GENERIC); // PAIL rename withDamageSource, damageSource - builder.a(new BlockPosition(nmsLootedEntity)); // PAIL rename withPosition, position + builder.entity(nmsLootedEntity); + builder.damageSource(DamageSource.GENERIC); + builder.position(new BlockPosition(nmsLootedEntity)); } if (context.getKiller() != null) { EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle(); - builder.a(nmsKiller); // PAIL rename withKiller, killer + builder.killer(nmsKiller); // If there is a player killer, damage source should reflect that in case loot tables use that information - builder.a(DamageSource.playerAttack(nmsKiller)); // PAIL rename withDamageSource, damageSource + builder.damageSource(DamageSource.playerAttack(nmsKiller)); } - return builder.a(); // PAIL rename build + return builder.build(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 7b49f673..698cfb91 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import net.minecraft.server.EntityPlayer; +import net.minecraft.server.DimensionManager; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.WhiteListEntry; import net.minecraft.server.WorldNBTStorage; @@ -32,7 +32,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa protected CraftOfflinePlayer(CraftServer server, GameProfile profile) { this.server = server; this.profile = profile; - this.storage = (WorldNBTStorage) (server.console.worlds.get(0).getDataManager()); + this.storage = (WorldNBTStorage) (server.console.getWorldServer(DimensionManager.OVERWORLD).getDataManager()); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index 7e1f4e3f..f4c52bf6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -5,6 +5,7 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import java.util.HashMap; import java.util.Map; +import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import net.minecraft.server.ParticleParam; import net.minecraft.server.ParticleParamBlock; @@ -114,7 +115,7 @@ public enum CraftParticle { canonical = aliases.get(particle); } - net.minecraft.server.Particle nms = net.minecraft.server.Particle.REGISTRY.get(particles.get(canonical)); + net.minecraft.server.Particle nms = IRegistry.PARTICLE_TYPE.get(particles.get(canonical)); Preconditions.checkArgument(nms != null, "No NMS particle %s", particle); if (particle.getDataType().equals(Void.class)) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 9bb0ceb2..52216ec2 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -134,6 +134,7 @@ import com.mojang.brigadier.tree.LiteralCommandNode; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; +import it.unimi.dsi.fastutil.longs.LongIterator; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Base64; @@ -694,8 +695,8 @@ public final class CraftServer implements Server { ((DedicatedServer) console).propertyManager = config; boolean animals = config.getBoolean("spawn-animals", console.getSpawnAnimals()); - boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).getDifficulty() != EnumDifficulty.PEACEFUL); - EnumDifficulty difficulty = EnumDifficulty.getById(config.getInt("difficulty", console.worlds.get(0).getDifficulty().ordinal())); + boolean monsters = config.getBoolean("spawn-monsters", console.getWorldServer(DimensionManager.OVERWORLD).getDifficulty() != EnumDifficulty.PEACEFUL); + EnumDifficulty difficulty = EnumDifficulty.getById(config.getInt("difficulty", console.getWorldServer(DimensionManager.OVERWORLD).getDifficulty().ordinal())); online.value = config.getBoolean("online-mode", console.getOnlineMode()); console.setSpawnAnimals(config.getBoolean("spawn-animals", console.getSpawnAnimals())); @@ -724,7 +725,7 @@ public final class CraftServer implements Server { logger.log(Level.WARNING, "Failed to load banned-players.json, " + ex.getMessage()); } - for (WorldServer world : console.worlds) { + for (WorldServer world : console.getWorlds()) { world.worldData.setDifficulty(difficulty); world.setSpawnFlags(monsters, animals); if (this.getTicksPerAnimalSpawns() < 0) { @@ -886,11 +887,11 @@ public final class CraftServer implements Server { console.convertWorld(name); - int dimension = CraftWorld.CUSTOM_DIMENSION_OFFSET + console.worlds.size(); + int dimension = CraftWorld.CUSTOM_DIMENSION_OFFSET + console.worldServer.size(); boolean used = false; do { - for (WorldServer server : console.worlds) { - used = server.dimension == dimension; + for (WorldServer server : console.getWorlds()) { + used = server.dimension.getDimensionID() == dimension; if (used) { dimension++; break; @@ -900,6 +901,7 @@ public final class CraftServer implements Server { boolean hardcore = false; IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, getServer(), getHandle().getServer().dataConverterManager); + PersistentCollection persistentcollection = new PersistentCollection(sdm); WorldData worlddata = sdm.getWorldData(); WorldSettings worldSettings = null; if (worlddata == null) { @@ -911,7 +913,9 @@ public final class CraftServer implements Server { worlddata = new WorldData(worldSettings, name); } worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) - WorldServer internal = (WorldServer) new WorldServer(console, sdm, worlddata, dimension, console.methodProfiler, creator.environment(), generator).b(); + + DimensionManager internalDimension = new DimensionManager(dimension, name, name, () -> DimensionManager.a(creator.environment().getId()).e()); + WorldServer internal = (WorldServer) new WorldServer(console, sdm, persistentcollection, worlddata, internalDimension, console.methodProfiler, creator.environment(), generator).i_(); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { return null; @@ -925,10 +929,10 @@ public final class CraftServer implements Server { internal.addIWorldAccess(new WorldManager(console, internal)); internal.worldData.setDifficulty(EnumDifficulty.EASY); internal.setSpawnFlags(true, true); - console.worlds.add(internal); + console.worldServer.put(internal.dimension, internal); pluginManager.callEvent(new WorldInitEvent(internal.getWorld())); - System.out.println("Preparing start region for level " + (console.worlds.size() - 1) + " (Seed: " + internal.getSeed() + ")"); + System.out.println("Preparing start region for level " + (console.worldServer.size() - 1) + " (Seed: " + internal.getSeed() + ")"); if (internal.getWorld().getKeepSpawnInMemory()) { short short1 = 196; @@ -950,10 +954,26 @@ public final class CraftServer implements Server { } BlockPosition chunkcoordinates = internal.getSpawn(); - internal.getChunkProviderServer().getChunkAt(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4); + internal.getChunkProviderServer().getChunkAt(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4, true, true); } } } + + DimensionManager dimensionmanager = internalDimension.e().getDimensionManager(); + ForcedChunk forcedchunk = (ForcedChunk) persistentcollection.get(dimensionmanager, ForcedChunk::new, "chunks"); + + if (forcedchunk != null) { + LongIterator longiterator = forcedchunk.a().iterator(); + + while (longiterator.hasNext()) { + System.out.println("Loading forced chunks for dimension " + dimension + ", " + forcedchunk.a().size() * 100 / 625 + "%"); + long k = longiterator.nextLong(); + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(k); + + internal.getChunkProviderServer().getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, true, true); + } + } + pluginManager.callEvent(new WorldLoadEvent(internal.getWorld())); return internal.getWorld(); } @@ -971,11 +991,11 @@ public final class CraftServer implements Server { WorldServer handle = ((CraftWorld) world).getHandle(); - if (!(console.worlds.contains(handle))) { + if (!(console.worldServer.containsKey(handle.dimension))) { return false; } - if (handle.dimension == 0) { + if (handle.dimension == DimensionManager.OVERWORLD) { return false; } @@ -1000,7 +1020,7 @@ public final class CraftServer implements Server { } worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH)); - console.worlds.remove(console.worlds.indexOf(handle)); + console.worldServer.remove(handle.dimension); return true; } @@ -1215,8 +1235,8 @@ public final class CraftServer implements Server { @Override @Deprecated public CraftMapView getMap(short id) { - PersistentCollection collection = console.worlds.get(0).worldMaps; - WorldMap worldmap = (WorldMap) collection.get(WorldMap::new, "map_" + id); + PersistentCollection collection = console.getWorldServer(DimensionManager.OVERWORLD).worldMaps; + WorldMap worldmap = (WorldMap) collection.get(DimensionManager.OVERWORLD, WorldMap::new, "map_" + id); if (worldmap == null) { return null; } @@ -1388,7 +1408,7 @@ public final class CraftServer implements Server { @Override public GameMode getDefaultGameMode() { - return GameMode.getByValue(console.worlds.get(0).getWorldData().getGameType().getId()); + return GameMode.getByValue(console.getWorldServer(DimensionManager.OVERWORLD).getWorldData().getGameType().getId()); } @Override @@ -1432,7 +1452,7 @@ public final class CraftServer implements Server { @Override public OfflinePlayer[] getOfflinePlayers() { - WorldNBTStorage storage = (WorldNBTStorage) console.worlds.get(0).getDataManager(); + WorldNBTStorage storage = (WorldNBTStorage) console.getWorldServer(DimensionManager.OVERWORLD).getDataManager(); String[] files = storage.getPlayerDir().list(new DatFileFilter()); Set<OfflinePlayer> players = new HashSet<OfflinePlayer>(); @@ -1687,7 +1707,7 @@ public final class CraftServer implements Server { public Entity getEntity(UUID uuid) { Validate.notNull(uuid, "UUID cannot be null"); - for (WorldServer world : getServer().worlds) { + for (WorldServer world : getServer().getWorlds()) { net.minecraft.server.Entity entity = world.getEntity(uuid); if (entity != null) { return entity.getBukkitEntity(); @@ -1769,8 +1789,8 @@ public final class CraftServer implements Server { public LootTable getLootTable(NamespacedKey key) { Validate.notNull(key, "NamespacedKey cannot be null"); - LootTableRegistry registry = getServer().aP(); // PAIL getLootTableRegistry - return new CraftLootTable(key, registry.a(CraftNamespacedKey.toMinecraft(key))); // PAIL rename getLootTable + LootTableRegistry registry = getServer().getLootTableRegistry(); + return new CraftLootTable(key, registry.getLootTable(CraftNamespacedKey.toMinecraft(key))); } @Deprecated diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java index 1181701e..17fab031 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; +import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import net.minecraft.server.SoundEffect; @@ -684,7 +685,7 @@ public enum CraftSound { } public static SoundEffect getSoundEffect(String s) { - SoundEffect effect = SoundEffect.a.get(new MinecraftKey(s)); + SoundEffect effect = IRegistry.SOUND_EVENT.get(new MinecraftKey(s)); Preconditions.checkArgument(effect != null, "Sound effect %s does not exist", s); return effect; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index e1eaef5e..31252df5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -11,9 +11,9 @@ import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; import net.minecraft.server.Block; import net.minecraft.server.EntityTypes; +import net.minecraft.server.IRegistry; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; -import net.minecraft.server.RegistryMaterials; import org.bukkit.craftbukkit.util.CraftMagicNumbers; public enum CraftStatistic { @@ -75,8 +75,14 @@ public enum CraftStatistic { CHEST_OPENED(StatisticList.OPEN_CHEST), SLEEP_IN_BED(StatisticList.SLEEP_IN_BED), SHULKER_BOX_OPENED(StatisticList.OPEN_SHULKER_BOX), - TIME_SINCE_REST(StatisticList.n), - SWIM_ONE_CM(StatisticList.SWIM_ONE_CM); + TIME_SINCE_REST(StatisticList.TIME_SINCE_REST), + SWIM_ONE_CM(StatisticList.SWIM_ONE_CM), + DAMAGE_DEALT_ABSORBED(StatisticList.DAMAGE_DEALT_ABSORBED), + DAMAGE_DEALT_RESISTED(StatisticList.DAMAGE_DEALT_RESISTED), + DAMAGE_BLOCKED_BY_SHIELD(StatisticList.DAMAGE_BLOCKED_BY_SHIELD), + DAMAGE_ABSORBED(StatisticList.DAMAGE_ABSORBED), + DAMAGE_RESISTED(StatisticList.DAMAGE_RESISTED), + CLEAN_SHULKER_BOX(StatisticList.CLEAN_SHULKER_BOX); private final MinecraftKey minecraftKey; private final org.bukkit.Statistic bukkit; private static final BiMap<MinecraftKey, org.bukkit.Statistic> statistics; @@ -98,10 +104,10 @@ public enum CraftStatistic { } public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.server.Statistic<?> statistic) { - RegistryMaterials statRegistry = statistic.a().a(); - MinecraftKey nmsKey = StatisticList.REGISTRY.b(statistic.a()); + IRegistry statRegistry = statistic.a().a(); + MinecraftKey nmsKey = IRegistry.STATS.getKey(statistic.a()); - if (statRegistry == StatisticList.REGISTRY_CUSTOM) { + if (statRegistry == IRegistry.CUSTOM_STAT) { nmsKey = (MinecraftKey) statistic.b(); } @@ -145,7 +151,7 @@ public enum CraftStatistic { public static net.minecraft.server.Statistic getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) { if (entity.getName() != null) { - EntityTypes<?> nmsEntity = EntityTypes.REGISTRY.get(new MinecraftKey(entity.getName())); + EntityTypes<?> nmsEntity = IRegistry.ENTITY_TYPE.get(new MinecraftKey(entity.getName())); if (stat == org.bukkit.Statistic.KILL_ENTITY) { return net.minecraft.server.StatisticList.ENTITY_KILLED.b(nmsEntity); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java b/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java index 1d5dce10..d4639c82 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit; import net.minecraft.server.BlockPosition; +import net.minecraft.server.DimensionManager; import net.minecraft.server.PortalTravelAgent; import net.minecraft.server.WorldServer; @@ -17,7 +18,7 @@ public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent { public CraftTravelAgent(WorldServer worldserver) { super(worldserver); - if (DEFAULT == null && worldserver.dimension == 0) { + if (DEFAULT == null && worldserver.dimension == DimensionManager.OVERWORLD) { DEFAULT = this; } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index e4b88cb7..303481a0 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -134,7 +134,7 @@ public class CraftWorld implements World { } public Chunk getChunkAt(int x, int z) { - return this.world.getChunkProviderServer().getChunkAt(x, z).bukkitChunk; + return this.world.getChunkProviderServer().getChunkAt(x, z, true, true).bukkitChunk; } public Chunk getChunkAt(Block block) { @@ -182,7 +182,7 @@ public class CraftWorld implements World { return false; } - net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getLoadedChunkAt(x, z); + net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkAt(x, z, false, false); if (chunk != null) { world.getChunkProviderServer().unload(chunk); } @@ -199,7 +199,7 @@ public class CraftWorld implements World { } private boolean unloadChunk0(int x, int z, boolean save) { - net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkIfLoaded(x, z); + net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkAt(x, z, false, false); if (chunk == null) { return true; } @@ -216,9 +216,7 @@ public class CraftWorld implements World { final long chunkKey = ChunkCoordIntPair.a(x, z); world.getChunkProviderServer().unloadQueue.remove(chunkKey); - net.minecraft.server.Chunk chunk = null; - - chunk = Futures.getUnchecked(world.getChunkProviderServer().generateChunk(x, z, true)); + net.minecraft.server.Chunk chunk = world.getChunkProviderServer().generateChunk(x, z); PlayerChunk playerChunk = world.getPlayerChunkMap().getChunk(x, z); if (playerChunk != null) { playerChunk.chunk = chunk; @@ -252,17 +250,12 @@ public class CraftWorld implements World { } public boolean isChunkInUse(int x, int z) { - return world.getPlayerChunkMap().isChunkInUse(x, z); + return world.getPlayerChunkMap().isChunkInUse(x, z) || world.f(x, z); } public boolean loadChunk(int x, int z, boolean generate) { chunkLoadCount++; - if (generate) { - // Use the default variant of loadChunk when generate == true. - return world.getChunkProviderServer().getChunkAt(x, z) != null; - } - - return world.getChunkProviderServer().getOrLoadChunkAt(x, z) != null; + return world.getChunkProviderServer().getChunkAt(x, z, true, generate) != null; } public boolean isChunkLoaded(Chunk chunk) { @@ -1497,13 +1490,13 @@ public class CraftWorld implements World { return null; } - switch (value.e()) { + switch (value.getType()) { case BOOLEAN_VALUE: return rule.getType().cast(value.b()); case NUMERICAL_VALUE: return rule.getType().cast(value.c()); default: - throw new IllegalArgumentException("Invalid GameRule type (" + value.e() + ") for GameRule " + rule.getName()); + throw new IllegalArgumentException("Invalid GameRule type (" + value.getType() + ") for GameRule " + rule.getName()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index bcb5007b..452d236e 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -177,7 +177,7 @@ 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 SimpleDateFormat("yyyyMMdd-HHmm").parse(Main.class.getPackage().getImplementationVendor()); Calendar deadline = Calendar.getInstance(); @@ -190,8 +190,7 @@ public class Main { } } - System.err.println("*** WARNING: This build is obsolete. It contains severe bugs that may damage your world. All users are recommended to update to 1.13.1"); - System.err.println("*** Please see https://www.spigotmc.org/ for more information about updating."); + System.err.println("*** WARNING: This is a development build. It is not meant for production server usage! Please keep backups and update frequently."); System.out.println("Loading libraries, please wait..."); MinecraftServer.main(options); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index dfddbaf8..370a222f 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -416,7 +416,7 @@ public class CraftBlock implements Block { return null; } - return Biome.valueOf(BiomeBase.REGISTRY_ID.b(base).getKey().toUpperCase(java.util.Locale.ENGLISH)); + return Biome.valueOf(IRegistry.BIOME.getKey(base).getKey().toUpperCase(java.util.Locale.ENGLISH)); } public static BiomeBase biomeToBiomeBase(Biome bio) { @@ -424,7 +424,7 @@ public class CraftBlock implements Block { return null; } - return BiomeBase.REGISTRY_ID.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH))); + return IRegistry.BIOME.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH))); } public double getTemperature() { @@ -479,12 +479,12 @@ 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 = wire.getPower(world, new BlockPosition(x, y - 1, z), power); - if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = wire.getPower(world, new BlockPosition(x, y + 1, z), power); - if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = wire.getPower(world, new BlockPosition(x + 1, y, z), power); - if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = wire.getPower(world, new BlockPosition(x - 1, y, z), power); - if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = wire.getPower(world, new BlockPosition(x, y, z - 1), power); - if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = wire.getPower(world, new BlockPosition(x, y, z - 1), power); + if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = wire.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 = wire.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 = wire.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 = wire.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 = wire.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 = wire.getPower(power, world.getType(new BlockPosition(x, y, z + 1))); return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0; } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java index 34bcc49c..d5192525 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java @@ -39,18 +39,18 @@ public abstract class CraftLootable<T extends TileEntityLootable> extends CraftC if (!this.getSnapshot().hasCustomName()) { lootable.setCustomName(null); } - if (this.getSnapshot().Q_() == null) { - lootable.a((MinecraftKey) null, 0L); // PAIL rename setLootTable + if (this.getSnapshot().getLootTable()== null) { + lootable.setLootTable((MinecraftKey) null, 0L); } } @Override public LootTable getLootTable() { - if (getSnapshot().Q_() == null) { + if (getSnapshot().getLootTable() == null) { return null; } - MinecraftKey key = getSnapshot().Q_(); + MinecraftKey key = getSnapshot().getLootTable(); return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key)); } @@ -71,6 +71,6 @@ public abstract class CraftLootable<T extends TileEntityLootable> extends CraftC private void setLootTable(LootTable table, long seed) { MinecraftKey key = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()); - getSnapshot().a(key, seed); // PAIL setLootTable + getSnapshot().setLootTable(key, seed); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index a4f3dd1b..8ee5d217 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -19,6 +19,7 @@ import net.minecraft.server.EnumDirection; import net.minecraft.server.IBlockData; import net.minecraft.server.IBlockState; import net.minecraft.server.INamable; +import net.minecraft.server.IRegistry; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.BlockData; @@ -310,7 +311,7 @@ public class CraftBlockData implements BlockData { private static IBlockState<?> getState(Class<? extends Block> block, String name, boolean optional) { IBlockState<?> state = null; - for (Block instance : (Iterable<Block>) Block.REGISTRY) { // Eclipse fail + for (Block instance : (Iterable<Block>) IRegistry.BLOCK) { // Eclipse fail if (instance.getClass() == block) { if (state == null) { state = instance.getStates().a(name); @@ -369,10 +370,13 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockCobbleWall.class, org.bukkit.craftbukkit.block.impl.CraftCobbleWall::new); register(net.minecraft.server.BlockCocoa.class, org.bukkit.craftbukkit.block.impl.CraftCocoa::new); register(net.minecraft.server.BlockCommand.class, org.bukkit.craftbukkit.block.impl.CraftCommand::new); + register(net.minecraft.server.BlockConduit.class, org.bukkit.craftbukkit.block.impl.CraftConduit::new); + register(net.minecraft.server.BlockCoralDead.class, org.bukkit.craftbukkit.block.impl.CraftCoralDead::new); register(net.minecraft.server.BlockCoralFan.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan::new); register(net.minecraft.server.BlockCoralFanAbstract.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanAbstract::new); register(net.minecraft.server.BlockCoralFanWall.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanWall::new); register(net.minecraft.server.BlockCoralFanWallAbstract.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanWallAbstract::new); + register(net.minecraft.server.BlockCoralPlant.class, org.bukkit.craftbukkit.block.impl.CraftCoralPlant::new); register(net.minecraft.server.BlockCrops.class, org.bukkit.craftbukkit.block.impl.CraftCrops::new); register(net.minecraft.server.BlockDaylightDetector.class, org.bukkit.craftbukkit.block.impl.CraftDaylightDetector::new); register(net.minecraft.server.BlockDirtSnow.class, org.bukkit.craftbukkit.block.impl.CraftDirtSnow::new); @@ -442,6 +446,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockStepAbstract.class, org.bukkit.craftbukkit.block.impl.CraftStepAbstract::new); register(net.minecraft.server.BlockStoneButton.class, org.bukkit.craftbukkit.block.impl.CraftStoneButton::new); register(net.minecraft.server.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure::new); + register(net.minecraft.server.BlockTNT.class, org.bukkit.craftbukkit.block.impl.CraftTNT::new); register(net.minecraft.server.BlockTallPlantFlower.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower::new); register(net.minecraft.server.BlockTallPlantShearable.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantShearable::new); register(net.minecraft.server.BlockTallSeaGrass.class, org.bukkit.craftbukkit.block.impl.CraftTallSeaGrass::new); @@ -473,7 +478,7 @@ public class CraftBlockData implements BlockData { try { // Material provided, force that material in if (block != null) { - data = Block.REGISTRY.b(block) + data; + data = IRegistry.BLOCK.getKey(block) + data; } StringReader reader = new StringReader(data); diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTNT.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTNT.java new file mode 100644 index 00000000..18662a80 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTNT.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.TNT; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftTNT extends CraftBlockData implements TNT { + + private static final net.minecraft.server.BlockStateBoolean UNSTABLE = getBoolean("unstable"); + + @Override + public boolean isUnstable() { + return get(UNSTABLE); + } + + @Override + public void setUnstable(boolean unstable) { + set(UNSTABLE, unstable); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftConduit.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftConduit.java new file mode 100644 index 00000000..ec2c9152 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftConduit.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftConduit extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged { + + public CraftConduit() { + super(); + } + + public CraftConduit(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockConduit.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralDead.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralDead.java new file mode 100644 index 00000000..450f6658 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralDead.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCoralDead extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged { + + public CraftCoralDead() { + super(); + } + + public CraftCoralDead(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockCoralDead.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralPlant.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralPlant.java new file mode 100644 index 00000000..4fb0fa98 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralPlant.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCoralPlant extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged { + + public CraftCoralPlant() { + super(); + } + + public CraftCoralPlant(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockCoralPlant.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTNT.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTNT.java new file mode 100644 index 00000000..cf9c33b8 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTNT.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTNT extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.TNT { + + public CraftTNT() { + super(); + } + + public CraftTNT(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftTNT + + private static final net.minecraft.server.BlockStateBoolean UNSTABLE = getBoolean(net.minecraft.server.BlockTNT.class, "unstable"); + + @Override + public boolean isUnstable() { + return get(UNSTABLE); + } + + @Override + public void setUnstable(boolean unstable) { + set(UNSTABLE, unstable); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index b57eb251..6e187250 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.command; import com.google.common.base.Joiner; import com.mojang.brigadier.ParseResults; -import com.mojang.brigadier.suggestion.Suggestion; import com.mojang.brigadier.tree.CommandNode; import java.util.ArrayList; import java.util.Collections; @@ -12,7 +11,6 @@ import net.minecraft.server.CommandListenerWrapper; import net.minecraft.server.DedicatedServer; import net.minecraft.server.EntityMinecartCommandBlock; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.WorldServer; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.command.BlockCommandSender; @@ -65,35 +63,6 @@ public final class VanillaCommandWrapper extends BukkitCommand { return results; } - public static class WorldRescueContext { - - private WorldServer[] prev; - - public WorldRescueContext start(WorldServer def) { - // Some commands use the worldserver variable but we leave it full of null values, - // so we must temporarily populate it with the world of the commandsender - prev = MinecraftServer.getServer().worldServer; - MinecraftServer server = MinecraftServer.getServer(); - server.worldServer = new WorldServer[server.worlds.size()]; - server.worldServer[0] = def; - int bpos = 0; - for (int pos = 1; pos < server.worldServer.length; pos++) { - WorldServer world = server.worlds.get(bpos++); - if (server.worldServer[0] == world) { - pos--; - continue; - } - server.worldServer[pos] = world; - } - - return this; - } - - public void end() { - MinecraftServer.getServer().worldServer = prev; - } - } - private CommandListenerWrapper getListener(CommandSender sender) { if (sender instanceof Player) { return ((CraftPlayer) sender).getHandle().getCommandListener(); diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 4ce44495..2897713a 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.enchantments; import net.minecraft.server.EnchantmentBinding; import net.minecraft.server.EnchantmentVanishing; +import net.minecraft.server.IRegistry; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.enchantments.Enchantment; @@ -13,7 +14,7 @@ public class CraftEnchantment extends Enchantment { private final net.minecraft.server.Enchantment target; public CraftEnchantment(net.minecraft.server.Enchantment target) { - super(CraftNamespacedKey.fromMinecraft(net.minecraft.server.Enchantment.enchantments.b(target))); + super(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(target))); this.target = target; } @@ -79,7 +80,7 @@ public class CraftEnchantment extends Enchantment { @Override public String getName() { // PAIL: migration paths - switch (net.minecraft.server.Enchantment.enchantments.a(target)) { + switch (IRegistry.ENCHANTMENT.a(target)) { case 0: return "PROTECTION_ENVIRONMENTAL"; case 1: diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index e47080db..516269ea 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -7,8 +7,8 @@ import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.projectiles.ProjectileSource; public class CraftArrow extends AbstractProjectile implements Arrow { @@ -39,10 +39,10 @@ public class CraftArrow extends AbstractProjectile implements Arrow { } public void setShooter(ProjectileSource shooter) { - if (shooter instanceof LivingEntity) { - getHandle().shooter = ((CraftLivingEntity) shooter).getHandle(); + if (shooter instanceof Entity) { + getHandle().setShooter(((CraftEntity) shooter).getHandle()); } else { - getHandle().shooter = null; + getHandle().setShooter(null); } getHandle().projectileSource = shooter; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index cce9366f..289e267b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -192,7 +192,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { if (iinventory instanceof ITileInventory) { if (iinventory instanceof TileEntity) { TileEntity te = (TileEntity) iinventory; - if (!te.u()) { // PAIL rename hasWorld + if (!te.hasWorld()) { te.setWorld(getHandle().world); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index f726e709..cc9e48d5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -480,7 +480,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public boolean isRiptiding() { - return getHandle().cO(); + return getHandle().isRiptiding(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java index 8ce97374..87303ecd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java @@ -28,7 +28,7 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo @Override public LootTable getLootTable() { - MinecraftKey nmsTable = getHandle().Q_(); // PAIL getLootTable + MinecraftKey nmsTable = getHandle().getLootTable(); if (nmsTable == null) { return null; // return empty loot table? } @@ -44,7 +44,7 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo @Override public long getSeed() { - return getHandle().d; // PAIL rename lootTableSeed + return getHandle().lootTableSeed; } private void setLootTable(LootTable table, long seed) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index eb643cff..5bf1cd06 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -43,26 +43,26 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { @Override public void setLootTable(LootTable table) { - getHandle().bI = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()); // PAIL rename lootTableKey + getHandle().lootTableKey = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()); } @Override public LootTable getLootTable() { - if (getHandle().bI == null) { - getHandle().bI = getHandle().getLootTable(); // Restore to entity default + if (getHandle().lootTableKey == null) { + getHandle().lootTableKey = getHandle().getLootTable(); } - NamespacedKey key = CraftNamespacedKey.fromMinecraft(getHandle().bI); // PAIL rename lootTableKey + NamespacedKey key = CraftNamespacedKey.fromMinecraft(getHandle().lootTableKey); return Bukkit.getLootTable(key); } @Override public void setSeed(long seed) { - getHandle().bJ = seed; // PAIL rename lootTableSeed + getHandle().lootTableSeed = seed; } @Override public long getSeed() { - return getHandle().bJ; // PAIL rename lootTableSeed + return getHandle().lootTableSeed; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index a8b0bc4e..82000a35 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -266,8 +266,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().playerConnection == null) return; PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); - packet.a = (this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader; - packet.b = (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter; + packet.header = (this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader; + packet.footer = (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter; getHandle().playerConnection.sendPacket(packet); } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 72b5dfd7..a50f91c9 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -81,7 +81,7 @@ public class CraftEventFactory { WorldServer worldServer = world.getHandle(); int spawnSize = Bukkit.getServer().getSpawnRadius(); - if (world.getHandle().dimension != 0) return true; + if (world.getHandle().dimension != DimensionManager.OVERWORLD) return true; if (spawnSize <= 0) return true; if (((CraftServer) Bukkit.getServer()).getHandle().getOPs().isEmpty()) return true; if (player.isOp()) return true; @@ -889,12 +889,11 @@ public class CraftEventFactory { human.activeContainer.transferTo(human.defaultContainer, human.getBukkitEntity()); } - public static void handleEditBookEvent(EntityPlayer player, ItemStack newBookItem) { - int itemInHandIndex = player.inventory.itemInHandIndex; + public static ItemStack handleEditBookEvent(EntityPlayer player, EnumItemSlot slot, ItemStack itemInHand, ItemStack newBookItem) { + int itemInHandIndex = (slot == EnumItemSlot.MAINHAND) ? player.inventory.itemInHandIndex : -1; - PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), player.inventory.itemInHandIndex, (BookMeta) CraftItemStack.getItemMeta(player.inventory.getItemInHand()), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.getItem() == Items.WRITTEN_BOOK); + PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), itemInHandIndex, (BookMeta) CraftItemStack.getItemMeta(itemInHand), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.getItem() == Items.WRITTEN_BOOK); player.world.getServer().getPluginManager().callEvent(editBookEvent); - ItemStack itemInHand = player.inventory.getItem(itemInHandIndex); // If they've got the same item in their hand, it'll need to be updated. if (itemInHand != null && itemInHand.getItem() == Items.WRITABLE_BOOK) { @@ -909,11 +908,9 @@ public class CraftEventFactory { } CraftItemStack.setItemMeta(itemInHand, meta); } - - // Client will have updated its idea of the book item; we need to overwrite that - Slot slot = player.activeContainer.getSlot(player.inventory, itemInHandIndex); - player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, slot.rawSlotIndex, itemInHand)); } + + return itemInHand; } private static IChatBaseComponent stripEvents(IChatBaseComponent c) { @@ -925,7 +922,7 @@ public class CraftEventFactory { c.setChatModifier(modi); if (c instanceof ChatMessage) { ChatMessage cm = (ChatMessage) c; - Object[] oo = cm.i(); + Object[] oo = cm.l(); for (int i = 0; i < oo.length; i++) { Object o = oo[i]; if (o instanceof IChatBaseComponent) { diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 774a5e34..8c8fa453 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -114,8 +114,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettin } @Override - public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position, int i) { - return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, this, position, i) : null; + public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position, int i, boolean flag) { + return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, this, position, i, flag) : null; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java index 4356d2bf..aaa1bc1c 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java @@ -38,8 +38,8 @@ public class NormalChunkGenerator<C extends GeneratorSettings> extends InternalC } @Override - public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition, int i) { - return generator.findNearestMapFeature(world, s, blockPosition, i); + public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition, int i, boolean flag) { + return generator.findNearestMapFeature(world, s, blockPosition, i, flag); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java index 66c2249e..bb09139f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.inventory.util; +import net.minecraft.server.DimensionManager; import net.minecraft.server.ITileInventory; import net.minecraft.server.MinecraftServer; import net.minecraft.server.TileEntityBeacon; @@ -46,7 +47,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public ITileInventory getTileEntity() { TileEntityFurnace furnace = new TileEntityFurnace(); - furnace.setWorld(MinecraftServer.getServer().getWorldServer(0)); // TODO: customize this if required + furnace.setWorld(MinecraftServer.getServer().getWorldServer(DimensionManager.OVERWORLD)); // TODO: customize this if required return furnace; } diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index 4d5eb2c1..186c04be 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -7,7 +7,10 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; +import net.minecraft.server.DimensionManager; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.WorldMap; +import net.minecraft.server.WorldServer; import org.bukkit.Bukkit; import org.bukkit.World; @@ -55,17 +58,14 @@ public final class CraftMapView implements MapView { } public World getWorld() { - byte dimension = worldMap.map; - for (World world : Bukkit.getServer().getWorlds()) { - if (((CraftWorld) world).getHandle().dimension == dimension) { - return world; - } - } - return null; + DimensionManager dimension = worldMap.map; + WorldServer world = MinecraftServer.getServer().getWorldServer(dimension); + + return (world == null) ? null : world.getWorld(); } public void setWorld(World world) { - worldMap.map = (byte) ((CraftWorld) world).getHandle().dimension; + worldMap.map = ((CraftWorld) world).getHandle().dimension; } public int getCenterX() { diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index 299b9a28..a067e39d 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -197,7 +197,7 @@ public final class CraftChatMessage { private static IChatBaseComponent fixComponent(IChatBaseComponent component, Matcher matcher) { if (component instanceof ChatComponentText) { ChatComponentText text = ((ChatComponentText) component); - String msg = text.f(); + String msg = text.getText(); if (matcher.reset(msg).find()) { matcher.reset(); @@ -248,7 +248,7 @@ public final class CraftChatMessage { } if (component instanceof ChatMessage) { - Object[] subs = ((ChatMessage) component).i(); + Object[] subs = ((ChatMessage) component).l(); for (int i = 0; i < subs.length; i++) { Object comp = subs[i]; if (comp instanceof IChatBaseComponent) { diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java index 01ebbbca..f7881201 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java @@ -19,6 +19,7 @@ import net.minecraft.server.DispenserRegistry; import net.minecraft.server.DynamicOpsNBT; import net.minecraft.server.IBlockData; import net.minecraft.server.IBlockState; +import net.minecraft.server.IRegistry; import net.minecraft.server.Item; import net.minecraft.server.Items; import net.minecraft.server.MinecraftKey; @@ -333,7 +334,10 @@ public class CraftLegacy { name = "minecraft:nether_portal"; } - Block block = Block.REGISTRY.get(new MinecraftKey(name)); + Block block = IRegistry.BLOCK.get(new MinecraftKey(name)); + if (block == null) { + continue; + } IBlockData blockData = block.getBlockData(); BlockStateList states = block.getStates(); @@ -405,7 +409,7 @@ public class CraftLegacy { } // Preconditions.checkState(newId.contains("minecraft:"), "Unknown new material for " + matData); - Item newMaterial = Item.REGISTRY.get(new MinecraftKey(newId)); + Item newMaterial = IRegistry.ITEM.get(new MinecraftKey(newId)); if (newMaterial == Items.AIR) { continue; diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 21d0062d..fedb660a 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -17,6 +17,7 @@ import net.minecraft.server.AdvancementDataWorld; import net.minecraft.server.Block; import net.minecraft.server.ChatDeserializer; import net.minecraft.server.IBlockData; +import net.minecraft.server.IRegistry; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; import net.minecraft.server.MinecraftServer; @@ -74,19 +75,19 @@ public final class CraftMagicNumbers implements UnsafeValues { private static final Map<Material, Block> MATERIAL_BLOCK = new HashMap<>(); static { - for (Block block : (Iterable<Block>) Block.REGISTRY) { // Eclipse fail - BLOCK_MATERIAL.put(block, Material.getMaterial(Block.REGISTRY.b(block).getKey().toUpperCase(Locale.ROOT))); + for (Block block : (Iterable<Block>) IRegistry.BLOCK) { // Eclipse fail + BLOCK_MATERIAL.put(block, Material.getMaterial(IRegistry.BLOCK.getKey(block).getKey().toUpperCase(Locale.ROOT))); } - for (Item item : (Iterable<Item>) Item.REGISTRY) { // Eclipse fail - ITEM_MATERIAL.put(item, Material.getMaterial(Item.REGISTRY.b(item).getKey().toUpperCase(Locale.ROOT))); + for (Item item : (Iterable<Item>) IRegistry.ITEM) { // Eclipse fail + ITEM_MATERIAL.put(item, Material.getMaterial(IRegistry.ITEM.getKey(item).getKey().toUpperCase(Locale.ROOT))); } for (Material material : Material.values()) { MinecraftKey key = key(material); // TODO: only register if block/item? - MATERIAL_ITEM.put(material, Item.REGISTRY.get(key)); - MATERIAL_BLOCK.put(material, Block.REGISTRY.get(key)); + MATERIAL_ITEM.put(material, IRegistry.ITEM.get(key)); + MATERIAL_BLOCK.put(material, IRegistry.BLOCK.get(key)); } } @@ -144,7 +145,7 @@ public final class CraftMagicNumbers implements UnsafeValues { return CraftBlockData.fromData(getBlock(material, data)); } - public static final int DATA_VERSION = 1519; + public static final int DATA_VERSION = 1628; @Override public int getDataVersion() { diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index 897c8cc5..b9d92a1e 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -1,10 +1,7 @@ package org.bukkit.craftbukkit.util; -import java.util.List; import java.util.Random; -import java.util.function.Function; import java.util.function.Predicate; -import net.minecraft.server.AxisAlignedBB; import net.minecraft.server.BiomeBase; import net.minecraft.server.Block; import net.minecraft.server.BlockPosition; @@ -22,7 +19,6 @@ import net.minecraft.server.IChunkAccess; import net.minecraft.server.IChunkProvider; import net.minecraft.server.IDataManager; import net.minecraft.server.ParticleParam; -import net.minecraft.server.PersistentBase; import net.minecraft.server.PersistentCollection; import net.minecraft.server.SoundCategory; import net.minecraft.server.SoundEffect; @@ -48,17 +44,17 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public TickList<Block> I() { + public TickList<Block> J() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public TickList<FluidType> H() { + public TickList<FluidType> I() { throw new UnsupportedOperationException("Not supported yet."); } @Override - public IChunkAccess c(int i, int i1) { + public IChunkAccess b(int i, int i1) { throw new UnsupportedOperationException("Not supported yet."); } @@ -78,16 +74,6 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public <T extends PersistentBase> T a(Function<String, T> fnctn, String string) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public PersistentCollection s_() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override public IChunkProvider getChunkProvider() { throw new UnsupportedOperationException("Not supported yet."); } @@ -178,11 +164,6 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public List<Entity> getEntities(Entity entity, AxisAlignedBB aabb) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override public int a(BlockPosition bp, EnumDirection ed) { throw new UnsupportedOperationException("Not supported yet."); } @@ -218,6 +199,11 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override + public PersistentCollection h() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { return false; } diff --git a/src/test/java/org/bukkit/ArtTest.java b/src/test/java/org/bukkit/ArtTest.java index 29d14d4b..e6888dec 100644 --- a/src/test/java/org/bukkit/ArtTest.java +++ b/src/test/java/org/bukkit/ArtTest.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import net.minecraft.server.Paintings; @@ -16,16 +17,17 @@ import org.bukkit.craftbukkit.CraftArt; import org.junit.Test; import com.google.common.collect.Lists; +import org.bukkit.support.AbstractTestingBase; -public class ArtTest { +public class ArtTest extends AbstractTestingBase { private static final int UNIT_MULTIPLIER = 16; @Test public void verifyMapping() { List<Art> arts = Lists.newArrayList(Art.values()); - for (MinecraftKey key : Paintings.a.keySet()) { - Paintings enumArt = Paintings.a.get(key); + for (MinecraftKey key : IRegistry.MOTIVE.keySet()) { + Paintings enumArt = IRegistry.MOTIVE.get(key); String name = key.getKey(); int width = enumArt.b() / UNIT_MULTIPLIER; int height = enumArt.c() / UNIT_MULTIPLIER; @@ -58,7 +60,7 @@ public class ArtTest { @Test public void testCraftArtToBukkit() { Map<Art, Paintings> cache = new EnumMap(Art.class); - for (Paintings enumArt : (Iterable<Paintings>) Paintings.a) { // Eclipse fail + for (Paintings enumArt : (Iterable<Paintings>) IRegistry.MOTIVE) { // Eclipse fail Art art = CraftArt.NotchToBukkit(enumArt); assertNotNull("Could not CraftArt.NotchToBukkit " + enumArt, art); assertThat("Duplicate artwork " + enumArt, cache.put(art, enumArt), is(nullValue())); diff --git a/src/test/java/org/bukkit/BiomeTest.java b/src/test/java/org/bukkit/BiomeTest.java index 17a8005a..913c4cf3 100644 --- a/src/test/java/org/bukkit/BiomeTest.java +++ b/src/test/java/org/bukkit/BiomeTest.java @@ -1,6 +1,7 @@ package org.bukkit; import net.minecraft.server.BiomeBase; +import net.minecraft.server.IRegistry; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.support.AbstractTestingBase; @@ -18,7 +19,7 @@ public class BiomeTest extends AbstractTestingBase { @Test public void testMinecraftToBukkit() { - for (Object biome : BiomeBase.REGISTRY_ID) { + for (Object biome : IRegistry.BIOME) { Assert.assertNotNull("No Bukkit mapping for " + biome, CraftBlock.biomeBaseToBiome((BiomeBase) biome)); } } diff --git a/src/test/java/org/bukkit/EnchantmentTest.java b/src/test/java/org/bukkit/EnchantmentTest.java index 86bfbb45..e69283b1 100644 --- a/src/test/java/org/bukkit/EnchantmentTest.java +++ b/src/test/java/org/bukkit/EnchantmentTest.java @@ -1,5 +1,6 @@ package org.bukkit; +import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.enchantments.Enchantment; @@ -11,8 +12,8 @@ public class EnchantmentTest extends AbstractTestingBase { @Test public void verifyMapping() { - for (MinecraftKey key : net.minecraft.server.Enchantment.enchantments.keySet()) { - net.minecraft.server.Enchantment nms = net.minecraft.server.Enchantment.enchantments.get(key); + for (MinecraftKey key : IRegistry.ENCHANTMENT.keySet()) { + net.minecraft.server.Enchantment nms = IRegistry.ENCHANTMENT.get(key); Enchantment bukkitById = Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(key)); diff --git a/src/test/java/org/bukkit/LegacyTest.java b/src/test/java/org/bukkit/LegacyTest.java index fbc9e85c..b441d40d 100644 --- a/src/test/java/org/bukkit/LegacyTest.java +++ b/src/test/java/org/bukkit/LegacyTest.java @@ -33,7 +33,7 @@ public class LegacyTest extends AbstractTestingBase { Material.ACACIA_WOOD, Material.BIRCH_WOOD, Material.DARK_OAK_WOOD, Material.JUNGLE_WOOD, Material.OAK_WOOD, Material.SPRUCE_WOOD, Material.TUBE_CORAL_WALL_FAN, Material.BRAIN_CORAL_WALL_FAN, Material.BUBBLE_CORAL_WALL_FAN, Material.FIRE_CORAL_WALL_FAN, Material.HORN_CORAL_WALL_FAN, Material.DEAD_TUBE_CORAL_WALL_FAN, Material.DEAD_BRAIN_CORAL_WALL_FAN, Material.DEAD_BUBBLE_CORAL_WALL_FAN, Material.DEAD_FIRE_CORAL_WALL_FAN, Material.DEAD_HORN_CORAL_WALL_FAN, Material.DEAD_TUBE_CORAL_FAN, Material.DEAD_BRAIN_CORAL_FAN, Material.DEAD_BUBBLE_CORAL_FAN, Material.DEAD_FIRE_CORAL_FAN, - Material.DEAD_HORN_CORAL_FAN, + Material.DEAD_HORN_CORAL_FAN, Material.DEAD_BRAIN_CORAL, Material.DEAD_BUBBLE_CORAL, Material.DEAD_FIRE_CORAL, Material.DEAD_HORN_CORAL, Material.DEAD_TUBE_CORAL, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java index be0690f3..8c972447 100644 --- a/src/test/java/org/bukkit/MaterialTest.java +++ b/src/test/java/org/bukkit/MaterialTest.java @@ -6,6 +6,7 @@ import static org.hamcrest.Matchers.*; import java.util.Collections; import java.util.Map; +import net.minecraft.server.IRegistry; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; @@ -29,13 +30,13 @@ public class MaterialTest extends AbstractTestingBase { materials.put(CraftMagicNumbers.key(material), material); } - Iterator<Item> items = Item.REGISTRY.iterator(); + Iterator<Item> items = IRegistry.ITEM.iterator(); while (items.hasNext()) { Item item = items.next(); if (item == null) continue; - MinecraftKey id = Item.REGISTRY.b(item); + MinecraftKey id = IRegistry.ITEM.getKey(item); String name = item.getName(); Material material = materials.remove(id); diff --git a/src/test/java/org/bukkit/ParticleTest.java b/src/test/java/org/bukkit/ParticleTest.java index c0cb4a1e..829dfa11 100644 --- a/src/test/java/org/bukkit/ParticleTest.java +++ b/src/test/java/org/bukkit/ParticleTest.java @@ -1,5 +1,6 @@ package org.bukkit; +import net.minecraft.server.IRegistry; import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftParticle; import org.bukkit.craftbukkit.block.data.CraftBlockData; @@ -27,7 +28,7 @@ public class ParticleTest extends AbstractTestingBase { Assert.assertNotNull("Missing Bukkit->NMS particle mapping for " + bukkit, CraftParticle.toNMS(bukkit, data)); } - for (net.minecraft.server.Particle nms : (Iterable<net.minecraft.server.Particle<?>>) net.minecraft.server.Particle.REGISTRY) { // Eclipse fail + for (net.minecraft.server.Particle nms : (Iterable<net.minecraft.server.Particle<?>>) IRegistry.PARTICLE_TYPE) { // Eclipse fail Assert.assertNotNull("Missing NMS->Bukkit particle mapping for " + nms, CraftParticle.toBukkit(nms)); } } diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java index 57e779ec..82b5b1af 100644 --- a/src/test/java/org/bukkit/PerMaterialTest.java +++ b/src/test/java/org/bukkit/PerMaterialTest.java @@ -60,7 +60,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isBlock() { if (material != Material.AIR && material != Material.CAVE_AIR && material != Material.VOID_AIR) { - assertThat(material.isBlock(), is(not(CraftMagicNumbers.getBlock(material).getBlockData().isAir()))); + assertThat(material.isBlock(), is(not(CraftMagicNumbers.getBlock(material) == null))); } } @@ -191,7 +191,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material == Material.AIR) { assertTrue(material.isBlock()); } else { - assertThat(material.isBlock(), is(equalTo(CraftMagicNumbers.getBlock(material) != Blocks.AIR))); + assertThat(material.isBlock(), is(equalTo(CraftMagicNumbers.getBlock(material) != null))); } } @@ -226,7 +226,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void testBlastResistance() { if (material.isBlock()) { - assertThat(material.getBlastResistance(), is(CraftMagicNumbers.getBlock(material).k())); // PAIL getDurability + assertThat(material.getBlastResistance(), is(CraftMagicNumbers.getBlock(material).getDurability())); } } } diff --git a/src/test/java/org/bukkit/SoundTest.java b/src/test/java/org/bukkit/SoundTest.java index 942cb4ea..a2bb73f0 100644 --- a/src/test/java/org/bukkit/SoundTest.java +++ b/src/test/java/org/bukkit/SoundTest.java @@ -1,7 +1,7 @@ package org.bukkit; +import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; -import net.minecraft.server.SoundEffect; import static org.junit.Assert.*; import static org.hamcrest.Matchers.*; @@ -20,7 +20,7 @@ public class SoundTest { @Test public void testReverse() { - for (MinecraftKey effect : SoundEffect.a.keySet()) { + for (MinecraftKey effect : IRegistry.SOUND_EVENT.keySet()) { assertNotNull(effect + "", Sound.valueOf(effect.getKey().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH))); } } diff --git a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java index 055bc426..4edbc126 100644 --- a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java +++ b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java @@ -3,10 +3,8 @@ package org.bukkit; import static org.junit.Assert.*; import static org.hamcrest.Matchers.*; -import net.minecraft.server.Block; import net.minecraft.server.EntityTypes; -import net.minecraft.server.Item; -import net.minecraft.server.StatisticList; +import net.minecraft.server.IRegistry; import net.minecraft.server.StatisticWrapper; import org.bukkit.entity.EntityType; @@ -36,7 +34,7 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { @SuppressWarnings("unchecked") public void verifyStatisticMapping() throws Throwable { HashMultiset<Statistic> statistics = HashMultiset.create(); - for (StatisticWrapper wrapper : (Iterable<StatisticWrapper<?>>) StatisticList.REGISTRY) { // Eclipse fail + for (StatisticWrapper wrapper : (Iterable<StatisticWrapper<?>>) IRegistry.STATS) { // Eclipse fail for (Object child : wrapper.a()) { net.minecraft.server.Statistic<?> statistic = wrapper.b(child); String message = String.format("org.bukkit.Statistic is missing: '%s'", statistic); @@ -44,9 +42,9 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { Statistic subject = CraftStatistic.getBukkitStatistic(statistic); assertThat(message, subject, is(not(nullValue()))); - if (wrapper.a() == Block.REGISTRY || wrapper.a() == Item.REGISTRY) { + if (wrapper.a() == IRegistry.BLOCK || wrapper.a() == IRegistry.ITEM) { assertNotNull("Material type map missing for " + child, CraftStatistic.getMaterialFromStatistic(statistic)); - } else if (wrapper.a() == EntityTypes.REGISTRY) { + } else if (wrapper.a() == IRegistry.ENTITY_TYPE) { assertNotNull("Entity type map missing for " + EntityTypes.getName((EntityTypes<?>) child), CraftStatistic.getEntityTypeFromStatistic((net.minecraft.server.Statistic<EntityTypes<?>>) statistic)); } diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index f66cc81d..00f89f22 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import net.minecraft.server.Block; +import net.minecraft.server.IRegistry; import net.minecraft.server.ITileEntity; import net.minecraft.server.Item; import net.minecraft.server.ItemBlock; @@ -159,7 +160,7 @@ public class ItemMetaTest extends AbstractTestingBase { public void testBlockStateMeta() { List<Block> queue = new ArrayList<>(); - for (Item item : (Iterable<Item>) Item.REGISTRY) { // Eclipse fail + for (Item item : (Iterable<Item>) IRegistry.ITEM) { // Eclipse fail if (item instanceof ItemBlock) { queue.add(((ItemBlock) item).getBlock()); } diff --git a/src/test/java/org/bukkit/entity/EntityTypesTest.java b/src/test/java/org/bukkit/entity/EntityTypesTest.java index d8c3b013..ce9a098a 100644 --- a/src/test/java/org/bukkit/entity/EntityTypesTest.java +++ b/src/test/java/org/bukkit/entity/EntityTypesTest.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; import net.minecraft.server.EntityTypes; +import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import org.junit.Assert; import org.junit.Test; @@ -14,7 +15,7 @@ public class EntityTypesTest { public void testMaps() { Set<EntityType> allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet()); - for (Object o : EntityTypes.REGISTRY) { + for (Object o : IRegistry.ENTITY_TYPE) { EntityTypes<?> nms = (EntityTypes<?>) o; // Eclipse fail MinecraftKey key = EntityTypes.getName(nms); diff --git a/src/test/java/org/bukkit/potion/PotionTest.java b/src/test/java/org/bukkit/potion/PotionTest.java index 74ed926f..f6c23ebb 100644 --- a/src/test/java/org/bukkit/potion/PotionTest.java +++ b/src/test/java/org/bukkit/potion/PotionTest.java @@ -1,11 +1,11 @@ package org.bukkit.potion; import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; import java.util.EnumMap; import java.util.List; import java.util.Map; +import net.minecraft.server.IRegistry; import net.minecraft.server.MobEffect; import net.minecraft.server.MobEffectList; @@ -17,7 +17,7 @@ public class PotionTest extends AbstractTestingBase { @Test public void testEffectCompleteness() throws Throwable { Map<PotionType, String> effects = new EnumMap(PotionType.class); - for (Object reg : PotionRegistry.a) { + for (Object reg : IRegistry.POTION) { List<MobEffect> eff = ((PotionRegistry)reg).a(); if (eff.size() != 1) continue; int id = MobEffectList.getId(eff.get(0).getMobEffect()); diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java index 02a31f09..c9fd5e27 100644 --- a/src/test/java/org/bukkit/support/DummyServer.java +++ b/src/test/java/org/bukkit/support/DummyServer.java @@ -87,7 +87,7 @@ public class DummyServer implements InvocationHandler { @Override
public Object handle(DummyServer server, Object[] args) {
NamespacedKey key = (NamespacedKey) args[0];
- return new CraftLootTable(key, AbstractTestingBase.LOOT_TABLE_REGISTRY.a(CraftNamespacedKey.toMinecraft(key)));
+ return new CraftLootTable(key, AbstractTestingBase.LOOT_TABLE_REGISTRY.getLootTable(CraftNamespacedKey.toMinecraft(key)));
}
}
);
|