Update to Minecraft 1.14-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-04-23 12:00:00 +10:00
parent 0e98365784
commit a0f2b74c8d
560 changed files with 10642 additions and 10867 deletions

View File

@@ -14,22 +14,22 @@ import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.entity.Entity;
import org.bukkit.ChunkSnapshot;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftChunk implements Chunk {
private WeakReference<net.minecraft.server.Chunk> weakChunk;
private final WorldServer worldServer;
private final int x;
private final int z;
private static final byte[] emptyData = new byte[2048];
private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new ChunkSection(0, false).getBlocks();
private static final byte[] emptySkyLight = new byte[2048];
private static final DataPaletteBlock<IBlockData> emptyBlockIDs = new ChunkSection(0).getBlocks();
private static final byte[] emptyLight = new byte[2048];
public CraftChunk(net.minecraft.server.Chunk chunk) {
this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk);
worldServer = (WorldServer) getHandle().world;
x = getHandle().locX;
z = getHandle().locZ;
x = getHandle().getPos().x;
z = getHandle().getPos().z;
}
public World getWorld() {
@@ -143,10 +143,6 @@ public class CraftChunk implements Chunk {
return getWorld().unloadChunk(getX(), getZ(), save);
}
public boolean unload(boolean save, boolean safe) {
return getWorld().unloadChunk(getX(), getZ(), save, safe);
}
@Override
public boolean isForceLoaded() {
return getWorld().isChunkForceLoaded(getX(), getZ());
@@ -173,34 +169,41 @@ public class CraftChunk implements Chunk {
for (int i = 0; i < cs.length; i++) {
if (cs[i] == null) { // Section is empty?
sectionBlockIDs[i] = emptyBlockIDs;
sectionSkyLights[i] = emptySkyLight;
sectionEmitLights[i] = emptyData;
sectionSkyLights[i] = emptyLight;
sectionEmitLights[i] = emptyLight;
sectionEmpty[i] = true;
} else { // Not empty
NBTTagCompound data = new NBTTagCompound();
cs[i].getBlocks().b(data, "Spigot", "Magic");
cs[i].getBlocks().a(data, "Palette", "BlockStates");
DataPaletteBlock blockids = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, net.minecraft.server.Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // TODO: snapshot whole ChunkSection
blockids.a(data, "Spigot", "Magic");
blockids.a(data.getList("Palette", CraftMagicNumbers.NBT.TAG_COMPOUND), data.getLongArray("BlockStates"));
sectionBlockIDs[i] = blockids;
if (cs[i].getSkyLightArray() == null) {
sectionSkyLights[i] = emptySkyLight;
LightEngine lightengine = chunk.world.getChunkProvider().getLightEngine();
NibbleArray skyLightArray = lightengine.a(EnumSkyBlock.SKY).a(SectionPosition.a(x, i, z));
if (skyLightArray == null) {
sectionSkyLights[i] = emptyLight;
} else {
sectionSkyLights[i] = new byte[2048];
System.arraycopy(cs[i].getSkyLightArray().asBytes(), 0, sectionSkyLights[i], 0, 2048);
System.arraycopy(skyLightArray.asBytes(), 0, sectionSkyLights[i], 0, 2048);
}
NibbleArray emitLightArray = lightengine.a(EnumSkyBlock.BLOCK).a(SectionPosition.a(x, i, z));
if (emitLightArray == null) {
sectionEmitLights[i] = emptyLight;
} else {
sectionEmitLights[i] = new byte[2048];
System.arraycopy(emitLightArray.asBytes(), 0, sectionEmitLights[i], 0, 2048);
}
sectionEmitLights[i] = new byte[2048];
System.arraycopy(cs[i].getEmittedLightArray().asBytes(), 0, sectionEmitLights[i], 0, 2048);
}
}
HeightMap hmap = null;
if (includeMaxBlockY) {
hmap = new HeightMap(null, HeightMap.Type.LIGHT_BLOCKING);
hmap.a(chunk.heightMap.get(HeightMap.Type.LIGHT_BLOCKING).b());
hmap = new HeightMap(null, HeightMap.Type.MOTION_BLOCKING);
hmap.a(chunk.heightMap.get(HeightMap.Type.MOTION_BLOCKING).a());
}
BiomeBase[] biome = null;
@@ -263,16 +266,16 @@ public class CraftChunk implements Chunk {
for (int i = 0; i < hSection; i++) {
blockIDs[i] = emptyBlockIDs;
skyLight[i] = emptySkyLight;
emitLight[i] = emptyData;
skyLight[i] = emptyLight;
emitLight[i] = emptyLight;
empty[i] = true;
}
return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(null, HeightMap.Type.LIGHT_BLOCKING), biome, biomeTemp);
return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(null, HeightMap.Type.MOTION_BLOCKING), biome, biomeTemp);
}
private static float[] getTemperatures(WorldChunkManager chunkmanager, int chunkX, int chunkZ) {
BiomeBase[] biomes = chunkmanager.getBiomes(chunkX, chunkZ, 16, 16);
BiomeBase[] biomes = chunkmanager.getBiomeBlock(chunkX, chunkZ, 16, 16);
float[] temps = new float[biomes.length];
for (int i = 0; i < biomes.length; i++) {
@@ -295,6 +298,6 @@ public class CraftChunk implements Chunk {
}
static {
Arrays.fill(emptySkyLight, (byte) 0xFF);
Arrays.fill(emptyLight, (byte) 0xFF);
}
}

View File

@@ -1,7 +1,7 @@
package org.bukkit.craftbukkit;
import org.bukkit.FluidCollisionMode;
import net.minecraft.server.FluidCollisionOption;
import net.minecraft.server.RayTrace.FluidCollisionOption;
public class CraftFluidCollisionMode {
@@ -12,11 +12,11 @@ public class CraftFluidCollisionMode {
switch (fluidCollisionMode) {
case ALWAYS:
return FluidCollisionOption.ALWAYS;
return FluidCollisionOption.ANY;
case SOURCE_ONLY:
return FluidCollisionOption.SOURCE_ONLY;
case NEVER:
return FluidCollisionOption.NEVER;
return FluidCollisionOption.NONE;
default:
return null;
}

View File

@@ -9,6 +9,8 @@ import net.minecraft.server.DamageSource;
import net.minecraft.server.Entity;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.IInventory;
import net.minecraft.server.LootContextParameterSets;
import net.minecraft.server.LootContextParameters;
import net.minecraft.server.LootTable;
import net.minecraft.server.LootTableInfo;
import net.minecraft.server.WorldServer;
@@ -39,7 +41,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
@Override
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
LootTableInfo nmsContext = convertContext(context);
List<net.minecraft.server.ItemStack> nmsItems = handle.populateLoot(random, nmsContext);
List<net.minecraft.server.ItemStack> nmsItems = handle.populateLoot(nmsContext);
Collection<ItemStack> bukkit = new ArrayList<>(nmsItems.size());
for (net.minecraft.server.ItemStack item : nmsItems) {
@@ -59,7 +61,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
IInventory handle = craftInventory.getInventory();
// TODO: When events are added, call event here w/ custom reason?
getHandle().fillInventory(handle, random, nmsContext);
getHandle().fillInventory(handle, nmsContext);
}
@Override
@@ -72,23 +74,23 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle();
LootTableInfo.Builder builder = new LootTableInfo.Builder(handle);
builder.luck(context.getLuck());
// builder.luck(context.getLuck());
if (context.getLootedEntity() != null) {
Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle();
builder.entity(nmsLootedEntity);
builder.damageSource(DamageSource.GENERIC);
builder.position(new BlockPosition(nmsLootedEntity));
builder.set(LootContextParameters.THIS_ENTITY, nmsLootedEntity);
builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC);
builder.set(LootContextParameters.POSITION, new BlockPosition(nmsLootedEntity));
}
if (context.getKiller() != null) {
EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle();
builder.killer(nmsKiller);
builder.set(LootContextParameters.KILLER_ENTITY, nmsKiller);
// If there is a player killer, damage source should reflect that in case loot tables use that information
builder.damageSource(DamageSource.playerAttack(nmsKiller));
builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.playerAttack(nmsKiller));
}
return builder.build();
return builder.build(LootContextParameterSets.GENERIC);
}
@Override

View File

@@ -76,6 +76,14 @@ public enum CraftParticle {
BUBBLE_COLUMN_UP("bubble_column_up"),
NAUTILUS("nautilus"),
DOLPHIN("dolphin"),
SNEEZE("sneeze"),
CAMPFIRE_COSY_SMOKE("campfire_cosy_smoke"),
CAMPFIRE_SIGNAL_SMOKE("campfire_signal_smoke"),
COMPOSTER("composter"),
FLASH("flash"),
FALLING_LAVA("falling_lava"),
LANDING_LAVA("landing_lava"),
FALLING_WATER("falling_water"),
// ----- Legacy Separator -----
LEGACY_BLOCK_CRACK("block"),
LEGACY_BLOCK_DUST("block"),
@@ -147,6 +155,6 @@ public enum CraftParticle {
}
public static Particle toBukkit(net.minecraft.server.Particle nms) {
return particles.inverse().get(nms.d());
return particles.inverse().get(IRegistry.PARTICLE_TYPE.getKey(nms));
}
}

View File

@@ -154,6 +154,10 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.command.BukkitCommandWrapper;
import org.bukkit.craftbukkit.command.CraftCommandMap;
import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe;
import org.bukkit.craftbukkit.inventory.CraftCampfireRecipe;
import org.bukkit.craftbukkit.inventory.CraftSmokingRecipe;
import org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe;
import org.bukkit.craftbukkit.inventory.util.CraftInventoryCreator;
import org.bukkit.craftbukkit.tag.CraftBlockTag;
import org.bukkit.craftbukkit.tag.CraftItemTag;
@@ -161,6 +165,10 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.event.server.ServerLoadEvent;
import org.bukkit.event.server.TabCompleteEvent;
import org.bukkit.inventory.BlastingRecipe;
import org.bukkit.inventory.CampfireRecipe;
import org.bukkit.inventory.SmokingRecipe;
import org.bukkit.inventory.StonecuttingRecipe;
public final class CraftServer implements Server {
private final String serverName = "CraftBukkit";
@@ -173,7 +181,7 @@ public final class CraftServer implements Server {
private final SimpleHelpMap helpMap = new SimpleHelpMap(this);
private final StandardMessenger messenger = new StandardMessenger();
private final SimplePluginManager pluginManager = new SimplePluginManager(this, commandMap);
protected final MinecraftServer console;
protected final DedicatedServer console;
protected final DedicatedPlayerList playerList;
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
private YamlConfiguration configuration;
@@ -187,11 +195,8 @@ public final class CraftServer implements Server {
private int animalSpawn = -1;
private int waterAnimalSpawn = -1;
private int ambientSpawn = -1;
public int chunkGCPeriod = -1;
public int chunkGCLoadThresh = 0;
private File container;
private WarningState warningState = WarningState.DEFAULT;
private final BooleanWrapper online = new BooleanWrapper();
public CraftScoreboardManager scoreboardManager;
public boolean playerCommandState;
private boolean printSaveWarning;
@@ -201,16 +206,12 @@ public final class CraftServer implements Server {
private final List<CraftPlayer> playerView;
public int reloadCount;
private final class BooleanWrapper {
private boolean value = true;
}
static {
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
CraftItemFactory.instance();
}
public CraftServer(MinecraftServer console, PlayerList playerList) {
public CraftServer(DedicatedServer console, PlayerList playerList) {
this.console = console;
this.playerList = (DedicatedPlayerList) playerList;
this.playerView = Collections.unmodifiableList(Lists.transform(playerList.players, new Function<EntityPlayer, CraftPlayer>() {
@@ -220,7 +221,6 @@ public final class CraftServer implements Server {
}
}));
this.serverVersion = CraftServer.class.getPackage().getImplementationVersion();
online.value = console.getPropertyManager().getBoolean("online-mode", true);
Bukkit.setServer(this);
@@ -282,8 +282,6 @@ public final class CraftServer implements Server {
ambientSpawn = configuration.getInt("spawn-limits.ambient");
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
loadIcon();
}
@@ -535,37 +533,27 @@ public final class CraftServer implements Server {
// so if that changes this will need to as well
@Override
public int getPort() {
return this.getConfigInt("server-port", 25565);
return this.getServer().getPort();
}
@Override
public int getViewDistance() {
return this.getConfigInt("view-distance", 10);
return this.getProperties().viewDistance;
}
@Override
public String getIp() {
return this.getConfigString("server-ip", "");
}
@Override
public String getServerName() {
return this.getConfigString("server-name", "Unknown Server");
}
@Override
public String getServerId() {
return this.getConfigString("server-id", "unnamed");
return this.getServer().getServerIp();
}
@Override
public String getWorldType() {
return this.getConfigString("level-type", "DEFAULT");
return this.getProperties().levelType.name();
}
@Override
public boolean getGenerateStructures() {
return this.getConfigBoolean("generate-structures", true);
return this.getServer().getGenerateStructures();
}
@Override
@@ -575,7 +563,7 @@ public final class CraftServer implements Server {
@Override
public boolean getAllowNether() {
return this.getConfigBoolean("allow-nether", true);
return this.getServer().getAllowNether();
}
public boolean getWarnOnOverload() {
@@ -588,22 +576,13 @@ public final class CraftServer implements Server {
@Override
public boolean hasWhitelist() {
return this.getConfigBoolean("white-list", false);
return this.getProperties().whiteList.get();
}
// NOTE: Temporary calls through to server.properies until its replaced
private String getConfigString(String variable, String defaultValue) {
return this.console.getPropertyManager().getString(variable, defaultValue);
private DedicatedServerProperties getProperties() {
return this.console.getDedicatedServerProperties();
}
private int getConfigInt(String variable, int defaultValue) {
return this.console.getPropertyManager().getInt(variable, defaultValue);
}
private boolean getConfigBoolean(String variable, boolean defaultValue) {
return this.console.getPropertyManager().getBoolean(variable, defaultValue);
}
// End Temporary calls
@Override
@@ -699,19 +678,14 @@ public final class CraftServer implements Server {
reloadCount++;
configuration = YamlConfiguration.loadConfiguration(getConfigFile());
commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile());
PropertyManager config = new PropertyManager(console.options);
((DedicatedServer) console).propertyManager = config;
console.propertyManager = new DedicatedServerSettings(console.options);
DedicatedServerProperties config = console.propertyManager.getProperties();
boolean animals = config.getBoolean("spawn-animals", console.getSpawnAnimals());
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()));
console.setPVP(config.getBoolean("pvp", console.getPVP()));
console.setAllowFlight(config.getBoolean("allow-flight", console.getAllowFlight()));
console.setMotd(config.getString("motd", console.getMotd()));
console.setSpawnAnimals(config.spawnAnimals);
console.setPVP(config.pvp);
console.setAllowFlight(config.allowFlight);
console.setMotd(config.motd);
monsterSpawn = configuration.getInt("spawn-limits.monsters");
animalSpawn = configuration.getInt("spawn-limits.animals");
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
@@ -719,8 +693,6 @@ public final class CraftServer implements Server {
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
printSaveWarning = false;
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
loadIcon();
try {
@@ -735,8 +707,8 @@ public final class CraftServer implements Server {
}
for (WorldServer world : console.getWorlds()) {
world.worldData.setDifficulty(difficulty);
world.setSpawnFlags(monsters, animals);
world.worldData.setDifficulty(config.difficulty);
world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals);
if (this.getTicksPerAnimalSpawns() < 0) {
world.ticksPerAnimalSpawns = 400;
} else {
@@ -911,8 +883,7 @@ public final class CraftServer implements Server {
} while(used);
boolean hardcore = false;
IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, getServer(), getHandle().getServer().dataConverterManager);
PersistentCollection persistentcollection = new PersistentCollection(sdm);
WorldNBTStorage sdm = new WorldNBTStorage(getWorldContainer(), name, getServer(), getHandle().getServer().dataConverterManager);
WorldData worlddata = sdm.getWorldData();
WorldSettings worldSettings = null;
if (worlddata == null) {
@@ -925,65 +896,23 @@ public final class CraftServer implements Server {
}
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)
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_();
DimensionManager actualDimension = DimensionManager.a(creator.environment().getId());
DimensionManager internalDimension = new DimensionManager(dimension, name, name, (w, manager) -> actualDimension.getWorldProvider(w), actualDimension.hasSkyLight());
WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, sdm, worlddata, internalDimension, console.getMethodProfiler(), getServer().worldLoadListenerFactory.create(11), creator.environment(), generator);
if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) {
return null;
}
if (worldSettings != null) {
internal.a(worldSettings);
}
console.initWorld(internal, worlddata, worldSettings);
internal.tracker = new EntityTracker(internal);
internal.addIWorldAccess(new WorldManager(console, internal));
internal.worldData.setDifficulty(EnumDifficulty.EASY);
internal.setSpawnFlags(true, true);
console.worldServer.put(internal.dimension, internal);
pluginManager.callEvent(new WorldInitEvent(internal.getWorld()));
System.out.println("Preparing start region for level " + (console.worldServer.size() - 1) + " (Seed: " + internal.getSeed() + ")");
if (internal.getWorld().getKeepSpawnInMemory()) {
short short1 = 196;
long i = System.currentTimeMillis();
for (int j = -short1; j <= short1; j += 16) {
for (int k = -short1; k <= short1; k += 16) {
long l = System.currentTimeMillis();
if (l < i) {
i = l;
}
if (l > i + 1000L) {
int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;
System.out.println("Preparing spawn area for " + name + ", " + (j1 * 100 / i1) + "%");
i = l;
}
BlockPosition chunkcoordinates = internal.getSpawn();
internal.getChunkProvider().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.getChunkProvider().getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, true, true);
}
}
getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal);
pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
return internal.getWorld();
@@ -1010,7 +939,7 @@ public final class CraftServer implements Server {
return false;
}
if (handle.players.size() > 0) {
if (handle.getPlayers().size() > 0) {
return false;
}
@@ -1023,9 +952,9 @@ public final class CraftServer implements Server {
if (save) {
try {
handle.save(true, null);
handle.save(null, true, true);
handle.close();
} catch (ExceptionWorldConflict ex) {
} catch (Exception ex) {
getLogger().log(Level.SEVERE, null, ex);
}
}
@@ -1035,7 +964,7 @@ public final class CraftServer implements Server {
return true;
}
public MinecraftServer getServer() {
public DedicatedServer getServer() {
return console;
}
@@ -1103,6 +1032,14 @@ public final class CraftServer implements Server {
toAdd = CraftShapelessRecipe.fromBukkitRecipe((ShapelessRecipe) recipe);
} else if (recipe instanceof FurnaceRecipe) {
toAdd = CraftFurnaceRecipe.fromBukkitRecipe((FurnaceRecipe) recipe);
} else if (recipe instanceof BlastingRecipe) {
toAdd = CraftBlastingRecipe.fromBukkitRecipe((BlastingRecipe) recipe);
} else if (recipe instanceof CampfireRecipe) {
toAdd = CraftCampfireRecipe.fromBukkitRecipe((CampfireRecipe) recipe);
} else if (recipe instanceof SmokingRecipe) {
toAdd = CraftSmokingRecipe.fromBukkitRecipe((SmokingRecipe) recipe);
} else if (recipe instanceof StonecuttingRecipe) {
toAdd = CraftStonecuttingRecipe.fromBukkitRecipe((StonecuttingRecipe) recipe);
} else {
return false;
}
@@ -1183,7 +1120,7 @@ public final class CraftServer implements Server {
@Override
public int getSpawnRadius() {
return ((DedicatedServer) console).propertyManager.getInt("spawn-protection", 16);
return this.getServer().getSpawnProtection();
}
@Override
@@ -1194,7 +1131,7 @@ public final class CraftServer implements Server {
@Override
public boolean getOnlineMode() {
return online.value;
return console.getOnlineMode();
}
@Override
@@ -1246,8 +1183,7 @@ public final class CraftServer implements Server {
@Override
@Deprecated
public CraftMapView getMap(int id) {
PersistentCollection collection = console.getWorldServer(DimensionManager.OVERWORLD).worldMaps;
WorldMap worldmap = (WorldMap) collection.get(DimensionManager.OVERWORLD, WorldMap::new, "map_" + id);
WorldMap worldmap = console.getWorldServer(DimensionManager.OVERWORLD).a("map_" + id);
if (worldmap == null) {
return null;
}
@@ -1289,7 +1225,7 @@ public final class CraftServer implements Server {
@Override
public void shutdown() {
console.safeShutdown();
console.safeShutdown(false);
}
@Override
@@ -1412,7 +1348,7 @@ public final class CraftServer implements Server {
@Override
public void setWhitelist(boolean value) {
playerList.setHasWhitelist(value);
console.getPropertyManager().setProperty("white-list", value);
console.setHasWhitelist(value);
}
@Override
@@ -1590,7 +1526,7 @@ public final class CraftServer implements Server {
@Override
public boolean isPrimaryThread() {
return Thread.currentThread().equals(console.primaryThread);
return Thread.currentThread().equals(console.serverThread) || console.hasStopped(); // All bets are off if we have shut down (e.g. due to watchdog)
}
@Override
@@ -1900,12 +1836,12 @@ public final class CraftServer implements Server {
Preconditions.checkArgument(selector != null, "Selector cannot be null");
Preconditions.checkArgument(sender != null, "Sender cannot be null");
ArgumentEntity arg = ArgumentEntity.b();
ArgumentEntity arg = ArgumentEntity.multipleEntities();
List<? extends net.minecraft.server.Entity> nms;
try {
StringReader reader = new StringReader(selector);
nms = arg.parse(reader, true).b(VanillaCommandWrapper.getListener(sender));
nms = arg.parse(reader, true).getEntities(VanillaCommandWrapper.getListener(sender));
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data in selector: " + selector);
} catch (CommandSyntaxException ex) {
throw new IllegalArgumentException("Could not parse selector: " + selector, ex);

View File

@@ -25,22 +25,40 @@ public enum CraftSound {
BLOCK_ANVIL_PLACE("block.anvil.place"),
BLOCK_ANVIL_STEP("block.anvil.step"),
BLOCK_ANVIL_USE("block.anvil.use"),
BLOCK_BAMBOO_BREAK("block.bamboo.break"),
BLOCK_BAMBOO_FALL("block.bamboo.fall"),
BLOCK_BAMBOO_HIT("block.bamboo.hit"),
BLOCK_BAMBOO_PLACE("block.bamboo.place"),
BLOCK_BAMBOO_SAPLING_BREAK("block.bamboo_sapling.break"),
BLOCK_BAMBOO_SAPLING_HIT("block.bamboo_sapling.hit"),
BLOCK_BAMBOO_SAPLING_PLACE("block.bamboo_sapling.place"),
BLOCK_BAMBOO_STEP("block.bamboo.step"),
BLOCK_BARREL_CLOSE("block.barrel.close"),
BLOCK_BARREL_OPEN("block.barrel.open"),
BLOCK_BEACON_ACTIVATE("block.beacon.activate"),
BLOCK_BEACON_AMBIENT("block.beacon.ambient"),
BLOCK_BEACON_DEACTIVATE("block.beacon.deactivate"),
BLOCK_BEACON_POWER_SELECT("block.beacon.power_select"),
BLOCK_BELL_RESONATE("block.bell.resonate"),
BLOCK_BELL_USE("block.bell.use"),
BLOCK_BLASTFURNACE_FIRE_CRACKLE("block.blastfurnace.fire_crackle"),
BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"),
BLOCK_BUBBLE_COLUMN_BUBBLE_POP("block.bubble_column.bubble_pop"),
BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT("block.bubble_column.upwards_ambient"),
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"),
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT("block.bubble_column.whirlpool_ambient"),
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE("block.bubble_column.whirlpool_inside"),
BLOCK_CAMPFIRE_CRACKLE("block.campfire.crackle"),
BLOCK_CHEST_CLOSE("block.chest.close"),
BLOCK_CHEST_LOCKED("block.chest.locked"),
BLOCK_CHEST_OPEN("block.chest.open"),
BLOCK_CHORUS_FLOWER_DEATH("block.chorus_flower.death"),
BLOCK_CHORUS_FLOWER_GROW("block.chorus_flower.grow"),
BLOCK_COMPARATOR_CLICK("block.comparator.click"),
BLOCK_COMPOSTER_EMPTY("block.composter.empty"),
BLOCK_COMPOSTER_FILL("block.composter.fill"),
BLOCK_COMPOSTER_FILL_SUCCESS("block.composter.fill_success"),
BLOCK_COMPOSTER_READY("block.composter.ready"),
BLOCK_CONDUIT_ACTIVATE("block.conduit.activate"),
BLOCK_CONDUIT_AMBIENT("block.conduit.ambient"),
BLOCK_CONDUIT_AMBIENT_SHORT("block.conduit.ambient.short"),
@@ -51,6 +69,7 @@ public enum CraftSound {
BLOCK_CORAL_BLOCK_HIT("block.coral_block.hit"),
BLOCK_CORAL_BLOCK_PLACE("block.coral_block.place"),
BLOCK_CORAL_BLOCK_STEP("block.coral_block.step"),
BLOCK_CROP_BREAK("block.crop.break"),
BLOCK_DISPENSER_DISPENSE("block.dispenser.dispense"),
BLOCK_DISPENSER_FAIL("block.dispenser.fail"),
BLOCK_DISPENSER_LAUNCH("block.dispenser.launch"),
@@ -80,6 +99,7 @@ public enum CraftSound {
BLOCK_GRAVEL_HIT("block.gravel.hit"),
BLOCK_GRAVEL_PLACE("block.gravel.place"),
BLOCK_GRAVEL_STEP("block.gravel.step"),
BLOCK_GRINDSTONE_USE("block.grindstone.use"),
BLOCK_IRON_DOOR_CLOSE("block.iron_door.close"),
BLOCK_IRON_DOOR_OPEN("block.iron_door.open"),
BLOCK_IRON_TRAPDOOR_CLOSE("block.iron_trapdoor.close"),
@@ -89,6 +109,11 @@ public enum CraftSound {
BLOCK_LADDER_HIT("block.ladder.hit"),
BLOCK_LADDER_PLACE("block.ladder.place"),
BLOCK_LADDER_STEP("block.ladder.step"),
BLOCK_LANTERN_BREAK("block.lantern.break"),
BLOCK_LANTERN_FALL("block.lantern.fall"),
BLOCK_LANTERN_HIT("block.lantern.hit"),
BLOCK_LANTERN_PLACE("block.lantern.place"),
BLOCK_LANTERN_STEP("block.lantern.step"),
BLOCK_LAVA_AMBIENT("block.lava.ambient"),
BLOCK_LAVA_EXTINGUISH("block.lava.extinguish"),
BLOCK_LAVA_POP("block.lava.pop"),
@@ -101,14 +126,20 @@ public enum CraftSound {
BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF("block.metal_pressure_plate.click_off"),
BLOCK_METAL_PRESSURE_PLATE_CLICK_ON("block.metal_pressure_plate.click_on"),
BLOCK_METAL_STEP("block.metal.step"),
BLOCK_NETHER_WART_BREAK("block.nether_wart.break"),
BLOCK_NOTE_BLOCK_BANJO("block.note_block.banjo"),
BLOCK_NOTE_BLOCK_BASEDRUM("block.note_block.basedrum"),
BLOCK_NOTE_BLOCK_BASS("block.note_block.bass"),
BLOCK_NOTE_BLOCK_BELL("block.note_block.bell"),
BLOCK_NOTE_BLOCK_BIT("block.note_block.bit"),
BLOCK_NOTE_BLOCK_CHIME("block.note_block.chime"),
BLOCK_NOTE_BLOCK_COW_BELL("block.note_block.cow_bell"),
BLOCK_NOTE_BLOCK_DIDGERIDOO("block.note_block.didgeridoo"),
BLOCK_NOTE_BLOCK_FLUTE("block.note_block.flute"),
BLOCK_NOTE_BLOCK_GUITAR("block.note_block.guitar"),
BLOCK_NOTE_BLOCK_HARP("block.note_block.harp"),
BLOCK_NOTE_BLOCK_HAT("block.note_block.hat"),
BLOCK_NOTE_BLOCK_IRON_XYLOPHONE("block.note_block.iron_xylophone"),
BLOCK_NOTE_BLOCK_PLING("block.note_block.pling"),
BLOCK_NOTE_BLOCK_SNARE("block.note_block.snare"),
BLOCK_NOTE_BLOCK_XYLOPHONE("block.note_block.xylophone"),
@@ -124,6 +155,11 @@ public enum CraftSound {
BLOCK_SAND_HIT("block.sand.hit"),
BLOCK_SAND_PLACE("block.sand.place"),
BLOCK_SAND_STEP("block.sand.step"),
BLOCK_SCAFFOLDING_BREAK("block.scaffolding.break"),
BLOCK_SCAFFOLDING_FALL("block.scaffolding.fall"),
BLOCK_SCAFFOLDING_HIT("block.scaffolding.hit"),
BLOCK_SCAFFOLDING_PLACE("block.scaffolding.place"),
BLOCK_SCAFFOLDING_STEP("block.scaffolding.step"),
BLOCK_SHULKER_BOX_CLOSE("block.shulker_box.close"),
BLOCK_SHULKER_BOX_OPEN("block.shulker_box.open"),
BLOCK_SLIME_BLOCK_BREAK("block.slime_block.break"),
@@ -131,6 +167,7 @@ public enum CraftSound {
BLOCK_SLIME_BLOCK_HIT("block.slime_block.hit"),
BLOCK_SLIME_BLOCK_PLACE("block.slime_block.place"),
BLOCK_SLIME_BLOCK_STEP("block.slime_block.step"),
BLOCK_SMOKER_SMOKE("block.smoker.smoke"),
BLOCK_SNOW_BREAK("block.snow.break"),
BLOCK_SNOW_FALL("block.snow.fall"),
BLOCK_SNOW_HIT("block.snow.hit"),
@@ -145,6 +182,8 @@ public enum CraftSound {
BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF("block.stone_pressure_plate.click_off"),
BLOCK_STONE_PRESSURE_PLATE_CLICK_ON("block.stone_pressure_plate.click_on"),
BLOCK_STONE_STEP("block.stone.step"),
BLOCK_SWEET_BERRY_BUSH_BREAK("block.sweet_berry_bush.break"),
BLOCK_SWEET_BERRY_BUSH_PLACE("block.sweet_berry_bush.place"),
BLOCK_TRIPWIRE_ATTACH("block.tripwire.attach"),
BLOCK_TRIPWIRE_CLICK_OFF("block.tripwire.click_off"),
BLOCK_TRIPWIRE_CLICK_ON("block.tripwire.click_on"),
@@ -194,11 +233,14 @@ public enum CraftSound {
ENTITY_BOAT_PADDLE_LAND("entity.boat.paddle_land"),
ENTITY_BOAT_PADDLE_WATER("entity.boat.paddle_water"),
ENTITY_CAT_AMBIENT("entity.cat.ambient"),
ENTITY_CAT_BEG_FOR_FOOD("entity.cat.beg_for_food"),
ENTITY_CAT_DEATH("entity.cat.death"),
ENTITY_CAT_EAT("entity.cat.eat"),
ENTITY_CAT_HISS("entity.cat.hiss"),
ENTITY_CAT_HURT("entity.cat.hurt"),
ENTITY_CAT_PURR("entity.cat.purr"),
ENTITY_CAT_PURREOW("entity.cat.purreow"),
ENTITY_CAT_STRAY_AMBIENT("entity.cat.stray_ambient"),
ENTITY_CHICKEN_AMBIENT("entity.chicken.ambient"),
ENTITY_CHICKEN_DEATH("entity.chicken.death"),
ENTITY_CHICKEN_EGG("entity.chicken.egg"),
@@ -271,6 +313,7 @@ public enum CraftSound {
ENTITY_ENDER_PEARL_THROW("entity.ender_pearl.throw"),
ENTITY_EVOKER_AMBIENT("entity.evoker.ambient"),
ENTITY_EVOKER_CAST_SPELL("entity.evoker.cast_spell"),
ENTITY_EVOKER_CELEBRATE("entity.evoker.celebrate"),
ENTITY_EVOKER_DEATH("entity.evoker.death"),
ENTITY_EVOKER_FANGS_ATTACK("entity.evoker_fangs.attack"),
ENTITY_EVOKER_HURT("entity.evoker.hurt"),
@@ -291,6 +334,16 @@ public enum CraftSound {
ENTITY_FISHING_BOBBER_SPLASH("entity.fishing_bobber.splash"),
ENTITY_FISHING_BOBBER_THROW("entity.fishing_bobber.throw"),
ENTITY_FISH_SWIM("entity.fish.swim"),
ENTITY_FOX_AGGRO("entity.fox.aggro"),
ENTITY_FOX_AMBIENT("entity.fox.ambient"),
ENTITY_FOX_BITE("entity.fox.bite"),
ENTITY_FOX_DEATH("entity.fox.death"),
ENTITY_FOX_EAT("entity.fox.eat"),
ENTITY_FOX_HURT("entity.fox.hurt"),
ENTITY_FOX_SCREECH("entity.fox.screech"),
ENTITY_FOX_SLEEP("entity.fox.sleep"),
ENTITY_FOX_SNIFF("entity.fox.sniff"),
ENTITY_FOX_SPIT("entity.fox.spit"),
ENTITY_GENERIC_BIG_FALL("entity.generic.big_fall"),
ENTITY_GENERIC_BURN("entity.generic.burn"),
ENTITY_GENERIC_DEATH("entity.generic.death"),
@@ -381,13 +434,31 @@ public enum CraftSound {
ENTITY_MAGMA_CUBE_SQUISH_SMALL("entity.magma_cube.squish_small"),
ENTITY_MINECART_INSIDE("entity.minecart.inside"),
ENTITY_MINECART_RIDING("entity.minecart.riding"),
ENTITY_MOOSHROOM_CONVERT("entity.mooshroom.convert"),
ENTITY_MOOSHROOM_EAT("entity.mooshroom.eat"),
ENTITY_MOOSHROOM_MILK("entity.mooshroom.milk"),
ENTITY_MOOSHROOM_SHEAR("entity.mooshroom.shear"),
ENTITY_MOOSHROOM_SUSPICIOUS_MILK("entity.mooshroom.suspicious_milk"),
ENTITY_MULE_AMBIENT("entity.mule.ambient"),
ENTITY_MULE_CHEST("entity.mule.chest"),
ENTITY_MULE_DEATH("entity.mule.death"),
ENTITY_MULE_HURT("entity.mule.hurt"),
ENTITY_OCELOT_AMBIENT("entity.ocelot.ambient"),
ENTITY_OCELOT_DEATH("entity.ocelot.death"),
ENTITY_OCELOT_HURT("entity.ocelot.hurt"),
ENTITY_PAINTING_BREAK("entity.painting.break"),
ENTITY_PAINTING_PLACE("entity.painting.place"),
ENTITY_PANDA_AGGRESSIVE_AMBIENT("entity.panda.aggressive_ambient"),
ENTITY_PANDA_AMBIENT("entity.panda.ambient"),
ENTITY_PANDA_BITE("entity.panda.bite"),
ENTITY_PANDA_CANT_BREED("entity.panda.cant_breed"),
ENTITY_PANDA_DEATH("entity.panda.death"),
ENTITY_PANDA_EAT("entity.panda.eat"),
ENTITY_PANDA_HURT("entity.panda.hurt"),
ENTITY_PANDA_PRE_SNEEZE("entity.panda.pre_sneeze"),
ENTITY_PANDA_SNEEZE("entity.panda.sneeze"),
ENTITY_PANDA_STEP("entity.panda.step"),
ENTITY_PANDA_WORRIED_AMBIENT("entity.panda.worried_ambient"),
ENTITY_PARROT_AMBIENT("entity.parrot.ambient"),
ENTITY_PARROT_DEATH("entity.parrot.death"),
ENTITY_PARROT_EAT("entity.parrot.eat"),
@@ -402,11 +473,15 @@ public enum CraftSound {
ENTITY_PARROT_IMITATE_ENDER_DRAGON("entity.parrot.imitate.ender_dragon"),
ENTITY_PARROT_IMITATE_EVOKER("entity.parrot.imitate.evoker"),
ENTITY_PARROT_IMITATE_GHAST("entity.parrot.imitate.ghast"),
ENTITY_PARROT_IMITATE_GUARDIAN("entity.parrot.imitate.guardian"),
ENTITY_PARROT_IMITATE_HUSK("entity.parrot.imitate.husk"),
ENTITY_PARROT_IMITATE_ILLUSIONER("entity.parrot.imitate.illusioner"),
ENTITY_PARROT_IMITATE_MAGMA_CUBE("entity.parrot.imitate.magma_cube"),
ENTITY_PARROT_IMITATE_PANDA("entity.parrot.imitate.panda"),
ENTITY_PARROT_IMITATE_PHANTOM("entity.parrot.imitate.phantom"),
ENTITY_PARROT_IMITATE_PILLAGER("entity.parrot.imitate.pillager"),
ENTITY_PARROT_IMITATE_POLAR_BEAR("entity.parrot.imitate.polar_bear"),
ENTITY_PARROT_IMITATE_RAVAGER("entity.parrot.imitate.ravager"),
ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"),
ENTITY_PARROT_IMITATE_SILVERFISH("entity.parrot.imitate.silverfish"),
ENTITY_PARROT_IMITATE_SKELETON("entity.parrot.imitate.skeleton"),
@@ -434,6 +509,10 @@ public enum CraftSound {
ENTITY_PIG_HURT("entity.pig.hurt"),
ENTITY_PIG_SADDLE("entity.pig.saddle"),
ENTITY_PIG_STEP("entity.pig.step"),
ENTITY_PILLAGER_AMBIENT("entity.pillager.ambient"),
ENTITY_PILLAGER_CELEBRATE("entity.pillager.celebrate"),
ENTITY_PILLAGER_DEATH("entity.pillager.death"),
ENTITY_PILLAGER_HURT("entity.pillager.hurt"),
ENTITY_PLAYER_ATTACK_CRIT("entity.player.attack.crit"),
ENTITY_PLAYER_ATTACK_KNOCKBACK("entity.player.attack.knockback"),
ENTITY_PLAYER_ATTACK_NODAMAGE("entity.player.attack.nodamage"),
@@ -447,6 +526,7 @@ public enum CraftSound {
ENTITY_PLAYER_HURT("entity.player.hurt"),
ENTITY_PLAYER_HURT_DROWN("entity.player.hurt_drown"),
ENTITY_PLAYER_HURT_ON_FIRE("entity.player.hurt_on_fire"),
ENTITY_PLAYER_HURT_SWEET_BERRY_BUSH("entity.player.hurt_sweet_berry_bush"),
ENTITY_PLAYER_LEVELUP("entity.player.levelup"),
ENTITY_PLAYER_SMALL_FALL("entity.player.small_fall"),
ENTITY_PLAYER_SPLASH("entity.player.splash"),
@@ -470,6 +550,14 @@ public enum CraftSound {
ENTITY_RABBIT_DEATH("entity.rabbit.death"),
ENTITY_RABBIT_HURT("entity.rabbit.hurt"),
ENTITY_RABBIT_JUMP("entity.rabbit.jump"),
ENTITY_RAVAGER_AMBIENT("entity.ravager.ambient"),
ENTITY_RAVAGER_ATTACK("entity.ravager.attack"),
ENTITY_RAVAGER_CELEBRATE("entity.ravager.celebrate"),
ENTITY_RAVAGER_DEATH("entity.ravager.death"),
ENTITY_RAVAGER_HURT("entity.ravager.hurt"),
ENTITY_RAVAGER_ROAR("entity.ravager.roar"),
ENTITY_RAVAGER_STEP("entity.ravager.step"),
ENTITY_RAVAGER_STUNNED("entity.ravager.stunned"),
ENTITY_SALMON_AMBIENT("entity.salmon.ambient"),
ENTITY_SALMON_DEATH("entity.salmon.death"),
ENTITY_SALMON_FLOP("entity.salmon.flop"),
@@ -556,15 +644,41 @@ public enum CraftSound {
ENTITY_VEX_DEATH("entity.vex.death"),
ENTITY_VEX_HURT("entity.vex.hurt"),
ENTITY_VILLAGER_AMBIENT("entity.villager.ambient"),
ENTITY_VILLAGER_CELEBRATE("entity.villager.celebrate"),
ENTITY_VILLAGER_DEATH("entity.villager.death"),
ENTITY_VILLAGER_HURT("entity.villager.hurt"),
ENTITY_VILLAGER_NO("entity.villager.no"),
ENTITY_VILLAGER_TRADE("entity.villager.trade"),
ENTITY_VILLAGER_WORK_ARMORER("entity.villager.work_armorer"),
ENTITY_VILLAGER_WORK_BUTCHER("entity.villager.work_butcher"),
ENTITY_VILLAGER_WORK_CARTOGRAPHER("entity.villager.work_cartographer"),
ENTITY_VILLAGER_WORK_CLERIC("entity.villager.work_cleric"),
ENTITY_VILLAGER_WORK_FARMER("entity.villager.work_farmer"),
ENTITY_VILLAGER_WORK_FISHERMAN("entity.villager.work_fisherman"),
ENTITY_VILLAGER_WORK_FLETCHER("entity.villager.work_fletcher"),
ENTITY_VILLAGER_WORK_LEATHERWORKER("entity.villager.work_leatherworker"),
ENTITY_VILLAGER_WORK_LIBRARIAN("entity.villager.work_librarian"),
ENTITY_VILLAGER_WORK_MASON("entity.villager.work_mason"),
ENTITY_VILLAGER_WORK_SHEPHERD("entity.villager.work_shepherd"),
ENTITY_VILLAGER_WORK_TOOLSMITH("entity.villager.work_toolsmith"),
ENTITY_VILLAGER_WORK_WEAPONSMITH("entity.villager.work_weaponsmith"),
ENTITY_VILLAGER_YES("entity.villager.yes"),
ENTITY_VINDICATOR_AMBIENT("entity.vindicator.ambient"),
ENTITY_VINDICATOR_CELEBRATE("entity.vindicator.celebrate"),
ENTITY_VINDICATOR_DEATH("entity.vindicator.death"),
ENTITY_VINDICATOR_HURT("entity.vindicator.hurt"),
ENTITY_WANDERING_TRADER_AMBIENT("entity.wandering_trader.ambient"),
ENTITY_WANDERING_TRADER_DEATH("entity.wandering_trader.death"),
ENTITY_WANDERING_TRADER_DISAPPEARED("entity.wandering_trader.disappeared"),
ENTITY_WANDERING_TRADER_DRINK_MILK("entity.wandering_trader.drink_milk"),
ENTITY_WANDERING_TRADER_DRINK_POTION("entity.wandering_trader.drink_potion"),
ENTITY_WANDERING_TRADER_HURT("entity.wandering_trader.hurt"),
ENTITY_WANDERING_TRADER_NO("entity.wandering_trader.no"),
ENTITY_WANDERING_TRADER_REAPPEARED("entity.wandering_trader.reappeared"),
ENTITY_WANDERING_TRADER_TRADE("entity.wandering_trader.trade"),
ENTITY_WANDERING_TRADER_YES("entity.wandering_trader.yes"),
ENTITY_WITCH_AMBIENT("entity.witch.ambient"),
ENTITY_WITCH_CELEBRATE("entity.witch.celebrate"),
ENTITY_WITCH_DEATH("entity.witch.death"),
ENTITY_WITCH_DRINK("entity.witch.drink"),
ENTITY_WITCH_HURT("entity.witch.hurt"),
@@ -611,6 +725,7 @@ public enum CraftSound {
ENTITY_ZOMBIE_VILLAGER_DEATH("entity.zombie_villager.death"),
ENTITY_ZOMBIE_VILLAGER_HURT("entity.zombie_villager.hurt"),
ENTITY_ZOMBIE_VILLAGER_STEP("entity.zombie_villager.step"),
EVENT_RAID_HORN("event.raid.horn"),
ITEM_ARMOR_EQUIP_CHAIN("item.armor.equip_chain"),
ITEM_ARMOR_EQUIP_DIAMOND("item.armor.equip_diamond"),
ITEM_ARMOR_EQUIP_ELYTRA("item.armor.equip_elytra"),
@@ -620,6 +735,8 @@ public enum CraftSound {
ITEM_ARMOR_EQUIP_LEATHER("item.armor.equip_leather"),
ITEM_ARMOR_EQUIP_TURTLE("item.armor.equip_turtle"),
ITEM_AXE_STRIP("item.axe.strip"),
ITEM_BOOK_PAGE_TURN("item.book.page_turn"),
ITEM_BOOK_PUT("item.book.put"),
ITEM_BOTTLE_EMPTY("item.bottle.empty"),
ITEM_BOTTLE_FILL("item.bottle.fill"),
ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"),
@@ -630,13 +747,24 @@ public enum CraftSound {
ITEM_BUCKET_FILL_FISH("item.bucket.fill_fish"),
ITEM_BUCKET_FILL_LAVA("item.bucket.fill_lava"),
ITEM_CHORUS_FRUIT_TELEPORT("item.chorus_fruit.teleport"),
ITEM_CROP_PLANT("item.crop.plant"),
ITEM_CROSSBOW_HIT("item.crossbow.hit"),
ITEM_CROSSBOW_LOADING_END("item.crossbow.loading_end"),
ITEM_CROSSBOW_LOADING_MIDDLE("item.crossbow.loading_middle"),
ITEM_CROSSBOW_LOADING_START("item.crossbow.loading_start"),
ITEM_CROSSBOW_QUICK_CHARGE_1("item.crossbow.quick_charge_1"),
ITEM_CROSSBOW_QUICK_CHARGE_2("item.crossbow.quick_charge_2"),
ITEM_CROSSBOW_QUICK_CHARGE_3("item.crossbow.quick_charge_3"),
ITEM_CROSSBOW_SHOOT("item.crossbow.shoot"),
ITEM_ELYTRA_FLYING("item.elytra.flying"),
ITEM_FIRECHARGE_USE("item.firecharge.use"),
ITEM_FLINTANDSTEEL_USE("item.flintandsteel.use"),
ITEM_HOE_TILL("item.hoe.till"),
ITEM_NETHER_WART_PLANT("item.nether_wart.plant"),
ITEM_SHIELD_BLOCK("item.shield.block"),
ITEM_SHIELD_BREAK("item.shield.break"),
ITEM_SHOVEL_FLATTEN("item.shovel.flatten"),
ITEM_SWEET_BERRIES_PICK_FROM_BUSH("item.sweet_berries.pick_from_bush"),
ITEM_TOTEM_USE("item.totem.use"),
ITEM_TRIDENT_HIT("item.trident.hit"),
ITEM_TRIDENT_HIT_GROUND("item.trident.hit_ground"),
@@ -667,6 +795,11 @@ public enum CraftSound {
MUSIC_NETHER("music.nether"),
MUSIC_UNDER_WATER("music.under_water"),
UI_BUTTON_CLICK("ui.button.click"),
UI_CARTOGRAPHY_TABLE_TAKE_RESULT("ui.cartography_table.take_result"),
UI_LOOM_SELECT_PATTERN("ui.loom.select_pattern"),
UI_LOOM_TAKE_RESULT("ui.loom.take_result"),
UI_STONECUTTER_SELECT_RECIPE("ui.stonecutter.select_recipe"),
UI_STONECUTTER_TAKE_RESULT("ui.stonecutter.take_result"),
UI_TOAST_CHALLENGE_COMPLETE("ui.toast.challenge_complete"),
UI_TOAST_IN("ui.toast.in"),
UI_TOAST_OUT("ui.toast.out"),

View File

@@ -82,7 +82,18 @@ public enum CraftStatistic {
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);
CLEAN_SHULKER_BOX(StatisticList.CLEAN_SHULKER_BOX),
OPEN_BARREL(StatisticList.OPEN_BARREL),
INTERACT_WITH_BLAST_FURNACE(StatisticList.INTERACT_WITH_BLAST_FURNACE),
INTERACT_WITH_SMOKER(StatisticList.INTERACT_WITH_SMOKER),
INTERACT_WITH_LECTERN(StatisticList.INTERACT_WITH_LECTERN),
INTERACT_WITH_CAMPFIRE(StatisticList.INTERACT_WITH_CAMPFIRE),
INTERACT_WITH_CARTOGRAPHY_TABLE(StatisticList.INTERACT_WITH_CARTOGRAPHY_TABLE),
INTERACT_WITH_LOOM(StatisticList.INTERACT_WITH_LOOM),
INTERACT_WITH_STONECUTTER(StatisticList.INTERACT_WITH_STONECUTTER),
BELL_RING(StatisticList.BELL_RING),
RAID_TRIGGER(StatisticList.RAID_TRIGGER),
RAID_WIN(StatisticList.RAID_WIN);
private final MinecraftKey minecraftKey;
private final org.bukkit.Statistic bukkit;
private static final BiMap<MinecraftKey, org.bukkit.Statistic> statistics;

View File

@@ -1,86 +0,0 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.DimensionManager;
import net.minecraft.server.PortalTravelAgent;
import net.minecraft.server.WorldServer;
import org.bukkit.Location;
import org.bukkit.TravelAgent;
public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent {
public static TravelAgent DEFAULT = null;
private int searchRadius = 128;
private int creationRadius = 16;
private boolean canCreatePortal = true;
public CraftTravelAgent(WorldServer worldserver) {
super(worldserver);
if (DEFAULT == null && worldserver.dimension == DimensionManager.OVERWORLD) {
DEFAULT = this;
}
}
@Override
public Location findOrCreate(Location target) {
WorldServer worldServer = ((CraftWorld) target.getWorld()).getHandle();
Location found = this.findPortal(target);
if (found == null) {
if (this.getCanCreatePortal() && this.createPortal(target)) {
found = this.findPortal(target);
} else {
found = target; // fallback to original if unable to find or create
}
}
return found;
}
@Override
public Location findPortal(Location location) {
PortalTravelAgent pta = ((CraftWorld) location.getWorld()).getHandle().getTravelAgent();
BlockPosition found = pta.findPortal(location.getX(), location.getY(), location.getZ(), this.getSearchRadius());
return found != null ? new Location(location.getWorld(), found.getX(), found.getY(), found.getZ(), location.getYaw(), location.getPitch()) : null;
}
@Override
public boolean createPortal(Location location) {
PortalTravelAgent pta = ((CraftWorld) location.getWorld()).getHandle().getTravelAgent();
return pta.createPortal(location.getX(), location.getY(), location.getZ(), this.getCreationRadius());
}
@Override
public TravelAgent setSearchRadius(int radius) {
this.searchRadius = radius;
return this;
}
@Override
public int getSearchRadius() {
return this.searchRadius;
}
@Override
public TravelAgent setCreationRadius(int radius) {
this.creationRadius = radius < 2 ? 0 : radius;
return this;
}
@Override
public int getCreationRadius() {
return this.creationRadius;
}
@Override
public boolean getCanCreatePortal() {
return this.canCreatePortal;
}
@Override
public void setCanCreatePortal(boolean create) {
this.canCreatePortal = create;
}
}

View File

@@ -1,15 +1,16 @@
package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Iterator;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
@@ -85,8 +86,6 @@ public class CraftWorld implements World {
private int animalSpawn = -1;
private int waterAnimalSpawn = -1;
private int ambientSpawn = -1;
private int chunkLoadCount = 0;
private int chunkGCTickCount;
private static final Random rand = new Random();
@@ -95,10 +94,6 @@ public class CraftWorld implements World {
this.generator = gen;
environment = env;
if (server.chunkGCPeriod > 0) {
chunkGCTickCount = rand.nextInt(server.chunkGCPeriod);
}
}
public Block getBlockAt(int x, int y, int z) {
@@ -107,10 +102,10 @@ public class CraftWorld implements World {
public int getHighestBlockYAt(int x, int z) {
if (!isChunkLoaded(x >> 4, z >> 4)) {
loadChunk(x >> 4, z >> 4);
getChunkAt(x >> 4, z >> 4); // Transient load for this tick
}
return world.getHighestBlockYAt(HeightMap.Type.LIGHT_BLOCKING, new BlockPosition(x, 0, z)).getY();
return world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, new BlockPosition(x, 0, z)).getY();
}
public Location getSpawnLocation() {
@@ -141,7 +136,7 @@ public class CraftWorld implements World {
}
public Chunk getChunkAt(int x, int z) {
return this.world.getChunkProvider().getChunkAt(x, z, true, true).bukkitChunk;
return this.world.getChunkProvider().getChunkAt(x, z, true).bukkitChunk;
}
public Chunk getChunkAt(Block block) {
@@ -149,24 +144,23 @@ public class CraftWorld implements World {
}
public boolean isChunkLoaded(int x, int z) {
return world.getChunkProvider().isLoaded(x, z);
net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false);
return chunk != null && chunk.loaded;
}
@Override
public boolean isChunkGenerated(int x, int z) {
return isChunkLoaded(x, z) || ((ChunkRegionLoader) world.getChunkProvider().chunkLoader).chunkExists(x, z);
try {
return isChunkLoaded(x, z) || world.getChunkProvider().playerChunkMap.chunkExists(new ChunkCoordIntPair(x, z));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
public Chunk[] getLoadedChunks() {
Object[] chunks = world.getChunkProvider().chunks.values().toArray();
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];
Long2ObjectLinkedOpenHashMap<PlayerChunk> chunks = world.getChunkProvider().playerChunkMap.visibleChunks;
for (int i = 0; i < chunks.length; i++) {
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) chunks[i];
craftChunks[i] = chunk.bukkitChunk;
}
return craftChunks;
return chunks.values().stream().map(PlayerChunk::getChunk).filter(Objects::nonNull).filter((chunk) -> chunk.loaded).map(net.minecraft.server.Chunk::getBukkitChunk).toArray(Chunk[]::new);
}
public void loadChunk(int x, int z) {
@@ -182,50 +176,39 @@ public class CraftWorld implements World {
}
public boolean unloadChunk(int x, int z, boolean save) {
return unloadChunk(x, z, save, false);
return unloadChunk0(x, z, save);
}
public boolean unloadChunkRequest(int x, int z) {
return unloadChunkRequest(x, z, true);
}
public boolean unloadChunkRequest(int x, int z, boolean safe) {
if (safe && isChunkInUse(x, z)) {
return false;
}
net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false, false);
net.minecraft.server.IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false);
if (chunk != null) {
world.getChunkProvider().unload(chunk);
world.getChunkProvider().removeTicket(TicketType.PLUGIN, chunk.getPos(), 1, Unit.INSTANCE);
}
return true;
}
public boolean unloadChunk(int x, int z, boolean save, boolean safe) {
if (isChunkInUse(x, z)) {
return false;
}
return unloadChunk0(x, z, save);
}
private boolean unloadChunk0(int x, int z, boolean save) {
net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false, false);
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false);
if (chunk == null) {
return true;
}
// If chunk had previously been queued to save, must do save to avoid loss of that data
return world.getChunkProvider().unloadChunk(chunk, chunk.mustSave || save);
chunk.mustNotSave = !save;
unloadChunkRequest(x, z);
world.getChunkProvider().purgeUnload();
return !isChunkLoaded(x, z);
}
public boolean regenerateChunk(int x, int z) {
throw new UnsupportedOperationException("Not supported in this Minecraft version! Unless you can fix it, this is not a bug :)");
/*
if (!unloadChunk0(x, z, false)) {
return false;
}
final long chunkKey = ChunkCoordIntPair.a(x, z);
final long chunkKey = ChunkCoordIntPair.pair(x, z);
world.getChunkProvider().unloadQueue.remove(chunkKey);
net.minecraft.server.Chunk chunk = world.getChunkProvider().generateChunk(x, z);
@@ -239,6 +222,7 @@ public class CraftWorld implements World {
}
return chunk != null;
*/
}
public boolean refreshChunk(int x, int z) {
@@ -262,12 +246,24 @@ public class CraftWorld implements World {
}
public boolean isChunkInUse(int x, int z) {
return world.getPlayerChunkMap().isChunkInUse(x, z) || world.isForceLoaded(x, z);
return isChunkLoaded(x, z);
}
public boolean loadChunk(int x, int z, boolean generate) {
chunkLoadCount++;
return world.getChunkProvider().getChunkAt(x, z, true, generate) != null;
IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, generate ? ChunkStatus.FULL : ChunkStatus.EMPTY, true);
// If generate = false, but the chunk already exists, we will get this back.
if (chunk instanceof ProtoChunkExtension) {
// We then cycle through again to get the full chunk immediately, rather than after the ticket addition
chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true);
}
if (chunk instanceof net.minecraft.server.Chunk) {
world.getChunkProvider().addTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
return true;
}
return false;
}
public boolean isChunkLoaded(Chunk chunk) {
@@ -281,7 +277,7 @@ public class CraftWorld implements World {
@Override
public boolean isChunkForceLoaded(int x, int z) {
return getHandle().isForceLoaded(x, z);
return getHandle().getForceLoadedChunks().contains(ChunkCoordIntPair.pair(x, z));
}
@Override
@@ -293,8 +289,8 @@ public class CraftWorld implements World {
public Collection<Chunk> getForceLoadedChunks() {
Set<Chunk> chunks = new HashSet<>();
for (long coord : getHandle().ag()) { // PAIL
chunks.add(getChunkAt(ChunkCoordIntPair.a(coord), ChunkCoordIntPair.b(coord)));
for (long coord : getHandle().getForceLoadedChunks()) {
chunks.add(getChunkAt(ChunkCoordIntPair.getX(coord), ChunkCoordIntPair.getZ(coord)));
}
return Collections.unmodifiableCollection(chunks);
@@ -336,14 +332,14 @@ public class CraftWorld implements World {
EntityArrow arrow;
if (TippedArrow.class.isAssignableFrom(clazz)) {
arrow = new EntityTippedArrow(world);
arrow = EntityTypes.ARROW.a(world);
((EntityTippedArrow) arrow).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
arrow = new EntitySpectralArrow(world);
arrow = EntityTypes.SPECTRAL_ARROW.a(world);
} else if (Trident.class.isAssignableFrom(clazz)){
arrow = new EntityThrownTrident(world);
arrow = EntityTypes.TRIDENT.a(world);
} else {
arrow = new EntityTippedArrow(world);
arrow = EntityTypes.ARROW.a(world);
}
arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
@@ -374,56 +370,56 @@ public class CraftWorld implements World {
net.minecraft.server.WorldGenerator gen;
switch (type) {
case BIG_TREE:
gen = new WorldGenBigTree(true);
gen = WorldGenerator.FANCY_TREE;
break;
case BIRCH:
gen = new WorldGenForest(true, false);
gen = WorldGenerator.BIRCH_TREE;
break;
case REDWOOD:
gen = new WorldGenTaiga2(true);
gen = WorldGenerator.SPRUCE_TREE;
break;
case TALL_REDWOOD:
gen = new WorldGenTaiga1();
gen = WorldGenerator.PINE_TREE;
break;
case JUNGLE:
gen = new WorldGenJungleTree(true, 10, 20, Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData());
gen = WorldGenerator.MEGA_JUNGLE_TREE;
break;
case SMALL_JUNGLE:
gen = new WorldGenTrees(true, 4 + rand.nextInt(7), Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData(), false);
gen = WorldGenerator.JUNGLE_TREE;
break;
case COCOA_TREE:
gen = new WorldGenJungleTree(true, 10, 20, Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData());
gen = WorldGenerator.MEGA_JUNGLE_TREE;
break;
case JUNGLE_BUSH:
gen = new WorldGenGroundBush(Blocks.JUNGLE_LOG.getBlockData(), Blocks.OAK_LEAVES.getBlockData());
gen = WorldGenerator.JUNGLE_GROUND_BUSH;
break;
case RED_MUSHROOM:
gen = new WorldGenHugeMushroomRed();
gen = WorldGenerator.HUGE_RED_MUSHROOM;
break;
case BROWN_MUSHROOM:
gen = new WorldGenHugeMushroomBrown();
gen = WorldGenerator.HUGE_BROWN_MUSHROOM;
break;
case SWAMP:
gen = new WorldGenSwampTree();
gen = WorldGenerator.SWAMP_TREE;
break;
case ACACIA:
gen = new WorldGenAcaciaTree(true);
gen = WorldGenerator.SAVANNA_TREE;
break;
case DARK_OAK:
gen = new WorldGenForestTree(true);
gen = WorldGenerator.DARK_OAK_TREE;
break;
case MEGA_REDWOOD:
gen = new WorldGenMegaTree(false, rand.nextBoolean());
gen = WorldGenerator.MEGA_PINE_TREE;
break;
case TALL_BIRCH:
gen = new WorldGenForest(true, true);
gen = WorldGenerator.SUPER_BIRCH_TREE;
break;
case CHORUS_PLANT:
((BlockChorusFlower) Blocks.CHORUS_FLOWER).a(world, pos, rand, 8);
return true;
case TREE:
default:
gen = new WorldGenTrees(true);
gen = WorldGenerator.NORMAL_TREE;
break;
}
@@ -508,7 +504,7 @@ public class CraftWorld implements World {
}
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks) {
return !world.createExplosion(null, x, y, z, power, setFire, breakBlocks).wasCanceled;
return !world.createExplosion(null, x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled;
}
public boolean createExplosion(Location loc, float power) {
@@ -528,13 +524,13 @@ public class CraftWorld implements World {
environment = env;
switch (env) {
case NORMAL:
world.worldProvider = new WorldProviderNormal();
world.worldProvider = new WorldProviderNormal(world, world.dimension);
break;
case NETHER:
world.worldProvider = new WorldProviderHell();
world.worldProvider = new WorldProviderHell(world, world.dimension);
break;
case THE_END:
world.worldProvider = new WorldProviderTheEnd();
world.worldProvider = new WorldProviderTheEnd(world, world.dimension);
break;
}
}
@@ -597,7 +593,7 @@ public class CraftWorld implements World {
public List<Entity> getEntities() {
List<Entity> list = new ArrayList<Entity>();
for (Object o : world.entityList) {
for (Object o : world.entitiesById.values()) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
Entity bukkitEntity = mcEnt.getBukkitEntity();
@@ -615,7 +611,7 @@ public class CraftWorld implements World {
public List<LivingEntity> getLivingEntities() {
List<LivingEntity> list = new ArrayList<LivingEntity>();
for (Object o : world.entityList) {
for (Object o : world.entitiesById.values()) {
if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
Entity bukkitEntity = mcEnt.getBukkitEntity();
@@ -640,7 +636,7 @@ public class CraftWorld implements World {
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> clazz) {
Collection<T> list = new ArrayList<T>();
for (Object entity: world.entityList) {
for (Object entity: world.entitiesById.values()) {
if (entity instanceof net.minecraft.server.Entity) {
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
@@ -662,7 +658,7 @@ public class CraftWorld implements World {
public Collection<Entity> getEntitiesByClasses(Class<?>... classes) {
Collection<Entity> list = new ArrayList<Entity>();
for (Object entity: world.entityList) {
for (Object entity: world.entitiesById.values()) {
if (entity instanceof net.minecraft.server.Entity) {
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
@@ -807,7 +803,7 @@ public class CraftWorld implements World {
Vector dir = direction.clone().normalize().multiply(maxDistance);
Vec3D startPos = new Vec3D(start.getX(), start.getY(), start.getZ());
Vec3D endPos = new Vec3D(start.getX() + dir.getX(), start.getY() + dir.getY(), start.getZ() + dir.getZ());
MovingObjectPosition nmsHitResult = this.getHandle().rayTrace(startPos, endPos, CraftFluidCollisionMode.toNMS(fluidCollisionMode), ignorePassableBlocks, false);
MovingObjectPosition nmsHitResult = this.getHandle().rayTrace(new RayTrace(startPos, endPos, ignorePassableBlocks ? RayTrace.BlockCollisionOption.COLLIDER : RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null));
return CraftRayTraceResult.fromNMS(this, nmsHitResult);
}
@@ -843,9 +839,9 @@ public class CraftWorld implements World {
}
public List<Player> getPlayers() {
List<Player> list = new ArrayList<Player>(world.players.size());
List<Player> list = new ArrayList<Player>(world.getPlayers().size());
for (EntityHuman human : world.players) {
for (EntityHuman human : world.getPlayers()) {
HumanEntity bukkitEntity = human.getBukkitEntity();
if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) {
@@ -862,7 +858,7 @@ public class CraftWorld implements World {
boolean oldSave = world.savingDisabled;
world.savingDisabled = false;
world.save(true, null);
world.save(null, false, false);
world.savingDisabled = oldSave;
} catch (ExceptionWorldConflict ex) {
@@ -1045,46 +1041,48 @@ public class CraftWorld implements World {
entity = new EntityEgg(world, x, y, z);
} else if (Arrow.class.isAssignableFrom(clazz)) {
if (TippedArrow.class.isAssignableFrom(clazz)) {
entity = new EntityTippedArrow(world);
entity = EntityTypes.ARROW.a(world);
((EntityTippedArrow) entity).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
entity = new EntitySpectralArrow(world);
entity = EntityTypes.SPECTRAL_ARROW.a(world);
} else if (Trident.class.isAssignableFrom(clazz)) {
entity = new EntityThrownTrident(world);
entity = EntityTypes.TRIDENT.a(world);
} else {
entity = new EntityTippedArrow(world);
entity = EntityTypes.ARROW.a(world);
}
entity.setPositionRotation(x, y, z, 0, 0);
} else if (ThrownExpBottle.class.isAssignableFrom(clazz)) {
entity = new EntityThrownExpBottle(world);
entity = EntityTypes.EXPERIENCE_BOTTLE.a(world);
entity.setPositionRotation(x, y, z, 0, 0);
} else if (EnderPearl.class.isAssignableFrom(clazz)) {
entity = new EntityEnderPearl(world);
entity = EntityTypes.ENDER_PEARL.a(world);
entity.setPositionRotation(x, y, z, 0, 0);
} else if (ThrownPotion.class.isAssignableFrom(clazz)) {
if (LingeringPotion.class.isAssignableFrom(clazz)) {
entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
entity = new EntityPotion(world, x, y, z);
((EntityPotion) entity).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
} else {
entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
entity = new EntityPotion(world, x, y, z);
((EntityPotion) entity).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
}
} else if (Fireball.class.isAssignableFrom(clazz)) {
if (SmallFireball.class.isAssignableFrom(clazz)) {
entity = new EntitySmallFireball(world);
entity = EntityTypes.SMALL_FIREBALL.a(world);
} else if (WitherSkull.class.isAssignableFrom(clazz)) {
entity = new EntityWitherSkull(world);
entity = EntityTypes.WITHER_SKULL.a(world);
} else if (DragonFireball.class.isAssignableFrom(clazz)) {
entity = new EntityDragonFireball(world);
entity = EntityTypes.DRAGON_FIREBALL.a(world);
} else {
entity = new EntityLargeFireball(world);
entity = EntityTypes.FIREBALL.a(world);
}
entity.setPositionRotation(x, y, z, yaw, pitch);
Vector direction = location.getDirection().multiply(10);
((EntityFireball) entity).setDirection(direction.getX(), direction.getY(), direction.getZ());
} else if (ShulkerBullet.class.isAssignableFrom(clazz)) {
entity = new EntityShulkerBullet(world);
entity = EntityTypes.SHULKER_BULLET.a(world);
entity.setPositionRotation(x, y, z, yaw, pitch);
} else if (LlamaSpit.class.isAssignableFrom(clazz)) {
entity = new EntityLlamaSpit(world);
entity = EntityTypes.LLAMA_SPIT.a(world);
entity.setPositionRotation(x, y, z, yaw, pitch);
}
} else if (Minecart.class.isAssignableFrom(clazz)) {
@@ -1106,157 +1104,175 @@ public class CraftWorld implements World {
} else if (EnderSignal.class.isAssignableFrom(clazz)) {
entity = new EntityEnderSignal(world, x, y, z);
} else if (EnderCrystal.class.isAssignableFrom(clazz)) {
entity = new EntityEnderCrystal(world);
entity = EntityTypes.END_CRYSTAL.a(world);
entity.setPositionRotation(x, y, z, 0, 0);
} else if (LivingEntity.class.isAssignableFrom(clazz)) {
if (Chicken.class.isAssignableFrom(clazz)) {
entity = new EntityChicken(world);
entity = EntityTypes.CHICKEN.a(world);
} else if (Cow.class.isAssignableFrom(clazz)) {
if (MushroomCow.class.isAssignableFrom(clazz)) {
entity = new EntityMushroomCow(world);
entity = EntityTypes.MOOSHROOM.a(world);
} else {
entity = new EntityCow(world);
entity = EntityTypes.COW.a(world);
}
} else if (Golem.class.isAssignableFrom(clazz)) {
if (Snowman.class.isAssignableFrom(clazz)) {
entity = new EntitySnowman(world);
entity = EntityTypes.SNOW_GOLEM.a(world);
} else if (IronGolem.class.isAssignableFrom(clazz)) {
entity = new EntityIronGolem(world);
entity = EntityTypes.IRON_GOLEM.a(world);
} else if (Shulker.class.isAssignableFrom(clazz)) {
entity = new EntityShulker(world);
entity = EntityTypes.SHULKER.a(world);
}
} else if (Creeper.class.isAssignableFrom(clazz)) {
entity = new EntityCreeper(world);
entity = EntityTypes.CREEPER.a(world);
} else if (Ghast.class.isAssignableFrom(clazz)) {
entity = new EntityGhast(world);
entity = EntityTypes.GHAST.a(world);
} else if (Pig.class.isAssignableFrom(clazz)) {
entity = new EntityPig(world);
entity = EntityTypes.PIG.a(world);
} else if (Player.class.isAssignableFrom(clazz)) {
// need a net server handler for this one
} else if (Sheep.class.isAssignableFrom(clazz)) {
entity = new EntitySheep(world);
entity = EntityTypes.SHEEP.a(world);
} else if (AbstractHorse.class.isAssignableFrom(clazz)) {
if (ChestedHorse.class.isAssignableFrom(clazz)) {
if (Donkey.class.isAssignableFrom(clazz)) {
entity = new EntityHorseDonkey(world);
entity = EntityTypes.DONKEY.a(world);
} else if (Mule.class.isAssignableFrom(clazz)) {
entity = new EntityHorseMule(world);
entity = EntityTypes.MULE.a(world);
} else if (Llama.class.isAssignableFrom(clazz)) {
entity = new EntityLlama(world);
if (TraderLlama.class.isAssignableFrom(clazz)) {
entity = EntityTypes.TRADER_LLAMA.a(world);
} else {
entity = EntityTypes.LLAMA.a(world);
}
}
} else if (SkeletonHorse.class.isAssignableFrom(clazz)) {
entity = new EntityHorseSkeleton(world);
entity = EntityTypes.SKELETON_HORSE.a(world);
} else if (ZombieHorse.class.isAssignableFrom(clazz)) {
entity = new EntityHorseZombie(world);
entity = EntityTypes.ZOMBIE_HORSE.a(world);
} else {
entity = new EntityHorse(world);
entity = EntityTypes.HORSE.a(world);
}
} else if (Skeleton.class.isAssignableFrom(clazz)) {
if (Stray.class.isAssignableFrom(clazz)){
entity = new EntitySkeletonStray(world);
entity = EntityTypes.STRAY.a(world);
} else if (WitherSkeleton.class.isAssignableFrom(clazz)) {
entity = new EntitySkeletonWither(world);
entity = EntityTypes.WITHER_SKELETON.a(world);
} else {
entity = new EntitySkeleton(world);
entity = EntityTypes.SKELETON.a(world);
}
} else if (Slime.class.isAssignableFrom(clazz)) {
if (MagmaCube.class.isAssignableFrom(clazz)) {
entity = new EntityMagmaCube(world);
entity = EntityTypes.MAGMA_CUBE.a(world);
} else {
entity = new EntitySlime(world);
entity = EntityTypes.SLIME.a(world);
}
} else if (Spider.class.isAssignableFrom(clazz)) {
if (CaveSpider.class.isAssignableFrom(clazz)) {
entity = new EntityCaveSpider(world);
entity = EntityTypes.CAVE_SPIDER.a(world);
} else {
entity = new EntitySpider(world);
entity = EntityTypes.SPIDER.a(world);
}
} else if (Squid.class.isAssignableFrom(clazz)) {
entity = new EntitySquid(world);
entity = EntityTypes.SQUID.a(world);
} else if (Tameable.class.isAssignableFrom(clazz)) {
if (Wolf.class.isAssignableFrom(clazz)) {
entity = new EntityWolf(world);
} else if (Ocelot.class.isAssignableFrom(clazz)) {
entity = new EntityOcelot(world);
entity = EntityTypes.WOLF.a(world);
} else if (Parrot.class.isAssignableFrom(clazz)) {
entity = new EntityParrot(world);
entity = EntityTypes.PARROT.a(world);
}
} else if (PigZombie.class.isAssignableFrom(clazz)) {
entity = new EntityPigZombie(world);
entity = EntityTypes.ZOMBIE_PIGMAN.a(world);
} else if (Zombie.class.isAssignableFrom(clazz)) {
if (Husk.class.isAssignableFrom(clazz)) {
entity = new EntityZombieHusk(world);
entity = EntityTypes.HUSK.a(world);
} else if (ZombieVillager.class.isAssignableFrom(clazz)) {
entity = new EntityZombieVillager(world);
entity = EntityTypes.ZOMBIE_VILLAGER.a(world);
} else if (Drowned.class.isAssignableFrom(clazz)) {
entity = new EntityDrowned(world);
entity = EntityTypes.DROWNED.a(world);
} else {
entity = new EntityZombie(world);
}
} else if (Giant.class.isAssignableFrom(clazz)) {
entity = new EntityGiantZombie(world);
entity = EntityTypes.GIANT.a(world);
} else if (Silverfish.class.isAssignableFrom(clazz)) {
entity = new EntitySilverfish(world);
entity = EntityTypes.SILVERFISH.a(world);
} else if (Enderman.class.isAssignableFrom(clazz)) {
entity = new EntityEnderman(world);
entity = EntityTypes.ENDERMAN.a(world);
} else if (Blaze.class.isAssignableFrom(clazz)) {
entity = new EntityBlaze(world);
} else if (Villager.class.isAssignableFrom(clazz)) {
entity = new EntityVillager(world);
entity = EntityTypes.BLAZE.a(world);
} else if (AbstractVillager.class.isAssignableFrom(clazz)) {
if (Villager.class.isAssignableFrom(clazz)) {
entity = EntityTypes.VILLAGER.a(world);
} else if (WanderingTrader.class.isAssignableFrom(clazz)) {
entity = EntityTypes.WANDERING_TRADER.a(world);
}
} else if (Witch.class.isAssignableFrom(clazz)) {
entity = new EntityWitch(world);
entity = EntityTypes.WITCH.a(world);
} else if (Wither.class.isAssignableFrom(clazz)) {
entity = new EntityWither(world);
entity = EntityTypes.WITHER.a(world);
} else if (ComplexLivingEntity.class.isAssignableFrom(clazz)) {
if (EnderDragon.class.isAssignableFrom(clazz)) {
entity = new EntityEnderDragon(world);
entity = EntityTypes.ENDER_DRAGON.a(world);
}
} else if (Ambient.class.isAssignableFrom(clazz)) {
if (Bat.class.isAssignableFrom(clazz)) {
entity = new EntityBat(world);
entity = EntityTypes.BAT.a(world);
}
} else if (Rabbit.class.isAssignableFrom(clazz)) {
entity = new EntityRabbit(world);
entity = EntityTypes.RABBIT.a(world);
} else if (Endermite.class.isAssignableFrom(clazz)) {
entity = new EntityEndermite(world);
entity = EntityTypes.ENDERMITE.a(world);
} else if (Guardian.class.isAssignableFrom(clazz)) {
if (ElderGuardian.class.isAssignableFrom(clazz)){
entity = new EntityGuardianElder(world);
entity = EntityTypes.ELDER_GUARDIAN.a(world);
} else {
entity = new EntityGuardian(world);
entity = EntityTypes.GUARDIAN.a(world);
}
} else if (ArmorStand.class.isAssignableFrom(clazz)) {
entity = new EntityArmorStand(world, x, y, z);
} else if (PolarBear.class.isAssignableFrom(clazz)) {
entity = new EntityPolarBear(world);
entity = EntityTypes.POLAR_BEAR.a(world);
} else if (Vex.class.isAssignableFrom(clazz)) {
entity = new EntityVex(world);
entity = EntityTypes.VEX.a(world);
} else if (Illager.class.isAssignableFrom(clazz)) {
if (Spellcaster.class.isAssignableFrom(clazz)) {
if (Evoker.class.isAssignableFrom(clazz)) {
entity = new EntityEvoker(world);
entity = EntityTypes.EVOKER.a(world);
} else if (Illusioner.class.isAssignableFrom(clazz)) {
entity = new EntityIllagerIllusioner(world);
entity = EntityTypes.ILLUSIONER.a(world);
}
} else if (Vindicator.class.isAssignableFrom(clazz)) {
entity = new EntityVindicator(world);
entity = EntityTypes.VINDICATOR.a(world);
} else if (Pillager.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PILLAGER.a(world);
}
} else if (Turtle.class.isAssignableFrom(clazz)) {
entity = new EntityTurtle(world);
entity = EntityTypes.TURTLE.a(world);
} else if (Phantom.class.isAssignableFrom(clazz)) {
entity = new EntityPhantom(world);
entity = EntityTypes.PHANTOM.a(world);
} else if (Fish.class.isAssignableFrom(clazz)) {
if (Cod.class.isAssignableFrom(clazz)) {
entity = new EntityCod(world);
entity = EntityTypes.COD.a(world);
} else if (PufferFish.class.isAssignableFrom(clazz)) {
entity = new EntityPufferFish(world);
entity = EntityTypes.PUFFERFISH.a(world);
} else if (Salmon.class.isAssignableFrom(clazz)) {
entity = new EntitySalmon(world);
entity = EntityTypes.SALMON.a(world);
} else if (TropicalFish.class.isAssignableFrom(clazz)) {
entity = new EntityTropicalFish(world);
entity = EntityTypes.TROPICAL_FISH.a(world);
}
} else if (Dolphin.class.isAssignableFrom(clazz)) {
entity = new EntityDolphin(world);
entity = EntityTypes.DOLPHIN.a(world);
} else if (Ocelot.class.isAssignableFrom(clazz)) {
entity = EntityTypes.OCELOT.a(world);
} else if (Cat.class.isAssignableFrom(clazz)) {
entity = EntityTypes.CAT.a(world);
} else if (Ravager.class.isAssignableFrom(clazz)) {
entity = EntityTypes.RAVAGER.a(world);
} else if (Panda.class.isAssignableFrom(clazz)) {
entity = EntityTypes.PANDA.a(world);
} else if (Fox.class.isAssignableFrom(clazz)) {
entity = EntityTypes.FOX.a(world);
}
if (entity != null) {
@@ -1321,12 +1337,8 @@ public class CraftWorld implements World {
entity = new EntityTNTPrimed(world, x, y, z, null);
} else if (ExperienceOrb.class.isAssignableFrom(clazz)) {
entity = new EntityExperienceOrb(world, x, y, z, 0);
} else if (Weather.class.isAssignableFrom(clazz)) {
// not sure what this can do
if (LightningStrike.class.isAssignableFrom(clazz)) {
entity = new EntityLightning(world, x, y, z, false);
// what is this, I don't even
}
} else if (LightningStrike.class.isAssignableFrom(clazz)) {
entity = new EntityLightning(world, x, y, z, false);
} else if (Firework.class.isAssignableFrom(clazz)) {
entity = new EntityFireworks(world, x, y, z, net.minecraft.server.ItemStack.a);
} else if (AreaEffectCloud.class.isAssignableFrom(clazz)) {
@@ -1352,7 +1364,7 @@ public class CraftWorld implements World {
Preconditions.checkArgument(entity != null, "Cannot spawn null entity");
if (entity instanceof EntityInsentient) {
((EntityInsentient) entity).prepare(getHandle().getDamageScaler(new BlockPosition(entity)), (GroupDataEntity) null, null);
((EntityInsentient) entity).prepare(getHandle(), getHandle().getDamageScaler(new BlockPosition(entity)), EnumMobSpawn.COMMAND, (GroupDataEntity) null, null);
}
if (function != null) {
@@ -1378,11 +1390,11 @@ public class CraftWorld implements World {
}
public boolean getAllowAnimals() {
return world.allowAnimals;
return world.getChunkProvider().allowAnimals;
}
public boolean getAllowMonsters() {
return world.allowMonsters;
return world.getChunkProvider().allowMonsters;
}
public int getMaxHeight() {
@@ -1584,7 +1596,7 @@ public class CraftWorld implements World {
}
GameRules.GameRuleValue value = getHandle().getGameRules().get(rule);
return value != null ? value.a() : "";
return value != null ? value.getValue() : "";
}
public boolean setGameRuleValue(String rule, String value) {
@@ -1636,9 +1648,9 @@ public class CraftWorld implements World {
switch (value.getType()) {
case BOOLEAN_VALUE:
return rule.getType().cast(value.b());
return rule.getType().cast(value.getBooleanValue());
case NUMERICAL_VALUE:
return rule.getType().cast(value.c());
return rule.getType().cast(value.getIntValue());
default:
throw new IllegalArgumentException("Invalid GameRule type (" + value.getType() + ") for GameRule " + rule.getName());
}
@@ -1741,32 +1753,4 @@ public class CraftWorld implements World {
BlockPosition nearest = getHandle().getChunkProvider().getChunkGenerator().findNearestMapFeature(getHandle(), structureType.getName(), originPos, radius, findUnexplored);
return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
}
public void processChunkGC() {
chunkGCTickCount++;
if (chunkLoadCount >= server.chunkGCLoadThresh && server.chunkGCLoadThresh > 0) {
chunkLoadCount = 0;
} else if (chunkGCTickCount >= server.chunkGCPeriod && server.chunkGCPeriod > 0) {
chunkGCTickCount = 0;
} else {
return;
}
ChunkProviderServer cps = world.getChunkProvider();
for (net.minecraft.server.Chunk chunk : cps.chunks.values()) {
// If in use, skip it
if (isChunkInUse(chunk.locX, chunk.locZ)) {
continue;
}
// Already unloading?
if (cps.unloadQueue.contains(ChunkCoordIntPair.a(chunk.locX, chunk.locZ))) {
continue;
}
// Add unload request
cps.unload(chunk);
}
}
}

View File

@@ -1,47 +0,0 @@
package org.bukkit.craftbukkit;
/**
* Credits for this class goes to user aioobe on stackoverflow.com
* Source: http://stackoverflow.com/questions/4454630/j2me-calculate-the-the-distance-between-2-latitude-and-longitude
*/
public class TrigMath {
static final double sq2p1 = 2.414213562373095048802e0;
static final double sq2m1 = .414213562373095048802e0;
static final double p4 = .161536412982230228262e2;
static final double p3 = .26842548195503973794141e3;
static final double p2 = .11530293515404850115428136e4;
static final double p1 = .178040631643319697105464587e4;
static final double p0 = .89678597403663861959987488e3;
static final double q4 = .5895697050844462222791e2;
static final double q3 = .536265374031215315104235e3;
static final double q2 = .16667838148816337184521798e4;
static final double q1 = .207933497444540981287275926e4;
static final double q0 = .89678597403663861962481162e3;
static final double PIO2 = 1.5707963267948966135E0;
private static double mxatan(double arg) {
double argsq = arg * arg, value;
value = ((((p4 * argsq + p3) * argsq + p2) * argsq + p1) * argsq + p0);
value = value / (((((argsq + q4) * argsq + q3) * argsq + q2) * argsq + q1) * argsq + q0);
return value * arg;
}
private static double msatan(double arg) {
return arg < sq2m1 ? mxatan(arg)
: arg > sq2p1 ? PIO2 - mxatan(1 / arg)
: PIO2 / 2 + mxatan((arg - 1) / (arg + 1));
}
public static double atan(double arg) {
return arg > 0 ? msatan(arg) : -msatan(-arg);
}
public static double atan2(double arg1, double arg2) {
if (arg1 + arg2 == arg1)
return arg1 >= 0 ? PIO2 : -PIO2;
arg1 = atan(arg1 / arg2);
return arg2 < 0 ? arg1 <= 0 ? arg1 + Math.PI : arg1 - Math.PI : arg1;
}
}

View File

@@ -66,10 +66,10 @@ public class CraftAttributeInstance implements AttributeInstance {
}
public static net.minecraft.server.AttributeModifier convert(AttributeModifier bukkit) {
return new net.minecraft.server.AttributeModifier(bukkit.getUniqueId(), bukkit.getName(), bukkit.getAmount(), bukkit.getOperation().ordinal());
return new net.minecraft.server.AttributeModifier(bukkit.getUniqueId(), bukkit.getName(), bukkit.getAmount(), net.minecraft.server.AttributeModifier.Operation.values()[bukkit.getOperation().ordinal()]);
}
public static AttributeModifier convert(net.minecraft.server.AttributeModifier nms) {
return new AttributeModifier(nms.a(), nms.b(), nms.d(), AttributeModifier.Operation.values()[nms.c()]);
return new AttributeModifier(nms.a(), nms.b(), nms.d(), AttributeModifier.Operation.values()[nms.c().ordinal()]);
}
}

View File

@@ -0,0 +1,33 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityBarrel;
import org.bukkit.Material;
import org.bukkit.block.Barrel;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftBarrel extends CraftLootable<TileEntityBarrel> implements Barrel {
public CraftBarrel(Block block) {
super(block, TileEntityBarrel.class);
}
public CraftBarrel(Material material, TileEntityBarrel te) {
super(material, te);
}
@Override
public Inventory getSnapshotInventory() {
return new CraftInventory(this.getSnapshot());
}
@Override
public Inventory getInventory() {
if (!this.isPlaced()) {
return this.getSnapshotInventory();
}
return new CraftInventory(this.getTileEntity());
}
}

View File

@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.block;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.server.ChestLock;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.MobEffectList;
import net.minecraft.server.TileEntity;
@@ -9,14 +10,12 @@ import net.minecraft.server.TileEntityBeacon;
import org.bukkit.Material;
import org.bukkit.block.Beacon;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.inventory.CraftInventoryBeacon;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.BeaconInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class CraftBeacon extends CraftContainer<TileEntityBeacon> implements Beacon {
public class CraftBeacon extends CraftBlockEntityState<TileEntityBeacon> implements Beacon {
public CraftBeacon(final Block block) {
super(block, TileEntityBeacon.class);
@@ -26,20 +25,6 @@ public class CraftBeacon extends CraftContainer<TileEntityBeacon> implements Bea
super(material, te);
}
@Override
public BeaconInventory getSnapshotInventory() {
return new CraftInventoryBeacon(this.getSnapshot());
}
@Override
public BeaconInventory getInventory() {
if (!this.isPlaced()) {
return this.getSnapshotInventory();
}
return new CraftInventoryBeacon(this.getTileEntity());
}
@Override
public Collection<LivingEntity> getEntitiesInRange() {
TileEntity tileEntity = this.getTileEntityFromWorld();
@@ -88,11 +73,26 @@ public class CraftBeacon extends CraftContainer<TileEntityBeacon> implements Bea
@Override
public String getCustomName() {
TileEntityBeacon beacon = this.getSnapshot();
return beacon.hasCustomName() ? CraftChatMessage.fromComponent(beacon.getCustomName()) : null;
return beacon.customName != null ? CraftChatMessage.fromComponent(beacon.customName) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override
public boolean isLocked() {
return !this.getSnapshot().chestLock.key.isEmpty();
}
@Override
public String getLock() {
return this.getSnapshot().chestLock.key;
}
@Override
public void setLock(String key) {
this.getSnapshot().chestLock = (key == null) ? ChestLock.a : new ChestLock(key);
}
}

View File

@@ -0,0 +1,16 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityBell;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class CraftBell extends CraftBlockEntityState<TileEntityBell> {
public CraftBell(Block block) {
super(block, TileEntityBell.class);
}
public CraftBell(Material material, TileEntityBell te) {
super(material, te);
}
}

View File

@@ -0,0 +1,17 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityBlastFurnace;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlastFurnace;
public class CraftBlastFurnace extends CraftFurnace implements BlastFurnace {
public CraftBlastFurnace(Block block) {
super(block, TileEntityBlastFurnace.class);
}
public CraftBlastFurnace(Material material, TileEntityBlastFurnace te) {
super(material, te);
}
}

View File

@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.server.*;
@@ -40,7 +41,7 @@ public class CraftBlock implements Block {
public CraftBlock(GeneratorAccess world, BlockPosition position) {
this.world = world;
this.position = position.h();
this.position = position.immutableCopy();
}
public static CraftBlock at(GeneratorAccess world, BlockPosition position) {
@@ -158,7 +159,12 @@ public class CraftBlock implements Block {
public boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) {
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
if (!blockData.isAir() && blockData.getBlock() instanceof BlockTileEntity && blockData.getBlock() != getNMSBlock()) {
world.setTypeAndData(position, Blocks.AIR.getBlockData(), 0);
// SPIGOT-4612: faster - just clear tile
if (world instanceof net.minecraft.server.World) {
((net.minecraft.server.World) world).removeTileEntity(position);
} else {
world.setTypeAndData(position, Blocks.AIR.getBlockData(), 0);
}
}
if (applyPhysics) {
@@ -278,14 +284,24 @@ public class CraftBlock implements Block {
Material material = getType();
switch (material) {
case SIGN:
case WALL_SIGN:
case ACACIA_SIGN:
case ACACIA_WALL_SIGN:
case BIRCH_SIGN:
case BIRCH_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:
return new CraftSign(this);
case CHEST:
case TRAPPED_CHEST:
return new CraftChest(this);
case FURNACE:
return new CraftFurnace(this);
return new CraftFurnaceFurnace(this);
case DISPENSER:
return new CraftDispenser(this);
case DROPPER:
@@ -399,6 +415,22 @@ public class CraftBlock implements Block {
return new CraftBed(this);
case CONDUIT:
return new CraftConduit(this);
case BARRIER:
return new CraftBarrel(this);
case BARREL:
return new CraftBarrel(this);
case BELL:
return new CraftBell(this);
case BLAST_FURNACE:
return new CraftBlastFurnace(this);
case CAMPFIRE:
return new CraftCampfire(this);
case JIGSAW:
return new CraftJigsaw(this);
case LECTERN:
return new CraftLectern(this);
case SMOKER:
return new CraftSmoker(this);
default:
TileEntity tileEntity = world.getTileEntity(position);
if (tileEntity != null) {
@@ -512,80 +544,30 @@ public class CraftBlock implements Block {
return PistonMoveReaction.getById(getNMS().getPushReaction().ordinal());
}
private boolean itemCausesDrops(ItemStack item) {
net.minecraft.server.Block block = this.getNMSBlock();
net.minecraft.server.Item itemType = CraftMagicNumbers.getItem(item.getType());
return block != null && (block.getBlockData().getMaterial().isAlwaysDestroyable() || (itemType != null && itemType.canDestroySpecialBlock(block.getBlockData())));
public boolean breakNaturally() {
return breakNaturally(new ItemStack(Material.AIR));
}
public boolean breakNaturally() {
public boolean breakNaturally(ItemStack item) {
// Order matters here, need to drop before setting to air so skulls can get their data
net.minecraft.server.Block block = this.getNMSBlock();
boolean result = false;
if (block != null && block != Blocks.AIR) {
block.dropNaturally(getNMS(), world.getMinecraftWorld(), position, 1.0F, 0);
net.minecraft.server.Block.dropItems(getNMS(), world.getMinecraftWorld(), position, world.getTileEntity(position), null, CraftItemStack.asNMSCopy(item));
result = true;
}
setType(Material.AIR);
return result;
}
public boolean breakNaturally(ItemStack item) {
if (itemCausesDrops(item)) {
return breakNaturally();
} else {
return setTypeAndData(Blocks.AIR.getBlockData(), true);
}
return setTypeAndData(Blocks.AIR.getBlockData(), true) && result;
}
public Collection<ItemStack> getDrops() {
List<ItemStack> drops = new ArrayList<ItemStack>();
net.minecraft.server.Block block = this.getNMSBlock();
if (block != Blocks.AIR) {
IBlockData data = getData0();
// based on nms.Block.dropNaturally
int count = block.getDropCount(data, 0, world.getMinecraftWorld(), position, world.getMinecraftWorld().random);
for (int i = 0; i < count; ++i) {
Item item = block.getDropType(data, world.getMinecraftWorld(), position, 0).getItem();
if (item != Items.AIR) {
// Skulls are special, their data is based on the tile entity
if (block instanceof BlockSkullAbstract) {
net.minecraft.server.ItemStack nmsStack = block.a((IBlockAccess) world, position, data);
TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(position);
if ((block == Blocks.PLAYER_HEAD || block == Blocks.PLAYER_WALL_HEAD) && tileentityskull.getGameProfile() != null) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
nmsStack.getOrCreateTag().set("SkullOwner", nbttagcompound);
}
drops.add(CraftItemStack.asBukkitCopy(nmsStack));
// We don't want to drop cocoa blocks, we want to drop cocoa beans.
} else if (Blocks.COCOA == block) {
int age = (Integer) data.get(BlockCocoa.AGE);
int dropAmount = (age >= 2 ? 3 : 1);
for (int j = 0; j < dropAmount; ++j) {
drops.add(new ItemStack(Material.COCOA_BEANS, 1));
}
} else {
drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1));
}
}
}
}
return drops;
return getDrops(new ItemStack(Material.AIR));
}
public Collection<ItemStack> getDrops(ItemStack item) {
if (itemCausesDrops(item)) {
return getDrops();
} else {
return Collections.emptyList();
}
return net.minecraft.server.Block.getDrops(getNMS(), (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), null, CraftItemStack.asNMSCopy(item))
.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList());
}
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
@@ -628,25 +610,7 @@ public class CraftBlock implements Block {
Vec3D startPos = new Vec3D(start.getX(), start.getY(), start.getZ());
Vec3D endPos = new Vec3D(start.getX() + dir.getX(), start.getY() + dir.getY(), start.getZ() + dir.getZ());
// Similar to to nms.World#rayTrace:
IBlockData blockData = world.getType(position);
Fluid fluid = world.getFluid(position);
boolean collidableBlock = blockData.getBlock().isCollidable(blockData);
boolean collideWithFluid = CraftFluidCollisionMode.toNMS(fluidCollisionMode).predicate.test(fluid);
if (!collidableBlock && !collideWithFluid) {
return null;
}
MovingObjectPosition nmsHitResult = null;
if (collidableBlock) {
nmsHitResult = net.minecraft.server.Block.rayTrace(blockData, world.getMinecraftWorld(), position, startPos, endPos);
}
if (nmsHitResult == null && collideWithFluid) {
nmsHitResult = VoxelShapes.create(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid.getHeight(), 1.0D).rayTrace(startPos, endPos, position);
}
MovingObjectPosition nmsHitResult = world.rayTrace(new RayTrace(startPos, endPos, RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null));
return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult);
}

View File

@@ -34,41 +34,21 @@ public class CraftBrewingStand extends CraftContainer<TileEntityBrewingStand> im
@Override
public int getBrewingTime() {
return this.getSnapshot().getProperty(0);
return this.getSnapshot().brewTime;
}
@Override
public void setBrewingTime(int brewTime) {
this.getSnapshot().setProperty(0, brewTime);
this.getSnapshot().brewTime = brewTime;
}
@Override
public int getFuelLevel() {
return this.getSnapshot().getProperty(1);
return this.getSnapshot().fuelLevel;
}
@Override
public void setFuelLevel(int level) {
this.getSnapshot().setProperty(1, level);
}
@Override
public String getCustomName() {
TileEntityBrewingStand brewingStand = this.getSnapshot();
return brewingStand.hasCustomName() ? CraftChatMessage.fromComponent(brewingStand.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override
public void applyTo(TileEntityBrewingStand brewingStand) {
super.applyTo(brewingStand);
if (!this.getSnapshot().hasCustomName()) {
brewingStand.setCustomName(null);
}
this.getSnapshot().fuelLevel = level;
}
}

View File

@@ -0,0 +1,55 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityCampfire;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Campfire;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class CraftCampfire extends CraftBlockEntityState<TileEntityCampfire> implements Campfire {
public CraftCampfire(Block block) {
super(block, TileEntityCampfire.class);
}
public CraftCampfire(Material material, TileEntityCampfire te) {
super(material, te);
}
@Override
public int getSize() {
return getSnapshot().getItems().size();
}
@Override
public ItemStack getItem(int index) {
net.minecraft.server.ItemStack item = getSnapshot().getItems().get(index);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
@Override
public void setItem(int index, ItemStack item) {
getSnapshot().getItems().set(index, CraftItemStack.asNMSCopy(item));
}
@Override
public int getCookTime(int index) {
return getSnapshot().cookingTimes[index];
}
@Override
public void setCookTime(int index, int cookTime) {
getSnapshot().cookingTimes[index] = cookTime;
}
@Override
public int getCookTimeTotal(int index) {
return getSnapshot().cookingTotalTimes[index];
}
@Override
public void setCookTimeTotal(int index, int cookTimeTotal) {
getSnapshot().cookingTotalTimes[index] = cookTimeTotal;
}
}

View File

@@ -49,7 +49,7 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
CraftWorld world = (CraftWorld) this.getWorld();
BlockChest blockChest = (BlockChest) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST);
ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition(), true);
ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition());
if (nms instanceof InventoryLargeChest) {
inventory = new CraftInventoryDoubleChest((InventoryLargeChest) nms);

View File

@@ -5,6 +5,7 @@ import net.minecraft.server.TileEntityContainer;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Container;
import org.bukkit.craftbukkit.util.CraftChatMessage;
public abstract class CraftContainer<T extends TileEntityContainer> extends CraftBlockEntityState<T> implements Container {
@@ -18,16 +19,36 @@ public abstract class CraftContainer<T extends TileEntityContainer> extends Craf
@Override
public boolean isLocked() {
return this.getSnapshot().isLocked();
return !this.getSnapshot().chestLock.key.isEmpty();
}
@Override
public String getLock() {
return this.getSnapshot().getLock().getKey();
return this.getSnapshot().chestLock.key;
}
@Override
public void setLock(String key) {
this.getSnapshot().setLock(key == null ? ChestLock.a : new ChestLock(key));
this.getSnapshot().chestLock = (key == null) ? ChestLock.a : new ChestLock(key);
}
@Override
public String getCustomName() {
T container = this.getSnapshot();
return container.customName != null ? CraftChatMessage.fromComponent(container.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override
public void applyTo(T container) {
super.applyTo(container);
if (this.getSnapshot().customName == null) {
container.setCustomName(null);
}
}
}

View File

@@ -32,7 +32,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
throw new IllegalArgumentException("Can't spawn EntityType " + entityType + " from mobspawners!");
}
this.getSnapshot().getSpawner().setMobName(EntityTypes.a(entityType.getName()));
this.getSnapshot().getSpawner().setMobName(EntityTypes.a(entityType.getName()).get());
}
@Override

View File

@@ -6,16 +6,15 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Furnace;
import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.inventory.FurnaceInventory;
public class CraftFurnace extends CraftContainer<TileEntityFurnace> implements Furnace {
public class CraftFurnace<T extends TileEntityFurnace> extends CraftContainer<T> implements Furnace {
public CraftFurnace(final Block block) {
super(block, TileEntityFurnace.class);
public CraftFurnace(Block block, Class<T> tileEntityClass) {
super(block, tileEntityClass);
}
public CraftFurnace(final Material material, final TileEntityFurnace te) {
public CraftFurnace(final Material material, final T te) {
super(material, te);
}
@@ -35,53 +34,33 @@ public class CraftFurnace extends CraftContainer<TileEntityFurnace> implements F
@Override
public short getBurnTime() {
return (short) this.getSnapshot().getProperty(0);
return (short) this.getSnapshot().burnTime;
}
@Override
public void setBurnTime(short burnTime) {
this.getSnapshot().setProperty(0, burnTime);
this.getSnapshot().burnTime = burnTime;
// SPIGOT-844: Allow lighting and relighting using this API
this.data = this.data.set(BlockFurnace.LIT, burnTime > 0);
}
@Override
public short getCookTime() {
return (short) this.getSnapshot().getProperty(2);
return (short) this.getSnapshot().cookTime;
}
@Override
public void setCookTime(short cookTime) {
this.getSnapshot().setProperty(2, cookTime);
this.getSnapshot().cookTime = cookTime;
}
@Override
public int getCookTimeTotal() {
return this.getSnapshot().getProperty(3);
return this.getSnapshot().cookTimeTotal;
}
@Override
public void setCookTimeTotal(int cookTimeTotal) {
this.getSnapshot().setProperty(3, cookTimeTotal);
}
@Override
public String getCustomName() {
TileEntityFurnace furnace = this.getSnapshot();
return furnace.hasCustomName() ? CraftChatMessage.fromComponent(furnace.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override
public void applyTo(TileEntityFurnace furnace) {
super.applyTo(furnace);
if (!this.getSnapshot().hasCustomName()) {
furnace.setCustomName(null);
}
this.getSnapshot().cookTimeTotal = cookTimeTotal;
}
}

View File

@@ -0,0 +1,16 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityFurnaceFurnace;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class CraftFurnaceFurnace extends CraftFurnace {
public CraftFurnaceFurnace(Block block) {
super(block, TileEntityFurnaceFurnace.class);
}
public CraftFurnaceFurnace(Material material, TileEntityFurnaceFurnace te) {
super(material, te);
}
}

View File

@@ -0,0 +1,17 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityJigsaw;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Jigsaw;
public class CraftJigsaw extends CraftBlockEntityState<TileEntityJigsaw> implements Jigsaw {
public CraftJigsaw(Block block) {
super(block, TileEntityJigsaw.class);
}
public CraftJigsaw(Material material, TileEntityJigsaw te) {
super(material, te);
}
}

View File

@@ -0,0 +1,43 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityLectern;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Lectern;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> implements Lectern {
public CraftLectern(Block block) {
super(block, TileEntityLectern.class);
}
public CraftLectern(Material material, TileEntityLectern te) {
super(material, te);
}
@Override
public int getPage() {
return getSnapshot().getPage();
}
@Override
public void setPage(int page) {
getSnapshot().setPage(page);
}
@Override
public Inventory getSnapshotInventory() {
return new CraftInventory(this.getSnapshot().inventory);
}
@Override
public Inventory getInventory() {
if (!this.isPlaced()) {
return this.getSnapshotInventory();
}
return new CraftInventory(this.getTileEntity().inventory);
}
}

View File

@@ -6,7 +6,6 @@ import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Nameable;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.loot.LootTable;
import org.bukkit.loot.Lootable;
@@ -21,36 +20,22 @@ public abstract class CraftLootable<T extends TileEntityLootable> extends CraftC
super(material, tileEntity);
}
@Override
public String getCustomName() {
T lootable = this.getSnapshot();
return lootable.hasCustomName() ? CraftChatMessage.fromComponent(lootable.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override
public void applyTo(T lootable) {
super.applyTo(lootable);
if (!this.getSnapshot().hasCustomName()) {
lootable.setCustomName(null);
}
if (this.getSnapshot().getLootTable() == null) {
if (this.getSnapshot().lootTable == null) {
lootable.setLootTable((MinecraftKey) null, 0L);
}
}
@Override
public LootTable getLootTable() {
if (getSnapshot().getLootTable() == null) {
if (getSnapshot().lootTable == null) {
return null;
}
MinecraftKey key = getSnapshot().getLootTable();
MinecraftKey key = getSnapshot().lootTable;
return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
}
@@ -61,7 +46,7 @@ public abstract class CraftLootable<T extends TileEntityLootable> extends CraftC
@Override
public long getSeed() {
return getSnapshotNBT().getLong("LootTableSeed"); // returns OL if an error occurred
return getSnapshot().lootTableSeed;
}
@Override

View File

@@ -34,7 +34,7 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
public void load(TileEntitySkull skull) {
super.load(skull);
profile = skull.getGameProfile();
profile = skull.gameProfile;
}
static int getSkullType(SkullType type) {

View File

@@ -0,0 +1,17 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntitySmoker;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Smoker;
public class CraftSmoker extends CraftFurnace implements Smoker {
public CraftSmoker(Block block) {
super(block, TileEntitySmoker.class);
}
public CraftSmoker(Material material, TileEntitySmoker te) {
super(material, te);
}
}

View File

@@ -275,6 +275,10 @@ public class CraftBlockData implements BlockData {
return stateString.toString();
}
public String toStates() {
return ((BlockDataAbstract) state).getStateMap().entrySet().stream().map(BlockDataAbstract.STATE_TO_VALUE).collect(Collectors.joining(",")).toString();
}
@Override
public boolean equals(Object obj) {
return obj instanceof CraftBlockData && state.equals(((CraftBlockData) obj).state);
@@ -331,7 +335,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>) IRegistry.BLOCK) { // Eclipse fail
for (Block instance : IRegistry.BLOCK) {
if (instance.getClass() == block) {
if (state == null) {
state = instance.getStates().a(name);
@@ -374,14 +378,19 @@ public class CraftBlockData implements BlockData {
static {
//<editor-fold desc="CraftBlockData Registration" defaultstate="collapsed">
register(net.minecraft.server.BlockAnvil.class, org.bukkit.craftbukkit.block.impl.CraftAnvil::new);
register(net.minecraft.server.BlockBamboo.class, org.bukkit.craftbukkit.block.impl.CraftBamboo::new);
register(net.minecraft.server.BlockBanner.class, org.bukkit.craftbukkit.block.impl.CraftBanner::new);
register(net.minecraft.server.BlockBannerWall.class, org.bukkit.craftbukkit.block.impl.CraftBannerWall::new);
register(net.minecraft.server.BlockBarrel.class, org.bukkit.craftbukkit.block.impl.CraftBarrel::new);
register(net.minecraft.server.BlockBed.class, org.bukkit.craftbukkit.block.impl.CraftBed::new);
register(net.minecraft.server.BlockBeetroot.class, org.bukkit.craftbukkit.block.impl.CraftBeetroot::new);
register(net.minecraft.server.BlockBell.class, org.bukkit.craftbukkit.block.impl.CraftBell::new);
register(net.minecraft.server.BlockBlastFurnace.class, org.bukkit.craftbukkit.block.impl.CraftBlastFurnace::new);
register(net.minecraft.server.BlockBrewingStand.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand::new);
register(net.minecraft.server.BlockBubbleColumn.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn::new);
register(net.minecraft.server.BlockCactus.class, org.bukkit.craftbukkit.block.impl.CraftCactus::new);
register(net.minecraft.server.BlockCake.class, org.bukkit.craftbukkit.block.impl.CraftCake::new);
register(net.minecraft.server.BlockCampfire.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new);
register(net.minecraft.server.BlockCarrots.class, org.bukkit.craftbukkit.block.impl.CraftCarrots::new);
register(net.minecraft.server.BlockCauldron.class, org.bukkit.craftbukkit.block.impl.CraftCauldron::new);
register(net.minecraft.server.BlockChest.class, org.bukkit.craftbukkit.block.impl.CraftChest::new);
@@ -391,6 +400,7 @@ 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.BlockComposter.class, org.bukkit.craftbukkit.block.impl.CraftComposter::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);
@@ -412,21 +422,25 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.server.BlockFire.class, org.bukkit.craftbukkit.block.impl.CraftFire::new);
register(net.minecraft.server.BlockFloorSign.class, org.bukkit.craftbukkit.block.impl.CraftFloorSign::new);
register(net.minecraft.server.BlockFluids.class, org.bukkit.craftbukkit.block.impl.CraftFluids::new);
register(net.minecraft.server.BlockFurnace.class, org.bukkit.craftbukkit.block.impl.CraftFurnace::new);
register(net.minecraft.server.BlockGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftGlassPane::new);
register(net.minecraft.server.BlockFurnaceFurace.class, org.bukkit.craftbukkit.block.impl.CraftFurnaceFurace::new);
register(net.minecraft.server.BlockGlazedTerracotta.class, org.bukkit.craftbukkit.block.impl.CraftGlazedTerracotta::new);
register(net.minecraft.server.BlockGrass.class, org.bukkit.craftbukkit.block.impl.CraftGrass::new);
register(net.minecraft.server.BlockGrindstone.class, org.bukkit.craftbukkit.block.impl.CraftGrindstone::new);
register(net.minecraft.server.BlockHay.class, org.bukkit.craftbukkit.block.impl.CraftHay::new);
register(net.minecraft.server.BlockHopper.class, org.bukkit.craftbukkit.block.impl.CraftHopper::new);
register(net.minecraft.server.BlockHugeMushroom.class, org.bukkit.craftbukkit.block.impl.CraftHugeMushroom::new);
register(net.minecraft.server.BlockIceFrost.class, org.bukkit.craftbukkit.block.impl.CraftIceFrost::new);
register(net.minecraft.server.BlockIronBars.class, org.bukkit.craftbukkit.block.impl.CraftIronBars::new);
register(net.minecraft.server.BlockJigsaw.class, org.bukkit.craftbukkit.block.impl.CraftJigsaw::new);
register(net.minecraft.server.BlockJukeBox.class, org.bukkit.craftbukkit.block.impl.CraftJukeBox::new);
register(net.minecraft.server.BlockKelp.class, org.bukkit.craftbukkit.block.impl.CraftKelp::new);
register(net.minecraft.server.BlockLadder.class, org.bukkit.craftbukkit.block.impl.CraftLadder::new);
register(net.minecraft.server.BlockLantern.class, org.bukkit.craftbukkit.block.impl.CraftLantern::new);
register(net.minecraft.server.BlockLeaves.class, org.bukkit.craftbukkit.block.impl.CraftLeaves::new);
register(net.minecraft.server.BlockLectern.class, org.bukkit.craftbukkit.block.impl.CraftLectern::new);
register(net.minecraft.server.BlockLever.class, org.bukkit.craftbukkit.block.impl.CraftLever::new);
register(net.minecraft.server.BlockLogAbstract.class, org.bukkit.craftbukkit.block.impl.CraftLogAbstract::new);
register(net.minecraft.server.BlockLoom.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new);
register(net.minecraft.server.BlockMinecartDetector.class, org.bukkit.craftbukkit.block.impl.CraftMinecartDetector::new);
register(net.minecraft.server.BlockMinecartTrack.class, org.bukkit.craftbukkit.block.impl.CraftMinecartTrack::new);
register(net.minecraft.server.BlockMycel.class, org.bukkit.craftbukkit.block.impl.CraftMycel::new);
@@ -452,12 +466,14 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.server.BlockRepeater.class, org.bukkit.craftbukkit.block.impl.CraftRepeater::new);
register(net.minecraft.server.BlockRotatable.class, org.bukkit.craftbukkit.block.impl.CraftRotatable::new);
register(net.minecraft.server.BlockSapling.class, org.bukkit.craftbukkit.block.impl.CraftSapling::new);
register(net.minecraft.server.BlockScaffolding.class, org.bukkit.craftbukkit.block.impl.CraftScaffolding::new);
register(net.minecraft.server.BlockSeaPickle.class, org.bukkit.craftbukkit.block.impl.CraftSeaPickle::new);
register(net.minecraft.server.BlockShulkerBox.class, org.bukkit.craftbukkit.block.impl.CraftShulkerBox::new);
register(net.minecraft.server.BlockSkull.class, org.bukkit.craftbukkit.block.impl.CraftSkull::new);
register(net.minecraft.server.BlockSkullPlayer.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayer::new);
register(net.minecraft.server.BlockSkullPlayerWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayerWall::new);
register(net.minecraft.server.BlockSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullWall::new);
register(net.minecraft.server.BlockSmoker.class, org.bukkit.craftbukkit.block.impl.CraftSmoker::new);
register(net.minecraft.server.BlockSnow.class, org.bukkit.craftbukkit.block.impl.CraftSnow::new);
register(net.minecraft.server.BlockSoil.class, org.bukkit.craftbukkit.block.impl.CraftSoil::new);
register(net.minecraft.server.BlockStainedGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftStainedGlassPane::new);
@@ -466,10 +482,12 @@ public class CraftBlockData implements BlockData {
register(net.minecraft.server.BlockStemAttached.class, org.bukkit.craftbukkit.block.impl.CraftStemAttached::new);
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.BlockStonecutter.class, org.bukkit.craftbukkit.block.impl.CraftStonecutter::new);
register(net.minecraft.server.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure::new);
register(net.minecraft.server.BlockSweetBerryBush.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new);
register(net.minecraft.server.BlockTNT.class, org.bukkit.craftbukkit.block.impl.CraftTNT::new);
register(net.minecraft.server.BlockTallPlant.class, org.bukkit.craftbukkit.block.impl.CraftTallPlant::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);
register(net.minecraft.server.BlockTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftTorchWall::new);
register(net.minecraft.server.BlockTrapdoor.class, org.bukkit.craftbukkit.block.impl.CraftTrapdoor::new);

View File

@@ -0,0 +1,19 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.Bamboo;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftBamboo extends CraftBlockData implements Bamboo {
private static final net.minecraft.server.BlockStateEnum<?> LEAVES = getEnum("leaves");
@Override
public Leaves getLeaves() {
return get(LEAVES, Leaves.class);
}
@Override
public void setLeaves(Leaves leaves) {
set(LEAVES, leaves);
}
}

View File

@@ -0,0 +1,19 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.Campfire;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftCampfire extends CraftBlockData implements Campfire {
private static final net.minecraft.server.BlockStateBoolean SIGNAL_FIRE = getBoolean("signal_fire");
@Override
public boolean isSignalFire() {
return get(SIGNAL_FIRE);
}
@Override
public void setSignalFire(boolean signalFire) {
set(SIGNAL_FIRE, signalFire);
}
}

View File

@@ -0,0 +1,19 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.Lantern;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftLantern extends CraftBlockData implements Lantern {
private static final net.minecraft.server.BlockStateBoolean HANGING = getBoolean("hanging");
@Override
public boolean isHanging() {
return get(HANGING);
}
@Override
public void setHanging(boolean hanging) {
set(HANGING, hanging);
}
}

View File

@@ -0,0 +1,14 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.Lectern;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftLectern extends CraftBlockData implements Lectern {
private static final net.minecraft.server.BlockStateBoolean HAS_BOOK = getBoolean("has_book");
@Override
public boolean hasBook() {
return get(HAS_BOOK);
}
}

View File

@@ -0,0 +1,35 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.Scaffolding;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftScaffolding extends CraftBlockData implements Scaffolding {
private static final net.minecraft.server.BlockStateBoolean BOTTOM = getBoolean("bottom");
private static final net.minecraft.server.BlockStateInteger DISTANCE = getInteger("distance");
@Override
public boolean isBottom() {
return get(BOTTOM);
}
@Override
public void setBottom(boolean bottom) {
set(BOTTOM, bottom);
}
@Override
public int getDistance() {
return get(DISTANCE);
}
@Override
public void setDistance(int distance) {
set(DISTANCE, distance);
}
@Override
public int getMaximumDistance() {
return getMax(DISTANCE);
}
}

View File

@@ -0,0 +1,67 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftBamboo extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Bamboo, org.bukkit.block.data.Ageable, org.bukkit.block.data.type.Sapling {
public CraftBamboo() {
super();
}
public CraftBamboo(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftBamboo
private static final net.minecraft.server.BlockStateEnum<?> LEAVES = getEnum(net.minecraft.server.BlockBamboo.class, "leaves");
@Override
public Leaves getLeaves() {
return get(LEAVES, Leaves.class);
}
@Override
public void setLeaves(Leaves leaves) {
set(LEAVES, leaves);
}
// org.bukkit.craftbukkit.block.data.CraftAgeable
private static final net.minecraft.server.BlockStateInteger AGE = getInteger(net.minecraft.server.BlockBamboo.class, "age");
@Override
public int getAge() {
return get(AGE);
}
@Override
public void setAge(int age) {
set(AGE, age);
}
@Override
public int getMaximumAge() {
return getMax(AGE);
}
// org.bukkit.craftbukkit.block.data.type.CraftSapling
private static final net.minecraft.server.BlockStateInteger STAGE = getInteger(net.minecraft.server.BlockBamboo.class, "stage");
@Override
public int getStage() {
return get(STAGE);
}
@Override
public void setStage(int stage) {
set(STAGE, stage);
}
@Override
public int getMaximumStage() {
return getMax(STAGE);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftBarrel extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional {
public CraftBarrel() {
super();
}
public CraftBarrel(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockBarrel.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftBell extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Bell, org.bukkit.block.data.Directional {
public CraftBell() {
super();
}
public CraftBell(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockBell.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,48 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftBlastFurnace extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Furnace, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable {
public CraftBlastFurnace() {
super();
}
public CraftBlastFurnace(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockBlastFurnace.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
// org.bukkit.craftbukkit.block.data.CraftLightable
private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockBlastFurnace.class, "lit");
@Override
public boolean isLit() {
return get(LIT);
}
@Override
public void setLit(boolean lit) {
set(LIT, lit);
}
}

View File

@@ -0,0 +1,57 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftCampfire extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Campfire, org.bukkit.block.data.Lightable, org.bukkit.block.data.Waterlogged {
public CraftCampfire() {
super();
}
public CraftCampfire(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftCampfire
private static final net.minecraft.server.BlockStateBoolean SIGNAL_FIRE = getBoolean(net.minecraft.server.BlockCampfire.class, "signal_fire");
@Override
public boolean isSignalFire() {
return get(SIGNAL_FIRE);
}
@Override
public void setSignalFire(boolean signalFire) {
set(SIGNAL_FIRE, signalFire);
}
// org.bukkit.craftbukkit.block.data.CraftLightable
private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockCampfire.class, "lit");
@Override
public boolean isLit() {
return get(LIT);
}
@Override
public void setLit(boolean lit) {
set(LIT, lit);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockCampfire.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftComposter extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Levelled {
public CraftComposter() {
super();
}
public CraftComposter(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftLevelled
private static final net.minecraft.server.BlockStateInteger LEVEL = getInteger(net.minecraft.server.BlockComposter.class, "level");
@Override
public int getLevel() {
return get(LEVEL);
}
@Override
public void setLevel(int level) {
set(LEVEL, level);
}
@Override
public int getMaximumLevel() {
return getMax(LEVEL);
}
}

View File

@@ -0,0 +1,48 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftFurnaceFurace extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Furnace, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable {
public CraftFurnaceFurace() {
super();
}
public CraftFurnaceFurace(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockFurnaceFurace.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
// org.bukkit.craftbukkit.block.data.CraftLightable
private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockFurnaceFurace.class, "lit");
@Override
public boolean isLit() {
return get(LIT);
}
@Override
public void setLit(boolean lit) {
set(LIT, lit);
}
}

View File

@@ -1,71 +0,0 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftGlassPane extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.GlassPane, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Waterlogged {
public CraftGlassPane() {
super();
}
public CraftGlassPane(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftMultipleFacing
private static final net.minecraft.server.BlockStateBoolean[] FACES = new net.minecraft.server.BlockStateBoolean[]{
getBoolean(net.minecraft.server.BlockGlassPane.class, "north", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "east", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "south", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "west", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "up", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "down", true)
};
@Override
public boolean hasFace(org.bukkit.block.BlockFace face) {
return get(FACES[face.ordinal()]);
}
@Override
public void setFace(org.bukkit.block.BlockFace face, boolean has) {
set(FACES[face.ordinal()], has);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
com.google.common.collect.ImmutableSet.Builder<org.bukkit.block.BlockFace> faces = com.google.common.collect.ImmutableSet.builder();
for (int i = 0; i < FACES.length; i++) {
if (FACES[i] != null && get(FACES[i])) {
faces.add(org.bukkit.block.BlockFace.values()[i]);
}
}
return faces.build();
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getAllowedFaces() {
com.google.common.collect.ImmutableSet.Builder<org.bukkit.block.BlockFace> faces = com.google.common.collect.ImmutableSet.builder();
for (int i = 0; i < FACES.length; i++) {
if (FACES[i] != null) {
faces.add(org.bukkit.block.BlockFace.values()[i]);
}
}
return faces.build();
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockGlassPane.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftGrindstone extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional {
public CraftGrindstone() {
super();
}
public CraftGrindstone(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockGrindstone.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftJigsaw extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional {
public CraftJigsaw() {
super();
}
public CraftJigsaw(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockJigsaw.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,29 @@
/**
* Automatically generated file, changes will be lost.
*/
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 CraftLantern() {
super();
}
public CraftLantern(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftLantern
private static final net.minecraft.server.BlockStateBoolean HANGING = getBoolean(net.minecraft.server.BlockLantern.class, "hanging");
@Override
public boolean isHanging() {
return get(HANGING);
}
@Override
public void setHanging(boolean hanging) {
set(HANGING, hanging);
}
}

View File

@@ -0,0 +1,57 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftLectern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lectern, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable {
public CraftLectern() {
super();
}
public CraftLectern(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftLectern
private static final net.minecraft.server.BlockStateBoolean HAS_BOOK = getBoolean(net.minecraft.server.BlockLectern.class, "has_book");
@Override
public boolean hasBook() {
return get(HAS_BOOK);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockLectern.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
// org.bukkit.craftbukkit.block.data.CraftPowerable
private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockLectern.class, "powered");
@Override
public boolean isPowered() {
return get(POWERED);
}
@Override
public void setPowered(boolean powered) {
set(POWERED, powered);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftLoom extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional {
public CraftLoom() {
super();
}
public CraftLoom(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockLoom.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,59 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftScaffolding extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Scaffolding, org.bukkit.block.data.Waterlogged {
public CraftScaffolding() {
super();
}
public CraftScaffolding(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftScaffolding
private static final net.minecraft.server.BlockStateBoolean BOTTOM = getBoolean(net.minecraft.server.BlockScaffolding.class, "bottom");
private static final net.minecraft.server.BlockStateInteger DISTANCE = getInteger(net.minecraft.server.BlockScaffolding.class, "distance");
@Override
public boolean isBottom() {
return get(BOTTOM);
}
@Override
public void setBottom(boolean bottom) {
set(BOTTOM, bottom);
}
@Override
public int getDistance() {
return get(DISTANCE);
}
@Override
public void setDistance(int distance) {
set(DISTANCE, distance);
}
@Override
public int getMaximumDistance() {
return getMax(DISTANCE);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockScaffolding.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

@@ -3,19 +3,19 @@
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftFurnace extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Furnace, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable {
public final class CraftSmoker extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Furnace, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable {
public CraftFurnace() {
public CraftSmoker() {
super();
}
public CraftFurnace(net.minecraft.server.IBlockData state) {
public CraftSmoker(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockFurnace.class, "facing");
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockSmoker.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
@@ -34,7 +34,7 @@ public final class CraftFurnace extends org.bukkit.craftbukkit.block.data.CraftB
// org.bukkit.craftbukkit.block.data.CraftLightable
private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockFurnace.class, "lit");
private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockSmoker.class, "lit");
@Override
public boolean isLit() {

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftStonecutter extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional {
public CraftStonecutter() {
super();
}
public CraftStonecutter(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockStonecutter.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftSweetBerryBush extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable {
public CraftSweetBerryBush() {
super();
}
public CraftSweetBerryBush(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftAgeable
private static final net.minecraft.server.BlockStateInteger AGE = getInteger(net.minecraft.server.BlockSweetBerryBush.class, "age");
@Override
public int getAge() {
return get(AGE);
}
@Override
public void setAge(int age) {
set(AGE, age);
}
@Override
public int getMaximumAge() {
return getMax(AGE);
}
}

View File

@@ -3,19 +3,19 @@
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftTallPlantShearable extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected {
public final class CraftTallPlant extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected {
public CraftTallPlantShearable() {
public CraftTallPlant() {
super();
}
public CraftTallPlantShearable(net.minecraft.server.IBlockData state) {
public CraftTallPlant(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftBisected
private static final net.minecraft.server.BlockStateEnum<?> HALF = getEnum(net.minecraft.server.BlockTallPlantShearable.class, "half");
private static final net.minecraft.server.BlockStateEnum<?> HALF = getEnum(net.minecraft.server.BlockTallPlant.class, "half");
@Override
public Half getHalf() {

View File

@@ -1,36 +0,0 @@
package org.bukkit.craftbukkit.chunkio;
import net.minecraft.server.Chunk;
import net.minecraft.server.ChunkProviderServer;
import net.minecraft.server.ChunkRegionLoader;
import net.minecraft.server.World;
import org.bukkit.craftbukkit.util.AsynchronousExecutor;
public class ChunkIOExecutor {
static final int BASE_THREADS = 1;
static final int PLAYERS_PER_THREAD = 50;
private static final AsynchronousExecutor<QueuedChunk, Chunk, Runnable, RuntimeException> instance = new AsynchronousExecutor<QueuedChunk, Chunk, Runnable, RuntimeException>(new ChunkIOProvider(), BASE_THREADS);
public static Chunk syncChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z) {
return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider));
}
public static void queueChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z, Runnable runnable) {
instance.add(new QueuedChunk(x, z, loader, world, provider), runnable);
}
// Abuses the fact that hashCode and equals for QueuedChunk only use world and coords
public static void dropQueuedChunkLoad(World world, int x, int z, Runnable runnable) {
instance.drop(new QueuedChunk(x, z, null, world, null), runnable);
}
public static void adjustPoolSize(int players) {
int size = Math.max(BASE_THREADS, (int) Math.ceil(players / PLAYERS_PER_THREAD));
instance.setActiveThreads(size);
}
public static void tick() {
instance.finishActive();
}
}

View File

@@ -1,57 +0,0 @@
package org.bukkit.craftbukkit.chunkio;
import java.io.IOException;
import net.minecraft.server.Chunk;
import net.minecraft.server.ChunkCoordIntPair;
import net.minecraft.server.ChunkRegionLoader;
import net.minecraft.server.NBTTagCompound;
import org.bukkit.Server;
import org.bukkit.craftbukkit.util.AsynchronousExecutor;
import java.util.concurrent.atomic.AtomicInteger;
class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChunk, Chunk, Runnable, RuntimeException> {
private final AtomicInteger threadNumber = new AtomicInteger(1);
// async stuff
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
try {
ChunkRegionLoader loader = queuedChunk.loader;
Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z, (chunk) -> {});
if (data != null) {
queuedChunk.compound = (NBTTagCompound) data[1];
return (Chunk) data[0];
}
return null;
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
// sync stuff
public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException {
if (chunk == null) {
// If the chunk loading failed just do it synchronously (may generate)
// queuedChunk.provider.originalGetChunkAt(queuedChunk.x, queuedChunk.z);
return;
}
queuedChunk.loader.loadEntities(queuedChunk.compound.getCompound("Level"), chunk);
chunk.setLastSaved(queuedChunk.provider.world.getTime());
queuedChunk.provider.chunks.put(ChunkCoordIntPair.a(queuedChunk.x, queuedChunk.z), chunk);
chunk.addEntities();
}
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
runnable.run();
}
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, "Chunk I/O Executor Thread-" + threadNumber.getAndIncrement());
thread.setDaemon(true);
return thread;
}
}

View File

@@ -1,38 +0,0 @@
package org.bukkit.craftbukkit.chunkio;
import net.minecraft.server.ChunkProviderServer;
import net.minecraft.server.ChunkRegionLoader;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.World;
class QueuedChunk {
final int x;
final int z;
final ChunkRegionLoader loader;
final World world;
final ChunkProviderServer provider;
NBTTagCompound compound;
public QueuedChunk(int x, int z, ChunkRegionLoader loader, World world, ChunkProviderServer provider) {
this.x = x;
this.z = z;
this.loader = loader;
this.world = world;
this.provider = provider;
}
@Override
public int hashCode() {
return (x * 31 + z * 29) ^ world.hashCode();
}
@Override
public boolean equals(Object object) {
if (object instanceof QueuedChunk) {
QueuedChunk other = (QueuedChunk) object;
return x == other.x && z == other.z && world == other.world;
}
return false;
}
}

View File

@@ -57,6 +57,8 @@ public class CraftEnchantment extends Enchantment {
return EnchantmentTarget.WEARABLE;
case TRIDENT:
return EnchantmentTarget.TRIDENT;
case CROSSBOW:
return EnchantmentTarget.CROSSBOW;
default:
return null;
}
@@ -146,11 +148,17 @@ public class CraftEnchantment extends Enchantment {
case 31:
return "CHANNELING";
case 32:
return "MENDING";
return "MULTSHOT";
case 33:
return "QUICK_CHARGE";
case 34:
return "PIERCING";
case 35:
return "MENDING";
case 36:
return "VANISHING_CURSE";
default:
return "UNKNOWN_ENCHANT_" + getName();
return "UNKNOWN_ENCHANT_" + IRegistry.ENCHANTMENT.a(target);
}
}

View File

@@ -0,0 +1,76 @@
package org.bukkit.craftbukkit.entity;
import java.util.List;
import net.minecraft.server.EntityVillager;
import net.minecraft.server.EntityVillagerAbstract;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.craftbukkit.inventory.CraftMerchant;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.entity.AbstractVillager;
public class CraftAbstractVillager extends CraftAgeable implements AbstractVillager, InventoryHolder {
private CraftMerchant merchant;
public CraftAbstractVillager(CraftServer server, EntityVillagerAbstract entity) {
super(server, entity);
}
@Override
public EntityVillagerAbstract getHandle() {
return (EntityVillager) entity;
}
@Override
public String toString() {
return "CraftAbstractVillager";
}
@Override
public Inventory getInventory() {
return new CraftInventory(getHandle().getInventory());
}
private CraftMerchant getMerchant() {
return (merchant == null) ? merchant = new CraftMerchant(getHandle()) : merchant;
}
@Override
public List<MerchantRecipe> getRecipes() {
return getMerchant().getRecipes();
}
@Override
public void setRecipes(List<MerchantRecipe> recipes) {
this.getMerchant().setRecipes(recipes);
}
@Override
public MerchantRecipe getRecipe(int i) {
return getMerchant().getRecipe(i);
}
@Override
public void setRecipe(int i, MerchantRecipe merchantRecipe) {
getMerchant().setRecipe(i, merchantRecipe);
}
@Override
public int getRecipeCount() {
return getMerchant().getRecipeCount();
}
@Override
public boolean isTrading() {
return getTrader() != null;
}
@Override
public HumanEntity getTrader() {
return getMerchant().getTrader();
}
}

View File

@@ -40,11 +40,11 @@ public class CraftAnimals extends CraftAgeable implements Animals {
@Override
public void setLoveModeTicks(int ticks) {
Preconditions.checkArgument(ticks >= 0, "Love mode ticks must be positive or 0");
getHandle().d(ticks); // PAIL rename setLoveModeTicks
getHandle().setLoveTicks(ticks);
}
@Override
public int getLoveModeTicks() {
return getHandle().bC; // PAIL rename loveTicks
return getHandle().loveTicks;
}
}

View File

@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.EntityArrow;
import org.apache.commons.lang.Validate;
@@ -69,8 +70,8 @@ public class CraftArrow extends AbstractProjectile implements Arrow {
return null;
}
EntityArrow handle = getHandle();
return getWorld().getBlockAt(handle.tileX, handle.tileY, handle.tileZ);
BlockPosition pos = getHandle().getChunkCoordinates();
return getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
}
@Override
@@ -103,6 +104,6 @@ public class CraftArrow extends AbstractProjectile implements Arrow {
}
public EntityType getType() {
return EntityType.ARROW;
return EntityType.UNKNOWN;
}
}

View File

@@ -0,0 +1,41 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.EntityCat;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Cat;
import org.bukkit.entity.EntityType;
public class CraftCat extends CraftTameableAnimal implements Cat {
public CraftCat(CraftServer server, EntityCat entity) {
super(server, entity);
}
@Override
public EntityCat getHandle() {
return (EntityCat) super.getHandle();
}
@Override
public EntityType getType() {
return EntityType.CAT;
}
@Override
public String toString() {
return "CraftCat";
}
@Override
public Type getCatType() {
return Type.values()[getHandle().getCatType()];
}
@Override
public void setCatType(Type type) {
Preconditions.checkArgument(type != null, "Cannot have null Type");
getHandle().setCatType(type.ordinal());
}
}

View File

@@ -43,6 +43,6 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart {
}
public EntityType getType() {
return EntityType.COMPLEX_PART;
return EntityType.UNKNOWN;
}
}

View File

@@ -19,6 +19,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.craftbukkit.util.CraftVector;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.metadata.MetadataValue;
@@ -78,7 +79,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof EntityPig) { return new CraftPig(server, (EntityPig) entity); }
else if (entity instanceof EntityTameableAnimal) {
if (entity instanceof EntityWolf) { return new CraftWolf(server, (EntityWolf) entity); }
else if (entity instanceof EntityOcelot) { return new CraftOcelot(server, (EntityOcelot) entity); }
else if (entity instanceof EntityCat) { return new CraftCat(server, (EntityCat) entity); }
else if (entity instanceof EntityParrot) { return new CraftParrot(server, (EntityParrot) entity); }
}
else if (entity instanceof EntitySheep) { return new CraftSheep(server, (EntitySheep) entity); }
@@ -86,6 +87,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
if (entity instanceof EntityHorseChestedAbstract){
if (entity instanceof EntityHorseDonkey) { return new CraftDonkey(server, (EntityHorseDonkey) entity); }
else if (entity instanceof EntityHorseMule) { return new CraftMule(server, (EntityHorseMule) entity); }
else if (entity instanceof EntityLLamaTrader) { return new CraftTraderLlama(server, (EntityLLamaTrader) entity); }
else if (entity instanceof EntityLlama) { return new CraftLlama(server, (EntityLlama) entity); }
} else if (entity instanceof EntityHorse) { return new CraftHorse(server, (EntityHorse) entity); }
else if (entity instanceof EntityHorseSkeleton) { return new CraftSkeletonHorse(server, (EntityHorseSkeleton) entity); }
@@ -94,6 +96,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof EntityRabbit) { return new CraftRabbit(server, (EntityRabbit) entity); }
else if (entity instanceof EntityPolarBear) { return new CraftPolarBear(server, (EntityPolarBear) entity); }
else if (entity instanceof EntityTurtle) { return new CraftTurtle(server, (EntityTurtle) entity); }
else if (entity instanceof EntityOcelot) { return new CraftOcelot(server, (EntityOcelot) entity); }
else if (entity instanceof EntityPanda) { return new CraftPanda(server, (EntityPanda) entity); }
else if (entity instanceof EntityFox) { return new CraftFox(server, (EntityFox) entity); }
else { return new CraftAnimals(server, (EntityAnimal) entity); }
}
// Monsters
@@ -134,8 +139,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else { return new CraftSpellcaster(server, (EntityIllagerWizard) entity); }
}
else if (entity instanceof EntityVindicator) { return new CraftVindicator(server, (EntityVindicator) entity); }
else if (entity instanceof EntityPillager) { return new CraftPillager(server, (EntityPillager) entity); }
else { return new CraftIllager(server, (EntityIllagerAbstract) entity); }
}
else if (entity instanceof EntityRavager) { return new CraftRavager(server, (EntityRavager) entity); }
else { return new CraftMonster(server, (EntityMonster) entity); }
}
@@ -144,7 +151,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof EntityIronGolem) { return new CraftIronGolem(server, (EntityIronGolem) entity); }
else if (entity instanceof EntityShulker) { return new CraftShulker(server, (EntityShulker) entity); }
}
else if (entity instanceof EntityVillager) { return new CraftVillager(server, (EntityVillager) entity); }
else if (entity instanceof EntityVillagerAbstract) {
if (entity instanceof EntityVillager) { return new CraftVillager(server, (EntityVillager) entity); }
else if (entity instanceof EntityVillagerTrader) { return new CraftWanderingTrader(server, (EntityVillagerTrader) entity); }
else { return new CraftAbstractVillager(server, (EntityVillagerAbstract) entity); }
}
else { return new CraftCreature(server, (EntityCreature) entity); }
}
// Slimes are a special (and broken) case
@@ -175,10 +186,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else { return new CraftComplexPart(server, (EntityComplexPart) entity); }
}
else if (entity instanceof EntityExperienceOrb) { return new CraftExperienceOrb(server, (EntityExperienceOrb) entity); }
else if (entity instanceof EntityTippedArrow) {
if (((EntityTippedArrow) entity).isTipped()) { return new CraftTippedArrow(server, (EntityTippedArrow) entity); }
else { return new CraftArrow(server, (EntityArrow) entity); }
}
else if (entity instanceof EntityTippedArrow) { return new CraftTippedArrow(server, (EntityTippedArrow) entity); }
else if (entity instanceof EntitySpectralArrow) { return new CraftSpectralArrow(server, (EntitySpectralArrow) entity); }
else if (entity instanceof EntityArrow) {
if (entity instanceof EntityThrownTrident) { return new CraftTrident(server, (EntityThrownTrident) entity); }
@@ -188,10 +196,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof EntityProjectile) {
if (entity instanceof EntityEgg) { return new CraftEgg(server, (EntityEgg) entity); }
else if (entity instanceof EntitySnowball) { return new CraftSnowball(server, (EntitySnowball) entity); }
else if (entity instanceof EntityPotion) {
if (!((EntityPotion) entity).isLingering()) { return new CraftSplashPotion(server, (EntityPotion) entity); }
else { return new CraftLingeringPotion(server, (EntityPotion) entity); }
}
else if (entity instanceof EntityPotion) { return new CraftThrownPotion(server, (EntityPotion) entity); }
else if (entity instanceof EntityEnderPearl) { return new CraftEnderPearl(server, (EntityEnderPearl) entity); }
else if (entity instanceof EntityThrownExpBottle) { return new CraftThrownExpBottle(server, (EntityThrownExpBottle) entity); }
}
@@ -207,10 +212,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof EntityEnderCrystal) { return new CraftEnderCrystal(server, (EntityEnderCrystal) entity); }
else if (entity instanceof EntityFishingHook) { return new CraftFishHook(server, (EntityFishingHook) entity); }
else if (entity instanceof EntityItem) { return new CraftItem(server, (EntityItem) entity); }
else if (entity instanceof EntityWeather) {
if (entity instanceof EntityLightning) { return new CraftLightningStrike(server, (EntityLightning) entity); }
else { return new CraftWeather(server, (EntityWeather) entity); }
}
else if (entity instanceof EntityLightning) { return new CraftLightningStrike(server, (EntityLightning) entity); }
else if (entity instanceof EntityMinecartAbstract) {
if (entity instanceof EntityMinecartFurnace) { return new CraftMinecartFurnace(server, (EntityMinecartFurnace) entity); }
else if (entity instanceof EntityMinecartChest) { return new CraftMinecartChest(server, (EntityMinecartChest) entity); }
@@ -253,26 +255,24 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public Vector getVelocity() {
return new Vector(entity.motX, entity.motY, entity.motZ);
return CraftVector.toBukkit(entity.getMot());
}
public void setVelocity(Vector velocity) {
Preconditions.checkArgument(velocity != null, "velocity");
velocity.checkFinite();
entity.motX = velocity.getX();
entity.motY = velocity.getY();
entity.motZ = velocity.getZ();
entity.setMot(CraftVector.toNMS(velocity));
entity.velocityChanged = true;
}
@Override
public double getHeight() {
return getHandle().length;
return getHandle().getHeight();
}
@Override
public double getWidth() {
return getHandle().width;
return getHandle().getWidth();
}
@Override
@@ -324,7 +324,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
// Let the server handle cross world teleports
if (!location.getWorld().equals(getWorld())) {
entity.teleportTo(location, false);
entity.teleportTo(((CraftWorld) location.getWorld()).getHandle().dimension, new BlockPosition(location.getX(), location.getY(), location.getZ()));
return true;
}

View File

@@ -0,0 +1,28 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityFox;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fox;
public class CraftFox extends CraftAnimals implements Fox {
public CraftFox(CraftServer server, EntityFox entity) {
super(server, entity);
}
@Override
public EntityFox getHandle() {
return (EntityFox) super.getHandle();
}
@Override
public EntityType getType() {
return EntityType.FOX;
}
@Override
public String toString() {
return "CraftFox";
}
}

View File

@@ -4,13 +4,17 @@ import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
import net.minecraft.server.BlockAnvil;
import net.minecraft.server.BlockBed;
import net.minecraft.server.BlockEnchantmentTable;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.BlockWorkbench;
import net.minecraft.server.Blocks;
import net.minecraft.server.ChatComponentText;
import net.minecraft.server.Container;
import net.minecraft.server.Containers;
import net.minecraft.server.CraftingManager;
import net.minecraft.server.Entity;
import net.minecraft.server.EntityHuman;
@@ -19,6 +23,7 @@ import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityTypes;
import net.minecraft.server.EnumMainHand;
import net.minecraft.server.IBlockData;
import net.minecraft.server.IChatBaseComponent;
import net.minecraft.server.IInventory;
import net.minecraft.server.IMerchant;
import net.minecraft.server.IRecipe;
@@ -29,14 +34,19 @@ import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.PacketPlayInCloseWindow;
import net.minecraft.server.PacketPlayOutOpenWindow;
import net.minecraft.server.TileEntity;
import net.minecraft.server.TileEntityBarrel;
import net.minecraft.server.TileEntityBeacon;
import net.minecraft.server.TileEntityBlastFurnace;
import net.minecraft.server.TileEntityBrewingStand;
import net.minecraft.server.TileEntityDispenser;
import net.minecraft.server.TileEntityDropper;
import net.minecraft.server.TileEntityEnchantTable;
import net.minecraft.server.TileEntityFurnace;
import net.minecraft.server.TileEntityFurnaceFurnace;
import net.minecraft.server.TileEntityHopper;
import net.minecraft.server.TileEntityLectern;
import net.minecraft.server.TileEntityShulkerBox;
import net.minecraft.server.TileEntitySmoker;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -52,6 +62,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.inventory.CraftMerchant;
import org.bukkit.craftbukkit.inventory.CraftMerchantCustom;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.entity.HumanEntity;
@@ -121,7 +132,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
}
public boolean isSleeping() {
return getHandle().sleeping;
return getHandle().isSleeping();
}
public int getSleepTicks() {
@@ -168,7 +179,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
return false;
}
if (getHandle().a(blockposition, force) != EntityHuman.EnumBedResult.OK) {
if (getHandle().sleep(blockposition, force).left().isPresent()) {
return false;
}
@@ -183,14 +194,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
public void wakeup(boolean setSpawnLocation) {
Preconditions.checkState(isSleeping(), "Cannot wakeup if not sleeping");
getHandle().a(true, true, setSpawnLocation);
getHandle().wakeup(true, true, setSpawnLocation);
}
@Override
public Location getBedLocation() {
Preconditions.checkState(isSleeping(), "Not sleeping");
return new Location(getWorld(), getHandle().bedPosition.getX(), getHandle().bedPosition.getY(), getHandle().bedPosition.getZ());
BlockPosition bed = getHandle().getBed();
return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ());
}
@Override
@@ -303,41 +315,64 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
case PLAYER:
case CHEST:
case ENDER_CHEST:
getHandle().openContainer(iinventory);
Containers customSize;
switch (inventory.getSize()) {
case 9:
customSize = Containers.GENERIC_9X1;
break;
case 18:
customSize = Containers.GENERIC_9X2;
break;
case 27:
customSize = Containers.GENERIC_9X3;
break;
case 36:
customSize = Containers.GENERIC_9X4;
break;
case 45:
customSize = Containers.GENERIC_9X5;
break;
case 54:
customSize = Containers.GENERIC_9X6;
break;
default:
throw new IllegalArgumentException("Unsupported custom size " + inventory.getSize());
}
openCustomInventory(inventory, player, customSize);
break;
case DISPENSER:
if (iinventory instanceof TileEntityDispenser) {
getHandle().openContainer((TileEntityDispenser) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:dispenser");
openCustomInventory(inventory, player, Containers.GENERIC_3X3);
}
break;
case DROPPER:
if (iinventory instanceof TileEntityDropper) {
getHandle().openContainer((TileEntityDropper) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:dropper");
openCustomInventory(inventory, player, Containers.GENERIC_3X3);
}
break;
case FURNACE:
if (iinventory instanceof TileEntityFurnace) {
getHandle().openContainer((TileEntityFurnace) iinventory);
if (iinventory instanceof TileEntityFurnaceFurnace) {
getHandle().openContainer((TileEntityFurnaceFurnace) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:furnace");
openCustomInventory(inventory, player, Containers.FURNACE);
}
break;
case WORKBENCH:
openCustomInventory(inventory, player, "minecraft:crafting_table");
openCustomInventory(inventory, player, Containers.CRAFTING);
break;
case BREWING:
if (iinventory instanceof TileEntityBrewingStand) {
getHandle().openContainer((TileEntityBrewingStand) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:brewing_stand");
openCustomInventory(inventory, player, Containers.BREWING_STAND);
}
break;
case ENCHANTING:
openCustomInventory(inventory, player, "minecraft:enchanting_table");
openCustomInventory(inventory, player, Containers.ENCHANTMENT);
break;
case HOPPER:
if (iinventory instanceof TileEntityHopper) {
@@ -345,33 +380,67 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
} else if (iinventory instanceof EntityMinecartHopper) {
getHandle().openContainer((EntityMinecartHopper) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:hopper");
openCustomInventory(inventory, player, Containers.HOPPER);
}
break;
case BEACON:
if (iinventory instanceof TileEntityBeacon) {
getHandle().openContainer((TileEntityBeacon) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:beacon");
openCustomInventory(inventory, player, Containers.BEACON);
}
break;
case ANVIL:
if (iinventory instanceof BlockAnvil.TileEntityContainerAnvil) {
getHandle().openTileEntity((BlockAnvil.TileEntityContainerAnvil) iinventory);
if (iinventory instanceof ITileInventory) {
getHandle().openContainer((ITileInventory) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:anvil");
openCustomInventory(inventory, player, Containers.ANVIL);
}
break;
case SHULKER_BOX:
if (iinventory instanceof TileEntityShulkerBox) {
getHandle().openContainer((TileEntityShulkerBox) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:shulker_box");
openCustomInventory(inventory, player, Containers.SHULKER_BOX);
}
break;
case BARREL:
if (iinventory instanceof TileEntityBarrel) {
getHandle().openContainer((TileEntityBarrel) iinventory);
} else {
openCustomInventory(inventory, player, Containers.GENERIC_9X3);
}
break;
case BLAST_FURNACE:
if (iinventory instanceof TileEntityBlastFurnace) {
getHandle().openContainer((TileEntityBlastFurnace) iinventory);
} else {
openCustomInventory(inventory, player, Containers.BLAST_FURNACE);
}
break;
case LECTERN:
if (iinventory instanceof TileEntityLectern) {
getHandle().openContainer((TileEntityLectern) iinventory);
} else {
openCustomInventory(inventory, player, Containers.LECTERN);
}
break;
case SMOKER:
if (iinventory instanceof TileEntitySmoker) {
getHandle().openContainer((TileEntitySmoker) iinventory);
} else {
openCustomInventory(inventory, player, Containers.SMOKER);
}
break;
case STONECUTTER:
openCustomInventory(inventory, player, Containers.STONECUTTER);
break;
case CREATIVE:
case CRAFTING:
case MERCHANT:
case LOOM:
case CARTOGRAPHY:
case GRINDSTONE:
throw new IllegalArgumentException("Can't open a " + type + " inventory!");
}
if (getHandle().activeContainer == formerContainer) {
@@ -381,25 +450,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
return getHandle().activeContainer.getBukkitView();
}
private void openCustomInventory(Inventory inventory, EntityPlayer player, String windowType) {
private void openCustomInventory(Inventory inventory, EntityPlayer player, Containers<?> windowType) {
if (player.playerConnection == null) return;
Preconditions.checkArgument(windowType != null, "Unknown windowType");
Container container = new CraftContainer(inventory, this.getHandle(), player.nextContainerCounter());
container = CraftEventFactory.callInventoryOpenEvent(player, container);
if(container == null) return;
String title = container.getBukkitView().getTitle();
int size = container.getBukkitView().getTopInventory().getSize();
// Special cases
if (windowType.equals("minecraft:crafting_table")
|| windowType.equals("minecraft:anvil")
|| windowType.equals("minecraft:enchanting_table")
) {
size = 0;
}
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size));
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title)));
getHandle().activeContainer = container;
getHandle().activeContainer.addSlotListener(player);
}
@@ -414,7 +475,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
if (location == null) {
location = getLocation();
}
getHandle().openTileEntity(new BlockWorkbench.TileEntityContainerWorkbench(getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
getHandle().openContainer(((BlockWorkbench) Blocks.CRAFTING_TABLE).getInventory(null, getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
if (force) {
getHandle().activeContainer.checkReachable = false;
}
@@ -434,13 +495,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// If there isn't an enchant table we can force create one, won't be very useful though.
BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
TileEntity container = getHandle().world.getTileEntity(pos);
if (container == null && force) {
container = new TileEntityEnchantTable();
container.setWorld(getHandle().world);
container.setPosition(pos);
}
getHandle().openTileEntity((ITileEntityContainer) container);
getHandle().openContainer(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getInventory(null, getHandle().world, pos));
if (force) {
getHandle().activeContainer.checkReachable = false;
@@ -471,10 +526,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// Now open the window
InventoryType type = inventory.getType();
String windowType = CraftContainer.getNotchInventoryType(type);
Containers<?> windowType = CraftContainer.getNotchInventoryType(type);
String title = inventory.getTitle();
int size = inventory.getTopInventory().getSize();
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size));
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title)));
player.activeContainer = container;
player.activeContainer.addSlotListener(player);
}
@@ -498,16 +552,19 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
}
IMerchant mcMerchant;
IChatBaseComponent name;
if (merchant instanceof CraftVillager) {
mcMerchant = ((CraftVillager) merchant).getHandle();
} else if (merchant instanceof CraftMerchant) {
mcMerchant = ((CraftMerchant) merchant).getMerchant();
name = ((CraftVillager) merchant).getHandle().getScoreboardDisplayName();
} else if (merchant instanceof CraftMerchantCustom) {
mcMerchant = ((CraftMerchantCustom) merchant).getMerchant();
name = ((CraftMerchantCustom) merchant).getMerchant().getScoreboardDisplayName();
} else {
throw new IllegalArgumentException("Can't open merchant " + merchant.toString());
}
mcMerchant.setTradingPlayer(this.getHandle());
this.getHandle().openTrade(mcMerchant);
mcMerchant.openTrade(this.getHandle(), name, 0);
return this.getHandle().activeContainer.getBukkitView();
}
@@ -576,17 +633,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
return getHandle().undiscoverRecipes(bukkitKeysToMinecraftRecipes(recipes));
}
private Collection<IRecipe> bukkitKeysToMinecraftRecipes(Collection<NamespacedKey> recipeKeys) {
Collection<IRecipe> recipes = new ArrayList<>();
private Collection<IRecipe<?>> bukkitKeysToMinecraftRecipes(Collection<NamespacedKey> recipeKeys) {
Collection<IRecipe<?>> recipes = new ArrayList<>();
CraftingManager manager = getHandle().world.getMinecraftServer().getCraftingManager();
for (NamespacedKey recipeKey : recipeKeys) {
IRecipe recipe = manager.a(CraftNamespacedKey.toMinecraft(recipeKey));
if (recipe == null) {
Optional<? extends IRecipe<?>> recipe = manager.a(CraftNamespacedKey.toMinecraft(recipeKey));
if (!recipe.isPresent()) {
continue;
}
recipes.add(recipe);
recipes.add(recipe.get());
}
return recipes;
@@ -595,9 +652,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public org.bukkit.entity.Entity getShoulderEntityLeft() {
if (!getHandle().getShoulderEntityLeft().isEmpty()) {
Entity shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().world);
Optional<Entity> shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().world);
return (shoulder == null) ? null : shoulder.getBukkitEntity();
return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity();
}
return null;
@@ -614,9 +671,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public org.bukkit.entity.Entity getShoulderEntityRight() {
if (!getHandle().getShoulderEntityRight().isEmpty()) {
Entity shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().world);
Optional<Entity> shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().world);
return (shoulder == null) ? null : shoulder.getBukkitEntity();
return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity();
}
return null;

View File

@@ -4,7 +4,7 @@ import net.minecraft.server.EntityIllagerAbstract;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Illager;
public class CraftIllager extends CraftMonster implements Illager {
public class CraftIllager extends CraftRaider implements Illager {
public CraftIllager(CraftServer server, EntityIllagerAbstract entity) {
super(server, entity);

View File

@@ -1,42 +0,0 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityPotion;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LingeringPotion;
import org.bukkit.inventory.ItemStack;
public class CraftLingeringPotion extends CraftThrownPotion implements LingeringPotion {
public CraftLingeringPotion(CraftServer server, EntityPotion entity) {
super(server, entity);
}
public void setItem(ItemStack item) {
// The ItemStack must not be null.
Validate.notNull(item, "ItemStack cannot be null.");
// The ItemStack must be a potion.
Validate.isTrue(item.getType() == Material.LINGERING_POTION, "ItemStack must be a lingering potion. This item stack was " + item.getType() + ".");
getHandle().setItem(CraftItemStack.asNMSCopy(item));
}
@Override
public EntityPotion getHandle() {
return (EntityPotion) entity;
}
@Override
public String toString() {
return "CraftLingeringPotion";
}
@Override
public EntityType getType() {
return EntityType.LINGERING_POTION;
}
}

View File

@@ -29,6 +29,7 @@ import net.minecraft.server.EntityThrownExpBottle;
import net.minecraft.server.EntityTippedArrow;
import net.minecraft.server.EntitySpectralArrow;
import net.minecraft.server.EntityThrownTrident;
import net.minecraft.server.EntityTypes;
import net.minecraft.server.EntityWither;
import net.minecraft.server.EntityWitherSkull;
import net.minecraft.server.GenericAttributes;
@@ -117,7 +118,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setMaxHealth(double amount) {
Validate.isTrue(amount > 0, "Max health must be greater than 0");
getHandle().getAttributeInstance(GenericAttributes.maxHealth).setValue(amount);
getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(amount);
if (getHealth() > amount) {
setHealth(amount);
@@ -125,7 +126,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public void resetMaxHealth() {
setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.maxHealth).getAttribute().getDefault());
setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).getAttribute().getDefault());
}
public double getEyeHeight() {
@@ -352,16 +353,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
((EntityArrow) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 3.0F, 1.0F); // ItemBow
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
if (LingeringPotion.class.isAssignableFrom(projectile)) {
launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
launch = new EntityPotion(world, getHandle());
((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
} else {
launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
launch = new EntityPotion(world, getHandle());
((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
}
((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, -20.0F, 0.5F, 1.0F); // ItemSplashPotion
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
launch = new EntityThrownExpBottle(world, getHandle());
((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, -20.0F, 0.7F, 1.0F); // ItemExpBottle
} else if (FishHook.class.isAssignableFrom(projectile) && getHandle() instanceof EntityHuman) {
launch = new EntityFishingHook(world, (EntityHuman) getHandle());
launch = new EntityFishingHook((EntityHuman) getHandle(), world, 0, 0);
} else if (Fireball.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
Vector direction = location.getDirection().multiply(10);
@@ -382,7 +385,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
Location location = getEyeLocation();
Vector direction = location.getDirection();
launch = new EntityLlamaSpit(world);
launch = EntityTypes.LLAMA_SPIT.a(world);
((EntityLlamaSpit) launch).shooter = getHandle();
((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F); // EntityLlama

View File

@@ -28,7 +28,7 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo
@Override
public LootTable getLootTable() {
MinecraftKey nmsTable = getHandle().getLootTable();
MinecraftKey nmsTable = getHandle().lootTable;
if (nmsTable == null) {
return null; // return empty loot table?
}
@@ -49,6 +49,6 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo
private void setLootTable(LootTable table, long seed) {
MinecraftKey newKey = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
getHandle().a(newKey, seed);
getHandle().setLootTable(newKey, seed);
}
}

View File

@@ -1,12 +1,11 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityOcelot;
import org.apache.commons.lang.Validate;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Ocelot;
public class CraftOcelot extends CraftTameableAnimal implements Ocelot {
public class CraftOcelot extends CraftAnimals implements Ocelot {
public CraftOcelot(CraftServer server, EntityOcelot ocelot) {
super(server, ocelot);
}
@@ -17,12 +16,11 @@ public class CraftOcelot extends CraftTameableAnimal implements Ocelot {
}
public Type getCatType() {
return Type.getType(getHandle().getCatType());
return Type.WILD_OCELOT;
}
public void setCatType(Type type) {
Validate.notNull(type, "Cat type cannot be null");
getHandle().setCatType(type.getId());
throw new UnsupportedOperationException("Cats are now a different entity!");
}
@Override

View File

@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityPainting;
import net.minecraft.server.EntityTypes;
import net.minecraft.server.Paintings;
import net.minecraft.server.WorldServer;
@@ -53,7 +54,7 @@ public class CraftPainting extends CraftHanging implements Painting {
private void update() {
WorldServer world = ((CraftWorld) getWorld()).getHandle();
EntityPainting painting = new EntityPainting(world);
EntityPainting painting = EntityTypes.PAINTING.a(world);
painting.blockPosition = getHandle().blockPosition;
painting.art = getHandle().art;
painting.setDirection(getHandle().direction);

View File

@@ -0,0 +1,61 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.EntityPanda;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Panda;
import org.bukkit.entity.EntityType;
public class CraftPanda extends CraftAnimals implements Panda {
public CraftPanda(CraftServer server, EntityPanda entity) {
super(server, entity);
}
@Override
public EntityPanda getHandle() {
return (EntityPanda) super.getHandle();
}
@Override
public EntityType getType() {
return EntityType.PANDA;
}
@Override
public String toString() {
return "CraftPanda";
}
@Override
public Gene getMainGene() {
return fromNms(getHandle().getMainGene());
}
@Override
public void setMainGene(Gene gene) {
getHandle().setMainGene(toNms(gene));
}
@Override
public Gene getHiddenGene() {
return fromNms(getHandle().getHiddenGene());
}
@Override
public void setHiddenGene(Gene gene) {
getHandle().setHiddenGene(toNms(gene));
}
public static Gene fromNms(EntityPanda.Gene gene) {
Preconditions.checkArgument(gene != null, "Gene may not be null");
return Gene.values()[gene.ordinal()];
}
public static EntityPanda.Gene toNms(Gene gene) {
Preconditions.checkArgument(gene != null, "Gene may not be null");
return EntityPanda.Gene.values()[gene.ordinal()];
}
}

View File

@@ -0,0 +1,35 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityPillager;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.entity.Pillager;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.Inventory;
public class CraftPillager extends CraftIllager implements Pillager {
public CraftPillager(CraftServer server, EntityPillager entity) {
super(server, entity);
}
@Override
public EntityPillager getHandle() {
return (EntityPillager) super.getHandle();
}
@Override
public EntityType getType() {
return EntityType.PILLAGER;
}
@Override
public String toString() {
return "CraftPillager";
}
@Override
public Inventory getInventory() {
return new CraftInventory(getHandle().getInventory());
}
}

View File

@@ -36,8 +36,6 @@ import net.minecraft.server.Container;
import net.minecraft.server.Entity;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityTracker;
import net.minecraft.server.EntityTrackerEntry;
import net.minecraft.server.EnumChatFormat;
import net.minecraft.server.EnumGamemode;
import net.minecraft.server.IChatBaseComponent;
@@ -60,6 +58,7 @@ import net.minecraft.server.PacketPlayOutUpdateAttributes;
import net.minecraft.server.PacketPlayOutUpdateHealth;
import net.minecraft.server.PacketPlayOutWorldEvent;
import net.minecraft.server.PacketPlayOutWorldParticles;
import net.minecraft.server.PlayerChunkMap;
import net.minecraft.server.PlayerConnection;
import net.minecraft.server.TileEntitySign;
import net.minecraft.server.Vec3D;
@@ -399,6 +398,27 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
case 9:
instrumentName = "xylophone";
break;
case 10:
instrumentName = "iron_xylophone";
break;
case 11:
instrumentName = "cow_bell";
break;
case 12:
instrumentName = "didgeridoo";
break;
case 13:
instrumentName = "bit";
break;
case 14:
instrumentName = "banjo";
break;
case 15:
instrumentName = "pling";
break;
case 16:
instrumentName = "xylophone";
break;
}
float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.server.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
@@ -562,7 +582,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), true, icons, data.buffer, 0, 0, 128, 128);
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), true, map.isLocked(), icons, data.buffer, 0, 0, 128, 128);
getHandle().playerConnection.sendPacket(packet);
}
@@ -668,7 +688,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void setSleepingIgnored(boolean isSleeping) {
getHandle().fauxSleeping = isSleeping;
((CraftWorld) getWorld()).getHandle().checkSleepStatus();
((CraftWorld) getWorld()).getHandle().everyoneSleeping();
}
@Override
@@ -1000,9 +1020,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
hiddenPlayers.put(player.getUniqueId(), hidingPlugins);
// Remove this player from the hidden player's EntityTrackerEntry
EntityTracker tracker = ((WorldServer) entity.world).tracker;
PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap;
EntityPlayer other = ((CraftPlayer) player).getHandle();
EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId());
PlayerChunkMap.EntityTracker entry = tracker.trackedEntities.get(other.getId());
if (entry != null) {
entry.clear(getHandle());
}
@@ -1042,12 +1062,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
hiddenPlayers.remove(player.getUniqueId());
EntityTracker tracker = ((WorldServer) entity.world).tracker;
PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap;
EntityPlayer other = ((CraftPlayer) player).getHandle();
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other));
EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId());
PlayerChunkMap.EntityTracker entry = tracker.trackedEntities.get(other.getId());
if (entry != null && !entry.trackedPlayers.contains(getHandle())) {
entry.updatePlayer(getHandle());
}

View File

@@ -41,8 +41,8 @@ public class CraftRabbit extends CraftAnimals implements Rabbit {
if (getRabbitType() == Type.THE_KILLER_BUNNY) {
// Reset goals and target finders.
World world = ((CraftWorld) this.getWorld()).getHandle();
entity.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
entity.targetSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
entity.goalSelector = new PathfinderGoalSelector(world != null && world.getMethodProfiler() != null ? world.getMethodProfiler() : null);
entity.targetSelector = new PathfinderGoalSelector(world != null && world.getMethodProfiler() != null ? world.getMethodProfiler() : null);
entity.initializePathFinderGoals();
}

View File

@@ -0,0 +1,52 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.EntityRaider;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.entity.Raider;
public abstract class CraftRaider extends CraftMonster implements Raider {
public CraftRaider(CraftServer server, EntityRaider entity) {
super(server, entity);
}
@Override
public EntityRaider getHandle() {
return (EntityRaider) super.getHandle();
}
@Override
public String toString() {
return "CraftRaider";
}
@Override
public Block getPatrolTarget() {
return getHandle().getPatrolTarget() == null ? null : CraftBlock.at(getHandle().world, getHandle().getPatrolTarget());
}
@Override
public void setPatrolTarget(Block block) {
if (block == null) {
getHandle().setPatrolTarget((BlockPosition) null);
} else {
Preconditions.checkArgument(block.getWorld().equals(this.getWorld()), "Block must be in same world");
getHandle().setPatrolTarget(new BlockPosition(block.getX(), block.getY(), block.getZ()));
}
}
@Override
public boolean isPatrolLeader() {
return getHandle().isPatrolLeader();
}
@Override
public void setPatrolLeader(boolean leader) {
getHandle().setPatrolLeader(leader);
}
}

View File

@@ -0,0 +1,28 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityRavager;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Ravager;
public class CraftRavager extends CraftRaider implements Ravager {
public CraftRavager(CraftServer server, EntityRavager entity) {
super(server, entity);
}
@Override
public EntityRavager getHandle() {
return (EntityRavager) super.getHandle();
}
@Override
public EntityType getType() {
return EntityType.RAVAGER;
}
@Override
public String toString() {
return "CraftRavager";
}
}

View File

@@ -1,43 +0,0 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityPotion;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.SplashPotion;
import org.bukkit.inventory.ItemStack;
public class CraftSplashPotion extends CraftThrownPotion implements SplashPotion {
public CraftSplashPotion(CraftServer server, EntityPotion entity) {
super(server, entity);
}
@Override
public void setItem(ItemStack item) {
// The ItemStack must not be null.
Validate.notNull(item, "ItemStack cannot be null.");
// The ItemStack must be a potion.
Validate.isTrue(item.getType() == Material.SPLASH_POTION, "ItemStack must be a splash potion. This item stack was " + item.getType() + ".");
getHandle().setItem(CraftItemStack.asNMSCopy(item));
}
@Override
public EntityPotion getHandle() {
return (EntityPotion) entity;
}
@Override
public String toString() {
return "CraftSplashPotion";
}
@Override
public EntityType getType() {
return EntityType.SPLASH_POTION;
}
}

View File

@@ -17,7 +17,7 @@ import org.bukkit.potion.PotionEffect;
import com.google.common.collect.ImmutableList;
public abstract class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
public CraftThrownPotion(CraftServer server, EntityPotion entity) {
super(server, entity);
}
@@ -34,8 +34,24 @@ public abstract class CraftThrownPotion extends CraftProjectile implements Throw
return CraftItemStack.asBukkitCopy(getHandle().getItem());
}
@Override
public void setItem(ItemStack item) {
// The ItemStack must not be null.
Validate.notNull(item, "ItemStack cannot be null.");
// The ItemStack must be a potion.
Validate.isTrue(item.getType() == Material.LINGERING_POTION || item.getType() == Material.SPLASH_POTION, "ItemStack must be a lingering or splash potion. This item stack was " + item.getType() + ".");
getHandle().setItem(CraftItemStack.asNMSCopy(item));
}
@Override
public EntityPotion getHandle() {
return (EntityPotion) entity;
}
@Override
public EntityType getType() {
return EntityType.SPLASH_POTION;
}
}

View File

@@ -37,7 +37,7 @@ public class CraftTippedArrow extends CraftArrow implements TippedArrow {
@Override
public EntityType getType() {
return EntityType.TIPPED_ARROW;
return EntityType.ARROW;
}
@Override

View File

@@ -0,0 +1,28 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityLLamaTrader;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.TraderLlama;
public class CraftTraderLlama extends CraftLlama implements TraderLlama {
public CraftTraderLlama(CraftServer server, EntityLLamaTrader entity) {
super(server, entity);
}
@Override
public EntityLLamaTrader getHandle() {
return (EntityLLamaTrader) super.getHandle();
}
@Override
public String toString() {
return "CraftTraderLlama";
}
@Override
public EntityType getType() {
return EntityType.TRADER_LLAMA;
}
}

View File

@@ -28,11 +28,11 @@ public class CraftVex extends CraftMonster implements Vex {
@Override
public boolean isCharging() {
return getHandle().dA();
return getHandle().isCharging();
}
@Override
public void setCharging(boolean charging) {
getHandle().a(charging);
getHandle().setCharging(charging);
}
}

View File

@@ -1,25 +1,15 @@
package org.bukkit.craftbukkit.entity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import java.util.Locale;
import net.minecraft.server.EntityVillager;
import net.minecraft.server.IRegistry;
import net.minecraft.server.MinecraftKey;
import org.apache.commons.lang.Validate;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.craftbukkit.inventory.CraftMerchant;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.MerchantRecipe;
public class CraftVillager extends CraftAgeable implements Villager, InventoryHolder {
private static final Map<Career, Integer> careerIDMap = new HashMap<>();
private CraftMerchant merchant;
public class CraftVillager extends CraftAbstractVillager implements Villager {
public CraftVillager(CraftServer server, EntityVillager entity) {
super(server, entity);
@@ -40,126 +30,11 @@ public class CraftVillager extends CraftAgeable implements Villager, InventoryHo
}
public Profession getProfession() {
return Profession.values()[getHandle().getProfession() + 1]; // Offset by 1 from the zombie types
return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getKey().toUpperCase(Locale.ROOT));
}
public void setProfession(Profession profession) {
Validate.notNull(profession);
Validate.isTrue(!profession.isZombie(), "Profession is reserved for Zombies: ", profession);
getHandle().setProfession(profession.ordinal() - 1);
}
@Override
public Career getCareer() {
return getCareer(getProfession(), getHandle().careerId);
}
@Override
public void setCareer(Career career) {
setCareer(career, true);
}
@Override
public void setCareer(Career career, boolean resetTrades) {
if (career == null) {
getHandle().careerId = 0; // reset career
} else {
Validate.isTrue(career.getProfession() == getProfession(), "Career assignment mismatch. Found (" + getProfession() + ") Required (" + career.getProfession() + ")");
getHandle().careerId = getCareerID(career);
}
if (resetTrades) {
getHandle().trades = null;
getHandle().careerLevel = 0; // SPIGOT-4310
getHandle().populateTrades();
}
}
@Override
public Inventory getInventory() {
return new CraftInventory(getHandle().inventory);
}
private CraftMerchant getMerchant() {
return (merchant == null) ? merchant = new CraftMerchant(getHandle()) : merchant;
}
@Override
public List<MerchantRecipe> getRecipes() {
return getMerchant().getRecipes();
}
@Override
public void setRecipes(List<MerchantRecipe> recipes) {
this.getMerchant().setRecipes(recipes);
}
@Override
public MerchantRecipe getRecipe(int i) {
return getMerchant().getRecipe(i);
}
@Override
public void setRecipe(int i, MerchantRecipe merchantRecipe) {
getMerchant().setRecipe(i, merchantRecipe);
}
@Override
public int getRecipeCount() {
return getMerchant().getRecipeCount();
}
@Override
public boolean isTrading() {
return getTrader() != null;
}
@Override
public HumanEntity getTrader() {
return getMerchant().getTrader();
}
@Override
public int getRiches() {
return getHandle().riches;
}
@Override
public void setRiches(int riches) {
getHandle().riches = riches;
}
@Nullable
private static Career getCareer(Profession profession, int id) {
Validate.isTrue(id > 0, "Career id must be greater than 0");
List<Career> careers = profession.getCareers();
for (Career c : careers) {
if (careerIDMap.containsKey(c) && careerIDMap.get(c) == id) {
return c;
}
}
return null;
}
private static int getCareerID(Career career) {
return careerIDMap.getOrDefault(career, 0);
}
static {
// build Career -> ID map
int id = 0;
for (Profession prof : Profession.values()) {
List<Career> careers = prof.getCareers();
if (!careers.isEmpty()) {
for (Career c : careers) {
careerIDMap.put(c, ++id);
}
}
Validate.isTrue(id == careers.size(), "Career id registration mismatch");
id = 0;
}
getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT)))));
}
}

View File

@@ -1,8 +1,12 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import java.util.Locale;
import java.util.UUID;
import net.minecraft.server.EntityZombieVillager;
import net.minecraft.server.IRegistry;
import net.minecraft.server.MinecraftKey;
import org.apache.commons.lang.Validate;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Villager;
@@ -31,12 +35,13 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager {
@Override
public Villager.Profession getVillagerProfession() {
return Villager.Profession.values()[getHandle().getProfession() + Villager.Profession.FARMER.ordinal()];
return Villager.Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getKey().toUpperCase(Locale.ROOT));
}
@Override
public void setVillagerProfession(Villager.Profession profession) {
getHandle().setProfession(profession == null ? 0 : profession.ordinal() - Villager.Profession.FARMER.ordinal());
Validate.notNull(profession);
getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT)))));
}
@Override

View File

@@ -0,0 +1,28 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityVillagerTrader;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.WanderingTrader;
public class CraftWanderingTrader extends CraftAbstractVillager implements WanderingTrader {
public CraftWanderingTrader(CraftServer server, EntityVillagerTrader entity) {
super(server, entity);
}
@Override
public EntityVillagerTrader getHandle() {
return (EntityVillagerTrader) entity;
}
@Override
public String toString() {
return "CraftWanderingTrader";
}
@Override
public EntityType getType() {
return EntityType.WANDERING_TRADER;
}
}

View File

@@ -1,26 +0,0 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityWeather;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Weather;
public class CraftWeather extends CraftEntity implements Weather {
public CraftWeather(final CraftServer server, final EntityWeather entity) {
super(server, entity);
}
@Override
public EntityWeather getHandle() {
return (EntityWeather) entity;
}
@Override
public String toString() {
return "CraftWeather";
}
public EntityType getType() {
return EntityType.WEATHER;
}
}

View File

@@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Witch;
import org.bukkit.entity.EntityType;
public class CraftWitch extends CraftMonster implements Witch {
public class CraftWitch extends CraftRaider implements Witch {
public CraftWitch(CraftServer server, EntityWitch entity) {
super(server, entity);
}

View File

@@ -11,6 +11,7 @@ import javax.annotation.Nullable;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Either;
import net.minecraft.server.*;
@@ -106,36 +107,33 @@ public class CraftEventFactory {
/**
* PlayerBedEnterEvent
*/
public static EntityHuman.EnumBedResult callPlayerBedEnterEvent(EntityHuman player, BlockPosition bed, EntityHuman.EnumBedResult nmsBedResult) {
BedEnterResult bedEnterResult;
switch (nmsBedResult) {
case OK:
bedEnterResult = BedEnterResult.OK;
break;
case NOT_POSSIBLE_HERE:
bedEnterResult = BedEnterResult.NOT_POSSIBLE_HERE;
break;
case NOT_POSSIBLE_NOW:
bedEnterResult = BedEnterResult.NOT_POSSIBLE_NOW;
break;
case TOO_FAR_AWAY:
bedEnterResult = BedEnterResult.TOO_FAR_AWAY;
break;
case NOT_SAFE:
bedEnterResult = BedEnterResult.NOT_SAFE;
break;
default:
bedEnterResult = BedEnterResult.OTHER_PROBLEM;
}
public static Either<EntityHuman.EnumBedResult, Unit> callPlayerBedEnterEvent(EntityHuman player, BlockPosition bed, Either<EntityHuman.EnumBedResult, Unit> nmsBedResult) {
BedEnterResult bedEnterResult = nmsBedResult.mapBoth(new Function<EntityHuman.EnumBedResult, BedEnterResult>() {
@Override
public BedEnterResult apply(EntityHuman.EnumBedResult t) {
switch (t) {
case NOT_POSSIBLE_HERE:
return BedEnterResult.NOT_POSSIBLE_HERE;
case NOT_POSSIBLE_NOW:
return BedEnterResult.NOT_POSSIBLE_NOW;
case TOO_FAR_AWAY:
return BedEnterResult.TOO_FAR_AWAY;
case NOT_SAFE:
return BedEnterResult.NOT_SAFE;
default:
return BedEnterResult.OTHER_PROBLEM;
}
}
}, t -> BedEnterResult.OK).map(java.util.function.Function.identity(), java.util.function.Function.identity());
PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.world, bed), bedEnterResult);
Bukkit.getServer().getPluginManager().callEvent(event);
Result result = event.useBed();
if (result == Result.ALLOW) {
return EntityHuman.EnumBedResult.OK;
return Either.right(Unit.INSTANCE);
} else if (result == Result.DENY) {
return EntityHuman.EnumBedResult.OTHER_PROBLEM;
return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM);
}
return nmsBedResult;
@@ -331,10 +329,10 @@ public class CraftEventFactory {
/**
* EntityShootBowEvent
*/
public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, EntityArrow entityArrow, float force) {
public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, Entity entityArrow, float force) {
LivingEntity shooter = (LivingEntity) who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
Arrow arrow = (Arrow) entityArrow.getBukkitEntity();
org.bukkit.entity.Entity arrow = entityArrow.getBukkitEntity();
if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) {
itemInHand = null;
@@ -374,7 +372,7 @@ public class CraftEventFactory {
boolean isNpc = entity instanceof NPC;
if (spawnReason != SpawnReason.CUSTOM) {
if (isAnimal && !world.allowAnimals || isMonster && !world.allowMonsters || isNpc && !world.getServer().getServer().getSpawnNPCs()) {
if (isAnimal && !world.getWorld().getAllowAnimals() || isMonster && !world.getWorld().getAllowMonsters() || isNpc && !world.getServer().getServer().getSpawnNPCs()) {
entity.dead = true;
return false;
}
@@ -658,7 +656,7 @@ public class CraftEventFactory {
DamageCause cause = null;
Block damager = blockDamage;
blockDamage = null;
if (source == DamageSource.CACTUS) {
if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH) {
cause = DamageCause.CONTACT;
} else if (source == DamageSource.HOT_FLOOR) {
cause = DamageCause.HOT_FLOOR;
@@ -895,9 +893,9 @@ public class CraftEventFactory {
return event;
}
public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, int x, int y, int z) {
public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, BlockPosition pos) {
org.bukkit.entity.Entity entity1 = entity.getBukkitEntity();
Block block = entity1.getWorld().getBlockAt(x, y, z);
Block block = CraftBlock.at(entity.world, pos);
EntityBreakDoorEvent event = new EntityBreakDoorEvent((LivingEntity) entity1, block);
entity1.getServer().getPluginManager().callEvent(event);
@@ -952,12 +950,18 @@ public class CraftEventFactory {
public static ProjectileHitEvent callProjectileHitEvent(Entity entity, MovingObjectPosition position) {
Block hitBlock = null;
BlockFace hitFace = null;
if (position.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
hitBlock = CraftBlock.at(entity.world, position.getBlockPosition());
hitFace = CraftBlock.notchToBlockFace(position.direction);
if (position.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
MovingObjectPositionBlock positionBlock = (MovingObjectPositionBlock) position;
hitBlock = CraftBlock.at(entity.world, positionBlock.getBlockPosition());
hitFace = CraftBlock.notchToBlockFace(positionBlock.getDirection());
}
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), position.entity == null ? null : position.entity.getBukkitEntity(), hitBlock, hitFace);
org.bukkit.entity.Entity hitEntity = null;
if (position.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
hitEntity = ((MovingObjectPositionEntity) position).getEntity().getBukkitEntity();
}
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), hitEntity, hitBlock, hitFace);
entity.world.getServer().getPluginManager().callEvent(event);
return event;
}
@@ -1209,7 +1213,10 @@ public class CraftEventFactory {
public static BlockPhysicsEvent callBlockPhysicsEvent(GeneratorAccess world, BlockPosition blockposition) {
org.bukkit.block.Block block = CraftBlock.at(world, blockposition);
BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getBlockData());
world.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
// Suppress during worldgen
if (world instanceof World) {
world.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
}
return event;
}

View File

@@ -157,7 +157,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
private ChunkSection getChunkSection(int y, boolean create) {
ChunkSection section = sections[y >> 4];
if (create && section == null) {
sections[y >> 4] = section = new ChunkSection(y, create);
sections[y >> 4] = section = new ChunkSection(y);
}
return section;
}

View File

@@ -1,29 +1,23 @@
package org.bukkit.craftbukkit.generator;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.server.*;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettingsDefault> {
private final ChunkGenerator generator;
private final WorldServer world;
private final long seed;
private final Random random;
private final WorldChunkManager chunkManager;
private final WorldGenStronghold strongholdGen = new WorldGenStronghold();
private final GeneratorSettingsDefault settings = new GeneratorSettingsDefault();
private final StructureGenerator strongholdGen = WorldGenerator.STRONGHOLD;
private static class CustomBiomeGrid implements BiomeGrid {
BiomeBase[] biome;
@@ -40,23 +34,23 @@ public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettin
}
public CustomChunkGenerator(World world, long seed, ChunkGenerator generator) {
super(world, world.worldProvider.getChunkGenerator().getWorldChunkManager(), new GeneratorSettingsDefault());
this.world = (WorldServer) world;
this.generator = generator;
this.seed = seed;
this.random = new Random(seed);
this.chunkManager = world.worldProvider.getChunkGenerator().getWorldChunkManager();
}
@Override
public void createChunk(IChunkAccess ichunkaccess) {
public void buildBase(IChunkAccess ichunkaccess) {
int x = ichunkaccess.getPos().x;
int z = ichunkaccess.getPos().z;
random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
// Get default biome data for chunk
CustomBiomeGrid biomegrid = new CustomBiomeGrid();
biomegrid.biome = chunkManager.getBiomeBlock(x << 4, z << 4, 16, 16);
biomegrid.biome = this.getWorldChunkManager().getBiomeBlock(x << 4, z << 4, 16, 16);
ChunkData data = generator.generateChunkData(this.world.getWorld(), random, x, z, biomegrid);
Preconditions.checkArgument(data instanceof CraftChunkData, "Plugins must use createChunkData(World) rather than implementing ChunkData: %s", data);
@@ -87,26 +81,24 @@ public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettin
Block block = craftData.getTypeId(tx, ty, tz).getBlock();
if (block.isTileEntity()) {
TileEntity tile = ((ITileEntity) block).a(world);
ichunkaccess.a(new BlockPosition((x << 4) + tx, ty, (z << 4) + tz), tile);
TileEntity tile = ((ITileEntity) block).createTile(world);
ichunkaccess.setTileEntity(new BlockPosition((x << 4) + tx, ty, (z << 4) + tz), tile);
}
}
}
}
@Override
public ChunkData generateChunkData(org.bukkit.World world, Random random, int x, int z, BiomeGrid biome) {
return generator.generateChunkData(world, random, x, z, biome);
public void doCarving(IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features) {
}
@Override
public boolean canSpawn(org.bukkit.World world, int x, int z) {
return generator.canSpawn(world, x, z);
public void buildNoise(GeneratorAccess generatoraccess, IChunkAccess ichunkaccess) {
}
@Override
public List<BlockPopulator> getDefaultPopulators(org.bukkit.World world) {
return generator.getDefaultPopulators(world);
public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type) {
return 0;
}
@Override
@@ -116,10 +108,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettin
return biomebase == null ? null : biomebase.getMobs(type);
}
@Override
public void addFeatures(RegionLimitedWorldAccess regionlimitedworldaccess, WorldGenStage.Features worldgenstage_features) {
}
@Override
public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess) {
}
@@ -139,8 +127,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettin
}
@Override
public int a(World world, boolean flag, boolean flag1) {
return 0;
public void doMobSpawning(WorldServer worldserver, boolean flag, boolean flag1) {
}
@Override
@@ -148,36 +135,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator<GeneratorSettin
return biomebase.a(structuregenerator);
}
@Override
public WorldGenFeatureConfiguration getFeatureConfiguration(BiomeBase biomebase, StructureGenerator<? extends WorldGenFeatureConfiguration> structuregenerator) {
return biomebase.b(structuregenerator);
}
// Taken from ChunkGeneratorAbstract
private final Map<StructureGenerator<? extends WorldGenFeatureConfiguration>, Long2ObjectMap<StructureStart>> structureStartCache = Maps.newHashMap();
@Override
public Long2ObjectMap<StructureStart> getStructureStartCache(StructureGenerator<? extends WorldGenFeatureConfiguration> structuregenerator) {
return (Long2ObjectMap) this.structureStartCache.computeIfAbsent(structuregenerator, (s) -> {
return Long2ObjectMaps.synchronize(new ExpiringMap(8192, 10000));
});
}
// Taken from ChunkGeneratorAbstract
private final Map<StructureGenerator<? extends WorldGenFeatureConfiguration>, Long2ObjectMap<LongSet>> structureCache = Maps.newHashMap();
@Override
public Long2ObjectMap<LongSet> getStructureCache(StructureGenerator<? extends WorldGenFeatureConfiguration> structuregenerator) {
return (Long2ObjectMap) this.structureCache.computeIfAbsent(structuregenerator, (s) -> {
return Long2ObjectMaps.synchronize(new ExpiringMap(8192, 10000));
});
}
@Override
public WorldChunkManager getWorldChunkManager() {
return chunkManager;
}
@Override
public long getSeed() {
return seed;

View File

@@ -1,8 +1,13 @@
package org.bukkit.craftbukkit.generator;
import net.minecraft.server.GeneratorSettings;
import org.bukkit.generator.ChunkGenerator;
import net.minecraft.server.GeneratorAccess;
import net.minecraft.server.GeneratorSettingsDefault;
import net.minecraft.server.WorldChunkManager;
// Do not implement functions to this class, add to NormalChunkGenerator
public abstract class InternalChunkGenerator<C extends GeneratorSettings> extends ChunkGenerator implements net.minecraft.server.ChunkGenerator<C> {
public abstract class InternalChunkGenerator<C extends GeneratorSettingsDefault> extends net.minecraft.server.ChunkGenerator<C> {
public InternalChunkGenerator(GeneratorAccess generatorAccess, WorldChunkManager worldChunkManager, C c0) {
super(generatorAccess, worldChunkManager, c0);
}
}

View File

@@ -1,12 +0,0 @@
package org.bukkit.craftbukkit.generator;
import net.minecraft.server.World;
/**
* This class is useless. Just fyi.
*/
public class NetherChunkGenerator extends NormalChunkGenerator {
public NetherChunkGenerator(World world, long seed) {
super(world, seed);
}
}

View File

@@ -1,114 +0,0 @@
package org.bukkit.craftbukkit.generator;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.LongSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.server.*;
import org.bukkit.generator.BlockPopulator;
public class NormalChunkGenerator<C extends GeneratorSettings> extends InternalChunkGenerator<C> {
private final ChunkGenerator<?> generator;
public NormalChunkGenerator(World world, long seed) {
generator = world.worldProvider.getChunkGenerator();
}
@Override
public ChunkData generateChunkData(org.bukkit.World world, Random random, int x, int z, BiomeGrid biome) {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public boolean canSpawn(org.bukkit.World world, int x, int z) {
return true; // PAIL
}
@Override
public List<BlockPopulator> getDefaultPopulators(org.bukkit.World world) {
return new ArrayList<BlockPopulator>();
}
@Override
public List<BiomeBase.BiomeMeta> getMobsFor(EnumCreatureType enumCreatureType, BlockPosition blockPosition) {
return generator.getMobsFor(enumCreatureType, blockPosition);
}
@Override
public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition, int i, boolean flag) {
return generator.findNearestMapFeature(world, s, blockPosition, i, flag);
}
@Override
public void createChunk(IChunkAccess ichunkaccess) {
generator.createChunk(ichunkaccess);
}
@Override
public void addFeatures(RegionLimitedWorldAccess regionlimitedworldaccess, WorldGenStage.Features worldgenstage_features) {
generator.addFeatures(regionlimitedworldaccess, worldgenstage_features);
}
@Override
public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess) {
generator.addDecorations(regionlimitedworldaccess);
}
@Override
public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess) {
generator.addMobs(regionlimitedworldaccess);
}
@Override
public C getSettings() {
return (C) generator.getSettings();
}
@Override
public int a(World world, boolean flag, boolean flag1) {
return generator.a(world, flag, flag1);
}
@Override
public boolean canSpawnStructure(BiomeBase biomebase, StructureGenerator<? extends WorldGenFeatureConfiguration> structuregenerator) {
return generator.canSpawnStructure(biomebase, structuregenerator);
}
@Override
public WorldGenFeatureConfiguration getFeatureConfiguration(BiomeBase biomebase, StructureGenerator<? extends WorldGenFeatureConfiguration> structuregenerator) {
return generator.getFeatureConfiguration(biomebase, structuregenerator);
}
@Override
public Long2ObjectMap<StructureStart> getStructureStartCache(StructureGenerator<? extends WorldGenFeatureConfiguration> structuregenerator) {
return generator.getStructureStartCache(structuregenerator);
}
@Override
public Long2ObjectMap<LongSet> getStructureCache(StructureGenerator<? extends WorldGenFeatureConfiguration> structuregenerator) {
return generator.getStructureCache(structuregenerator);
}
@Override
public WorldChunkManager getWorldChunkManager() {
return generator.getWorldChunkManager();
}
@Override
public long getSeed() {
return generator.getSeed();
}
@Override
public int getSpawnHeight() {
return generator.getSpawnHeight();
}
@Override
public int getGenerationDepth() {
return generator.getGenerationDepth();
}
}

View File

@@ -1,12 +0,0 @@
package org.bukkit.craftbukkit.generator;
import net.minecraft.server.World;
/**
* This class is useless. Just fyi.
*/
public class SkyLandsChunkGenerator extends NormalChunkGenerator {
public SkyLandsChunkGenerator(World world, long seed) {
super(world, seed);
}
}

View File

@@ -0,0 +1,30 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.MinecraftServer;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.inventory.BlastingRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
public class CraftBlastingRecipe extends BlastingRecipe implements CraftRecipe {
public CraftBlastingRecipe(NamespacedKey key, ItemStack result, RecipeChoice source, float experience, int cookingTime) {
super(key, result, source, experience, cookingTime);
}
public static CraftBlastingRecipe fromBukkitRecipe(BlastingRecipe recipe) {
if (recipe instanceof CraftBlastingRecipe) {
return (CraftBlastingRecipe) recipe;
}
CraftBlastingRecipe ret = new CraftBlastingRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime());
ret.setGroup(recipe.getGroup());
return ret;
}
@Override
public void addToCraftingManager() {
ItemStack result = this.getResult();
MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.RecipeBlasting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
}
}

View File

@@ -0,0 +1,30 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.GeneratorAccess;
import net.minecraft.server.IInventory;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.Inventory;
public class CraftBlockInventoryHolder implements BlockInventoryHolder {
private final Block block;
private final Inventory inventory;
public CraftBlockInventoryHolder(GeneratorAccess world, BlockPosition pos, IInventory inv) {
this.block = CraftBlock.at(world, pos);
this.inventory = new CraftInventory(inv);
}
@Override
public Block getBlock() {
return block;
}
@Override
public Inventory getInventory() {
return inventory;
}
}

View File

@@ -0,0 +1,30 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.MinecraftServer;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.inventory.CampfireRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
public class CraftCampfireRecipe extends CampfireRecipe implements CraftRecipe {
public CraftCampfireRecipe(NamespacedKey key, ItemStack result, RecipeChoice source, float experience, int cookingTime) {
super(key, result, source, experience, cookingTime);
}
public static CraftCampfireRecipe fromBukkitRecipe(CampfireRecipe recipe) {
if (recipe instanceof CraftCampfireRecipe) {
return (CraftCampfireRecipe) recipe;
}
CraftCampfireRecipe ret = new CraftCampfireRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime());
ret.setGroup(recipe.getGroup());
return ret;
}
@Override
public void addToCraftingManager() {
ItemStack result = this.getResult();
MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.RecipeCampfire(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
}
}

View File

@@ -10,14 +10,23 @@ import org.bukkit.inventory.InventoryView;
import net.minecraft.server.Container;
import net.minecraft.server.ContainerAnvil;
import net.minecraft.server.ContainerBeacon;
import net.minecraft.server.ContainerBlastFurnace;
import net.minecraft.server.ContainerBrewingStand;
import net.minecraft.server.ContainerCartography;
import net.minecraft.server.ContainerChest;
import net.minecraft.server.ContainerDispenser;
import net.minecraft.server.ContainerEnchantTable;
import net.minecraft.server.ContainerFurnace;
import net.minecraft.server.ContainerFurnaceFurnace;
import net.minecraft.server.ContainerGrindstone;
import net.minecraft.server.ContainerHopper;
import net.minecraft.server.ContainerLectern;
import net.minecraft.server.ContainerLoom;
import net.minecraft.server.ContainerProperties;
import net.minecraft.server.ContainerShulkerBox;
import net.minecraft.server.ContainerSmoker;
import net.minecraft.server.ContainerStonecutter;
import net.minecraft.server.ContainerWorkbench;
import net.minecraft.server.Containers;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.IInventory;
import net.minecraft.server.ItemStack;
@@ -34,8 +43,8 @@ public class CraftContainer extends Container {
private final int cachedSize;
public CraftContainer(InventoryView view, EntityHuman player, int id) {
super(getNotchInventoryType(view.getType()), id);
this.view = view;
this.windowId = id;
// TODO: Do we need to check that it really is a CraftInventory?
IInventory top = ((CraftInventory) view.getTopInventory()).getInventory();
PlayerInventory bottom = (PlayerInventory) ((CraftInventory) view.getBottomInventory()).getInventory();
@@ -66,6 +75,11 @@ public class CraftContainer extends Container {
public InventoryType getType() {
return inventory.getType();
}
@Override
public String getTitle() {
return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle();
}
}, player, id);
}
@@ -91,7 +105,7 @@ public class CraftContainer extends Container {
cachedTitle = view.getTitle();
if (view.getPlayer() instanceof CraftPlayer) {
CraftPlayer player = (CraftPlayer) view.getPlayer();
String type = getNotchInventoryType(cachedType);
Containers type = getNotchInventoryType(cachedType);
IInventory top = ((CraftInventory) view.getTopInventory()).getInventory();
PlayerInventory bottom = (PlayerInventory) ((CraftInventory) view.getBottomInventory()).getInventory();
this.items.clear();
@@ -100,75 +114,112 @@ public class CraftContainer extends Container {
setupSlots(top, bottom, player.getHandle());
}
int size = getSize();
player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle)));
player.updateInventory();
}
return true;
}
public static String getNotchInventoryType(InventoryType type) {
public static Containers getNotchInventoryType(InventoryType type) {
switch (type) {
case WORKBENCH:
return "minecraft:crafting_table";
return Containers.CRAFTING;
case FURNACE:
return "minecraft:furnace";
return Containers.FURNACE;
case DISPENSER:
return "minecraft:dispenser";
return Containers.GENERIC_3X3;
case ENCHANTING:
return "minecraft:enchanting_table";
return Containers.ENCHANTMENT;
case BREWING:
return "minecraft:brewing_stand";
return Containers.BREWING_STAND;
case BEACON:
return "minecraft:beacon";
return Containers.BEACON;
case ANVIL:
return "minecraft:anvil";
return Containers.ANVIL;
case HOPPER:
return "minecraft:hopper";
return Containers.HOPPER;
case DROPPER:
return "minecraft:dropper";
return Containers.GENERIC_3X3;
case SHULKER_BOX:
return "minecraft:shulker_box";
return Containers.SHULKER_BOX;
case BLAST_FURNACE:
return Containers.BLAST_FURNACE;
case LECTERN:
return Containers.LECTERN;
case SMOKER:
return Containers.SMOKER;
case LOOM:
return Containers.LOOM;
case CARTOGRAPHY:
return Containers.CARTOGRAPHY;
case GRINDSTONE:
return Containers.GRINDSTONE;
case STONECUTTER:
return Containers.STONECUTTER;
default:
return "minecraft:chest";
return Containers.GENERIC_9X3;
}
}
private void setupSlots(IInventory top, PlayerInventory bottom, EntityHuman entityhuman) {
int windowId = -1;
switch (cachedType) {
case CREATIVE:
break; // TODO: This should be an error?
case PLAYER:
case CHEST:
delegate = new ContainerChest(bottom, top, entityhuman);
case BARREL:
delegate = new ContainerChest(Containers.GENERIC_9X3, windowId, bottom, top, 3);
break;
case DISPENSER:
case DROPPER:
delegate = new ContainerDispenser(bottom, top);
delegate = new ContainerDispenser(windowId, bottom, top);
break;
case FURNACE:
delegate = new ContainerFurnace(bottom, top);
delegate = new ContainerFurnaceFurnace(windowId, bottom, top, new ContainerProperties(4));
break;
case CRAFTING: // TODO: This should be an error?
case WORKBENCH:
setupWorkbench(top, bottom); // SPIGOT-3812 - manually set up slots so we can use the delegated inventory and not the automatically created one
break;
case ENCHANTING:
delegate = new ContainerEnchantTable(bottom, entityhuman.world, entityhuman.getChunkCoordinates());
delegate = new ContainerEnchantTable(windowId, bottom);
break;
case BREWING:
delegate = new ContainerBrewingStand(bottom, top);
delegate = new ContainerBrewingStand(windowId, bottom, top, new ContainerProperties(2));
break;
case HOPPER:
delegate = new ContainerHopper(bottom, top, entityhuman);
delegate = new ContainerHopper(windowId, bottom, top);
break;
case ANVIL:
delegate = new ContainerAnvil(bottom, entityhuman.world, entityhuman.getChunkCoordinates(), entityhuman);
delegate = new ContainerAnvil(windowId, bottom);
break;
case BEACON:
delegate = new ContainerBeacon(bottom, top);
delegate = new ContainerBeacon(windowId, bottom);
break;
case SHULKER_BOX:
delegate = new ContainerShulkerBox(bottom, top, entityhuman);
delegate = new ContainerShulkerBox(windowId, bottom, top);
break;
case BLAST_FURNACE:
delegate = new ContainerBlastFurnace(windowId, bottom, top, new ContainerProperties(4));
break;
case LECTERN:
delegate = new ContainerLectern(windowId, top, new ContainerProperties(1), bottom);
break;
case SMOKER:
delegate = new ContainerSmoker(windowId, bottom, top, new ContainerProperties(4));
break;
case LOOM:
delegate = new ContainerLoom(windowId, bottom);
break;
case CARTOGRAPHY:
delegate = new ContainerCartography(windowId, bottom);
break;
case GRINDSTONE:
delegate = new ContainerGrindstone(windowId, bottom);
break;
case STONECUTTER:
delegate = new ContainerStonecutter(windowId, bottom);
break;
}
@@ -179,7 +230,7 @@ public class CraftContainer extends Container {
// SPIGOT-4598 - we should still delegate the shift click handler
if (cachedType == InventoryType.WORKBENCH) {
delegate = new ContainerWorkbench(bottom, entityhuman.world, entityhuman.getChunkCoordinates());
delegate = new ContainerWorkbench(windowId, bottom);
}
}
@@ -217,4 +268,9 @@ public class CraftContainer extends Container {
public boolean canUse(EntityHuman entity) {
return true;
}
@Override
public Containers<?> getType() {
return getNotchInventoryType(cachedType);
}
}

View File

@@ -133,13 +133,13 @@ public final class CraftCustomTagTypeRegistry {
Primitive Arrays
*/
if (Objects.equals(byte[].class, type)) {
return createAdapter(byte[].class, NBTTagByteArray.class, array -> new NBTTagByteArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.c(), n.size()));
return createAdapter(byte[].class, NBTTagByteArray.class, array -> new NBTTagByteArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getBytes(), n.size()));
}
if (Objects.equals(int[].class, type)) {
return createAdapter(int[].class, NBTTagIntArray.class, array -> new NBTTagIntArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.d(), n.size()));
return createAdapter(int[].class, NBTTagIntArray.class, array -> new NBTTagIntArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getInts(), n.size()));
}
if (Objects.equals(long[].class, type)) {
return createAdapter(long[].class, NBTTagLongArray.class, array -> new NBTTagLongArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.d(), n.size()));
return createAdapter(long[].class, NBTTagLongArray.class, array -> new NBTTagLongArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getLongs(), n.size()));
}
/*

View File

@@ -25,6 +25,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe {
public void addToCraftingManager() {
ItemStack result = this.getResult();
MinecraftServer.getServer().getCraftingManager().a(new net.minecraft.server.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime()));
}
}

View File

@@ -10,12 +10,16 @@ import net.minecraft.server.InventoryCrafting;
import net.minecraft.server.InventoryEnderChest;
import net.minecraft.server.InventoryMerchant;
import net.minecraft.server.PlayerInventory;
import net.minecraft.server.TileEntityBarrel;
import net.minecraft.server.TileEntityBeacon;
import net.minecraft.server.TileEntityBlastFurnace;
import net.minecraft.server.TileEntityBrewingStand;
import net.minecraft.server.TileEntityDispenser;
import net.minecraft.server.TileEntityDropper;
import net.minecraft.server.TileEntityFurnace;
import net.minecraft.server.TileEntityLectern;
import net.minecraft.server.TileEntityShulkerBox;
import net.minecraft.server.TileEntitySmoker;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
@@ -43,10 +47,6 @@ public class CraftInventory implements Inventory {
return getInventory().getSize();
}
public String getName() {
return CraftChatMessage.fromComponent(getInventory().getDisplayName());
}
public ItemStack getItem(int index) {
net.minecraft.server.ItemStack item = getInventory().getItem(index);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
@@ -422,12 +422,8 @@ public class CraftInventory implements Inventory {
return this.inventory.getViewers();
}
public String getTitle() {
return getName();
}
public InventoryType getType() {
// Thanks to Droppers extending Dispensers, order is important.
// Thanks to Droppers extending Dispensers, Blast Furnaces & Smokers extending Furnace, order is important.
if (inventory instanceof InventoryCrafting) {
return inventory.getSize() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING;
} else if (inventory instanceof PlayerInventory) {
@@ -436,6 +432,10 @@ public class CraftInventory implements Inventory {
return InventoryType.DROPPER;
} else if (inventory instanceof TileEntityDispenser) {
return InventoryType.DISPENSER;
} else if (inventory instanceof TileEntityBlastFurnace) {
return InventoryType.BLAST_FURNACE;
} else if (inventory instanceof TileEntitySmoker) {
return InventoryType.SMOKER;
} else if (inventory instanceof TileEntityFurnace) {
return InventoryType.FURNACE;
} else if (this instanceof CraftInventoryEnchanting) {
@@ -456,6 +456,18 @@ public class CraftInventory implements Inventory {
return InventoryType.HOPPER;
} else if (inventory instanceof TileEntityShulkerBox) {
return InventoryType.SHULKER_BOX;
} else if (inventory instanceof TileEntityBarrel) {
return InventoryType.BARREL;
} else if (inventory instanceof TileEntityLectern) {
return InventoryType.LECTERN;
} else if (this instanceof CraftInventoryLoom) {
return InventoryType.LOOM;
} else if (this instanceof CraftInventoryCartography) {
return InventoryType.CARTOGRAPHY;
} else if (this instanceof CraftInventoryGrindstone) {
return InventoryType.GRINDSTONE;
} else if (this instanceof CraftInventoryStonecutter) {
return InventoryType.STONECUTTER;
} else {
return InventoryType.CHEST;
}

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