Upstream Paper
This commit is contained in:
34
src/main/java/org/bukkit/craftbukkit/CraftArt.java
Normal file
34
src/main/java/org/bukkit/craftbukkit/CraftArt.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import net.minecraft.server.IRegistry;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.Paintings;
|
||||
import org.bukkit.Art;
|
||||
|
||||
public class CraftArt {
|
||||
private static final BiMap<Paintings, Art> artwork;
|
||||
|
||||
static {
|
||||
ImmutableBiMap.Builder<Paintings, Art> artworkBuilder = ImmutableBiMap.builder();
|
||||
for (MinecraftKey key : IRegistry.MOTIVE.keySet()) {
|
||||
artworkBuilder.put(IRegistry.MOTIVE.get(key), Art.getByName(key.getKey()));
|
||||
}
|
||||
|
||||
artwork = artworkBuilder.build();
|
||||
}
|
||||
|
||||
public static Art NotchToBukkit(Paintings art) {
|
||||
Art bukkit = artwork.get(art);
|
||||
Preconditions.checkArgument(bukkit != null);
|
||||
return bukkit;
|
||||
}
|
||||
|
||||
public static Paintings BukkitToNotch(Art art) {
|
||||
Paintings nms = artwork.inverse().get(art);
|
||||
Preconditions.checkArgument(nms != null);
|
||||
return nms;
|
||||
}
|
||||
}
|
||||
305
src/main/java/org/bukkit/craftbukkit/CraftChunk.java
Normal file
305
src/main/java/org/bukkit/craftbukkit/CraftChunk.java
Normal file
@@ -0,0 +1,305 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Arrays;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
|
||||
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];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return worldServer.getWorld();
|
||||
}
|
||||
|
||||
public CraftWorld getCraftWorld() {
|
||||
return (CraftWorld) getWorld();
|
||||
}
|
||||
|
||||
public net.minecraft.server.Chunk getHandle() {
|
||||
net.minecraft.server.Chunk c = weakChunk.get();
|
||||
|
||||
if (c == null) {
|
||||
c = worldServer.getChunkAt(x, z);
|
||||
|
||||
weakChunk = new WeakReference<net.minecraft.server.Chunk>(c);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void breakLink() {
|
||||
weakChunk.clear();
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftChunk{" + "x=" + getX() + "z=" + getZ() + '}';
|
||||
}
|
||||
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
validateChunkCoordinates(x, y, z);
|
||||
|
||||
return new CraftBlock(worldServer, new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
|
||||
}
|
||||
|
||||
public Entity[] getEntities() {
|
||||
int count = 0, index = 0;
|
||||
net.minecraft.server.Chunk chunk = getHandle();
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
count += chunk.entitySlices[i].size();
|
||||
}
|
||||
|
||||
Entity[] entities = new Entity[count];
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
||||
for (Object obj : chunk.entitySlices[i].toArray()) {
|
||||
if (!(obj instanceof net.minecraft.server.Entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entities[index++] = ((net.minecraft.server.Entity) obj).getBukkitEntity();
|
||||
}
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
public BlockState[] getTileEntities() {
|
||||
return getTileEntities(true);
|
||||
}
|
||||
public BlockState[] getTileEntities(boolean useSnapshot) {
|
||||
// Paper end
|
||||
int index = 0;
|
||||
net.minecraft.server.Chunk chunk = getHandle();
|
||||
|
||||
BlockState[] entities = new BlockState[chunk.tileEntities.size()];
|
||||
|
||||
for (Object obj : chunk.tileEntities.keySet().toArray()) {
|
||||
if (!(obj instanceof BlockPosition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockPosition position = (BlockPosition) obj;
|
||||
entities[index++] = worldServer.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState(useSnapshot); // Paper
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return getWorld().isChunkLoaded(this);
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
return getWorld().loadChunk(getX(), getZ(), true);
|
||||
}
|
||||
|
||||
public boolean load(boolean generate) {
|
||||
return getWorld().loadChunk(getX(), getZ(), generate);
|
||||
}
|
||||
|
||||
public boolean unload() {
|
||||
return getWorld().unloadChunk(getX(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlimeChunk() {
|
||||
// 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk
|
||||
return SeededRandom.a(getX(), getZ(), getWorld().getSeed(), worldServer.spigotConfig.slimeSeed).nextInt(10) == 0;
|
||||
}
|
||||
|
||||
public boolean unload(boolean save) {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForceLoaded(boolean forced) {
|
||||
getWorld().setChunkForceLoaded(getX(), getZ(), forced);
|
||||
}
|
||||
|
||||
public ChunkSnapshot getChunkSnapshot() {
|
||||
return getChunkSnapshot(true, false, false);
|
||||
}
|
||||
|
||||
public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) {
|
||||
net.minecraft.server.Chunk chunk = getHandle();
|
||||
|
||||
ChunkSection[] cs = chunk.getSections();
|
||||
DataPaletteBlock[] sectionBlockIDs = new DataPaletteBlock[cs.length];
|
||||
byte[][] sectionSkyLights = new byte[cs.length][];
|
||||
byte[][] sectionEmitLights = new byte[cs.length][];
|
||||
boolean[] sectionEmpty = new boolean[cs.length];
|
||||
|
||||
for (int i = 0; i < cs.length; i++) {
|
||||
if (cs[i] == null) { // Section is empty?
|
||||
sectionBlockIDs[i] = emptyBlockIDs;
|
||||
sectionSkyLights[i] = emptySkyLight;
|
||||
sectionEmitLights[i] = emptyData;
|
||||
sectionEmpty[i] = true;
|
||||
} else { // Not empty
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
cs[i].getBlocks().b(data, "Spigot", "Magic");
|
||||
|
||||
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");
|
||||
|
||||
sectionBlockIDs[i] = blockids;
|
||||
|
||||
if (cs[i].getSkyLightArray() == null) {
|
||||
sectionSkyLights[i] = emptySkyLight;
|
||||
} else {
|
||||
sectionSkyLights[i] = new byte[2048];
|
||||
System.arraycopy(cs[i].getSkyLightArray().asBytes(), 0, sectionSkyLights[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());
|
||||
}
|
||||
|
||||
BiomeBase[] biome = null;
|
||||
double[] biomeTemp = null;
|
||||
|
||||
if (includeBiome || includeBiomeTempRain) {
|
||||
WorldChunkManager wcm = worldServer.getChunkProvider().getChunkGenerator().getWorldChunkManager();
|
||||
|
||||
if (includeBiome) {
|
||||
biome = new BiomeBase[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
biome[i] = chunk.getBiome(new BlockPosition(i & 0xF, 0, i >> 4));
|
||||
}
|
||||
}
|
||||
|
||||
if (includeBiomeTempRain) {
|
||||
biomeTemp = new double[256];
|
||||
float[] dat = getTemperatures(wcm, getX() << 4, getZ() << 4);
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
biomeTemp[i] = dat[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
World world = getWorld();
|
||||
return new CraftChunkSnapshot(getX(), getZ(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome, biomeTemp);
|
||||
}
|
||||
|
||||
public static ChunkSnapshot getEmptyChunkSnapshot(int x, int z, CraftWorld world, boolean includeBiome, boolean includeBiomeTempRain) {
|
||||
BiomeBase[] biome = null;
|
||||
double[] biomeTemp = null;
|
||||
|
||||
if (includeBiome || includeBiomeTempRain) {
|
||||
WorldChunkManager wcm = world.getHandle().getChunkProvider().getChunkGenerator().getWorldChunkManager();
|
||||
|
||||
if (includeBiome) {
|
||||
biome = new BiomeBase[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
biome[i] = world.getHandle().getBiome(new BlockPosition((x << 4) + (i & 0xF), 0, (z << 4) + (i >> 4)));
|
||||
}
|
||||
}
|
||||
|
||||
if (includeBiomeTempRain) {
|
||||
biomeTemp = new double[256];
|
||||
float[] dat = getTemperatures(wcm, x << 4, z << 4);
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
biomeTemp[i] = dat[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fill with empty data */
|
||||
int hSection = world.getMaxHeight() >> 4;
|
||||
DataPaletteBlock[] blockIDs = new DataPaletteBlock[hSection];
|
||||
byte[][] skyLight = new byte[hSection][];
|
||||
byte[][] emitLight = new byte[hSection][];
|
||||
boolean[] empty = new boolean[hSection];
|
||||
|
||||
for (int i = 0; i < hSection; i++) {
|
||||
blockIDs[i] = emptyBlockIDs;
|
||||
skyLight[i] = emptySkyLight;
|
||||
emitLight[i] = emptyData;
|
||||
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);
|
||||
}
|
||||
|
||||
private static float[] getTemperatures(WorldChunkManager chunkmanager, int chunkX, int chunkZ) {
|
||||
BiomeBase[] biomes = chunkmanager.getBiomes(chunkX, chunkZ, 16, 16);
|
||||
float[] temps = new float[biomes.length];
|
||||
|
||||
for (int i = 0; i < biomes.length; i++) {
|
||||
float temp = biomes[i].getTemperature(); // Vanilla of olde: ((int) biomes[i].temperature * 65536.0F) / 65536.0F
|
||||
|
||||
if (temp > 1F) {
|
||||
temp = 1F;
|
||||
}
|
||||
|
||||
temps[i] = temp;
|
||||
}
|
||||
|
||||
return temps;
|
||||
}
|
||||
|
||||
static void validateChunkCoordinates(int x, int y, int z) {
|
||||
Preconditions.checkArgument(0 <= x && x <= 15, "x out of range (expected 0-15, got %s)", x);
|
||||
Preconditions.checkArgument(0 <= y && y <= 255, "y out of range (expected 0-255, got %s)", y);
|
||||
Preconditions.checkArgument(0 <= z && z <= 15, "z out of range (expected 0-15, got %s)", z);
|
||||
}
|
||||
|
||||
static {
|
||||
Arrays.fill(emptySkyLight, (byte) 0xFF);
|
||||
}
|
||||
}
|
||||
119
src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
Normal file
119
src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
import net.minecraft.server.BiomeBase;
|
||||
import net.minecraft.server.DataPaletteBlock;
|
||||
import net.minecraft.server.HeightMap;
|
||||
import net.minecraft.server.IBlockData;
|
||||
|
||||
/**
|
||||
* Represents a static, thread-safe snapshot of chunk of blocks
|
||||
* Purpose is to allow clean, efficient copy of a chunk data to be made, and then handed off for processing in another thread (e.g. map rendering)
|
||||
*/
|
||||
public class CraftChunkSnapshot implements ChunkSnapshot {
|
||||
private final int x, z;
|
||||
private final String worldname;
|
||||
private final DataPaletteBlock<IBlockData>[] blockids;
|
||||
private final byte[][] skylight;
|
||||
private final byte[][] emitlight;
|
||||
private final boolean[] empty;
|
||||
private final HeightMap hmap; // Height map
|
||||
private final long captureFulltime;
|
||||
private final BiomeBase[] biome;
|
||||
private final double[] biomeTemp;
|
||||
|
||||
CraftChunkSnapshot(int x, int z, String wname, long wtime, DataPaletteBlock<IBlockData>[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, BiomeBase[] biome, double[] biomeTemp) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.worldname = wname;
|
||||
this.captureFulltime = wtime;
|
||||
this.blockids = sectionBlockIDs;
|
||||
this.skylight = sectionSkyLights;
|
||||
this.emitlight = sectionEmitLights;
|
||||
this.empty = sectionEmpty;
|
||||
this.hmap = hmap;
|
||||
this.biome = biome;
|
||||
this.biomeTemp = biomeTemp;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return worldname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getBlockType(int x, int y, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, y, z);
|
||||
|
||||
return CraftMagicNumbers.getMaterial(blockids[y >> 4].a(x, y & 0xF, z).getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BlockData getBlockData(int x, int y, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, y, z);
|
||||
|
||||
return CraftBlockData.fromData(blockids[y >> 4].a(x, y & 0xF, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getData(int x, int y, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, y, z);
|
||||
|
||||
return CraftMagicNumbers.toLegacyData(blockids[y >> 4].a(x, y & 0xF, z));
|
||||
}
|
||||
|
||||
public final int getBlockSkyLight(int x, int y, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, y, z);
|
||||
|
||||
int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1);
|
||||
return (skylight[y >> 4][off] >> ((x & 1) << 2)) & 0xF;
|
||||
}
|
||||
|
||||
public final int getBlockEmittedLight(int x, int y, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, y, z);
|
||||
|
||||
int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1);
|
||||
return (emitlight[y >> 4][off] >> ((x & 1) << 2)) & 0xF;
|
||||
}
|
||||
|
||||
public final int getHighestBlockYAt(int x, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, 0, z);
|
||||
|
||||
return hmap.a(x, z);
|
||||
}
|
||||
|
||||
public final Biome getBiome(int x, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, 0, z);
|
||||
|
||||
return CraftBlock.biomeBaseToBiome(biome[z << 4 | x]);
|
||||
}
|
||||
|
||||
public final double getRawBiomeTemperature(int x, int z) {
|
||||
CraftChunk.validateChunkCoordinates(x, 0, z);
|
||||
|
||||
return biomeTemp[z << 4 | x];
|
||||
}
|
||||
|
||||
public final long getCaptureFullTime() {
|
||||
return captureFulltime;
|
||||
}
|
||||
|
||||
public final boolean isSectionEmpty(int sy) {
|
||||
return empty[sy];
|
||||
}
|
||||
}
|
||||
45
src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java
Normal file
45
src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import net.minecraft.server.CrashReportCallable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public class CraftCrashReport implements CrashReportCallable<Object> {
|
||||
|
||||
public Object call() throws Exception {
|
||||
StringWriter value = new StringWriter();
|
||||
try {
|
||||
value.append("\n Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(MinecraftServer.getServer().getOnlineMode()));
|
||||
value.append("\n Plugins: {");
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
boolean legacy = CraftMagicNumbers.isLegacy(description);
|
||||
value.append(' ').append(description.getFullName()).append(legacy ? "*" : "").append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(',');
|
||||
}
|
||||
value.append("}\n Warnings: ").append(Bukkit.getWarningState().name());
|
||||
value.append("\n Reload Count: ").append(String.valueOf(MinecraftServer.getServer().server.reloadCount));
|
||||
value.append("\n Threads: {");
|
||||
for (Map.Entry<Thread, ? extends Object[]> entry : Thread.getAllStackTraces().entrySet()) {
|
||||
value.append(' ').append(entry.getKey().getState().name()).append(' ').append(entry.getKey().getName()).append(": ").append(Arrays.toString(entry.getValue())).append(',');
|
||||
}
|
||||
value.append("}\n ").append(Bukkit.getScheduler().toString());
|
||||
} catch (Throwable t) {
|
||||
value.append("\n Failed to handle CraftCrashReport:\n");
|
||||
PrintWriter writer = new PrintWriter(value);
|
||||
t.printStackTrace(writer);
|
||||
writer.flush();
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
}
|
||||
69
src/main/java/org/bukkit/craftbukkit/CraftEffect.java
Normal file
69
src/main/java/org/bukkit/craftbukkit/CraftEffect.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.Item;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.potion.Potion;
|
||||
|
||||
public class CraftEffect {
|
||||
public static <T> int getDataValue(Effect effect, T data) {
|
||||
int datavalue;
|
||||
switch(effect) {
|
||||
case VILLAGER_PLANT_GROW:
|
||||
datavalue = (Integer) data;
|
||||
break;
|
||||
case POTION_BREAK:
|
||||
datavalue = ((Potion) data).toDamageValue() & 0x3F;
|
||||
break;
|
||||
case RECORD_PLAY:
|
||||
Validate.isTrue(((Material) data).isRecord(), "Invalid record type!");
|
||||
datavalue = Item.getId(CraftMagicNumbers.getItem((Material) data));
|
||||
break;
|
||||
case SMOKE:
|
||||
switch((BlockFace) data) { // TODO: Verify (Where did these values come from...?)
|
||||
case SOUTH_EAST:
|
||||
datavalue = 0;
|
||||
break;
|
||||
case SOUTH:
|
||||
datavalue = 1;
|
||||
break;
|
||||
case SOUTH_WEST:
|
||||
datavalue = 2;
|
||||
break;
|
||||
case EAST:
|
||||
datavalue = 3;
|
||||
break;
|
||||
case UP:
|
||||
case SELF:
|
||||
datavalue = 4;
|
||||
break;
|
||||
case WEST:
|
||||
datavalue = 5;
|
||||
break;
|
||||
case NORTH_EAST:
|
||||
datavalue = 6;
|
||||
break;
|
||||
case NORTH:
|
||||
datavalue = 7;
|
||||
break;
|
||||
case NORTH_WEST:
|
||||
datavalue = 8;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Bad smoke direction!");
|
||||
}
|
||||
break;
|
||||
case STEP_SOUND:
|
||||
Validate.isTrue(((Material) data).isBlock(), "Material is not a block!");
|
||||
datavalue = Block.getCombinedId(CraftMagicNumbers.getBlock((Material) data).getBlockData());
|
||||
break;
|
||||
default:
|
||||
datavalue = 0;
|
||||
}
|
||||
return datavalue;
|
||||
}
|
||||
}
|
||||
32
src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java
Normal file
32
src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.EnumItemSlot;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
public class CraftEquipmentSlot {
|
||||
|
||||
private static final EnumItemSlot[] slots = new EnumItemSlot[EquipmentSlot.values().length];
|
||||
private static final EquipmentSlot[] enums = new EquipmentSlot[EnumItemSlot.values().length];
|
||||
|
||||
static {
|
||||
set(EquipmentSlot.HAND, EnumItemSlot.MAINHAND);
|
||||
set(EquipmentSlot.OFF_HAND, EnumItemSlot.OFFHAND);
|
||||
set(EquipmentSlot.FEET, EnumItemSlot.FEET);
|
||||
set(EquipmentSlot.LEGS, EnumItemSlot.LEGS);
|
||||
set(EquipmentSlot.CHEST, EnumItemSlot.CHEST);
|
||||
set(EquipmentSlot.HEAD, EnumItemSlot.HEAD);
|
||||
}
|
||||
|
||||
private static void set(EquipmentSlot type, EnumItemSlot value) {
|
||||
slots[type.ordinal()] = value;
|
||||
enums[value.ordinal()] = type;
|
||||
}
|
||||
|
||||
public static EquipmentSlot getSlot(EnumItemSlot nms) {
|
||||
return enums[nms.ordinal()];
|
||||
}
|
||||
|
||||
public static EnumItemSlot getNMS(EquipmentSlot slot) {
|
||||
return slots[slot.ordinal()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import net.minecraft.server.FluidCollisionOption;
|
||||
|
||||
public class CraftFluidCollisionMode {
|
||||
|
||||
private CraftFluidCollisionMode() {}
|
||||
|
||||
public static FluidCollisionOption toNMS(FluidCollisionMode fluidCollisionMode) {
|
||||
if (fluidCollisionMode == null) return null;
|
||||
|
||||
switch (fluidCollisionMode) {
|
||||
case ALWAYS:
|
||||
return FluidCollisionOption.ALWAYS;
|
||||
case SOURCE_ONLY:
|
||||
return FluidCollisionOption.SOURCE_ONLY;
|
||||
case NEVER:
|
||||
return FluidCollisionOption.NEVER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
88
src/main/java/org/bukkit/craftbukkit/CraftIpBanEntry.java
Normal file
88
src/main/java/org/bukkit/craftbukkit/CraftIpBanEntry.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.IpBanEntry;
|
||||
import net.minecraft.server.IpBanList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public final class CraftIpBanEntry implements org.bukkit.BanEntry {
|
||||
private final IpBanList list;
|
||||
private final String target;
|
||||
private Date created;
|
||||
private String source;
|
||||
private Date expiration;
|
||||
private String reason;
|
||||
|
||||
public CraftIpBanEntry(String target, IpBanEntry entry, IpBanList list) {
|
||||
this.list = list;
|
||||
this.target = target;
|
||||
this.created = entry.getCreated() != null ? new Date(entry.getCreated().getTime()) : null;
|
||||
this.source = entry.getSource();
|
||||
this.expiration = entry.getExpires() != null ? new Date(entry.getExpires().getTime()) : null;
|
||||
this.reason = entry.getReason();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return this.created == null ? null : (Date) this.created.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getExpiration() {
|
||||
return this.expiration == null ? null : (Date) this.expiration.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpiration(Date expiration) {
|
||||
if (expiration != null && expiration.getTime() == new Date(0, 0, 0, 0, 0, 0).getTime()) {
|
||||
expiration = null; // Forces "forever"
|
||||
}
|
||||
|
||||
this.expiration = expiration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReason() {
|
||||
return this.reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
IpBanEntry entry = new IpBanEntry(target, this.created, this.source, this.expiration, this.reason);
|
||||
this.list.add(entry);
|
||||
try {
|
||||
this.list.save();
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to save banned-ips.json, {0}", ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
79
src/main/java/org/bukkit/craftbukkit/CraftIpBanList.java
Normal file
79
src/main/java/org/bukkit/craftbukkit/CraftIpBanList.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.IpBanEntry;
|
||||
import net.minecraft.server.IpBanList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CraftIpBanList implements org.bukkit.BanList {
|
||||
private final IpBanList list;
|
||||
|
||||
public CraftIpBanList(IpBanList list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.BanEntry getBanEntry(String target) {
|
||||
Validate.notNull(target, "Target cannot be null");
|
||||
|
||||
IpBanEntry entry = (IpBanEntry) list.get(target);
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CraftIpBanEntry(target, entry, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) {
|
||||
Validate.notNull(target, "Ban target cannot be null");
|
||||
|
||||
IpBanEntry entry = new IpBanEntry(target, new Date(),
|
||||
StringUtils.isBlank(source) ? null : source, expires,
|
||||
StringUtils.isBlank(reason) ? null : reason);
|
||||
|
||||
list.add(entry);
|
||||
|
||||
try {
|
||||
list.save();
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to save banned-ips.json, {0}", ex.getMessage());
|
||||
}
|
||||
|
||||
return new CraftIpBanEntry(target, entry, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<org.bukkit.BanEntry> getBanEntries() {
|
||||
ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder();
|
||||
for (String target : list.getEntries()) {
|
||||
builder.add(new CraftIpBanEntry(target, (IpBanEntry) list.get(target), list));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned(String target) {
|
||||
Validate.notNull(target, "Target cannot be null");
|
||||
|
||||
return list.isBanned(InetSocketAddress.createUnresolved(target, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pardon(String target) {
|
||||
Validate.notNull(target, "Target cannot be null");
|
||||
|
||||
list.remove(target);
|
||||
}
|
||||
}
|
||||
108
src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
Normal file
108
src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.DamageSource;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.IInventory;
|
||||
import net.minecraft.server.LootTable;
|
||||
import net.minecraft.server.LootTableInfo;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.loot.LootContext;
|
||||
|
||||
public class CraftLootTable implements org.bukkit.loot.LootTable {
|
||||
|
||||
private final LootTable handle;
|
||||
private final NamespacedKey key;
|
||||
|
||||
public CraftLootTable(NamespacedKey key, LootTable handle) {
|
||||
this.handle = handle;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public LootTable getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
|
||||
LootTableInfo nmsContext = convertContext(context);
|
||||
List<net.minecraft.server.ItemStack> nmsItems = handle.populateLoot(random, nmsContext);
|
||||
Collection<ItemStack> bukkit = new ArrayList<>(nmsItems.size());
|
||||
|
||||
for (net.minecraft.server.ItemStack item : nmsItems) {
|
||||
if (item.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
bukkit.add(CraftItemStack.asBukkitCopy(item));
|
||||
}
|
||||
|
||||
return bukkit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInventory(Inventory inventory, Random random, LootContext context) {
|
||||
LootTableInfo nmsContext = convertContext(context);
|
||||
CraftInventory craftInventory = (CraftInventory) inventory;
|
||||
IInventory handle = craftInventory.getInventory();
|
||||
|
||||
// TODO: When events are added, call event here w/ custom reason?
|
||||
getHandle().fillInventory(handle, random, nmsContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
private LootTableInfo convertContext(LootContext context) {
|
||||
Location loc = context.getLocation();
|
||||
WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle();
|
||||
|
||||
LootTableInfo.Builder builder = new LootTableInfo.Builder(handle);
|
||||
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));
|
||||
}
|
||||
|
||||
if (context.getKiller() != null) {
|
||||
EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle();
|
||||
builder.killer(nmsKiller);
|
||||
// If there is a player killer, damage source should reflect that in case loot tables use that information
|
||||
builder.damageSource(DamageSource.playerAttack(nmsKiller));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getKey().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof org.bukkit.loot.LootTable)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
org.bukkit.loot.LootTable table = (org.bukkit.loot.LootTable) obj;
|
||||
return table.getKey().equals(this.getKey());
|
||||
}
|
||||
}
|
||||
332
src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
Normal file
332
src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
Normal file
@@ -0,0 +1,332 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.server.DimensionManager;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.WhiteListEntry;
|
||||
import net.minecraft.server.WorldNBTStorage;
|
||||
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@SerializableAs("Player")
|
||||
public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializable {
|
||||
private final GameProfile profile;
|
||||
private final CraftServer server;
|
||||
private WorldNBTStorage storage; // Paper - lazy init
|
||||
|
||||
protected CraftOfflinePlayer(CraftServer server, GameProfile profile) {
|
||||
this.server = server;
|
||||
this.profile = profile;
|
||||
//this.storage = (WorldNBTStorage) (server.console.getWorldServer(DimensionManager.OVERWORLD).getDataManager()); // Paper - lazy init
|
||||
|
||||
}
|
||||
|
||||
public GameProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
return getPlayer() != null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
// This might not match lastKnownName but if not it should be more correct
|
||||
if (profile.getName() != null) {
|
||||
return profile.getName();
|
||||
}
|
||||
|
||||
NBTTagCompound data = getBukkitData();
|
||||
|
||||
if (data != null) {
|
||||
if (data.hasKey("lastKnownName")) {
|
||||
return data.getString("lastKnownName");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return profile.getId();
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public boolean isOp() {
|
||||
return server.getHandle().isOp(profile);
|
||||
}
|
||||
|
||||
public void setOp(boolean value) {
|
||||
if (value == isOp()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
server.getHandle().addOp(profile);
|
||||
} else {
|
||||
server.getHandle().removeOp(profile);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBanned() {
|
||||
if (getName() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return server.getBanList(BanList.Type.NAME).isBanned(getName());
|
||||
}
|
||||
|
||||
public void setBanned(boolean value) {
|
||||
if (getName() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
server.getBanList(BanList.Type.NAME).addBan(getName(), null, null, null);
|
||||
} else {
|
||||
server.getBanList(BanList.Type.NAME).pardon(getName());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWhitelisted() {
|
||||
return server.getHandle().getWhitelist().isWhitelisted(profile);
|
||||
}
|
||||
|
||||
public void setWhitelisted(boolean value) {
|
||||
if (value) {
|
||||
server.getHandle().getWhitelist().add(new WhiteListEntry(profile));
|
||||
} else {
|
||||
server.getHandle().getWhitelist().remove(profile);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
|
||||
result.put("UUID", profile.getId().toString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static OfflinePlayer deserialize(Map<String, Object> args) {
|
||||
// Backwards comparability
|
||||
if (args.get("name") != null) {
|
||||
return Bukkit.getServer().getOfflinePlayer((String) args.get("name"));
|
||||
}
|
||||
|
||||
return Bukkit.getServer().getOfflinePlayer(UUID.fromString((String) args.get("UUID")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "[UUID=" + profile.getId() + "]";
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return server.getPlayer(getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof OfflinePlayer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OfflinePlayer other = (OfflinePlayer) obj;
|
||||
if ((this.getUniqueId() == null) || (other.getUniqueId() == null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.getUniqueId().equals(other.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 97 * hash + (this.getUniqueId() != null ? this.getUniqueId().hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Paper - lazy
|
||||
private WorldNBTStorage getStorageLazy() {
|
||||
if (this.storage == null) {
|
||||
net.minecraft.server.WorldServer worldServer = server.console.getWorldServer(DimensionManager.OVERWORLD);
|
||||
if (worldServer == null) {
|
||||
throw new IllegalStateException("Cannot get world storage when there are no worlds loaded!");
|
||||
} else {
|
||||
this.storage = (WorldNBTStorage) worldServer.getDataManager();
|
||||
}
|
||||
}
|
||||
|
||||
return this.storage;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
private NBTTagCompound getData() {
|
||||
return getStorageLazy().getPlayerData(getUniqueId().toString());
|
||||
}
|
||||
|
||||
private NBTTagCompound getBukkitData() {
|
||||
NBTTagCompound result = getData();
|
||||
|
||||
if (result != null) {
|
||||
if (!result.hasKey("bukkit")) {
|
||||
result.set("bukkit", new NBTTagCompound());
|
||||
}
|
||||
result = result.getCompound("bukkit");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private File getDataFile() {
|
||||
return new File(getStorageLazy().getPlayerDir(), getUniqueId() + ".dat");
|
||||
}
|
||||
|
||||
public long getFirstPlayed() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) return player.getFirstPlayed();
|
||||
|
||||
NBTTagCompound data = getBukkitData();
|
||||
|
||||
if (data != null) {
|
||||
if (data.hasKey("firstPlayed")) {
|
||||
return data.getLong("firstPlayed");
|
||||
} else {
|
||||
File file = getDataFile();
|
||||
return file.lastModified();
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public long getLastPlayed() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) return player.getLastPlayed();
|
||||
|
||||
NBTTagCompound data = getBukkitData();
|
||||
|
||||
if (data != null) {
|
||||
if (data.hasKey("lastPlayed")) {
|
||||
return data.getLong("lastPlayed");
|
||||
} else {
|
||||
File file = getDataFile();
|
||||
return file.lastModified();
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPlayedBefore() {
|
||||
return getData() != null;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public long getLastLogin() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) return player.getLastLogin();
|
||||
|
||||
NBTTagCompound data = getPaperData();
|
||||
|
||||
if (data != null) {
|
||||
if (data.hasKey("LastLogin")) {
|
||||
return data.getLong("LastLogin");
|
||||
} else {
|
||||
// if the player file cannot provide accurate data, this is probably the closest we can approximate
|
||||
File file = getDataFile();
|
||||
return file.lastModified();
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastSeen() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) return player.getLastSeen();
|
||||
|
||||
NBTTagCompound data = getPaperData();
|
||||
|
||||
if (data != null) {
|
||||
if (data.hasKey("LastSeen")) {
|
||||
return data.getLong("LastSeen");
|
||||
} else {
|
||||
// if the player file cannot provide accurate data, this is probably the closest we can approximate
|
||||
File file = getDataFile();
|
||||
return file.lastModified();
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private NBTTagCompound getPaperData() {
|
||||
NBTTagCompound result = getData();
|
||||
|
||||
if (result != null) {
|
||||
if (!result.hasKey("Paper")) {
|
||||
result.set("Paper", new NBTTagCompound());
|
||||
}
|
||||
result = result.getCompound("Paper");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public Location getBedSpawnLocation() {
|
||||
NBTTagCompound data = getData();
|
||||
if (data == null) return null;
|
||||
|
||||
if (data.hasKey("SpawnX") && data.hasKey("SpawnY") && data.hasKey("SpawnZ")) {
|
||||
String spawnWorld = data.getString("SpawnWorld");
|
||||
if (spawnWorld.equals("")) {
|
||||
spawnWorld = server.getWorlds().get(0).getName();
|
||||
}
|
||||
return new Location(server.getWorld(spawnWorld), data.getInt("SpawnX"), data.getInt("SpawnY"), data.getInt("SpawnZ"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMetadata(String metadataKey, MetadataValue metadataValue) {
|
||||
server.getPlayerMetadata().setMetadata(this, metadataKey, metadataValue);
|
||||
}
|
||||
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
return server.getPlayerMetadata().getMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
return server.getPlayerMetadata().hasMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
public void removeMetadata(String metadataKey, Plugin plugin) {
|
||||
server.getPlayerMetadata().removeMetadata(this, metadataKey, plugin);
|
||||
}
|
||||
}
|
||||
152
src/main/java/org/bukkit/craftbukkit/CraftParticle.java
Normal file
152
src/main/java/org/bukkit/craftbukkit/CraftParticle.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.server.IRegistry;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.ParticleParam;
|
||||
import net.minecraft.server.ParticleParamBlock;
|
||||
import net.minecraft.server.ParticleParamItem;
|
||||
import net.minecraft.server.ParticleParamRedstone;
|
||||
import net.minecraft.server.ParticleType;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
public enum CraftParticle {
|
||||
|
||||
EXPLOSION_NORMAL("poof"),
|
||||
EXPLOSION_LARGE("explosion"),
|
||||
EXPLOSION_HUGE("explosion_emitter"),
|
||||
FIREWORKS_SPARK("firework"),
|
||||
WATER_BUBBLE("bubble"),
|
||||
WATER_SPLASH("splash"),
|
||||
WATER_WAKE("fishing"),
|
||||
SUSPENDED("underwater"),
|
||||
SUSPENDED_DEPTH("underwater"),
|
||||
CRIT("crit"),
|
||||
CRIT_MAGIC("enchanted_hit"),
|
||||
SMOKE_NORMAL("smoke"),
|
||||
SMOKE_LARGE("large_smoke"),
|
||||
SPELL("effect"),
|
||||
SPELL_INSTANT("instant_effect"),
|
||||
SPELL_MOB("entity_effect"),
|
||||
SPELL_MOB_AMBIENT("ambient_entity_effect"),
|
||||
SPELL_WITCH("witch"),
|
||||
DRIP_WATER("dripping_water"),
|
||||
DRIP_LAVA("dripping_lava"),
|
||||
VILLAGER_ANGRY("angry_villager"),
|
||||
VILLAGER_HAPPY("happy_villager"),
|
||||
TOWN_AURA("mycelium"),
|
||||
NOTE("note"),
|
||||
PORTAL("portal"),
|
||||
ENCHANTMENT_TABLE("enchant"),
|
||||
FLAME("flame"),
|
||||
LAVA("lava"),
|
||||
CLOUD("cloud"),
|
||||
REDSTONE("dust"),
|
||||
SNOWBALL("item_snowball"),
|
||||
SNOW_SHOVEL("item_snowball"),
|
||||
SLIME("item_slime"),
|
||||
HEART("heart"),
|
||||
BARRIER("barrier"),
|
||||
ITEM_CRACK("item"),
|
||||
BLOCK_CRACK("block"),
|
||||
BLOCK_DUST("block"),
|
||||
WATER_DROP("rain"),
|
||||
MOB_APPEARANCE("elder_guardian"),
|
||||
DRAGON_BREATH("dragon_breath"),
|
||||
END_ROD("end_rod"),
|
||||
DAMAGE_INDICATOR("damage_indicator"),
|
||||
SWEEP_ATTACK("sweep_attack"),
|
||||
FALLING_DUST("falling_dust"),
|
||||
TOTEM("totem_of_undying"),
|
||||
SPIT("spit"),
|
||||
SQUID_INK("squid_ink"),
|
||||
BUBBLE_POP("bubble_pop"),
|
||||
CURRENT_DOWN("current_down"),
|
||||
BUBBLE_COLUMN_UP("bubble_column_up"),
|
||||
NAUTILUS("nautilus"),
|
||||
DOLPHIN("dolphin"),
|
||||
// ----- Legacy Separator -----
|
||||
LEGACY_BLOCK_CRACK("block"),
|
||||
LEGACY_BLOCK_DUST("block"),
|
||||
LEGACY_FALLING_DUST("falling_dust");
|
||||
private final MinecraftKey minecraftKey;
|
||||
private final Particle bukkit;
|
||||
private static final BiMap<Particle, MinecraftKey> particles;
|
||||
private static final Map<Particle, Particle> aliases;
|
||||
|
||||
static {
|
||||
particles = HashBiMap.create();
|
||||
aliases = new HashMap<>();
|
||||
|
||||
for (CraftParticle particle : CraftParticle.values()) {
|
||||
if (particles.containsValue(particle.minecraftKey)) {
|
||||
aliases.put(particle.bukkit, particles.inverse().get(particle.minecraftKey));
|
||||
} else {
|
||||
particles.put(particle.bukkit, particle.minecraftKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CraftParticle(String minecraftKey) {
|
||||
this.minecraftKey = new MinecraftKey(minecraftKey);
|
||||
|
||||
this.bukkit = Particle.valueOf(this.name());
|
||||
Preconditions.checkState(bukkit != null, "Bukkit particle %s does not exist", this.name());
|
||||
}
|
||||
|
||||
public static ParticleParam toNMS(Particle bukkit) {
|
||||
return toNMS(bukkit, null);
|
||||
}
|
||||
|
||||
public static <T> ParticleParam toNMS(Particle particle, T obj) {
|
||||
Particle canonical = particle;
|
||||
if (aliases.containsKey(particle)) {
|
||||
canonical = aliases.get(particle);
|
||||
}
|
||||
|
||||
net.minecraft.server.Particle nms = IRegistry.PARTICLE_TYPE.get(particles.get(canonical));
|
||||
Preconditions.checkArgument(nms != null, "No NMS particle %s", particle);
|
||||
|
||||
if (particle.getDataType().equals(Void.class)) {
|
||||
return (ParticleType) nms;
|
||||
}
|
||||
Preconditions.checkArgument(obj != null, "Particle %s requires data, null provided", particle);
|
||||
if (particle.getDataType().equals(ItemStack.class)) {
|
||||
ItemStack itemStack = (ItemStack) obj;
|
||||
return new ParticleParamItem((net.minecraft.server.Particle<ParticleParamItem>) nms, CraftItemStack.asNMSCopy(itemStack));
|
||||
}
|
||||
if (particle.getDataType() == MaterialData.class) {
|
||||
MaterialData data = (MaterialData) obj;
|
||||
return new ParticleParamBlock((net.minecraft.server.Particle<ParticleParamBlock>) nms, CraftMagicNumbers.getBlock(data));
|
||||
}
|
||||
if (particle.getDataType() == BlockData.class) {
|
||||
BlockData data = (BlockData) obj;
|
||||
return new ParticleParamBlock((net.minecraft.server.Particle<ParticleParamBlock>) nms, ((CraftBlockData) data).getState());
|
||||
}
|
||||
if (particle.getDataType() == Particle.DustOptions.class) {
|
||||
Particle.DustOptions data = (Particle.DustOptions) obj;
|
||||
Color color = data.getColor();
|
||||
return new ParticleParamRedstone(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, data.getSize());
|
||||
}
|
||||
throw new IllegalArgumentException(particle.getDataType().toString());
|
||||
}
|
||||
|
||||
public static Particle toBukkit(net.minecraft.server.ParticleParam nms) {
|
||||
return toBukkit(nms.b());
|
||||
}
|
||||
|
||||
public static Particle toBukkit(net.minecraft.server.Particle nms) {
|
||||
return particles.inverse().get(nms.d());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.GameProfileBanEntry;
|
||||
import net.minecraft.server.GameProfileBanList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public final class CraftProfileBanEntry implements org.bukkit.BanEntry {
|
||||
private final GameProfileBanList list;
|
||||
private final GameProfile profile;
|
||||
private Date created;
|
||||
private String source;
|
||||
private Date expiration;
|
||||
private String reason;
|
||||
|
||||
public CraftProfileBanEntry(GameProfile profile, GameProfileBanEntry entry, GameProfileBanList list) {
|
||||
this.list = list;
|
||||
this.profile = profile;
|
||||
this.created = entry.getCreated() != null ? new Date(entry.getCreated().getTime()) : null;
|
||||
this.source = entry.getSource();
|
||||
this.expiration = entry.getExpires() != null ? new Date(entry.getExpires().getTime()) : null;
|
||||
this.reason = entry.getReason();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTarget() {
|
||||
return this.profile.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreated() {
|
||||
return this.created == null ? null : (Date) this.created.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getExpiration() {
|
||||
return this.expiration == null ? null : (Date) this.expiration.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpiration(Date expiration) {
|
||||
if (expiration != null && expiration.getTime() == new Date(0, 0, 0, 0, 0, 0).getTime()) {
|
||||
expiration = null; // Forces "forever"
|
||||
}
|
||||
|
||||
this.expiration = expiration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReason() {
|
||||
return this.reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
GameProfileBanEntry entry = new GameProfileBanEntry(profile, this.created, this.source, this.expiration, this.reason);
|
||||
this.list.add(entry);
|
||||
try {
|
||||
this.list.save();
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to save banned-players.json, {0}", ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.GameProfileBanEntry;
|
||||
import net.minecraft.server.GameProfileBanList;
|
||||
import net.minecraft.server.JsonListEntry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class CraftProfileBanList implements org.bukkit.BanList {
|
||||
private final GameProfileBanList list;
|
||||
|
||||
public CraftProfileBanList(GameProfileBanList list){
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.BanEntry getBanEntry(String target) {
|
||||
Validate.notNull(target, "Target cannot be null");
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GameProfileBanEntry entry = (GameProfileBanEntry) list.get(profile);
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CraftProfileBanEntry(profile, entry, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) {
|
||||
Validate.notNull(target, "Ban target cannot be null");
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GameProfileBanEntry entry = new GameProfileBanEntry(profile, new Date(),
|
||||
StringUtils.isBlank(source) ? null : source, expires,
|
||||
StringUtils.isBlank(reason) ? null : reason);
|
||||
|
||||
list.add(entry);
|
||||
|
||||
try {
|
||||
list.save();
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to save banned-players.json, {0}", ex.getMessage());
|
||||
}
|
||||
|
||||
return new CraftProfileBanEntry(profile, entry, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<org.bukkit.BanEntry> getBanEntries() {
|
||||
ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder();
|
||||
|
||||
for (JsonListEntry entry : list.getValues()) {
|
||||
GameProfile profile = (GameProfile) entry.getKey();
|
||||
builder.add(new CraftProfileBanEntry(profile, (GameProfileBanEntry) entry, list));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned(String target) {
|
||||
Validate.notNull(target, "Target cannot be null");
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
|
||||
if (profile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return list.isBanned(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pardon(String target) {
|
||||
Validate.notNull(target, "Target cannot be null");
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
|
||||
list.remove(profile);
|
||||
}
|
||||
}
|
||||
2210
src/main/java/org/bukkit/craftbukkit/CraftServer.java
Normal file
2210
src/main/java/org/bukkit/craftbukkit/CraftServer.java
Normal file
File diff suppressed because it is too large
Load Diff
709
src/main/java/org/bukkit/craftbukkit/CraftSound.java
Normal file
709
src/main/java/org/bukkit/craftbukkit/CraftSound.java
Normal file
@@ -0,0 +1,709 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.IRegistry;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.SoundEffect;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public enum CraftSound {
|
||||
|
||||
AMBIENT_CAVE("ambient.cave"),
|
||||
AMBIENT_UNDERWATER_ENTER("ambient.underwater.enter"),
|
||||
AMBIENT_UNDERWATER_EXIT("ambient.underwater.exit"),
|
||||
AMBIENT_UNDERWATER_LOOP("ambient.underwater.loop"),
|
||||
AMBIENT_UNDERWATER_LOOP_ADDITIONS("ambient.underwater.loop.additions"),
|
||||
AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE("ambient.underwater.loop.additions.rare"),
|
||||
AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE("ambient.underwater.loop.additions.ultra_rare"),
|
||||
BLOCK_ANVIL_BREAK("block.anvil.break"),
|
||||
BLOCK_ANVIL_DESTROY("block.anvil.destroy"),
|
||||
BLOCK_ANVIL_FALL("block.anvil.fall"),
|
||||
BLOCK_ANVIL_HIT("block.anvil.hit"),
|
||||
BLOCK_ANVIL_LAND("block.anvil.land"),
|
||||
BLOCK_ANVIL_PLACE("block.anvil.place"),
|
||||
BLOCK_ANVIL_STEP("block.anvil.step"),
|
||||
BLOCK_ANVIL_USE("block.anvil.use"),
|
||||
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_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_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_CONDUIT_ACTIVATE("block.conduit.activate"),
|
||||
BLOCK_CONDUIT_AMBIENT("block.conduit.ambient"),
|
||||
BLOCK_CONDUIT_AMBIENT_SHORT("block.conduit.ambient.short"),
|
||||
BLOCK_CONDUIT_ATTACK_TARGET("block.conduit.attack.target"),
|
||||
BLOCK_CONDUIT_DEACTIVATE("block.conduit.deactivate"),
|
||||
BLOCK_CORAL_BLOCK_BREAK("block.coral_block.break"),
|
||||
BLOCK_CORAL_BLOCK_FALL("block.coral_block.fall"),
|
||||
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_DISPENSER_DISPENSE("block.dispenser.dispense"),
|
||||
BLOCK_DISPENSER_FAIL("block.dispenser.fail"),
|
||||
BLOCK_DISPENSER_LAUNCH("block.dispenser.launch"),
|
||||
BLOCK_ENCHANTMENT_TABLE_USE("block.enchantment_table.use"),
|
||||
BLOCK_ENDER_CHEST_CLOSE("block.ender_chest.close"),
|
||||
BLOCK_ENDER_CHEST_OPEN("block.ender_chest.open"),
|
||||
BLOCK_END_GATEWAY_SPAWN("block.end_gateway.spawn"),
|
||||
BLOCK_END_PORTAL_FRAME_FILL("block.end_portal_frame.fill"),
|
||||
BLOCK_END_PORTAL_SPAWN("block.end_portal.spawn"),
|
||||
BLOCK_FENCE_GATE_CLOSE("block.fence_gate.close"),
|
||||
BLOCK_FENCE_GATE_OPEN("block.fence_gate.open"),
|
||||
BLOCK_FIRE_AMBIENT("block.fire.ambient"),
|
||||
BLOCK_FIRE_EXTINGUISH("block.fire.extinguish"),
|
||||
BLOCK_FURNACE_FIRE_CRACKLE("block.furnace.fire_crackle"),
|
||||
BLOCK_GLASS_BREAK("block.glass.break"),
|
||||
BLOCK_GLASS_FALL("block.glass.fall"),
|
||||
BLOCK_GLASS_HIT("block.glass.hit"),
|
||||
BLOCK_GLASS_PLACE("block.glass.place"),
|
||||
BLOCK_GLASS_STEP("block.glass.step"),
|
||||
BLOCK_GRASS_BREAK("block.grass.break"),
|
||||
BLOCK_GRASS_FALL("block.grass.fall"),
|
||||
BLOCK_GRASS_HIT("block.grass.hit"),
|
||||
BLOCK_GRASS_PLACE("block.grass.place"),
|
||||
BLOCK_GRASS_STEP("block.grass.step"),
|
||||
BLOCK_GRAVEL_BREAK("block.gravel.break"),
|
||||
BLOCK_GRAVEL_FALL("block.gravel.fall"),
|
||||
BLOCK_GRAVEL_HIT("block.gravel.hit"),
|
||||
BLOCK_GRAVEL_PLACE("block.gravel.place"),
|
||||
BLOCK_GRAVEL_STEP("block.gravel.step"),
|
||||
BLOCK_IRON_DOOR_CLOSE("block.iron_door.close"),
|
||||
BLOCK_IRON_DOOR_OPEN("block.iron_door.open"),
|
||||
BLOCK_IRON_TRAPDOOR_CLOSE("block.iron_trapdoor.close"),
|
||||
BLOCK_IRON_TRAPDOOR_OPEN("block.iron_trapdoor.open"),
|
||||
BLOCK_LADDER_BREAK("block.ladder.break"),
|
||||
BLOCK_LADDER_FALL("block.ladder.fall"),
|
||||
BLOCK_LADDER_HIT("block.ladder.hit"),
|
||||
BLOCK_LADDER_PLACE("block.ladder.place"),
|
||||
BLOCK_LADDER_STEP("block.ladder.step"),
|
||||
BLOCK_LAVA_AMBIENT("block.lava.ambient"),
|
||||
BLOCK_LAVA_EXTINGUISH("block.lava.extinguish"),
|
||||
BLOCK_LAVA_POP("block.lava.pop"),
|
||||
BLOCK_LEVER_CLICK("block.lever.click"),
|
||||
BLOCK_LILY_PAD_PLACE("block.lily_pad.place"),
|
||||
BLOCK_METAL_BREAK("block.metal.break"),
|
||||
BLOCK_METAL_FALL("block.metal.fall"),
|
||||
BLOCK_METAL_HIT("block.metal.hit"),
|
||||
BLOCK_METAL_PLACE("block.metal.place"),
|
||||
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_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_CHIME("block.note_block.chime"),
|
||||
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_PLING("block.note_block.pling"),
|
||||
BLOCK_NOTE_BLOCK_SNARE("block.note_block.snare"),
|
||||
BLOCK_NOTE_BLOCK_XYLOPHONE("block.note_block.xylophone"),
|
||||
BLOCK_PISTON_CONTRACT("block.piston.contract"),
|
||||
BLOCK_PISTON_EXTEND("block.piston.extend"),
|
||||
BLOCK_PORTAL_AMBIENT("block.portal.ambient"),
|
||||
BLOCK_PORTAL_TRAVEL("block.portal.travel"),
|
||||
BLOCK_PORTAL_TRIGGER("block.portal.trigger"),
|
||||
BLOCK_PUMPKIN_CARVE("block.pumpkin.carve"),
|
||||
BLOCK_REDSTONE_TORCH_BURNOUT("block.redstone_torch.burnout"),
|
||||
BLOCK_SAND_BREAK("block.sand.break"),
|
||||
BLOCK_SAND_FALL("block.sand.fall"),
|
||||
BLOCK_SAND_HIT("block.sand.hit"),
|
||||
BLOCK_SAND_PLACE("block.sand.place"),
|
||||
BLOCK_SAND_STEP("block.sand.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"),
|
||||
BLOCK_SLIME_BLOCK_FALL("block.slime_block.fall"),
|
||||
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_SNOW_BREAK("block.snow.break"),
|
||||
BLOCK_SNOW_FALL("block.snow.fall"),
|
||||
BLOCK_SNOW_HIT("block.snow.hit"),
|
||||
BLOCK_SNOW_PLACE("block.snow.place"),
|
||||
BLOCK_SNOW_STEP("block.snow.step"),
|
||||
BLOCK_STONE_BREAK("block.stone.break"),
|
||||
BLOCK_STONE_BUTTON_CLICK_OFF("block.stone_button.click_off"),
|
||||
BLOCK_STONE_BUTTON_CLICK_ON("block.stone_button.click_on"),
|
||||
BLOCK_STONE_FALL("block.stone.fall"),
|
||||
BLOCK_STONE_HIT("block.stone.hit"),
|
||||
BLOCK_STONE_PLACE("block.stone.place"),
|
||||
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_TRIPWIRE_ATTACH("block.tripwire.attach"),
|
||||
BLOCK_TRIPWIRE_CLICK_OFF("block.tripwire.click_off"),
|
||||
BLOCK_TRIPWIRE_CLICK_ON("block.tripwire.click_on"),
|
||||
BLOCK_TRIPWIRE_DETACH("block.tripwire.detach"),
|
||||
BLOCK_WATER_AMBIENT("block.water.ambient"),
|
||||
BLOCK_WET_GRASS_BREAK("block.wet_grass.break"),
|
||||
BLOCK_WET_GRASS_FALL("block.wet_grass.fall"),
|
||||
BLOCK_WET_GRASS_HIT("block.wet_grass.hit"),
|
||||
BLOCK_WET_GRASS_PLACE("block.wet_grass.place"),
|
||||
BLOCK_WET_GRASS_STEP("block.wet_grass.step"),
|
||||
BLOCK_WOODEN_BUTTON_CLICK_OFF("block.wooden_button.click_off"),
|
||||
BLOCK_WOODEN_BUTTON_CLICK_ON("block.wooden_button.click_on"),
|
||||
BLOCK_WOODEN_DOOR_CLOSE("block.wooden_door.close"),
|
||||
BLOCK_WOODEN_DOOR_OPEN("block.wooden_door.open"),
|
||||
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF("block.wooden_pressure_plate.click_off"),
|
||||
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON("block.wooden_pressure_plate.click_on"),
|
||||
BLOCK_WOODEN_TRAPDOOR_CLOSE("block.wooden_trapdoor.close"),
|
||||
BLOCK_WOODEN_TRAPDOOR_OPEN("block.wooden_trapdoor.open"),
|
||||
BLOCK_WOOD_BREAK("block.wood.break"),
|
||||
BLOCK_WOOD_FALL("block.wood.fall"),
|
||||
BLOCK_WOOD_HIT("block.wood.hit"),
|
||||
BLOCK_WOOD_PLACE("block.wood.place"),
|
||||
BLOCK_WOOD_STEP("block.wood.step"),
|
||||
BLOCK_WOOL_BREAK("block.wool.break"),
|
||||
BLOCK_WOOL_FALL("block.wool.fall"),
|
||||
BLOCK_WOOL_HIT("block.wool.hit"),
|
||||
BLOCK_WOOL_PLACE("block.wool.place"),
|
||||
BLOCK_WOOL_STEP("block.wool.step"),
|
||||
ENCHANT_THORNS_HIT("enchant.thorns.hit"),
|
||||
ENTITY_ARMOR_STAND_BREAK("entity.armor_stand.break"),
|
||||
ENTITY_ARMOR_STAND_FALL("entity.armor_stand.fall"),
|
||||
ENTITY_ARMOR_STAND_HIT("entity.armor_stand.hit"),
|
||||
ENTITY_ARMOR_STAND_PLACE("entity.armor_stand.place"),
|
||||
ENTITY_ARROW_HIT("entity.arrow.hit"),
|
||||
ENTITY_ARROW_HIT_PLAYER("entity.arrow.hit_player"),
|
||||
ENTITY_ARROW_SHOOT("entity.arrow.shoot"),
|
||||
ENTITY_BAT_AMBIENT("entity.bat.ambient"),
|
||||
ENTITY_BAT_DEATH("entity.bat.death"),
|
||||
ENTITY_BAT_HURT("entity.bat.hurt"),
|
||||
ENTITY_BAT_LOOP("entity.bat.loop"),
|
||||
ENTITY_BAT_TAKEOFF("entity.bat.takeoff"),
|
||||
ENTITY_BLAZE_AMBIENT("entity.blaze.ambient"),
|
||||
ENTITY_BLAZE_BURN("entity.blaze.burn"),
|
||||
ENTITY_BLAZE_DEATH("entity.blaze.death"),
|
||||
ENTITY_BLAZE_HURT("entity.blaze.hurt"),
|
||||
ENTITY_BLAZE_SHOOT("entity.blaze.shoot"),
|
||||
ENTITY_BOAT_PADDLE_LAND("entity.boat.paddle_land"),
|
||||
ENTITY_BOAT_PADDLE_WATER("entity.boat.paddle_water"),
|
||||
ENTITY_CAT_AMBIENT("entity.cat.ambient"),
|
||||
ENTITY_CAT_DEATH("entity.cat.death"),
|
||||
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_CHICKEN_AMBIENT("entity.chicken.ambient"),
|
||||
ENTITY_CHICKEN_DEATH("entity.chicken.death"),
|
||||
ENTITY_CHICKEN_EGG("entity.chicken.egg"),
|
||||
ENTITY_CHICKEN_HURT("entity.chicken.hurt"),
|
||||
ENTITY_CHICKEN_STEP("entity.chicken.step"),
|
||||
ENTITY_COD_AMBIENT("entity.cod.ambient"),
|
||||
ENTITY_COD_DEATH("entity.cod.death"),
|
||||
ENTITY_COD_FLOP("entity.cod.flop"),
|
||||
ENTITY_COD_HURT("entity.cod.hurt"),
|
||||
ENTITY_COW_AMBIENT("entity.cow.ambient"),
|
||||
ENTITY_COW_DEATH("entity.cow.death"),
|
||||
ENTITY_COW_HURT("entity.cow.hurt"),
|
||||
ENTITY_COW_MILK("entity.cow.milk"),
|
||||
ENTITY_COW_STEP("entity.cow.step"),
|
||||
ENTITY_CREEPER_DEATH("entity.creeper.death"),
|
||||
ENTITY_CREEPER_HURT("entity.creeper.hurt"),
|
||||
ENTITY_CREEPER_PRIMED("entity.creeper.primed"),
|
||||
ENTITY_DOLPHIN_AMBIENT("entity.dolphin.ambient"),
|
||||
ENTITY_DOLPHIN_AMBIENT_WATER("entity.dolphin.ambient_water"),
|
||||
ENTITY_DOLPHIN_ATTACK("entity.dolphin.attack"),
|
||||
ENTITY_DOLPHIN_DEATH("entity.dolphin.death"),
|
||||
ENTITY_DOLPHIN_EAT("entity.dolphin.eat"),
|
||||
ENTITY_DOLPHIN_HURT("entity.dolphin.hurt"),
|
||||
ENTITY_DOLPHIN_JUMP("entity.dolphin.jump"),
|
||||
ENTITY_DOLPHIN_PLAY("entity.dolphin.play"),
|
||||
ENTITY_DOLPHIN_SPLASH("entity.dolphin.splash"),
|
||||
ENTITY_DOLPHIN_SWIM("entity.dolphin.swim"),
|
||||
ENTITY_DONKEY_AMBIENT("entity.donkey.ambient"),
|
||||
ENTITY_DONKEY_ANGRY("entity.donkey.angry"),
|
||||
ENTITY_DONKEY_CHEST("entity.donkey.chest"),
|
||||
ENTITY_DONKEY_DEATH("entity.donkey.death"),
|
||||
ENTITY_DONKEY_HURT("entity.donkey.hurt"),
|
||||
ENTITY_DRAGON_FIREBALL_EXPLODE("entity.dragon_fireball.explode"),
|
||||
ENTITY_DROWNED_AMBIENT("entity.drowned.ambient"),
|
||||
ENTITY_DROWNED_AMBIENT_WATER("entity.drowned.ambient_water"),
|
||||
ENTITY_DROWNED_DEATH("entity.drowned.death"),
|
||||
ENTITY_DROWNED_DEATH_WATER("entity.drowned.death_water"),
|
||||
ENTITY_DROWNED_HURT("entity.drowned.hurt"),
|
||||
ENTITY_DROWNED_HURT_WATER("entity.drowned.hurt_water"),
|
||||
ENTITY_DROWNED_SHOOT("entity.drowned.shoot"),
|
||||
ENTITY_DROWNED_STEP("entity.drowned.step"),
|
||||
ENTITY_DROWNED_SWIM("entity.drowned.swim"),
|
||||
ENTITY_EGG_THROW("entity.egg.throw"),
|
||||
ENTITY_ELDER_GUARDIAN_AMBIENT("entity.elder_guardian.ambient"),
|
||||
ENTITY_ELDER_GUARDIAN_AMBIENT_LAND("entity.elder_guardian.ambient_land"),
|
||||
ENTITY_ELDER_GUARDIAN_CURSE("entity.elder_guardian.curse"),
|
||||
ENTITY_ELDER_GUARDIAN_DEATH("entity.elder_guardian.death"),
|
||||
ENTITY_ELDER_GUARDIAN_DEATH_LAND("entity.elder_guardian.death_land"),
|
||||
ENTITY_ELDER_GUARDIAN_FLOP("entity.elder_guardian.flop"),
|
||||
ENTITY_ELDER_GUARDIAN_HURT("entity.elder_guardian.hurt"),
|
||||
ENTITY_ELDER_GUARDIAN_HURT_LAND("entity.elder_guardian.hurt_land"),
|
||||
ENTITY_ENDERMAN_AMBIENT("entity.enderman.ambient"),
|
||||
ENTITY_ENDERMAN_DEATH("entity.enderman.death"),
|
||||
ENTITY_ENDERMAN_HURT("entity.enderman.hurt"),
|
||||
ENTITY_ENDERMAN_SCREAM("entity.enderman.scream"),
|
||||
ENTITY_ENDERMAN_STARE("entity.enderman.stare"),
|
||||
ENTITY_ENDERMAN_TELEPORT("entity.enderman.teleport"),
|
||||
ENTITY_ENDERMITE_AMBIENT("entity.endermite.ambient"),
|
||||
ENTITY_ENDERMITE_DEATH("entity.endermite.death"),
|
||||
ENTITY_ENDERMITE_HURT("entity.endermite.hurt"),
|
||||
ENTITY_ENDERMITE_STEP("entity.endermite.step"),
|
||||
ENTITY_ENDER_DRAGON_AMBIENT("entity.ender_dragon.ambient"),
|
||||
ENTITY_ENDER_DRAGON_DEATH("entity.ender_dragon.death"),
|
||||
ENTITY_ENDER_DRAGON_FLAP("entity.ender_dragon.flap"),
|
||||
ENTITY_ENDER_DRAGON_GROWL("entity.ender_dragon.growl"),
|
||||
ENTITY_ENDER_DRAGON_HURT("entity.ender_dragon.hurt"),
|
||||
ENTITY_ENDER_DRAGON_SHOOT("entity.ender_dragon.shoot"),
|
||||
ENTITY_ENDER_EYE_DEATH("entity.ender_eye.death"),
|
||||
ENTITY_ENDER_EYE_LAUNCH("entity.ender_eye.launch"),
|
||||
ENTITY_ENDER_PEARL_THROW("entity.ender_pearl.throw"),
|
||||
ENTITY_EVOKER_AMBIENT("entity.evoker.ambient"),
|
||||
ENTITY_EVOKER_CAST_SPELL("entity.evoker.cast_spell"),
|
||||
ENTITY_EVOKER_DEATH("entity.evoker.death"),
|
||||
ENTITY_EVOKER_FANGS_ATTACK("entity.evoker_fangs.attack"),
|
||||
ENTITY_EVOKER_HURT("entity.evoker.hurt"),
|
||||
ENTITY_EVOKER_PREPARE_ATTACK("entity.evoker.prepare_attack"),
|
||||
ENTITY_EVOKER_PREPARE_SUMMON("entity.evoker.prepare_summon"),
|
||||
ENTITY_EVOKER_PREPARE_WOLOLO("entity.evoker.prepare_wololo"),
|
||||
ENTITY_EXPERIENCE_BOTTLE_THROW("entity.experience_bottle.throw"),
|
||||
ENTITY_EXPERIENCE_ORB_PICKUP("entity.experience_orb.pickup"),
|
||||
ENTITY_FIREWORK_ROCKET_BLAST("entity.firework_rocket.blast"),
|
||||
ENTITY_FIREWORK_ROCKET_BLAST_FAR("entity.firework_rocket.blast_far"),
|
||||
ENTITY_FIREWORK_ROCKET_LARGE_BLAST("entity.firework_rocket.large_blast"),
|
||||
ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR("entity.firework_rocket.large_blast_far"),
|
||||
ENTITY_FIREWORK_ROCKET_LAUNCH("entity.firework_rocket.launch"),
|
||||
ENTITY_FIREWORK_ROCKET_SHOOT("entity.firework_rocket.shoot"),
|
||||
ENTITY_FIREWORK_ROCKET_TWINKLE("entity.firework_rocket.twinkle"),
|
||||
ENTITY_FIREWORK_ROCKET_TWINKLE_FAR("entity.firework_rocket.twinkle_far"),
|
||||
ENTITY_FISHING_BOBBER_RETRIEVE("entity.fishing_bobber.retrieve"),
|
||||
ENTITY_FISHING_BOBBER_SPLASH("entity.fishing_bobber.splash"),
|
||||
ENTITY_FISHING_BOBBER_THROW("entity.fishing_bobber.throw"),
|
||||
ENTITY_FISH_SWIM("entity.fish.swim"),
|
||||
ENTITY_GENERIC_BIG_FALL("entity.generic.big_fall"),
|
||||
ENTITY_GENERIC_BURN("entity.generic.burn"),
|
||||
ENTITY_GENERIC_DEATH("entity.generic.death"),
|
||||
ENTITY_GENERIC_DRINK("entity.generic.drink"),
|
||||
ENTITY_GENERIC_EAT("entity.generic.eat"),
|
||||
ENTITY_GENERIC_EXPLODE("entity.generic.explode"),
|
||||
ENTITY_GENERIC_EXTINGUISH_FIRE("entity.generic.extinguish_fire"),
|
||||
ENTITY_GENERIC_HURT("entity.generic.hurt"),
|
||||
ENTITY_GENERIC_SMALL_FALL("entity.generic.small_fall"),
|
||||
ENTITY_GENERIC_SPLASH("entity.generic.splash"),
|
||||
ENTITY_GENERIC_SWIM("entity.generic.swim"),
|
||||
ENTITY_GHAST_AMBIENT("entity.ghast.ambient"),
|
||||
ENTITY_GHAST_DEATH("entity.ghast.death"),
|
||||
ENTITY_GHAST_HURT("entity.ghast.hurt"),
|
||||
ENTITY_GHAST_SCREAM("entity.ghast.scream"),
|
||||
ENTITY_GHAST_SHOOT("entity.ghast.shoot"),
|
||||
ENTITY_GHAST_WARN("entity.ghast.warn"),
|
||||
ENTITY_GUARDIAN_AMBIENT("entity.guardian.ambient"),
|
||||
ENTITY_GUARDIAN_AMBIENT_LAND("entity.guardian.ambient_land"),
|
||||
ENTITY_GUARDIAN_ATTACK("entity.guardian.attack"),
|
||||
ENTITY_GUARDIAN_DEATH("entity.guardian.death"),
|
||||
ENTITY_GUARDIAN_DEATH_LAND("entity.guardian.death_land"),
|
||||
ENTITY_GUARDIAN_FLOP("entity.guardian.flop"),
|
||||
ENTITY_GUARDIAN_HURT("entity.guardian.hurt"),
|
||||
ENTITY_GUARDIAN_HURT_LAND("entity.guardian.hurt_land"),
|
||||
ENTITY_HORSE_AMBIENT("entity.horse.ambient"),
|
||||
ENTITY_HORSE_ANGRY("entity.horse.angry"),
|
||||
ENTITY_HORSE_ARMOR("entity.horse.armor"),
|
||||
ENTITY_HORSE_BREATHE("entity.horse.breathe"),
|
||||
ENTITY_HORSE_DEATH("entity.horse.death"),
|
||||
ENTITY_HORSE_EAT("entity.horse.eat"),
|
||||
ENTITY_HORSE_GALLOP("entity.horse.gallop"),
|
||||
ENTITY_HORSE_HURT("entity.horse.hurt"),
|
||||
ENTITY_HORSE_JUMP("entity.horse.jump"),
|
||||
ENTITY_HORSE_LAND("entity.horse.land"),
|
||||
ENTITY_HORSE_SADDLE("entity.horse.saddle"),
|
||||
ENTITY_HORSE_STEP("entity.horse.step"),
|
||||
ENTITY_HORSE_STEP_WOOD("entity.horse.step_wood"),
|
||||
ENTITY_HOSTILE_BIG_FALL("entity.hostile.big_fall"),
|
||||
ENTITY_HOSTILE_DEATH("entity.hostile.death"),
|
||||
ENTITY_HOSTILE_HURT("entity.hostile.hurt"),
|
||||
ENTITY_HOSTILE_SMALL_FALL("entity.hostile.small_fall"),
|
||||
ENTITY_HOSTILE_SPLASH("entity.hostile.splash"),
|
||||
ENTITY_HOSTILE_SWIM("entity.hostile.swim"),
|
||||
ENTITY_HUSK_AMBIENT("entity.husk.ambient"),
|
||||
ENTITY_HUSK_CONVERTED_TO_ZOMBIE("entity.husk.converted_to_zombie"),
|
||||
ENTITY_HUSK_DEATH("entity.husk.death"),
|
||||
ENTITY_HUSK_HURT("entity.husk.hurt"),
|
||||
ENTITY_HUSK_STEP("entity.husk.step"),
|
||||
ENTITY_ILLUSIONER_AMBIENT("entity.illusioner.ambient"),
|
||||
ENTITY_ILLUSIONER_CAST_SPELL("entity.illusioner.cast_spell"),
|
||||
ENTITY_ILLUSIONER_DEATH("entity.illusioner.death"),
|
||||
ENTITY_ILLUSIONER_HURT("entity.illusioner.hurt"),
|
||||
ENTITY_ILLUSIONER_MIRROR_MOVE("entity.illusioner.mirror_move"),
|
||||
ENTITY_ILLUSIONER_PREPARE_BLINDNESS("entity.illusioner.prepare_blindness"),
|
||||
ENTITY_ILLUSIONER_PREPARE_MIRROR("entity.illusioner.prepare_mirror"),
|
||||
ENTITY_IRON_GOLEM_ATTACK("entity.iron_golem.attack"),
|
||||
ENTITY_IRON_GOLEM_DEATH("entity.iron_golem.death"),
|
||||
ENTITY_IRON_GOLEM_HURT("entity.iron_golem.hurt"),
|
||||
ENTITY_IRON_GOLEM_STEP("entity.iron_golem.step"),
|
||||
ENTITY_ITEM_BREAK("entity.item.break"),
|
||||
ENTITY_ITEM_FRAME_ADD_ITEM("entity.item_frame.add_item"),
|
||||
ENTITY_ITEM_FRAME_BREAK("entity.item_frame.break"),
|
||||
ENTITY_ITEM_FRAME_PLACE("entity.item_frame.place"),
|
||||
ENTITY_ITEM_FRAME_REMOVE_ITEM("entity.item_frame.remove_item"),
|
||||
ENTITY_ITEM_FRAME_ROTATE_ITEM("entity.item_frame.rotate_item"),
|
||||
ENTITY_ITEM_PICKUP("entity.item.pickup"),
|
||||
ENTITY_LEASH_KNOT_BREAK("entity.leash_knot.break"),
|
||||
ENTITY_LEASH_KNOT_PLACE("entity.leash_knot.place"),
|
||||
ENTITY_LIGHTNING_BOLT_IMPACT("entity.lightning_bolt.impact"),
|
||||
ENTITY_LIGHTNING_BOLT_THUNDER("entity.lightning_bolt.thunder"),
|
||||
ENTITY_LINGERING_POTION_THROW("entity.lingering_potion.throw"),
|
||||
ENTITY_LLAMA_AMBIENT("entity.llama.ambient"),
|
||||
ENTITY_LLAMA_ANGRY("entity.llama.angry"),
|
||||
ENTITY_LLAMA_CHEST("entity.llama.chest"),
|
||||
ENTITY_LLAMA_DEATH("entity.llama.death"),
|
||||
ENTITY_LLAMA_EAT("entity.llama.eat"),
|
||||
ENTITY_LLAMA_HURT("entity.llama.hurt"),
|
||||
ENTITY_LLAMA_SPIT("entity.llama.spit"),
|
||||
ENTITY_LLAMA_STEP("entity.llama.step"),
|
||||
ENTITY_LLAMA_SWAG("entity.llama.swag"),
|
||||
ENTITY_MAGMA_CUBE_DEATH("entity.magma_cube.death"),
|
||||
ENTITY_MAGMA_CUBE_DEATH_SMALL("entity.magma_cube.death_small"),
|
||||
ENTITY_MAGMA_CUBE_HURT("entity.magma_cube.hurt"),
|
||||
ENTITY_MAGMA_CUBE_HURT_SMALL("entity.magma_cube.hurt_small"),
|
||||
ENTITY_MAGMA_CUBE_JUMP("entity.magma_cube.jump"),
|
||||
ENTITY_MAGMA_CUBE_SQUISH("entity.magma_cube.squish"),
|
||||
ENTITY_MAGMA_CUBE_SQUISH_SMALL("entity.magma_cube.squish_small"),
|
||||
ENTITY_MINECART_INSIDE("entity.minecart.inside"),
|
||||
ENTITY_MINECART_RIDING("entity.minecart.riding"),
|
||||
ENTITY_MOOSHROOM_SHEAR("entity.mooshroom.shear"),
|
||||
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_PAINTING_BREAK("entity.painting.break"),
|
||||
ENTITY_PAINTING_PLACE("entity.painting.place"),
|
||||
ENTITY_PARROT_AMBIENT("entity.parrot.ambient"),
|
||||
ENTITY_PARROT_DEATH("entity.parrot.death"),
|
||||
ENTITY_PARROT_EAT("entity.parrot.eat"),
|
||||
ENTITY_PARROT_FLY("entity.parrot.fly"),
|
||||
ENTITY_PARROT_HURT("entity.parrot.hurt"),
|
||||
ENTITY_PARROT_IMITATE_BLAZE("entity.parrot.imitate.blaze"),
|
||||
ENTITY_PARROT_IMITATE_CREEPER("entity.parrot.imitate.creeper"),
|
||||
ENTITY_PARROT_IMITATE_DROWNED("entity.parrot.imitate.drowned"),
|
||||
ENTITY_PARROT_IMITATE_ELDER_GUARDIAN("entity.parrot.imitate.elder_guardian"),
|
||||
ENTITY_PARROT_IMITATE_ENDERMAN("entity.parrot.imitate.enderman"),
|
||||
ENTITY_PARROT_IMITATE_ENDERMITE("entity.parrot.imitate.endermite"),
|
||||
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_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_PHANTOM("entity.parrot.imitate.phantom"),
|
||||
ENTITY_PARROT_IMITATE_POLAR_BEAR("entity.parrot.imitate.polar_bear"),
|
||||
ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"),
|
||||
ENTITY_PARROT_IMITATE_SILVERFISH("entity.parrot.imitate.silverfish"),
|
||||
ENTITY_PARROT_IMITATE_SKELETON("entity.parrot.imitate.skeleton"),
|
||||
ENTITY_PARROT_IMITATE_SLIME("entity.parrot.imitate.slime"),
|
||||
ENTITY_PARROT_IMITATE_SPIDER("entity.parrot.imitate.spider"),
|
||||
ENTITY_PARROT_IMITATE_STRAY("entity.parrot.imitate.stray"),
|
||||
ENTITY_PARROT_IMITATE_VEX("entity.parrot.imitate.vex"),
|
||||
ENTITY_PARROT_IMITATE_VINDICATOR("entity.parrot.imitate.vindicator"),
|
||||
ENTITY_PARROT_IMITATE_WITCH("entity.parrot.imitate.witch"),
|
||||
ENTITY_PARROT_IMITATE_WITHER("entity.parrot.imitate.wither"),
|
||||
ENTITY_PARROT_IMITATE_WITHER_SKELETON("entity.parrot.imitate.wither_skeleton"),
|
||||
ENTITY_PARROT_IMITATE_WOLF("entity.parrot.imitate.wolf"),
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE("entity.parrot.imitate.zombie"),
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE_PIGMAN("entity.parrot.imitate.zombie_pigman"),
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER("entity.parrot.imitate.zombie_villager"),
|
||||
ENTITY_PARROT_STEP("entity.parrot.step"),
|
||||
ENTITY_PHANTOM_AMBIENT("entity.phantom.ambient"),
|
||||
ENTITY_PHANTOM_BITE("entity.phantom.bite"),
|
||||
ENTITY_PHANTOM_DEATH("entity.phantom.death"),
|
||||
ENTITY_PHANTOM_FLAP("entity.phantom.flap"),
|
||||
ENTITY_PHANTOM_HURT("entity.phantom.hurt"),
|
||||
ENTITY_PHANTOM_SWOOP("entity.phantom.swoop"),
|
||||
ENTITY_PIG_AMBIENT("entity.pig.ambient"),
|
||||
ENTITY_PIG_DEATH("entity.pig.death"),
|
||||
ENTITY_PIG_HURT("entity.pig.hurt"),
|
||||
ENTITY_PIG_SADDLE("entity.pig.saddle"),
|
||||
ENTITY_PIG_STEP("entity.pig.step"),
|
||||
ENTITY_PLAYER_ATTACK_CRIT("entity.player.attack.crit"),
|
||||
ENTITY_PLAYER_ATTACK_KNOCKBACK("entity.player.attack.knockback"),
|
||||
ENTITY_PLAYER_ATTACK_NODAMAGE("entity.player.attack.nodamage"),
|
||||
ENTITY_PLAYER_ATTACK_STRONG("entity.player.attack.strong"),
|
||||
ENTITY_PLAYER_ATTACK_SWEEP("entity.player.attack.sweep"),
|
||||
ENTITY_PLAYER_ATTACK_WEAK("entity.player.attack.weak"),
|
||||
ENTITY_PLAYER_BIG_FALL("entity.player.big_fall"),
|
||||
ENTITY_PLAYER_BREATH("entity.player.breath"),
|
||||
ENTITY_PLAYER_BURP("entity.player.burp"),
|
||||
ENTITY_PLAYER_DEATH("entity.player.death"),
|
||||
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_LEVELUP("entity.player.levelup"),
|
||||
ENTITY_PLAYER_SMALL_FALL("entity.player.small_fall"),
|
||||
ENTITY_PLAYER_SPLASH("entity.player.splash"),
|
||||
ENTITY_PLAYER_SPLASH_HIGH_SPEED("entity.player.splash.high_speed"),
|
||||
ENTITY_PLAYER_SWIM("entity.player.swim"),
|
||||
ENTITY_POLAR_BEAR_AMBIENT("entity.polar_bear.ambient"),
|
||||
ENTITY_POLAR_BEAR_AMBIENT_BABY("entity.polar_bear.ambient_baby"),
|
||||
ENTITY_POLAR_BEAR_DEATH("entity.polar_bear.death"),
|
||||
ENTITY_POLAR_BEAR_HURT("entity.polar_bear.hurt"),
|
||||
ENTITY_POLAR_BEAR_STEP("entity.polar_bear.step"),
|
||||
ENTITY_POLAR_BEAR_WARNING("entity.polar_bear.warning"),
|
||||
ENTITY_PUFFER_FISH_AMBIENT("entity.puffer_fish.ambient"),
|
||||
ENTITY_PUFFER_FISH_BLOW_OUT("entity.puffer_fish.blow_out"),
|
||||
ENTITY_PUFFER_FISH_BLOW_UP("entity.puffer_fish.blow_up"),
|
||||
ENTITY_PUFFER_FISH_DEATH("entity.puffer_fish.death"),
|
||||
ENTITY_PUFFER_FISH_FLOP("entity.puffer_fish.flop"),
|
||||
ENTITY_PUFFER_FISH_HURT("entity.puffer_fish.hurt"),
|
||||
ENTITY_PUFFER_FISH_STING("entity.puffer_fish.sting"),
|
||||
ENTITY_RABBIT_AMBIENT("entity.rabbit.ambient"),
|
||||
ENTITY_RABBIT_ATTACK("entity.rabbit.attack"),
|
||||
ENTITY_RABBIT_DEATH("entity.rabbit.death"),
|
||||
ENTITY_RABBIT_HURT("entity.rabbit.hurt"),
|
||||
ENTITY_RABBIT_JUMP("entity.rabbit.jump"),
|
||||
ENTITY_SALMON_AMBIENT("entity.salmon.ambient"),
|
||||
ENTITY_SALMON_DEATH("entity.salmon.death"),
|
||||
ENTITY_SALMON_FLOP("entity.salmon.flop"),
|
||||
ENTITY_SALMON_HURT("entity.salmon.hurt"),
|
||||
ENTITY_SHEEP_AMBIENT("entity.sheep.ambient"),
|
||||
ENTITY_SHEEP_DEATH("entity.sheep.death"),
|
||||
ENTITY_SHEEP_HURT("entity.sheep.hurt"),
|
||||
ENTITY_SHEEP_SHEAR("entity.sheep.shear"),
|
||||
ENTITY_SHEEP_STEP("entity.sheep.step"),
|
||||
ENTITY_SHULKER_AMBIENT("entity.shulker.ambient"),
|
||||
ENTITY_SHULKER_BULLET_HIT("entity.shulker_bullet.hit"),
|
||||
ENTITY_SHULKER_BULLET_HURT("entity.shulker_bullet.hurt"),
|
||||
ENTITY_SHULKER_CLOSE("entity.shulker.close"),
|
||||
ENTITY_SHULKER_DEATH("entity.shulker.death"),
|
||||
ENTITY_SHULKER_HURT("entity.shulker.hurt"),
|
||||
ENTITY_SHULKER_HURT_CLOSED("entity.shulker.hurt_closed"),
|
||||
ENTITY_SHULKER_OPEN("entity.shulker.open"),
|
||||
ENTITY_SHULKER_SHOOT("entity.shulker.shoot"),
|
||||
ENTITY_SHULKER_TELEPORT("entity.shulker.teleport"),
|
||||
ENTITY_SILVERFISH_AMBIENT("entity.silverfish.ambient"),
|
||||
ENTITY_SILVERFISH_DEATH("entity.silverfish.death"),
|
||||
ENTITY_SILVERFISH_HURT("entity.silverfish.hurt"),
|
||||
ENTITY_SILVERFISH_STEP("entity.silverfish.step"),
|
||||
ENTITY_SKELETON_AMBIENT("entity.skeleton.ambient"),
|
||||
ENTITY_SKELETON_DEATH("entity.skeleton.death"),
|
||||
ENTITY_SKELETON_HORSE_AMBIENT("entity.skeleton_horse.ambient"),
|
||||
ENTITY_SKELETON_HORSE_AMBIENT_WATER("entity.skeleton_horse.ambient_water"),
|
||||
ENTITY_SKELETON_HORSE_DEATH("entity.skeleton_horse.death"),
|
||||
ENTITY_SKELETON_HORSE_GALLOP_WATER("entity.skeleton_horse.gallop_water"),
|
||||
ENTITY_SKELETON_HORSE_HURT("entity.skeleton_horse.hurt"),
|
||||
ENTITY_SKELETON_HORSE_JUMP_WATER("entity.skeleton_horse.jump_water"),
|
||||
ENTITY_SKELETON_HORSE_STEP_WATER("entity.skeleton_horse.step_water"),
|
||||
ENTITY_SKELETON_HORSE_SWIM("entity.skeleton_horse.swim"),
|
||||
ENTITY_SKELETON_HURT("entity.skeleton.hurt"),
|
||||
ENTITY_SKELETON_SHOOT("entity.skeleton.shoot"),
|
||||
ENTITY_SKELETON_STEP("entity.skeleton.step"),
|
||||
ENTITY_SLIME_ATTACK("entity.slime.attack"),
|
||||
ENTITY_SLIME_DEATH("entity.slime.death"),
|
||||
ENTITY_SLIME_DEATH_SMALL("entity.slime.death_small"),
|
||||
ENTITY_SLIME_HURT("entity.slime.hurt"),
|
||||
ENTITY_SLIME_HURT_SMALL("entity.slime.hurt_small"),
|
||||
ENTITY_SLIME_JUMP("entity.slime.jump"),
|
||||
ENTITY_SLIME_JUMP_SMALL("entity.slime.jump_small"),
|
||||
ENTITY_SLIME_SQUISH("entity.slime.squish"),
|
||||
ENTITY_SLIME_SQUISH_SMALL("entity.slime.squish_small"),
|
||||
ENTITY_SNOWBALL_THROW("entity.snowball.throw"),
|
||||
ENTITY_SNOW_GOLEM_AMBIENT("entity.snow_golem.ambient"),
|
||||
ENTITY_SNOW_GOLEM_DEATH("entity.snow_golem.death"),
|
||||
ENTITY_SNOW_GOLEM_HURT("entity.snow_golem.hurt"),
|
||||
ENTITY_SNOW_GOLEM_SHOOT("entity.snow_golem.shoot"),
|
||||
ENTITY_SPIDER_AMBIENT("entity.spider.ambient"),
|
||||
ENTITY_SPIDER_DEATH("entity.spider.death"),
|
||||
ENTITY_SPIDER_HURT("entity.spider.hurt"),
|
||||
ENTITY_SPIDER_STEP("entity.spider.step"),
|
||||
ENTITY_SPLASH_POTION_BREAK("entity.splash_potion.break"),
|
||||
ENTITY_SPLASH_POTION_THROW("entity.splash_potion.throw"),
|
||||
ENTITY_SQUID_AMBIENT("entity.squid.ambient"),
|
||||
ENTITY_SQUID_DEATH("entity.squid.death"),
|
||||
ENTITY_SQUID_HURT("entity.squid.hurt"),
|
||||
ENTITY_SQUID_SQUIRT("entity.squid.squirt"),
|
||||
ENTITY_STRAY_AMBIENT("entity.stray.ambient"),
|
||||
ENTITY_STRAY_DEATH("entity.stray.death"),
|
||||
ENTITY_STRAY_HURT("entity.stray.hurt"),
|
||||
ENTITY_STRAY_STEP("entity.stray.step"),
|
||||
ENTITY_TNT_PRIMED("entity.tnt.primed"),
|
||||
ENTITY_TROPICAL_FISH_AMBIENT("entity.tropical_fish.ambient"),
|
||||
ENTITY_TROPICAL_FISH_DEATH("entity.tropical_fish.death"),
|
||||
ENTITY_TROPICAL_FISH_FLOP("entity.tropical_fish.flop"),
|
||||
ENTITY_TROPICAL_FISH_HURT("entity.tropical_fish.hurt"),
|
||||
ENTITY_TURTLE_AMBIENT_LAND("entity.turtle.ambient_land"),
|
||||
ENTITY_TURTLE_DEATH("entity.turtle.death"),
|
||||
ENTITY_TURTLE_DEATH_BABY("entity.turtle.death_baby"),
|
||||
ENTITY_TURTLE_EGG_BREAK("entity.turtle.egg_break"),
|
||||
ENTITY_TURTLE_EGG_CRACK("entity.turtle.egg_crack"),
|
||||
ENTITY_TURTLE_EGG_HATCH("entity.turtle.egg_hatch"),
|
||||
ENTITY_TURTLE_HURT("entity.turtle.hurt"),
|
||||
ENTITY_TURTLE_HURT_BABY("entity.turtle.hurt_baby"),
|
||||
ENTITY_TURTLE_LAY_EGG("entity.turtle.lay_egg"),
|
||||
ENTITY_TURTLE_SHAMBLE("entity.turtle.shamble"),
|
||||
ENTITY_TURTLE_SHAMBLE_BABY("entity.turtle.shamble_baby"),
|
||||
ENTITY_TURTLE_SWIM("entity.turtle.swim"),
|
||||
ENTITY_VEX_AMBIENT("entity.vex.ambient"),
|
||||
ENTITY_VEX_CHARGE("entity.vex.charge"),
|
||||
ENTITY_VEX_DEATH("entity.vex.death"),
|
||||
ENTITY_VEX_HURT("entity.vex.hurt"),
|
||||
ENTITY_VILLAGER_AMBIENT("entity.villager.ambient"),
|
||||
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_YES("entity.villager.yes"),
|
||||
ENTITY_VINDICATOR_AMBIENT("entity.vindicator.ambient"),
|
||||
ENTITY_VINDICATOR_DEATH("entity.vindicator.death"),
|
||||
ENTITY_VINDICATOR_HURT("entity.vindicator.hurt"),
|
||||
ENTITY_WITCH_AMBIENT("entity.witch.ambient"),
|
||||
ENTITY_WITCH_DEATH("entity.witch.death"),
|
||||
ENTITY_WITCH_DRINK("entity.witch.drink"),
|
||||
ENTITY_WITCH_HURT("entity.witch.hurt"),
|
||||
ENTITY_WITCH_THROW("entity.witch.throw"),
|
||||
ENTITY_WITHER_AMBIENT("entity.wither.ambient"),
|
||||
ENTITY_WITHER_BREAK_BLOCK("entity.wither.break_block"),
|
||||
ENTITY_WITHER_DEATH("entity.wither.death"),
|
||||
ENTITY_WITHER_HURT("entity.wither.hurt"),
|
||||
ENTITY_WITHER_SHOOT("entity.wither.shoot"),
|
||||
ENTITY_WITHER_SKELETON_AMBIENT("entity.wither_skeleton.ambient"),
|
||||
ENTITY_WITHER_SKELETON_DEATH("entity.wither_skeleton.death"),
|
||||
ENTITY_WITHER_SKELETON_HURT("entity.wither_skeleton.hurt"),
|
||||
ENTITY_WITHER_SKELETON_STEP("entity.wither_skeleton.step"),
|
||||
ENTITY_WITHER_SPAWN("entity.wither.spawn"),
|
||||
ENTITY_WOLF_AMBIENT("entity.wolf.ambient"),
|
||||
ENTITY_WOLF_DEATH("entity.wolf.death"),
|
||||
ENTITY_WOLF_GROWL("entity.wolf.growl"),
|
||||
ENTITY_WOLF_HOWL("entity.wolf.howl"),
|
||||
ENTITY_WOLF_HURT("entity.wolf.hurt"),
|
||||
ENTITY_WOLF_PANT("entity.wolf.pant"),
|
||||
ENTITY_WOLF_SHAKE("entity.wolf.shake"),
|
||||
ENTITY_WOLF_STEP("entity.wolf.step"),
|
||||
ENTITY_WOLF_WHINE("entity.wolf.whine"),
|
||||
ENTITY_ZOMBIE_AMBIENT("entity.zombie.ambient"),
|
||||
ENTITY_ZOMBIE_ATTACK_IRON_DOOR("entity.zombie.attack_iron_door"),
|
||||
ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR("entity.zombie.attack_wooden_door"),
|
||||
ENTITY_ZOMBIE_BREAK_WOODEN_DOOR("entity.zombie.break_wooden_door"),
|
||||
ENTITY_ZOMBIE_CONVERTED_TO_DROWNED("entity.zombie.converted_to_drowned"),
|
||||
ENTITY_ZOMBIE_DEATH("entity.zombie.death"),
|
||||
ENTITY_ZOMBIE_DESTROY_EGG("entity.zombie.destroy_egg"),
|
||||
ENTITY_ZOMBIE_HORSE_AMBIENT("entity.zombie_horse.ambient"),
|
||||
ENTITY_ZOMBIE_HORSE_DEATH("entity.zombie_horse.death"),
|
||||
ENTITY_ZOMBIE_HORSE_HURT("entity.zombie_horse.hurt"),
|
||||
ENTITY_ZOMBIE_HURT("entity.zombie.hurt"),
|
||||
ENTITY_ZOMBIE_INFECT("entity.zombie.infect"),
|
||||
ENTITY_ZOMBIE_PIGMAN_AMBIENT("entity.zombie_pigman.ambient"),
|
||||
ENTITY_ZOMBIE_PIGMAN_ANGRY("entity.zombie_pigman.angry"),
|
||||
ENTITY_ZOMBIE_PIGMAN_DEATH("entity.zombie_pigman.death"),
|
||||
ENTITY_ZOMBIE_PIGMAN_HURT("entity.zombie_pigman.hurt"),
|
||||
ENTITY_ZOMBIE_STEP("entity.zombie.step"),
|
||||
ENTITY_ZOMBIE_VILLAGER_AMBIENT("entity.zombie_villager.ambient"),
|
||||
ENTITY_ZOMBIE_VILLAGER_CONVERTED("entity.zombie_villager.converted"),
|
||||
ENTITY_ZOMBIE_VILLAGER_CURE("entity.zombie_villager.cure"),
|
||||
ENTITY_ZOMBIE_VILLAGER_DEATH("entity.zombie_villager.death"),
|
||||
ENTITY_ZOMBIE_VILLAGER_HURT("entity.zombie_villager.hurt"),
|
||||
ENTITY_ZOMBIE_VILLAGER_STEP("entity.zombie_villager.step"),
|
||||
ITEM_ARMOR_EQUIP_CHAIN("item.armor.equip_chain"),
|
||||
ITEM_ARMOR_EQUIP_DIAMOND("item.armor.equip_diamond"),
|
||||
ITEM_ARMOR_EQUIP_ELYTRA("item.armor.equip_elytra"),
|
||||
ITEM_ARMOR_EQUIP_GENERIC("item.armor.equip_generic"),
|
||||
ITEM_ARMOR_EQUIP_GOLD("item.armor.equip_gold"),
|
||||
ITEM_ARMOR_EQUIP_IRON("item.armor.equip_iron"),
|
||||
ITEM_ARMOR_EQUIP_LEATHER("item.armor.equip_leather"),
|
||||
ITEM_ARMOR_EQUIP_TURTLE("item.armor.equip_turtle"),
|
||||
ITEM_AXE_STRIP("item.axe.strip"),
|
||||
ITEM_BOTTLE_EMPTY("item.bottle.empty"),
|
||||
ITEM_BOTTLE_FILL("item.bottle.fill"),
|
||||
ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"),
|
||||
ITEM_BUCKET_EMPTY("item.bucket.empty"),
|
||||
ITEM_BUCKET_EMPTY_FISH("item.bucket.empty_fish"),
|
||||
ITEM_BUCKET_EMPTY_LAVA("item.bucket.empty_lava"),
|
||||
ITEM_BUCKET_FILL("item.bucket.fill"),
|
||||
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_ELYTRA_FLYING("item.elytra.flying"),
|
||||
ITEM_FIRECHARGE_USE("item.firecharge.use"),
|
||||
ITEM_FLINTANDSTEEL_USE("item.flintandsteel.use"),
|
||||
ITEM_HOE_TILL("item.hoe.till"),
|
||||
ITEM_SHIELD_BLOCK("item.shield.block"),
|
||||
ITEM_SHIELD_BREAK("item.shield.break"),
|
||||
ITEM_SHOVEL_FLATTEN("item.shovel.flatten"),
|
||||
ITEM_TOTEM_USE("item.totem.use"),
|
||||
ITEM_TRIDENT_HIT("item.trident.hit"),
|
||||
ITEM_TRIDENT_HIT_GROUND("item.trident.hit_ground"),
|
||||
ITEM_TRIDENT_RETURN("item.trident.return"),
|
||||
ITEM_TRIDENT_RIPTIDE_1("item.trident.riptide_1"),
|
||||
ITEM_TRIDENT_RIPTIDE_2("item.trident.riptide_2"),
|
||||
ITEM_TRIDENT_RIPTIDE_3("item.trident.riptide_3"),
|
||||
ITEM_TRIDENT_THROW("item.trident.throw"),
|
||||
ITEM_TRIDENT_THUNDER("item.trident.thunder"),
|
||||
MUSIC_CREATIVE("music.creative"),
|
||||
MUSIC_CREDITS("music.credits"),
|
||||
MUSIC_DISC_11("music_disc.11"),
|
||||
MUSIC_DISC_13("music_disc.13"),
|
||||
MUSIC_DISC_BLOCKS("music_disc.blocks"),
|
||||
MUSIC_DISC_CAT("music_disc.cat"),
|
||||
MUSIC_DISC_CHIRP("music_disc.chirp"),
|
||||
MUSIC_DISC_FAR("music_disc.far"),
|
||||
MUSIC_DISC_MALL("music_disc.mall"),
|
||||
MUSIC_DISC_MELLOHI("music_disc.mellohi"),
|
||||
MUSIC_DISC_STAL("music_disc.stal"),
|
||||
MUSIC_DISC_STRAD("music_disc.strad"),
|
||||
MUSIC_DISC_WAIT("music_disc.wait"),
|
||||
MUSIC_DISC_WARD("music_disc.ward"),
|
||||
MUSIC_DRAGON("music.dragon"),
|
||||
MUSIC_END("music.end"),
|
||||
MUSIC_GAME("music.game"),
|
||||
MUSIC_MENU("music.menu"),
|
||||
MUSIC_NETHER("music.nether"),
|
||||
MUSIC_UNDER_WATER("music.under_water"),
|
||||
UI_BUTTON_CLICK("ui.button.click"),
|
||||
UI_TOAST_CHALLENGE_COMPLETE("ui.toast.challenge_complete"),
|
||||
UI_TOAST_IN("ui.toast.in"),
|
||||
UI_TOAST_OUT("ui.toast.out"),
|
||||
WEATHER_RAIN("weather.rain"),
|
||||
WEATHER_RAIN_ABOVE("weather.rain.above");
|
||||
private final String minecraftKey;
|
||||
|
||||
// Paper start - cancellable death event
|
||||
public static CraftSound getBySoundEffect(final SoundEffect effect) {
|
||||
MinecraftKey key = IRegistry.SOUND_EVENT.getKey(effect);
|
||||
Preconditions.checkArgument(key != null, "Key for sound effect %s not found?", effect.toString());
|
||||
|
||||
return valueOf(key.getKey().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public static Sound getSoundByEffect(final SoundEffect effect) {
|
||||
return Sound.valueOf(getBySoundEffect(effect).name());
|
||||
}
|
||||
|
||||
public static SoundEffect getSoundEffect(final Sound sound) {
|
||||
return getSoundEffect(getSound(sound));
|
||||
}
|
||||
// Paper end
|
||||
CraftSound(String minecraftKey) {
|
||||
this.minecraftKey = minecraftKey;
|
||||
}
|
||||
|
||||
public static String getSound(final Sound sound) {
|
||||
Validate.notNull(sound, "Sound cannot be null");
|
||||
|
||||
return CraftSound.valueOf(sound.name()).minecraftKey;
|
||||
}
|
||||
|
||||
public static SoundEffect getSoundEffect(String s) {
|
||||
SoundEffect effect = IRegistry.SOUND_EVENT.get(new MinecraftKey(s));
|
||||
Preconditions.checkArgument(effect != null, "Sound effect %s does not exist", s);
|
||||
|
||||
return effect;
|
||||
}
|
||||
}
|
||||
180
src/main/java/org/bukkit/craftbukkit/CraftStatistic.java
Normal file
180
src/main/java/org/bukkit/craftbukkit/CraftStatistic.java
Normal file
@@ -0,0 +1,180 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.StatisticList;
|
||||
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.EntityTypes;
|
||||
import net.minecraft.server.IRegistry;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public enum CraftStatistic {
|
||||
DAMAGE_DEALT(StatisticList.DAMAGE_DEALT),
|
||||
DAMAGE_TAKEN(StatisticList.DAMAGE_TAKEN),
|
||||
DEATHS(StatisticList.DEATHS),
|
||||
MOB_KILLS(StatisticList.MOB_KILLS),
|
||||
PLAYER_KILLS(StatisticList.PLAYER_KILLS),
|
||||
FISH_CAUGHT(StatisticList.FISH_CAUGHT),
|
||||
ANIMALS_BRED(StatisticList.ANIMALS_BRED),
|
||||
LEAVE_GAME(StatisticList.LEAVE_GAME),
|
||||
JUMP(StatisticList.JUMP),
|
||||
DROP_COUNT(StatisticList.DROP),
|
||||
DROP(new MinecraftKey("dropped")),
|
||||
PICKUP(new MinecraftKey("picked_up")),
|
||||
PLAY_ONE_MINUTE(StatisticList.PLAY_ONE_MINUTE),
|
||||
WALK_ONE_CM(StatisticList.WALK_ONE_CM),
|
||||
WALK_ON_WATER_ONE_CM(StatisticList.WALK_ON_WATER_ONE_CM),
|
||||
FALL_ONE_CM(StatisticList.FALL_ONE_CM),
|
||||
SNEAK_TIME(StatisticList.SNEAK_TIME),
|
||||
CLIMB_ONE_CM(StatisticList.CLIMB_ONE_CM),
|
||||
FLY_ONE_CM(StatisticList.FLY_ONE_CM),
|
||||
WALK_UNDER_WATER_ONE_CM(StatisticList.WALK_UNDER_WATER_ONE_CM),
|
||||
MINECART_ONE_CM(StatisticList.MINECART_ONE_CM),
|
||||
BOAT_ONE_CM(StatisticList.BOAT_ONE_CM),
|
||||
PIG_ONE_CM(StatisticList.PIG_ONE_CM),
|
||||
HORSE_ONE_CM(StatisticList.HORSE_ONE_CM),
|
||||
SPRINT_ONE_CM(StatisticList.SPRINT_ONE_CM),
|
||||
CROUCH_ONE_CM(StatisticList.CROUCH_ONE_CM),
|
||||
AVIATE_ONE_CM(StatisticList.AVIATE_ONE_CM),
|
||||
MINE_BLOCK(new MinecraftKey("mined")),
|
||||
USE_ITEM(new MinecraftKey("used")),
|
||||
BREAK_ITEM(new MinecraftKey("broken")),
|
||||
CRAFT_ITEM(new MinecraftKey("crafted")),
|
||||
KILL_ENTITY(new MinecraftKey("killed")),
|
||||
ENTITY_KILLED_BY(new MinecraftKey("killed_by")),
|
||||
TIME_SINCE_DEATH(StatisticList.TIME_SINCE_DEATH),
|
||||
TALKED_TO_VILLAGER(StatisticList.TALKED_TO_VILLAGER),
|
||||
TRADED_WITH_VILLAGER(StatisticList.TRADED_WITH_VILLAGER),
|
||||
CAKE_SLICES_EATEN(StatisticList.EAT_CAKE_SLICE),
|
||||
CAULDRON_FILLED(StatisticList.FILL_CAULDRON),
|
||||
CAULDRON_USED(StatisticList.USE_CAULDRON),
|
||||
ARMOR_CLEANED(StatisticList.CLEAN_ARMOR),
|
||||
BANNER_CLEANED(StatisticList.CLEAN_BANNER),
|
||||
BREWINGSTAND_INTERACTION(StatisticList.INTERACT_WITH_BREWINGSTAND),
|
||||
BEACON_INTERACTION(StatisticList.INTERACT_WITH_BEACON),
|
||||
DROPPER_INSPECTED(StatisticList.INSPECT_DROPPER),
|
||||
HOPPER_INSPECTED(StatisticList.INSPECT_HOPPER),
|
||||
DISPENSER_INSPECTED(StatisticList.INSPECT_DISPENSER),
|
||||
NOTEBLOCK_PLAYED(StatisticList.PLAY_NOTEBLOCK),
|
||||
NOTEBLOCK_TUNED(StatisticList.TUNE_NOTEBLOCK),
|
||||
FLOWER_POTTED(StatisticList.POT_FLOWER),
|
||||
TRAPPED_CHEST_TRIGGERED(StatisticList.TRIGGER_TRAPPED_CHEST),
|
||||
ENDERCHEST_OPENED(StatisticList.OPEN_ENDERCHEST),
|
||||
ITEM_ENCHANTED(StatisticList.ENCHANT_ITEM),
|
||||
RECORD_PLAYED(StatisticList.PLAY_RECORD),
|
||||
FURNACE_INTERACTION(StatisticList.INTERACT_WITH_FURNACE),
|
||||
CRAFTING_TABLE_INTERACTION(StatisticList.INTERACT_WITH_CRAFTING_TABLE),
|
||||
CHEST_OPENED(StatisticList.OPEN_CHEST),
|
||||
SLEEP_IN_BED(StatisticList.SLEEP_IN_BED),
|
||||
SHULKER_BOX_OPENED(StatisticList.OPEN_SHULKER_BOX),
|
||||
TIME_SINCE_REST(StatisticList.TIME_SINCE_REST),
|
||||
SWIM_ONE_CM(StatisticList.SWIM_ONE_CM),
|
||||
DAMAGE_DEALT_ABSORBED(StatisticList.DAMAGE_DEALT_ABSORBED),
|
||||
DAMAGE_DEALT_RESISTED(StatisticList.DAMAGE_DEALT_RESISTED),
|
||||
DAMAGE_BLOCKED_BY_SHIELD(StatisticList.DAMAGE_BLOCKED_BY_SHIELD),
|
||||
DAMAGE_ABSORBED(StatisticList.DAMAGE_ABSORBED),
|
||||
DAMAGE_RESISTED(StatisticList.DAMAGE_RESISTED),
|
||||
CLEAN_SHULKER_BOX(StatisticList.CLEAN_SHULKER_BOX);
|
||||
private final MinecraftKey minecraftKey;
|
||||
private final org.bukkit.Statistic bukkit;
|
||||
private static final BiMap<MinecraftKey, org.bukkit.Statistic> statistics;
|
||||
|
||||
static {
|
||||
ImmutableBiMap.Builder<MinecraftKey, org.bukkit.Statistic> statisticBuilder = ImmutableBiMap.builder();
|
||||
for (CraftStatistic statistic : CraftStatistic.values()) {
|
||||
statisticBuilder.put(statistic.minecraftKey, statistic.bukkit);
|
||||
}
|
||||
|
||||
statistics = statisticBuilder.build();
|
||||
}
|
||||
|
||||
private CraftStatistic(MinecraftKey minecraftKey) {
|
||||
this.minecraftKey = minecraftKey;
|
||||
|
||||
this.bukkit = org.bukkit.Statistic.valueOf(this.name());
|
||||
Preconditions.checkState(bukkit != null, "Bukkit statistic %s does not exist", this.name());
|
||||
}
|
||||
|
||||
public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.server.Statistic<?> statistic) {
|
||||
IRegistry statRegistry = statistic.a().a();
|
||||
MinecraftKey nmsKey = IRegistry.STATS.getKey(statistic.a());
|
||||
|
||||
if (statRegistry == IRegistry.CUSTOM_STAT) {
|
||||
nmsKey = (MinecraftKey) statistic.b();
|
||||
}
|
||||
|
||||
return statistics.get(nmsKey);
|
||||
}
|
||||
|
||||
public static net.minecraft.server.Statistic getNMSStatistic(org.bukkit.Statistic bukkit) {
|
||||
Preconditions.checkArgument(bukkit.getType() == Statistic.Type.UNTYPED, "This method only accepts untyped statistics");
|
||||
|
||||
net.minecraft.server.Statistic<MinecraftKey> nms = StatisticList.CUSTOM.b(statistics.inverse().get(bukkit));
|
||||
Preconditions.checkArgument(nms != null, "NMS Statistic %s does not exist", bukkit);
|
||||
|
||||
return nms;
|
||||
}
|
||||
|
||||
public static net.minecraft.server.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
|
||||
try {
|
||||
if (stat == Statistic.MINE_BLOCK) {
|
||||
return StatisticList.BLOCK_MINED.b(CraftMagicNumbers.getBlock(material));
|
||||
}
|
||||
if (stat == Statistic.CRAFT_ITEM) {
|
||||
return StatisticList.ITEM_CRAFTED.b(CraftMagicNumbers.getItem(material));
|
||||
}
|
||||
if (stat == Statistic.USE_ITEM) {
|
||||
return StatisticList.ITEM_USED.b(CraftMagicNumbers.getItem(material));
|
||||
}
|
||||
if (stat == Statistic.BREAK_ITEM) {
|
||||
return StatisticList.ITEM_BROKEN.b(CraftMagicNumbers.getItem(material));
|
||||
}
|
||||
if (stat == Statistic.PICKUP) {
|
||||
return StatisticList.ITEM_PICKED_UP.b(CraftMagicNumbers.getItem(material));
|
||||
}
|
||||
if (stat == Statistic.DROP) {
|
||||
return StatisticList.ITEM_DROPPED.b(CraftMagicNumbers.getItem(material));
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static net.minecraft.server.Statistic getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) {
|
||||
if (entity.getName() != null) {
|
||||
EntityTypes<?> nmsEntity = IRegistry.ENTITY_TYPE.get(new MinecraftKey(entity.getName()));
|
||||
|
||||
if (stat == org.bukkit.Statistic.KILL_ENTITY) {
|
||||
return net.minecraft.server.StatisticList.ENTITY_KILLED.b(nmsEntity);
|
||||
}
|
||||
if (stat == org.bukkit.Statistic.ENTITY_KILLED_BY) {
|
||||
return net.minecraft.server.StatisticList.ENTITY_KILLED_BY.b(nmsEntity);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EntityType getEntityTypeFromStatistic(net.minecraft.server.Statistic<EntityTypes<?>> statistic) {
|
||||
MinecraftKey name = EntityTypes.getName(statistic.b());
|
||||
return EntityType.fromName(name.getKey());
|
||||
}
|
||||
|
||||
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic<?> statistic) {
|
||||
if (statistic.b() instanceof Item) {
|
||||
return CraftMagicNumbers.getMaterial((Item) statistic.b());
|
||||
}
|
||||
if (statistic.b() instanceof Block) {
|
||||
return CraftMagicNumbers.getMaterial((Block) statistic.b());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
86
src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java
Normal file
86
src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java
Normal file
@@ -0,0 +1,86 @@
|
||||
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 = world.paperConfig.portalSearchRadius; // Paper - Configurable search radius
|
||||
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;
|
||||
}
|
||||
}
|
||||
1885
src/main/java/org/bukkit/craftbukkit/CraftWorld.java
Normal file
1885
src/main/java/org/bukkit/craftbukkit/CraftWorld.java
Normal file
File diff suppressed because it is too large
Load Diff
120
src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java
Normal file
120
src/main/java/org/bukkit/craftbukkit/CraftWorldBorder.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
|
||||
public class CraftWorldBorder implements WorldBorder {
|
||||
|
||||
private final World world;
|
||||
private final net.minecraft.server.WorldBorder handle;
|
||||
|
||||
public CraftWorldBorder(CraftWorld world) {
|
||||
this.world = world;
|
||||
this.handle = world.getHandle().getWorldBorder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.setSize(6.0E7D);
|
||||
this.setDamageAmount(0.2D);
|
||||
this.setDamageBuffer(5.0D);
|
||||
this.setWarningDistance(5);
|
||||
this.setWarningTime(15);
|
||||
this.setCenter(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSize() {
|
||||
return this.handle.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(double newSize) {
|
||||
this.setSize(newSize, 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(double newSize, long time) {
|
||||
// PAIL: TODO: Magic Values
|
||||
newSize = Math.min(6.0E7D, Math.max(1.0D, newSize));
|
||||
time = Math.min(9223372036854775L, Math.max(0L, time));
|
||||
|
||||
if (time > 0L) {
|
||||
this.handle.transitionSizeBetween(this.handle.getSize(), newSize, time * 1000L);
|
||||
} else {
|
||||
this.handle.setSize(newSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getCenter() {
|
||||
double x = this.handle.getCenterX();
|
||||
double z = this.handle.getCenterZ();
|
||||
|
||||
return new Location(this.world, x, 0, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCenter(double x, double z) {
|
||||
// PAIL: TODO: Magic Values
|
||||
x = Math.min(3.0E7D, Math.max(-3.0E7D, x));
|
||||
z = Math.min(3.0E7D, Math.max(-3.0E7D, z));
|
||||
|
||||
this.handle.setCenter(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCenter(Location location) {
|
||||
this.setCenter(location.getX(), location.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamageBuffer() {
|
||||
return this.handle.getDamageBuffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDamageBuffer(double blocks) {
|
||||
this.handle.setDamageBuffer(blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamageAmount() {
|
||||
return this.handle.getDamageAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDamageAmount(double damage) {
|
||||
this.handle.setDamageAmount(damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningTime() {
|
||||
return this.handle.getWarningTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarningTime(int time) {
|
||||
this.handle.setWarningTime(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarningDistance() {
|
||||
return this.handle.getWarningDistance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWarningDistance(int distance) {
|
||||
this.handle.setWarningDistance(distance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInside(Location location) {
|
||||
Preconditions.checkArgument(location != null, "location");
|
||||
|
||||
return location.getWorld().equals(this.world) && this.handle.a(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
}
|
||||
31
src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java
Normal file
31
src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LoggerOutputStream extends ByteArrayOutputStream {
|
||||
private final String separator = System.getProperty("line.separator");
|
||||
private final Logger logger;
|
||||
private final Level level;
|
||||
|
||||
public LoggerOutputStream(Logger logger, Level level) {
|
||||
super();
|
||||
this.logger = logger;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
synchronized (this) {
|
||||
super.flush();
|
||||
String record = this.toString();
|
||||
super.reset();
|
||||
|
||||
if ((record.length() > 0) && (!record.equals(separator))) {
|
||||
logger.log(level, record);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
253
src/main/java/org/bukkit/craftbukkit/Main.java
Normal file
253
src/main/java/org/bukkit/craftbukkit/Main.java
Normal file
@@ -0,0 +1,253 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecrell.terminalconsole.TerminalConsoleAppender; // Paper
|
||||
|
||||
public class Main {
|
||||
public static boolean useJline = true;
|
||||
public static boolean useConsole = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Todo: Installation script
|
||||
OptionParser parser = new OptionParser() {
|
||||
{
|
||||
acceptsAll(asList("?", "help"), "Show the help");
|
||||
|
||||
acceptsAll(asList("c", "config"), "Properties file to use")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class)
|
||||
.defaultsTo(new File("server.properties"))
|
||||
.describedAs("Properties file");
|
||||
|
||||
acceptsAll(asList("P", "plugins"), "Plugin directory to use")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class)
|
||||
.defaultsTo(new File("plugins"))
|
||||
.describedAs("Plugin directory");
|
||||
|
||||
acceptsAll(asList("h", "host", "server-ip"), "Host to listen on")
|
||||
.withRequiredArg()
|
||||
.ofType(String.class)
|
||||
.describedAs("Hostname or IP");
|
||||
|
||||
acceptsAll(asList("W", "world-dir", "universe", "world-container"), "World container")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class)
|
||||
.describedAs("Directory containing worlds");
|
||||
|
||||
acceptsAll(asList("w", "world", "level-name"), "World name")
|
||||
.withRequiredArg()
|
||||
.ofType(String.class)
|
||||
.describedAs("World name");
|
||||
|
||||
acceptsAll(asList("p", "port", "server-port"), "Port to listen on")
|
||||
.withRequiredArg()
|
||||
.ofType(Integer.class)
|
||||
.describedAs("Port");
|
||||
|
||||
acceptsAll(asList("o", "online-mode"), "Whether to use online authentication")
|
||||
.withRequiredArg()
|
||||
.ofType(Boolean.class)
|
||||
.describedAs("Authentication");
|
||||
|
||||
acceptsAll(asList("s", "size", "max-players"), "Maximum amount of players")
|
||||
.withRequiredArg()
|
||||
.ofType(Integer.class)
|
||||
.describedAs("Server size");
|
||||
|
||||
acceptsAll(asList("d", "date-format"), "Format of the date to display in the console (for log entries)")
|
||||
.withRequiredArg()
|
||||
.ofType(SimpleDateFormat.class)
|
||||
.describedAs("Log date format");
|
||||
|
||||
acceptsAll(asList("log-pattern"), "Specfies the log filename pattern")
|
||||
.withRequiredArg()
|
||||
.ofType(String.class)
|
||||
.defaultsTo("server.log")
|
||||
.describedAs("Log filename");
|
||||
|
||||
acceptsAll(asList("log-limit"), "Limits the maximum size of the log file (0 = unlimited)")
|
||||
.withRequiredArg()
|
||||
.ofType(Integer.class)
|
||||
.defaultsTo(0)
|
||||
.describedAs("Max log size");
|
||||
|
||||
acceptsAll(asList("log-count"), "Specified how many log files to cycle through")
|
||||
.withRequiredArg()
|
||||
.ofType(Integer.class)
|
||||
.defaultsTo(1)
|
||||
.describedAs("Log count");
|
||||
|
||||
acceptsAll(asList("log-append"), "Whether to append to the log file")
|
||||
.withRequiredArg()
|
||||
.ofType(Boolean.class)
|
||||
.defaultsTo(true)
|
||||
.describedAs("Log append");
|
||||
|
||||
acceptsAll(asList("log-strip-color"), "Strips color codes from log file");
|
||||
|
||||
acceptsAll(asList("b", "bukkit-settings"), "File for bukkit settings")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class)
|
||||
.defaultsTo(new File("bukkit.yml"))
|
||||
.describedAs("Yml file");
|
||||
|
||||
acceptsAll(asList("C", "commands-settings"), "File for command settings")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class)
|
||||
.defaultsTo(new File("commands.yml"))
|
||||
.describedAs("Yml file");
|
||||
|
||||
acceptsAll(asList("forceUpgrade"), "Whether to force a world upgrade");
|
||||
|
||||
acceptsAll(asList("nojline"), "Disables jline and emulates the vanilla console");
|
||||
|
||||
acceptsAll(asList("noconsole"), "Disables the console");
|
||||
|
||||
acceptsAll(asList("v", "version"), "Show the CraftBukkit Version");
|
||||
|
||||
acceptsAll(asList("demo"), "Demo mode");
|
||||
|
||||
// Spigot Start
|
||||
acceptsAll(asList("S", "spigot-settings"), "File for spigot settings")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class)
|
||||
.defaultsTo(new File("spigot.yml"))
|
||||
.describedAs("Yml file");
|
||||
// Spigot End
|
||||
|
||||
// Paper Start
|
||||
acceptsAll(asList("paper", "paper-settings"), "File for paper settings")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class)
|
||||
.defaultsTo(new File("paper.yml"))
|
||||
.describedAs("Yml file");
|
||||
// Paper end
|
||||
|
||||
// Paper start
|
||||
acceptsAll(asList("server-name"), "Name of the server")
|
||||
.withRequiredArg()
|
||||
.ofType(String.class)
|
||||
.defaultsTo("Unknown Server")
|
||||
.describedAs("Name");
|
||||
// Paper end
|
||||
}
|
||||
};
|
||||
|
||||
OptionSet options = null;
|
||||
|
||||
try {
|
||||
options = parser.parse(args);
|
||||
} catch (joptsimple.OptionException ex) {
|
||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
if ((options == null) || (options.has("?"))) {
|
||||
try {
|
||||
parser.printHelpOn(System.out);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
} else if (options.has("v")) {
|
||||
System.out.println(CraftServer.class.getPackage().getImplementationVersion());
|
||||
} else {
|
||||
// Do you love Java using + and ! as string based identifiers? I sure do!
|
||||
String path = new File(".").getAbsolutePath();
|
||||
if (path.contains("!") || path.contains("+")) {
|
||||
System.err.println("Cannot run server in a directory with ! or + in the pathname. Please rename the affected folders and try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
float javaVersion = Float.parseFloat(System.getProperty("java.class.version"));
|
||||
if (javaVersion > 55.0) {
|
||||
System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 11 is supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Paper start - Handled by TerminalConsoleAppender
|
||||
/*
|
||||
// This trick bypasses Maven Shade's clever rewriting of our getProperty call when using String literals
|
||||
String jline_UnsupportedTerminal = new String(new char[] {'j','l','i','n','e','.','U','n','s','u','p','p','o','r','t','e','d','T','e','r','m','i','n','a','l'});
|
||||
String jline_terminal = new String(new char[] {'j','l','i','n','e','.','t','e','r','m','i','n','a','l'});
|
||||
|
||||
useJline = !(jline_UnsupportedTerminal).equals(System.getProperty(jline_terminal));
|
||||
|
||||
if (options.has("nojline")) {
|
||||
System.setProperty("user.language", "en");
|
||||
useJline = false;
|
||||
}
|
||||
|
||||
if (useJline) {
|
||||
AnsiConsole.systemInstall();
|
||||
} else {
|
||||
// This ensures the terminal literal will always match the jline implementation
|
||||
System.setProperty(jline.TerminalFactory.JLINE_TERMINAL, jline.UnsupportedTerminal.class.getName());
|
||||
}
|
||||
*/
|
||||
|
||||
if (options.has("nojline")) {
|
||||
System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false");
|
||||
useJline = false;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
if (options.has("noconsole")) {
|
||||
useConsole = false;
|
||||
useJline = false; // Paper
|
||||
System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false"); // Paper
|
||||
}
|
||||
|
||||
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
|
||||
Date buildDate = new SimpleDateFormat("yyyyMMdd-HHmm").parse(Main.class.getPackage().getImplementationVendor());
|
||||
|
||||
Calendar deadline = Calendar.getInstance();
|
||||
deadline.add(Calendar.DAY_OF_YEAR, -21);
|
||||
if (buildDate.before(deadline.getTime())) {
|
||||
// Paper start - This is some stupid bullshit
|
||||
System.err.println("*** Warning, you've not updated in a while! ***");
|
||||
System.err.println("*** Please download a new build as per instructions from https://papermc.io/downloads ***"); // Paper
|
||||
//System.err.println("*** Server will start in 20 seconds ***");
|
||||
//Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
||||
// Paper End
|
||||
}
|
||||
}
|
||||
|
||||
// Paper start - Log Java and OS versioning to help with debugging plugin issues
|
||||
java.lang.management.RuntimeMXBean runtimeMX = java.lang.management.ManagementFactory.getRuntimeMXBean();
|
||||
java.lang.management.OperatingSystemMXBean osMX = java.lang.management.ManagementFactory.getOperatingSystemMXBean();
|
||||
if (runtimeMX != null && osMX != null) {
|
||||
String javaInfo = "Java " + runtimeMX.getSpecVersion() + " (" + runtimeMX.getVmName() + " " + runtimeMX.getVmVersion() + ")";
|
||||
String osInfo = "Host: " + osMX.getName() + " " + osMX.getVersion() + " (" + osMX.getArch() + ")";
|
||||
|
||||
System.out.println("System Info: " + javaInfo + " " + osInfo);
|
||||
} else {
|
||||
System.out.println("Unable to read system info");
|
||||
}
|
||||
// Paper end
|
||||
|
||||
System.out.println("Loading libraries, please wait...");
|
||||
MinecraftServer.main(options);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> asList(String... params) {
|
||||
return Arrays.asList(params);
|
||||
}
|
||||
}
|
||||
14
src/main/java/org/bukkit/craftbukkit/Overridden.java
Normal file
14
src/main/java/org/bukkit/craftbukkit/Overridden.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Indicates a method needs to be overridden in sub classes
|
||||
*/
|
||||
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Overridden {
|
||||
}
|
||||
47
src/main/java/org/bukkit/craftbukkit/TrigMath.java
Normal file
47
src/main/java/org/bukkit/craftbukkit/TrigMath.java
Normal file
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.bukkit.craftbukkit.advancement;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import net.minecraft.server.Advancement;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
|
||||
public class CraftAdvancement implements org.bukkit.advancement.Advancement {
|
||||
|
||||
private final Advancement handle;
|
||||
|
||||
public CraftAdvancement(Advancement handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public Advancement getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return CraftNamespacedKey.fromMinecraft(handle.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getCriteria() {
|
||||
return Collections.unmodifiableCollection(handle.getCriteria().keySet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.bukkit.craftbukkit.advancement;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import net.minecraft.server.AdvancementDataPlayer;
|
||||
import net.minecraft.server.CriterionProgress;
|
||||
import org.bukkit.advancement.Advancement;
|
||||
import org.bukkit.advancement.AdvancementProgress;
|
||||
|
||||
public class CraftAdvancementProgress implements AdvancementProgress {
|
||||
|
||||
private final CraftAdvancement advancement;
|
||||
private final AdvancementDataPlayer playerData;
|
||||
private final net.minecraft.server.AdvancementProgress handle;
|
||||
|
||||
public CraftAdvancementProgress(CraftAdvancement advancement, AdvancementDataPlayer player, net.minecraft.server.AdvancementProgress handle) {
|
||||
this.advancement = advancement;
|
||||
this.playerData = player;
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Advancement getAdvancement() {
|
||||
return advancement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDone() {
|
||||
return handle.isDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awardCriteria(String criteria) {
|
||||
return playerData.grantCriteria(advancement.getHandle(), criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeCriteria(String criteria) {
|
||||
return playerData.revokeCritera(advancement.getHandle(), criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getDateAwarded(String criteria) {
|
||||
CriterionProgress criterion = handle.getCriterionProgress(criteria);
|
||||
return (criterion == null) ? null : criterion.getDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getRemainingCriteria() {
|
||||
return Collections.unmodifiableCollection(Lists.newArrayList(handle.getRemainingCriteria()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getAwardedCriteria() {
|
||||
return Collections.unmodifiableCollection(Lists.newArrayList(handle.getAwardedCriteria()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.bukkit.craftbukkit.attribute;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
|
||||
public class CraftAttributeInstance implements AttributeInstance {
|
||||
|
||||
private final net.minecraft.server.AttributeInstance handle;
|
||||
private final Attribute attribute;
|
||||
|
||||
public CraftAttributeInstance(net.minecraft.server.AttributeInstance handle, Attribute attribute) {
|
||||
this.handle = handle;
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attribute getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseValue() {
|
||||
return handle.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseValue(double d) {
|
||||
handle.setValue(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AttributeModifier> getModifiers() {
|
||||
List<AttributeModifier> result = new ArrayList<AttributeModifier>();
|
||||
for (net.minecraft.server.AttributeModifier nms : handle.c()) {
|
||||
result.add(convert(nms));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModifier(AttributeModifier modifier) {
|
||||
Preconditions.checkArgument(modifier != null, "modifier");
|
||||
handle.b(convert(modifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeModifier(AttributeModifier modifier) {
|
||||
Preconditions.checkArgument(modifier != null, "modifier");
|
||||
handle.c(convert(modifier));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getValue() {
|
||||
return handle.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDefaultValue() {
|
||||
return handle.getAttribute().getDefault();
|
||||
}
|
||||
|
||||
public static net.minecraft.server.AttributeModifier convert(AttributeModifier bukkit) {
|
||||
return new net.minecraft.server.AttributeModifier(bukkit.getUniqueId(), bukkit.getName(), bukkit.getAmount(), 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()]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.bukkit.craftbukkit.attribute;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.server.AttributeMapBase;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.attribute.Attributable;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
|
||||
public class CraftAttributeMap implements Attributable {
|
||||
|
||||
private final AttributeMapBase handle;
|
||||
|
||||
public CraftAttributeMap(AttributeMapBase handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeInstance getAttribute(Attribute attribute) {
|
||||
Preconditions.checkArgument(attribute != null, "attribute");
|
||||
net.minecraft.server.AttributeInstance nms = handle.a(toMinecraft(attribute.name()));
|
||||
|
||||
return (nms == null) ? null : new CraftAttributeInstance(nms, attribute);
|
||||
}
|
||||
|
||||
public static String toMinecraft(String bukkit) {
|
||||
int first = bukkit.indexOf('_');
|
||||
int second = bukkit.indexOf('_', first + 1);
|
||||
|
||||
StringBuilder sb = new StringBuilder(bukkit.toLowerCase(java.util.Locale.ENGLISH));
|
||||
|
||||
sb.setCharAt(first, '.');
|
||||
if (second != -1) {
|
||||
sb.deleteCharAt(second);
|
||||
sb.setCharAt(second, bukkit.charAt(second + 1));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String toMinecraft(Attribute attribute) {
|
||||
return toMinecraft(attribute.name());
|
||||
}
|
||||
|
||||
public static Attribute fromMinecraft(String nms) {
|
||||
String[] split = nms.split("\\.", 2);
|
||||
|
||||
String generic = split[0];
|
||||
String descriptor = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, split[1]); // movementSpeed -> MOVEMENT_SPEED
|
||||
String fin = generic + "_" + descriptor;
|
||||
return EnumUtils.getEnum(Attribute.class, fin.toUpperCase(Locale.ROOT)); // so we can return null without throwing exceptions
|
||||
}
|
||||
}
|
||||
109
src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
Normal file
109
src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.EnumColor;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
import net.minecraft.server.TileEntityBanner;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
|
||||
public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> implements Banner {
|
||||
|
||||
private DyeColor base;
|
||||
private List<Pattern> patterns;
|
||||
|
||||
public CraftBanner(final Block block) {
|
||||
super(block, TileEntityBanner.class);
|
||||
}
|
||||
|
||||
public CraftBanner(final Material material, final TileEntityBanner te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(TileEntityBanner banner) {
|
||||
super.load(banner);
|
||||
|
||||
if (banner.color != null) {
|
||||
base = DyeColor.getByWoolData((byte) banner.color.getColorIndex());
|
||||
}
|
||||
patterns = new ArrayList<Pattern>();
|
||||
|
||||
if (banner.patterns != null) {
|
||||
for (int i = 0; i < banner.patterns.size(); i++) {
|
||||
NBTTagCompound p = (NBTTagCompound) banner.patterns.get(i);
|
||||
patterns.add(new Pattern(DyeColor.getByWoolData((byte) p.getInt("Color")), PatternType.getByIdentifier(p.getString("Pattern"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getBaseColor() {
|
||||
return this.base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseColor(DyeColor color) {
|
||||
Preconditions.checkArgument(color != null, "color");
|
||||
this.base = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pattern> getPatterns() {
|
||||
return new ArrayList<Pattern>(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPatterns(List<Pattern> patterns) {
|
||||
this.patterns = new ArrayList<Pattern>(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPattern(Pattern pattern) {
|
||||
this.patterns.add(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern getPattern(int i) {
|
||||
return this.patterns.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern removePattern(int i) {
|
||||
return this.patterns.remove(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPattern(int i, Pattern pattern) {
|
||||
this.patterns.set(i, pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numberOfPatterns() {
|
||||
return patterns.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(TileEntityBanner banner) {
|
||||
super.applyTo(banner);
|
||||
|
||||
banner.color = EnumColor.fromColorIndex(base.getWoolData());
|
||||
|
||||
NBTTagList newPatterns = new NBTTagList();
|
||||
|
||||
for (Pattern p : patterns) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInt("Color", p.getColor().getWoolData());
|
||||
compound.setString("Pattern", p.getPattern().getIdentifier());
|
||||
newPatterns.add(compound);
|
||||
}
|
||||
banner.patterns = newPatterns;
|
||||
}
|
||||
}
|
||||
98
src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
Normal file
98
src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
Normal file
@@ -0,0 +1,98 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.MobEffectList;
|
||||
import net.minecraft.server.TileEntity;
|
||||
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 CraftBeacon(final Block block) {
|
||||
super(block, TileEntityBeacon.class);
|
||||
}
|
||||
|
||||
public CraftBeacon(final Material material, final TileEntityBeacon te) {
|
||||
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();
|
||||
if (tileEntity instanceof TileEntityBeacon) {
|
||||
TileEntityBeacon beacon = (TileEntityBeacon) tileEntity;
|
||||
|
||||
Collection<EntityHuman> nms = beacon.getHumansInRange();
|
||||
Collection<LivingEntity> bukkit = new ArrayList<LivingEntity>(nms.size());
|
||||
|
||||
for (EntityHuman human : nms) {
|
||||
bukkit.add(human.getBukkitEntity());
|
||||
}
|
||||
|
||||
return bukkit;
|
||||
}
|
||||
|
||||
// block is no longer a beacon
|
||||
return new ArrayList<LivingEntity>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTier() {
|
||||
return this.getSnapshot().levels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffect getPrimaryEffect() {
|
||||
return this.getSnapshot().getPrimaryEffect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryEffect(PotionEffectType effect) {
|
||||
this.getSnapshot().primaryEffect = (effect != null) ? MobEffectList.fromId(effect.getId()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffect getSecondaryEffect() {
|
||||
return this.getSnapshot().getSecondaryEffect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondaryEffect(PotionEffectType effect) {
|
||||
this.getSnapshot().secondaryEffect = (effect != null) ? MobEffectList.fromId(effect.getId()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
TileEntityBeacon beacon = this.getSnapshot();
|
||||
return beacon.hasCustomName() ? CraftChatMessage.fromComponent(beacon.getCustomName()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
}
|
||||
63
src/main/java/org/bukkit/craftbukkit/block/CraftBed.java
Normal file
63
src/main/java/org/bukkit/craftbukkit/block/CraftBed.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityBed;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Bed;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class CraftBed extends CraftBlockEntityState<TileEntityBed> implements Bed {
|
||||
|
||||
public CraftBed(Block block) {
|
||||
super(block, TileEntityBed.class);
|
||||
}
|
||||
|
||||
public CraftBed(Material material, TileEntityBed te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
switch (getType()) {
|
||||
case BLACK_BED:
|
||||
return DyeColor.BLACK;
|
||||
case BLUE_BED:
|
||||
return DyeColor.BLUE;
|
||||
case BROWN_BED:
|
||||
return DyeColor.BROWN;
|
||||
case CYAN_BED:
|
||||
return DyeColor.CYAN;
|
||||
case GRAY_BED:
|
||||
return DyeColor.GRAY;
|
||||
case GREEN_BED:
|
||||
return DyeColor.GREEN;
|
||||
case LIGHT_BLUE_BED:
|
||||
return DyeColor.LIGHT_BLUE;
|
||||
case LIGHT_GRAY_BED:
|
||||
return DyeColor.LIGHT_GRAY;
|
||||
case LIME_BED:
|
||||
return DyeColor.LIME;
|
||||
case MAGENTA_BED:
|
||||
return DyeColor.MAGENTA;
|
||||
case ORANGE_BED:
|
||||
return DyeColor.ORANGE;
|
||||
case PINK_BED:
|
||||
return DyeColor.PINK;
|
||||
case PURPLE_BED:
|
||||
return DyeColor.PURPLE;
|
||||
case RED_BED:
|
||||
return DyeColor.RED;
|
||||
case WHITE_BED:
|
||||
return DyeColor.WHITE;
|
||||
case YELLOW_BED:
|
||||
return DyeColor.YELLOW;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown DyeColor for " + getType());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(DyeColor color) {
|
||||
throw new UnsupportedOperationException("Must set block type to appropriate bed colour");
|
||||
}
|
||||
}
|
||||
678
src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
Normal file
678
src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
Normal file
@@ -0,0 +1,678 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.PistonMoveReaction;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.CraftFluidCollisionMode;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.CraftRayTraceResult;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CraftBlock implements Block {
|
||||
private final net.minecraft.server.GeneratorAccess world;
|
||||
private final BlockPosition position;
|
||||
|
||||
public CraftBlock(GeneratorAccess world, BlockPosition position) {
|
||||
this.world = world;
|
||||
this.position = position.h();
|
||||
}
|
||||
|
||||
public static CraftBlock at(GeneratorAccess world, BlockPosition position) {
|
||||
return new CraftBlock(world, position);
|
||||
}
|
||||
|
||||
private net.minecraft.server.Block getNMSBlock() {
|
||||
return getNMS().getBlock();
|
||||
}
|
||||
|
||||
public net.minecraft.server.IBlockData getNMS() {
|
||||
return world.getType(position);
|
||||
}
|
||||
|
||||
public BlockPosition getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world.getMinecraftWorld().getWorld();
|
||||
}
|
||||
|
||||
public CraftWorld getCraftWorld() {
|
||||
return (CraftWorld) getWorld();
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return new Location(getWorld(), position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
public Location getLocation(Location loc) {
|
||||
if (loc != null) {
|
||||
loc.setWorld(getWorld());
|
||||
loc.setX(position.getX());
|
||||
loc.setY(position.getY());
|
||||
loc.setZ(position.getZ());
|
||||
loc.setYaw(0);
|
||||
loc.setPitch(0);
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public BlockVector getVector() {
|
||||
return new BlockVector(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return position.getX();
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return position.getY();
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return position.getZ();
|
||||
}
|
||||
|
||||
public Chunk getChunk() {
|
||||
return getWorld().getChunkAt(this);
|
||||
}
|
||||
|
||||
public void setData(final byte data) {
|
||||
setData(data, 3);
|
||||
}
|
||||
|
||||
public void setData(final byte data, boolean applyPhysics) {
|
||||
if (applyPhysics) {
|
||||
setData(data, 3);
|
||||
} else {
|
||||
setData(data, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void setData(final byte data, int flag) {
|
||||
world.setTypeAndData(position, CraftMagicNumbers.getBlock(getType(), data), flag);
|
||||
}
|
||||
|
||||
private IBlockData getData0() {
|
||||
return world.getType(position);
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
IBlockData blockData = world.getType(position);
|
||||
return CraftMagicNumbers.toLegacyData(blockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
return CraftBlockData.fromData(getData0());
|
||||
}
|
||||
|
||||
public void setType(final Material type) {
|
||||
setType(type, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Material type, boolean applyPhysics) {
|
||||
Preconditions.checkArgument(type != null, "Material cannot be null");
|
||||
setBlockData(type.createBlockData(), applyPhysics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(BlockData data) {
|
||||
setBlockData(data, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(BlockData data, boolean applyPhysics) {
|
||||
Preconditions.checkArgument(data != null, "BlockData cannot be null");
|
||||
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (applyPhysics) {
|
||||
return world.setTypeAndData(position, blockData, 3);
|
||||
} else {
|
||||
IBlockData old = world.getType(position);
|
||||
boolean success = world.setTypeAndData(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
|
||||
if (success) {
|
||||
world.getMinecraftWorld().notify(
|
||||
position,
|
||||
old,
|
||||
blockData,
|
||||
3
|
||||
);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
public Material getType() {
|
||||
return CraftMagicNumbers.getMaterial(world.getType(position).getBlock());
|
||||
}
|
||||
|
||||
public byte getLightLevel() {
|
||||
return (byte) world.getMinecraftWorld().getLightLevel(position);
|
||||
}
|
||||
|
||||
public byte getLightFromSky() {
|
||||
return (byte) world.getBrightness(EnumSkyBlock.SKY, position);
|
||||
}
|
||||
|
||||
public byte getLightFromBlocks() {
|
||||
return (byte) world.getBrightness(EnumSkyBlock.BLOCK, position);
|
||||
}
|
||||
|
||||
|
||||
public Block getFace(final BlockFace face) {
|
||||
return getRelative(face, 1);
|
||||
}
|
||||
|
||||
public Block getFace(final BlockFace face, final int distance) {
|
||||
return getRelative(face, distance);
|
||||
}
|
||||
|
||||
public Block getRelative(final int modX, final int modY, final int modZ) {
|
||||
return getWorld().getBlockAt(getX() + modX, getY() + modY, getZ() + modZ);
|
||||
}
|
||||
|
||||
public Block getRelative(BlockFace face) {
|
||||
return getRelative(face, 1);
|
||||
}
|
||||
|
||||
public Block getRelative(BlockFace face, int distance) {
|
||||
return getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
|
||||
}
|
||||
|
||||
public BlockFace getFace(final Block block) {
|
||||
BlockFace[] values = BlockFace.values();
|
||||
|
||||
for (BlockFace face : values) {
|
||||
if ((this.getX() + face.getModX() == block.getX()) &&
|
||||
(this.getY() + face.getModY() == block.getY()) &&
|
||||
(this.getZ() + face.getModZ() == block.getZ())
|
||||
) {
|
||||
return face;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftBlock{pos=" + position + ",type=" + getType() + ",data=" + getNMS() + ",fluid=" + world.getFluid(position) + '}';
|
||||
}
|
||||
|
||||
public static BlockFace notchToBlockFace(EnumDirection notch) {
|
||||
if (notch == null) return BlockFace.SELF;
|
||||
switch (notch) {
|
||||
case DOWN:
|
||||
return BlockFace.DOWN;
|
||||
case UP:
|
||||
return BlockFace.UP;
|
||||
case NORTH:
|
||||
return BlockFace.NORTH;
|
||||
case SOUTH:
|
||||
return BlockFace.SOUTH;
|
||||
case WEST:
|
||||
return BlockFace.WEST;
|
||||
case EAST:
|
||||
return BlockFace.EAST;
|
||||
default:
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumDirection blockFaceToNotch(BlockFace face) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
return EnumDirection.DOWN;
|
||||
case UP:
|
||||
return EnumDirection.UP;
|
||||
case NORTH:
|
||||
return EnumDirection.NORTH;
|
||||
case SOUTH:
|
||||
return EnumDirection.SOUTH;
|
||||
case WEST:
|
||||
return EnumDirection.WEST;
|
||||
case EAST:
|
||||
return EnumDirection.EAST;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockState getState() {
|
||||
// Paper start - allow disabling the use of snapshots
|
||||
return getState(true);
|
||||
}
|
||||
public BlockState getState(boolean useSnapshot) {
|
||||
boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT;
|
||||
CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot;
|
||||
try {
|
||||
return getState0();
|
||||
} finally {
|
||||
CraftBlockEntityState.DISABLE_SNAPSHOT = prev;
|
||||
}
|
||||
}
|
||||
public BlockState getState0() {
|
||||
// Paper end
|
||||
Material material = getType();
|
||||
|
||||
switch (material) {
|
||||
case SIGN:
|
||||
case WALL_SIGN:
|
||||
return new CraftSign(this);
|
||||
case CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
return new CraftChest(this);
|
||||
case FURNACE:
|
||||
return new CraftFurnace(this);
|
||||
case DISPENSER:
|
||||
return new CraftDispenser(this);
|
||||
case DROPPER:
|
||||
return new CraftDropper(this);
|
||||
case END_GATEWAY:
|
||||
return new CraftEndGateway(this);
|
||||
case HOPPER:
|
||||
return new CraftHopper(this);
|
||||
case SPAWNER:
|
||||
return new CraftCreatureSpawner(this);
|
||||
case JUKEBOX:
|
||||
return new CraftJukebox(this);
|
||||
case BREWING_STAND:
|
||||
return new CraftBrewingStand(this);
|
||||
case CREEPER_HEAD:
|
||||
case CREEPER_WALL_HEAD:
|
||||
case DRAGON_HEAD:
|
||||
case DRAGON_WALL_HEAD:
|
||||
case PLAYER_HEAD:
|
||||
case PLAYER_WALL_HEAD:
|
||||
case SKELETON_SKULL:
|
||||
case SKELETON_WALL_SKULL:
|
||||
case WITHER_SKELETON_SKULL:
|
||||
case WITHER_SKELETON_WALL_SKULL:
|
||||
case ZOMBIE_HEAD:
|
||||
case ZOMBIE_WALL_HEAD:
|
||||
return new CraftSkull(this);
|
||||
case COMMAND_BLOCK:
|
||||
case CHAIN_COMMAND_BLOCK:
|
||||
case REPEATING_COMMAND_BLOCK:
|
||||
return new CraftCommandBlock(this);
|
||||
case BEACON:
|
||||
return new CraftBeacon(this);
|
||||
case BLACK_BANNER:
|
||||
case BLACK_WALL_BANNER:
|
||||
case BLUE_BANNER:
|
||||
case BLUE_WALL_BANNER:
|
||||
case BROWN_BANNER:
|
||||
case BROWN_WALL_BANNER:
|
||||
case CYAN_BANNER:
|
||||
case CYAN_WALL_BANNER:
|
||||
case GRAY_BANNER:
|
||||
case GRAY_WALL_BANNER:
|
||||
case GREEN_BANNER:
|
||||
case GREEN_WALL_BANNER:
|
||||
case LIGHT_BLUE_BANNER:
|
||||
case LIGHT_BLUE_WALL_BANNER:
|
||||
case LIGHT_GRAY_BANNER:
|
||||
case LIGHT_GRAY_WALL_BANNER:
|
||||
case LIME_BANNER:
|
||||
case LIME_WALL_BANNER:
|
||||
case MAGENTA_BANNER:
|
||||
case MAGENTA_WALL_BANNER:
|
||||
case ORANGE_BANNER:
|
||||
case ORANGE_WALL_BANNER:
|
||||
case PINK_BANNER:
|
||||
case PINK_WALL_BANNER:
|
||||
case PURPLE_BANNER:
|
||||
case PURPLE_WALL_BANNER:
|
||||
case RED_BANNER:
|
||||
case RED_WALL_BANNER:
|
||||
case WHITE_BANNER:
|
||||
case WHITE_WALL_BANNER:
|
||||
case YELLOW_BANNER:
|
||||
case YELLOW_WALL_BANNER:
|
||||
return new CraftBanner(this);
|
||||
case STRUCTURE_BLOCK:
|
||||
return new CraftStructureBlock(this);
|
||||
case SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
return new CraftShulkerBox(this);
|
||||
case ENCHANTING_TABLE:
|
||||
return new CraftEnchantingTable(this);
|
||||
case ENDER_CHEST:
|
||||
return new CraftEnderChest(this);
|
||||
case DAYLIGHT_DETECTOR:
|
||||
return new CraftDaylightDetector(this);
|
||||
case COMPARATOR:
|
||||
return new CraftComparator(this);
|
||||
case BLACK_BED:
|
||||
case BLUE_BED:
|
||||
case BROWN_BED:
|
||||
case CYAN_BED:
|
||||
case GRAY_BED:
|
||||
case GREEN_BED:
|
||||
case LIGHT_BLUE_BED:
|
||||
case LIGHT_GRAY_BED:
|
||||
case LIME_BED:
|
||||
case MAGENTA_BED:
|
||||
case ORANGE_BED:
|
||||
case PINK_BED:
|
||||
case PURPLE_BED:
|
||||
case RED_BED:
|
||||
case WHITE_BED:
|
||||
case YELLOW_BED:
|
||||
return new CraftBed(this);
|
||||
case CONDUIT:
|
||||
return new CraftConduit(this);
|
||||
default:
|
||||
TileEntity tileEntity = world.getTileEntity(position);
|
||||
if (tileEntity != null) {
|
||||
// block with unhandled TileEntity:
|
||||
return new CraftBlockEntityState<TileEntity>(this, (Class<TileEntity>) tileEntity.getClass());
|
||||
} else {
|
||||
// Block without TileEntity:
|
||||
return new CraftBlockState(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Biome getBiome() {
|
||||
return getWorld().getBiome(getX(), getZ());
|
||||
}
|
||||
|
||||
public void setBiome(Biome bio) {
|
||||
getWorld().setBiome(getX(), getZ(), bio);
|
||||
}
|
||||
|
||||
public static Biome biomeBaseToBiome(BiomeBase base) {
|
||||
if (base == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Biome.valueOf(IRegistry.BIOME.getKey(base).getKey().toUpperCase(java.util.Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public static BiomeBase biomeToBiomeBase(Biome bio) {
|
||||
if (bio == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return IRegistry.BIOME.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH)));
|
||||
}
|
||||
|
||||
public double getTemperature() {
|
||||
return world.getBiome(position).getAdjustedTemperature(position);
|
||||
}
|
||||
|
||||
public double getHumidity() {
|
||||
return getWorld().getHumidity(getX(), getZ());
|
||||
}
|
||||
|
||||
public boolean isBlockPowered() {
|
||||
return world.getMinecraftWorld().getBlockPower(position) > 0;
|
||||
}
|
||||
|
||||
public boolean isBlockIndirectlyPowered() {
|
||||
return world.getMinecraftWorld().isBlockIndirectlyPowered(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) return true;
|
||||
if (!(o instanceof CraftBlock)) return false;
|
||||
CraftBlock other = (CraftBlock) o;
|
||||
|
||||
return this.position.equals(other.position) && this.getWorld().equals(other.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.position.hashCode() ^ this.getWorld().hashCode();
|
||||
}
|
||||
|
||||
public boolean isBlockFacePowered(BlockFace face) {
|
||||
return world.getMinecraftWorld().isBlockFacePowered(position, blockFaceToNotch(face));
|
||||
}
|
||||
|
||||
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
|
||||
int power = world.getMinecraftWorld().getBlockFacePower(position, blockFaceToNotch(face));
|
||||
|
||||
Block relative = getRelative(face);
|
||||
if (relative.getType() == Material.REDSTONE_WIRE) {
|
||||
return Math.max(power, relative.getData()) > 0;
|
||||
}
|
||||
|
||||
return power > 0;
|
||||
}
|
||||
|
||||
public int getBlockPower(BlockFace face) {
|
||||
int power = 0;
|
||||
BlockRedstoneWire wire = (BlockRedstoneWire) Blocks.REDSTONE_WIRE;
|
||||
net.minecraft.server.World world = this.world.getMinecraftWorld();
|
||||
int x = getX();
|
||||
int y = getY();
|
||||
int z = getZ();
|
||||
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = wire.getPower(power, world.getType(new BlockPosition(x, y - 1, z)));
|
||||
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = wire.getPower(power, world.getType(new BlockPosition(x, y + 1, z)));
|
||||
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = wire.getPower(power, world.getType(new BlockPosition(x + 1, y, z)));
|
||||
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = wire.getPower(power, world.getType(new BlockPosition(x - 1, y, z)));
|
||||
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = wire.getPower(power, world.getType(new BlockPosition(x, y, z - 1)));
|
||||
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = wire.getPower(power, world.getType(new BlockPosition(x, y, z + 1)));
|
||||
return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
|
||||
}
|
||||
|
||||
public int getBlockPower() {
|
||||
return getBlockPower(BlockFace.SELF);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getNMS().isAir();
|
||||
}
|
||||
|
||||
public boolean isLiquid() {
|
||||
return (getType() == Material.WATER) || (getType() == Material.LAVA);
|
||||
}
|
||||
|
||||
public PistonMoveReaction getPistonMoveReaction() {
|
||||
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() {
|
||||
// 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);
|
||||
result = true;
|
||||
}
|
||||
|
||||
setType(Material.AIR);
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean breakNaturally(ItemStack item) {
|
||||
if (itemCausesDrops(item)) {
|
||||
return breakNaturally();
|
||||
} else {
|
||||
return setTypeAndData(Blocks.AIR.getBlockData(), true);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Collection<ItemStack> getDrops(ItemStack item) {
|
||||
if (itemCausesDrops(item)) {
|
||||
return getDrops();
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
return getCraftWorld().getBlockMetadata().getMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
return getCraftWorld().getBlockMetadata().hasMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
getCraftWorld().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassable() {
|
||||
return this.getData0().getCollisionShape(world, position).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode) {
|
||||
Validate.notNull(start, "Start location is null!");
|
||||
Validate.isTrue(this.getWorld().equals(start.getWorld()), "Start location is from different world!");
|
||||
start.checkFinite();
|
||||
|
||||
Validate.notNull(direction, "Direction is null!");
|
||||
direction.checkFinite();
|
||||
Validate.isTrue(direction.lengthSquared() > 0, "Direction's magnitude is 0!");
|
||||
|
||||
Validate.notNull(fluidCollisionMode, "Fluid collision mode is null!");
|
||||
if (maxDistance < 0.0D) {
|
||||
return null;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getBoundingBox() {
|
||||
VoxelShape shape = getData0().getShape(world, position);
|
||||
|
||||
if (shape.isEmpty()) {
|
||||
return new BoundingBox(); // Return an empty bounding box if the block has no dimension
|
||||
}
|
||||
|
||||
AxisAlignedBB aabb = shape.getBoundingBox();
|
||||
return new BoundingBox(getX() + aabb.minX, getY() + aabb.minY, getZ() + aabb.minZ, getX() + aabb.maxX, getY() + aabb.maxY, getZ() + aabb.maxZ);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.TileEntity;
|
||||
import net.minecraft.server.World;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState {
|
||||
|
||||
private final Class<T> tileEntityClass;
|
||||
private final T tileEntity;
|
||||
private final T snapshot;
|
||||
|
||||
public CraftBlockEntityState(Block block, Class<T> tileEntityClass) {
|
||||
super(block);
|
||||
|
||||
this.tileEntityClass = tileEntityClass;
|
||||
|
||||
// get tile entity from block:
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
this.tileEntity = tileEntityClass.cast(world.getHandle().getTileEntity(this.getPosition()));
|
||||
|
||||
// Paper start
|
||||
this.snapshotDisabled = DISABLE_SNAPSHOT;
|
||||
if (DISABLE_SNAPSHOT) {
|
||||
this.snapshot = this.tileEntity;
|
||||
} else {
|
||||
this.snapshot = this.createSnapshot(this.tileEntity, world.getHandle());
|
||||
}
|
||||
// copy tile entity data:
|
||||
if(this.snapshot != null) {
|
||||
this.load(this.snapshot);
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
public final boolean snapshotDisabled; // Paper
|
||||
public static boolean DISABLE_SNAPSHOT = false; // Paper
|
||||
|
||||
public CraftBlockEntityState(Material material, T tileEntity) {
|
||||
super(material);
|
||||
|
||||
this.tileEntityClass = (Class<T>) tileEntity.getClass();
|
||||
this.tileEntity = tileEntity;
|
||||
// Paper start
|
||||
this.snapshotDisabled = DISABLE_SNAPSHOT;
|
||||
if (DISABLE_SNAPSHOT) {
|
||||
this.snapshot = this.tileEntity;
|
||||
} else {
|
||||
this.snapshot = this.createSnapshot(this.tileEntity, null);
|
||||
}
|
||||
// copy tile entity data:
|
||||
if(this.snapshot != null) {
|
||||
this.load(this.snapshot);
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
private T createSnapshot(T tileEntity, World world) {
|
||||
if (tileEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
NBTTagCompound nbtTagCompound = tileEntity.save(new NBTTagCompound());
|
||||
T snapshot = (T) TileEntity.create(nbtTagCompound, world);
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
// copies the TileEntity-specific data, retains the position
|
||||
private void copyData(T from, T to) {
|
||||
BlockPosition pos = to.getPosition();
|
||||
NBTTagCompound nbtTagCompound = from.save(new NBTTagCompound());
|
||||
to.load(nbtTagCompound);
|
||||
|
||||
// reset the original position:
|
||||
to.setPosition(pos);
|
||||
}
|
||||
|
||||
// gets the wrapped TileEntity
|
||||
public T getTileEntity() { // Paper - protected -> public
|
||||
return tileEntity;
|
||||
}
|
||||
|
||||
// gets the cloned TileEntity which is used to store the captured data
|
||||
protected T getSnapshot() {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
// gets the current TileEntity from the world at this position
|
||||
protected TileEntity getTileEntityFromWorld() {
|
||||
requirePlaced();
|
||||
|
||||
return ((CraftWorld) this.getWorld()).getHandle().getTileEntity(this.getPosition());
|
||||
}
|
||||
|
||||
// gets the NBT data of the TileEntity represented by this block state
|
||||
public NBTTagCompound getSnapshotNBT() {
|
||||
// update snapshot
|
||||
applyTo(snapshot);
|
||||
|
||||
return snapshot.save(new NBTTagCompound());
|
||||
}
|
||||
|
||||
// copies the data of the given tile entity to this block state
|
||||
protected void load(T tileEntity) {
|
||||
if (tileEntity != null && tileEntity != snapshot) {
|
||||
copyData(tileEntity, snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
// applies the TileEntity data of this block state to the given TileEntity
|
||||
protected void applyTo(T tileEntity) {
|
||||
if (tileEntity != null && tileEntity != snapshot) {
|
||||
copyData(snapshot, tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isApplicable(TileEntity tileEntity) {
|
||||
return tileEntityClass.isInstance(tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result && this.isPlaced()) {
|
||||
TileEntity tile = getTileEntityFromWorld();
|
||||
|
||||
if (isApplicable(tile)) {
|
||||
// Paper start
|
||||
if (!snapshotDisabled) {
|
||||
applyTo(tileEntityClass.cast(tile));
|
||||
}
|
||||
// Paper end
|
||||
tile.update();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
276
src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
Normal file
276
src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
Normal file
@@ -0,0 +1,276 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.CraftChunk;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.material.Attachable;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.server.GeneratorAccess;
|
||||
import net.minecraft.server.IBlockData;
|
||||
|
||||
public class CraftBlockState implements BlockState {
|
||||
private final CraftWorld world;
|
||||
private final CraftChunk chunk;
|
||||
private final BlockPosition position;
|
||||
protected IBlockData data;
|
||||
protected int flag;
|
||||
|
||||
public CraftBlockState(final Block block) {
|
||||
this.world = (CraftWorld) block.getWorld();
|
||||
this.position = ((CraftBlock) block).getPosition();
|
||||
this.data = ((CraftBlock) block).getNMS();
|
||||
this.chunk = (CraftChunk) block.getChunk();
|
||||
this.flag = 3;
|
||||
}
|
||||
|
||||
public CraftBlockState(final Block block, int flag) {
|
||||
this(block);
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public CraftBlockState(Material material) {
|
||||
world = null;
|
||||
data = CraftMagicNumbers.getBlock(material).getBlockData();
|
||||
chunk = null;
|
||||
position = BlockPosition.ZERO;
|
||||
}
|
||||
|
||||
public static CraftBlockState getBlockState(GeneratorAccess world, net.minecraft.server.BlockPosition pos) {
|
||||
return new CraftBlockState(CraftBlock.at(world, pos));
|
||||
}
|
||||
|
||||
public static CraftBlockState getBlockState(net.minecraft.server.World world, net.minecraft.server.BlockPosition pos, int flag) {
|
||||
return new CraftBlockState(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), flag);
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
requirePlaced();
|
||||
return world;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return position.getX();
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return position.getY();
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return position.getZ();
|
||||
}
|
||||
|
||||
public Chunk getChunk() {
|
||||
requirePlaced();
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public void setData(IBlockData data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public BlockPosition getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public IBlockData getHandle() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
return CraftBlockData.fromData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(BlockData data) {
|
||||
Preconditions.checkArgument(data != null, "BlockData cannot be null");
|
||||
this.data = ((CraftBlockData) data).getState();
|
||||
}
|
||||
|
||||
public void setData(final MaterialData data) {
|
||||
Material mat = CraftMagicNumbers.getMaterial(this.data).getItemType();
|
||||
|
||||
if ((mat == null) || (mat.getData() == null)) {
|
||||
this.data = CraftMagicNumbers.getBlock(data);
|
||||
} else {
|
||||
if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) {
|
||||
this.data = CraftMagicNumbers.getBlock(data);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Provided data is not of type "
|
||||
+ mat.getData().getName() + ", found " + data.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MaterialData getData() {
|
||||
return CraftMagicNumbers.getMaterial(data);
|
||||
}
|
||||
|
||||
public void setType(final Material type) {
|
||||
Preconditions.checkArgument(type != null, "Material cannot be null");
|
||||
Preconditions.checkArgument(type.isBlock(), "Material must be a block!");
|
||||
|
||||
if (this.getType() != type) {
|
||||
this.data = CraftMagicNumbers.getBlock(type).getBlockData();
|
||||
}
|
||||
}
|
||||
|
||||
public Material getType() {
|
||||
return CraftMagicNumbers.getMaterial(data.getBlock());
|
||||
}
|
||||
|
||||
public void setFlag(int flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public int getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public byte getLightLevel() {
|
||||
return getBlock().getLightLevel();
|
||||
}
|
||||
|
||||
public CraftBlock getBlock() {
|
||||
requirePlaced();
|
||||
return CraftBlock.at(world.getHandle(), position);
|
||||
}
|
||||
|
||||
public boolean update() {
|
||||
return update(false);
|
||||
}
|
||||
|
||||
public boolean update(boolean force) {
|
||||
return update(force, true);
|
||||
}
|
||||
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
if (!isPlaced()) {
|
||||
return true;
|
||||
}
|
||||
CraftBlock block = getBlock();
|
||||
|
||||
if (block.getType() != getType()) {
|
||||
if (!force) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
IBlockData newBlock = this.data;
|
||||
block.setTypeAndData(newBlock, applyPhysics);
|
||||
world.getHandle().notify(
|
||||
position,
|
||||
block.getNMS(),
|
||||
newBlock,
|
||||
3
|
||||
);
|
||||
|
||||
// Update levers etc
|
||||
if (false && applyPhysics && getData() instanceof Attachable) { // Call does not map to new API
|
||||
world.getHandle().applyPhysics(position.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public byte getRawData() {
|
||||
return CraftMagicNumbers.toLegacyData(data);
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return new Location(world, getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public Location getLocation(Location loc) {
|
||||
if (loc != null) {
|
||||
loc.setWorld(world);
|
||||
loc.setX(getX());
|
||||
loc.setY(getY());
|
||||
loc.setZ(getZ());
|
||||
loc.setYaw(0);
|
||||
loc.setPitch(0);
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public void setRawData(byte data) {
|
||||
this.data = CraftMagicNumbers.getBlock(getType(), data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final CraftBlockState other = (CraftBlockState) obj;
|
||||
if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) {
|
||||
return false;
|
||||
}
|
||||
if (this.position != other.position && (this.position == null || !this.position.equals(other.position))) {
|
||||
return false;
|
||||
}
|
||||
if (this.data != other.data && (this.data == null || !this.data.equals(other.data))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 73 * hash + (this.world != null ? this.world.hashCode() : 0);
|
||||
hash = 73 * hash + (this.position != null ? this.position.hashCode() : 0);
|
||||
hash = 73 * hash + (this.data != null ? this.data.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
requirePlaced();
|
||||
chunk.getCraftWorld().getBlockMetadata().setMetadata(getBlock(), metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
requirePlaced();
|
||||
return chunk.getCraftWorld().getBlockMetadata().getMetadata(getBlock(), metadataKey);
|
||||
}
|
||||
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
requirePlaced();
|
||||
return chunk.getCraftWorld().getBlockMetadata().hasMetadata(getBlock(), metadataKey);
|
||||
}
|
||||
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
requirePlaced();
|
||||
chunk.getCraftWorld().getBlockMetadata().removeMetadata(getBlock(), metadataKey, owningPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlaced() {
|
||||
return world != null;
|
||||
}
|
||||
|
||||
protected void requirePlaced() {
|
||||
if (!isPlaced()) {
|
||||
throw new IllegalStateException("The blockState must be placed to call this method");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityBrewingStand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BrewingStand;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
import org.bukkit.inventory.BrewerInventory;
|
||||
|
||||
public class CraftBrewingStand extends CraftContainer<TileEntityBrewingStand> implements BrewingStand {
|
||||
|
||||
public CraftBrewingStand(Block block) {
|
||||
super(block, TileEntityBrewingStand.class);
|
||||
}
|
||||
|
||||
public CraftBrewingStand(final Material material, final TileEntityBrewingStand te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrewerInventory getSnapshotInventory() {
|
||||
return new CraftInventoryBrewer(this.getSnapshot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrewerInventory getInventory() {
|
||||
if (!this.isPlaced()) {
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventoryBrewer(this.getTileEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrewingTime() {
|
||||
return this.getSnapshot().getProperty(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBrewingTime(int brewTime) {
|
||||
this.getSnapshot().setProperty(0, brewTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFuelLevel() {
|
||||
return this.getSnapshot().getProperty(1);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
Normal file
60
src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockChest;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.ITileInventory;
|
||||
import net.minecraft.server.InventoryLargeChest;
|
||||
import net.minecraft.server.TileEntityChest;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import com.destroystokyo.paper.loottable.PaperLootableBlockInventory; // Paper
|
||||
|
||||
public class CraftChest extends CraftLootable<TileEntityChest> implements Chest, PaperLootableBlockInventory { // Paper
|
||||
|
||||
public CraftChest(final Block block) {
|
||||
super(block, TileEntityChest.class);
|
||||
}
|
||||
|
||||
public CraftChest(final Material material, final TileEntityChest te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getSnapshotInventory() {
|
||||
return new CraftInventory(this.getSnapshot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getBlockInventory() {
|
||||
if (!this.isPlaced()) {
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventory(this.getTileEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
CraftInventory inventory = (CraftInventory) this.getBlockInventory();
|
||||
if (!isPlaced()) {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
// The logic here is basically identical to the logic in BlockChest.interact
|
||||
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);
|
||||
|
||||
if (nms instanceof InventoryLargeChest) {
|
||||
inventory = new CraftInventoryDoubleChest((InventoryLargeChest) nms);
|
||||
}
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityCommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
public class CraftCommandBlock extends CraftBlockEntityState<TileEntityCommand> implements CommandBlock {
|
||||
|
||||
private String command;
|
||||
private String name;
|
||||
|
||||
public CraftCommandBlock(Block block) {
|
||||
super(block, TileEntityCommand.class);
|
||||
}
|
||||
|
||||
public CraftCommandBlock(final Material material, final TileEntityCommand te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(TileEntityCommand commandBlock) {
|
||||
super.load(commandBlock);
|
||||
|
||||
command = commandBlock.getCommandBlock().getCommand();
|
||||
name = CraftChatMessage.fromComponent(commandBlock.getCommandBlock().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCommand(String command) {
|
||||
this.command = command != null ? command : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name != null ? name : "@";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(TileEntityCommand commandBlock) {
|
||||
super.applyTo(commandBlock);
|
||||
|
||||
commandBlock.getCommandBlock().setCommand(command);
|
||||
commandBlock.getCommandBlock().setName(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityComparator;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Comparator;
|
||||
|
||||
public class CraftComparator extends CraftBlockEntityState<TileEntityComparator> implements Comparator {
|
||||
|
||||
public CraftComparator(final Block block) {
|
||||
super(block, TileEntityComparator.class);
|
||||
}
|
||||
|
||||
public CraftComparator(final Material material, final TileEntityComparator te) {
|
||||
super(material, te);
|
||||
}
|
||||
}
|
||||
17
src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java
Normal file
17
src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityConduit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Conduit;
|
||||
|
||||
public class CraftConduit extends CraftBlockEntityState<TileEntityConduit> implements Conduit {
|
||||
|
||||
public CraftConduit(Block block) {
|
||||
super(block, TileEntityConduit.class);
|
||||
}
|
||||
|
||||
public CraftConduit(Material material, TileEntityConduit te) {
|
||||
super(material, te);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.ChestLock;
|
||||
import net.minecraft.server.TileEntityContainer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Container;
|
||||
|
||||
public abstract class CraftContainer<T extends TileEntityContainer> extends CraftBlockEntityState<T> implements Container {
|
||||
|
||||
public CraftContainer(Block block, Class<T> tileEntityClass) {
|
||||
super(block, tileEntityClass);
|
||||
}
|
||||
|
||||
public CraftContainer(final Material material, T tileEntity) {
|
||||
super(material, tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked() {
|
||||
return this.getSnapshot().isLocked();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLock() {
|
||||
return this.getSnapshot().getLock().getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLock(String key) {
|
||||
this.getSnapshot().setLock(key == null ? ChestLock.a : new ChestLock(key));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.EntityTypes;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.TileEntityMobSpawner;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpawner> implements CreatureSpawner {
|
||||
|
||||
public CraftCreatureSpawner(final Block block) {
|
||||
super(block, TileEntityMobSpawner.class);
|
||||
}
|
||||
|
||||
public CraftCreatureSpawner(final Material material, TileEntityMobSpawner te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getSpawnedType() {
|
||||
MinecraftKey key = this.getSnapshot().getSpawner().getMobName();
|
||||
return (key == null) ? EntityType.PIG : EntityType.fromName(key.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawnedType(EntityType entityType) {
|
||||
if (entityType == null || entityType.getName() == null) {
|
||||
throw new IllegalArgumentException("Can't spawn EntityType " + entityType + " from mobspawners!");
|
||||
}
|
||||
|
||||
this.getSnapshot().getSpawner().setMobName(EntityTypes.a(entityType.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreatureTypeName() {
|
||||
return this.getSnapshot().getSpawner().getMobName().getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreatureTypeByName(String creatureType) {
|
||||
// Verify input
|
||||
EntityType type = EntityType.fromName(creatureType);
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
setSpawnedType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDelay() {
|
||||
return this.getSnapshot().getSpawner().spawnDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDelay(int delay) {
|
||||
this.getSnapshot().getSpawner().spawnDelay = delay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinSpawnDelay() {
|
||||
return this.getSnapshot().getSpawner().minSpawnDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMinSpawnDelay(int spawnDelay) {
|
||||
Preconditions.checkArgument(spawnDelay <= getMaxSpawnDelay(), "Minimum Spawn Delay must be less than or equal to Maximum Spawn Delay");
|
||||
this.getSnapshot().getSpawner().minSpawnDelay = spawnDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSpawnDelay() {
|
||||
return this.getSnapshot().getSpawner().maxSpawnDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxSpawnDelay(int spawnDelay) {
|
||||
Preconditions.checkArgument(spawnDelay > 0, "Maximum Spawn Delay must be greater than 0.");
|
||||
Preconditions.checkArgument(spawnDelay >= getMinSpawnDelay(), "Maximum Spawn Delay must be greater than or equal to Minimum Spawn Delay");
|
||||
this.getSnapshot().getSpawner().maxSpawnDelay = spawnDelay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxNearbyEntities() {
|
||||
return this.getSnapshot().getSpawner().maxNearbyEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxNearbyEntities(int maxNearbyEntities) {
|
||||
this.getSnapshot().getSpawner().maxNearbyEntities = maxNearbyEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnCount() {
|
||||
return this.getSnapshot().getSpawner().spawnCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawnCount(int count) {
|
||||
this.getSnapshot().getSpawner().spawnCount = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPlayerRange() {
|
||||
return this.getSnapshot().getSpawner().requiredPlayerRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequiredPlayerRange(int requiredPlayerRange) {
|
||||
this.getSnapshot().getSpawner().requiredPlayerRange = requiredPlayerRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnRange() {
|
||||
return this.getSnapshot().getSpawner().spawnRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawnRange(int spawnRange) {
|
||||
this.getSnapshot().getSpawner().spawnRange = spawnRange;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityLightDetector;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.DaylightDetector;
|
||||
|
||||
public class CraftDaylightDetector extends CraftBlockEntityState<TileEntityLightDetector> implements DaylightDetector {
|
||||
|
||||
public CraftDaylightDetector(final Block block) {
|
||||
super(block, TileEntityLightDetector.class);
|
||||
}
|
||||
|
||||
public CraftDaylightDetector(final Material material, final TileEntityLightDetector te) {
|
||||
super(material, te);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockDispenser;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.TileEntityDispenser;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Dispenser;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
|
||||
public class CraftDispenser extends CraftLootable<TileEntityDispenser> implements Dispenser {
|
||||
|
||||
public CraftDispenser(final Block block) {
|
||||
super(block, TileEntityDispenser.class);
|
||||
}
|
||||
|
||||
public CraftDispenser(final Material material, final TileEntityDispenser 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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockProjectileSource getBlockProjectileSource() {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() != Material.DISPENSER) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CraftBlockProjectileSource((TileEntityDispenser) this.getTileEntityFromWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispense() {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.DISPENSER) {
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER;
|
||||
|
||||
dispense.dispense(world.getHandle(), this.getPosition());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
50
src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java
Normal file
50
src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockDropper;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.TileEntityDropper;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Dropper;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftDropper extends CraftLootable<TileEntityDropper> implements Dropper {
|
||||
|
||||
public CraftDropper(final Block block) {
|
||||
super(block, TileEntityDropper.class);
|
||||
}
|
||||
|
||||
public CraftDropper(final Material material, TileEntityDropper 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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drop() {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.DROPPER) {
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
BlockDropper drop = (BlockDropper) Blocks.DROPPER;
|
||||
|
||||
drop.dispense(world.getHandle(), this.getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityEnchantTable;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.EnchantingTable;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
public class CraftEnchantingTable extends CraftBlockEntityState<TileEntityEnchantTable> implements EnchantingTable {
|
||||
|
||||
public CraftEnchantingTable(final Block block) {
|
||||
super(block, TileEntityEnchantTable.class);
|
||||
}
|
||||
|
||||
public CraftEnchantingTable(final Material material, final TileEntityEnchantTable te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
TileEntityEnchantTable enchant = this.getSnapshot();
|
||||
return enchant.hasCustomName() ? CraftChatMessage.fromComponent(enchant.getCustomName()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(TileEntityEnchantTable enchantingTable) {
|
||||
super.applyTo(enchantingTable);
|
||||
|
||||
if (!this.getSnapshot().hasCustomName()) {
|
||||
enchantingTable.setCustomName(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import java.util.Objects;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.TileEntityEndGateway;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.EndGateway;
|
||||
|
||||
public class CraftEndGateway extends CraftBlockEntityState<TileEntityEndGateway> implements EndGateway {
|
||||
|
||||
public CraftEndGateway(Block block) {
|
||||
super(block, TileEntityEndGateway.class);
|
||||
}
|
||||
|
||||
public CraftEndGateway(final Material material, TileEntityEndGateway te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getExitLocation() {
|
||||
BlockPosition pos = this.getSnapshot().exitPortal;
|
||||
return pos == null ? null : new Location(this.isPlaced() ? this.getWorld() : null, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExitLocation(Location location) {
|
||||
if (location == null) {
|
||||
this.getSnapshot().exitPortal = null;
|
||||
} else if (!Objects.equals(location.getWorld(), this.isPlaced() ? this.getWorld() : null)) {
|
||||
throw new IllegalArgumentException("Cannot set exit location to different world");
|
||||
} else {
|
||||
this.getSnapshot().exitPortal = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExactTeleport() {
|
||||
return this.getSnapshot().exactTeleport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExactTeleport(boolean exact) {
|
||||
this.getSnapshot().exactTeleport = exact;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAge() {
|
||||
return this.getSnapshot().age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(long age) {
|
||||
this.getSnapshot().age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(TileEntityEndGateway endGateway) {
|
||||
super.applyTo(endGateway);
|
||||
|
||||
if (this.getSnapshot().exitPortal == null) {
|
||||
endGateway.exitPortal = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityEnderChest;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.EnderChest;
|
||||
|
||||
public class CraftEnderChest extends CraftBlockEntityState<TileEntityEnderChest> implements EnderChest {
|
||||
|
||||
public CraftEnderChest(final Block block) {
|
||||
super(block, TileEntityEnderChest.class);
|
||||
}
|
||||
|
||||
public CraftEnderChest(final Material material, final TileEntityEnderChest te) {
|
||||
super(material, te);
|
||||
}
|
||||
}
|
||||
101
src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
Normal file
101
src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockFurnace;
|
||||
import net.minecraft.server.TileEntityFurnace;
|
||||
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 CraftFurnace(final Block block) {
|
||||
super(block, TileEntityFurnace.class);
|
||||
}
|
||||
|
||||
public CraftFurnace(final Material material, final TileEntityFurnace te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FurnaceInventory getSnapshotInventory() {
|
||||
return new CraftInventoryFurnace(this.getSnapshot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FurnaceInventory getInventory() {
|
||||
if (!this.isPlaced()) {
|
||||
return this.getSnapshotInventory();
|
||||
}
|
||||
|
||||
return new CraftInventoryFurnace(this.getTileEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getBurnTime() {
|
||||
return (short) this.getSnapshot().getProperty(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBurnTime(short burnTime) {
|
||||
this.getSnapshot().setProperty(0, 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCookTime(short cookTime) {
|
||||
this.getSnapshot().setProperty(2, cookTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCookTimeTotal() {
|
||||
return this.getSnapshot().getProperty(3);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
// Paper start - cook speed multiplier API
|
||||
@Override
|
||||
public double getCookSpeedMultiplier() {
|
||||
return this.getSnapshot().cookSpeedMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCookSpeedMultiplier(double multiplier) {
|
||||
com.google.common.base.Preconditions.checkArgument(multiplier >= 0, "Furnace speed multiplier cannot be negative");
|
||||
com.google.common.base.Preconditions.checkArgument(multiplier <= 200, "Furnace speed multiplier cannot more than 200");
|
||||
this.getSnapshot().cookSpeedMultiplier = multiplier;
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
33
src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java
Normal file
33
src/main/java/org/bukkit/craftbukkit/block/CraftHopper.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityHopper;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Hopper;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftHopper extends CraftLootable<TileEntityHopper> implements Hopper {
|
||||
|
||||
public CraftHopper(final Block block) {
|
||||
super(block, TileEntityHopper.class);
|
||||
}
|
||||
|
||||
public CraftHopper(final Material material, final TileEntityHopper 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());
|
||||
}
|
||||
}
|
||||
92
src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java
Normal file
92
src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockJukeBox;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.ItemStack;
|
||||
import net.minecraft.server.TileEntity;
|
||||
import net.minecraft.server.TileEntityJukeBox;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> implements Jukebox {
|
||||
|
||||
public CraftJukebox(final Block block) {
|
||||
super(block, TileEntityJukeBox.class);
|
||||
}
|
||||
|
||||
public CraftJukebox(final Material material, TileEntityJukeBox te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) {
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
Material record = this.getPlaying();
|
||||
if (record == Material.AIR) {
|
||||
world.getHandle().setTypeAndData(this.getPosition(), Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, false), 3);
|
||||
} else {
|
||||
world.getHandle().setTypeAndData(this.getPosition(), Blocks.JUKEBOX.getBlockData().set(BlockJukeBox.HAS_RECORD, true), 3);
|
||||
}
|
||||
world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getPlaying() {
|
||||
return getRecord().getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaying(Material record) {
|
||||
if (record == null || CraftMagicNumbers.getItem(record) == null) {
|
||||
record = Material.AIR;
|
||||
}
|
||||
|
||||
setRecord(new org.bukkit.inventory.ItemStack(record));
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getRecord() {
|
||||
ItemStack record = this.getSnapshot().getRecord();
|
||||
return CraftItemStack.asBukkitCopy(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecord(org.bukkit.inventory.ItemStack record) {
|
||||
ItemStack nms = CraftItemStack.asNMSCopy(record);
|
||||
this.getSnapshot().setRecord(nms);
|
||||
if (nms.isEmpty()) {
|
||||
this.data = this.data.set(BlockJukeBox.HAS_RECORD, false);
|
||||
} else {
|
||||
this.data = this.data.set(BlockJukeBox.HAS_RECORD, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlaying() {
|
||||
return getHandle().get(BlockJukeBox.HAS_RECORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eject() {
|
||||
requirePlaced();
|
||||
TileEntity tileEntity = this.getTileEntityFromWorld();
|
||||
if (!(tileEntity instanceof TileEntityJukeBox)) return false;
|
||||
|
||||
TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity;
|
||||
boolean result = !jukebox.getRecord().isEmpty();
|
||||
CraftWorld world = (CraftWorld) this.getWorld();
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), getPosition());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.destroystokyo.paper.loottable.PaperLootableBlockInventory;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.TileEntityLootable;
|
||||
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;
|
||||
|
||||
public abstract class CraftLootable<T extends TileEntityLootable> extends CraftContainer<T> implements Nameable, Lootable, PaperLootableBlockInventory { // Paper
|
||||
|
||||
public CraftLootable(Block block, Class<T> tileEntityClass) {
|
||||
super(block, tileEntityClass);
|
||||
}
|
||||
|
||||
public CraftLootable(Material material, T tileEntity) {
|
||||
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) {
|
||||
lootable.setLootTable((MinecraftKey) null, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTable getLootTable() {
|
||||
if (getSnapshot().getLootTable() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MinecraftKey key = getSnapshot().getLootTable();
|
||||
return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLootTable(LootTable table) {
|
||||
setLootTable(table, getSeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
return getSnapshotNBT().getLong("LootTableSeed"); // returns OL if an error occurred
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeed(long seed) {
|
||||
setLootTable(getLootTable(), seed);
|
||||
}
|
||||
|
||||
public void setLootTable(LootTable table, long seed) { // Paper - public
|
||||
MinecraftKey key = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
|
||||
getSnapshot().setLootTable(key, seed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockShulkerBox;
|
||||
import net.minecraft.server.TileEntityShulkerBox;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CraftShulkerBox extends CraftLootable<TileEntityShulkerBox> implements ShulkerBox {
|
||||
|
||||
public CraftShulkerBox(final Block block) {
|
||||
super(block, TileEntityShulkerBox.class);
|
||||
}
|
||||
|
||||
public CraftShulkerBox(final Material material, final TileEntityShulkerBox 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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
net.minecraft.server.Block block = CraftMagicNumbers.getBlock(this.getType());
|
||||
|
||||
return DyeColor.getByWoolData((byte) ((BlockShulkerBox) block).color.getColorIndex());
|
||||
}
|
||||
}
|
||||
94
src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
Normal file
94
src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
import net.minecraft.server.IChatBaseComponent;
|
||||
import net.minecraft.server.TileEntitySign;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements Sign {
|
||||
|
||||
private String[] lines;
|
||||
private boolean editable;
|
||||
|
||||
public CraftSign(final Block block) {
|
||||
super(block, TileEntitySign.class);
|
||||
if (lines == null) { lines = new String[]{"", "", "", ""}; } // Paper
|
||||
}
|
||||
|
||||
public CraftSign(final Material material, final TileEntitySign te) {
|
||||
super(material, te);
|
||||
if (lines == null) { lines = new String[]{"", "", "", ""}; } // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(TileEntitySign sign) {
|
||||
super.load(sign);
|
||||
|
||||
lines = new String[sign.lines.length];
|
||||
System.arraycopy(revertComponents(sign.lines), 0, lines, 0, lines.length);
|
||||
editable = sign.isEditable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(int index) throws IndexOutOfBoundsException {
|
||||
return lines[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(int index, String line) throws IndexOutOfBoundsException {
|
||||
lines[index] = line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return this.editable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEditable(boolean editable) {
|
||||
this.editable = editable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(TileEntitySign sign) {
|
||||
super.applyTo(sign);
|
||||
|
||||
IChatBaseComponent[] newLines = sanitizeLines(lines);
|
||||
System.arraycopy(newLines, 0, sign.lines, 0, 4);
|
||||
sign.isEditable = editable;
|
||||
}
|
||||
|
||||
public static IChatBaseComponent[] sanitizeLines(String[] lines) {
|
||||
IChatBaseComponent[] components = new IChatBaseComponent[4];
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i < lines.length && lines[i] != null) {
|
||||
components[i] = CraftChatMessage.fromString(lines[i])[0];
|
||||
} else {
|
||||
components[i] = new ChatComponentText("");
|
||||
}
|
||||
}
|
||||
|
||||
return components;
|
||||
}
|
||||
|
||||
public static String[] revertComponents(IChatBaseComponent[] components) {
|
||||
String[] lines = new String[components.length];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
lines[i] = revertComponent(components[i]);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static String revertComponent(IChatBaseComponent component) {
|
||||
return CraftChatMessage.fromComponent(component);
|
||||
}
|
||||
}
|
||||
182
src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
Normal file
182
src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
Normal file
@@ -0,0 +1,182 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.TileEntitySkull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implements Skull {
|
||||
|
||||
private static final int MAX_OWNER_LENGTH = 16;
|
||||
private GameProfile profile;
|
||||
|
||||
public CraftSkull(final Block block) {
|
||||
super(block, TileEntitySkull.class);
|
||||
}
|
||||
|
||||
public CraftSkull(final Material material, final TileEntitySkull te) {
|
||||
super(material, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(TileEntitySkull skull) {
|
||||
super.load(skull);
|
||||
|
||||
profile = skull.getGameProfile();
|
||||
}
|
||||
|
||||
static int getSkullType(SkullType type) {
|
||||
switch(type) {
|
||||
default:
|
||||
case SKELETON:
|
||||
return 0;
|
||||
case WITHER:
|
||||
return 1;
|
||||
case ZOMBIE:
|
||||
return 2;
|
||||
case PLAYER:
|
||||
return 3;
|
||||
case CREEPER:
|
||||
return 4;
|
||||
case DRAGON:
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOwner() {
|
||||
return profile != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return hasOwner() ? profile.getName() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setOwner(String name) {
|
||||
if (name == null || name.length() > MAX_OWNER_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(name);
|
||||
if (profile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.profile = profile;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getOwningPlayer() {
|
||||
if (profile != null) {
|
||||
if (profile.getId() != null) {
|
||||
return Bukkit.getOfflinePlayer(profile.getId());
|
||||
}
|
||||
|
||||
if (profile.getName() != null) {
|
||||
return Bukkit.getOfflinePlayer(profile.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwningPlayer(OfflinePlayer player) {
|
||||
Preconditions.checkNotNull(player, "player");
|
||||
|
||||
if (player instanceof CraftPlayer) {
|
||||
this.profile = ((CraftPlayer) player).getProfile();
|
||||
} else {
|
||||
this.profile = new GameProfile(player.getUniqueId(), player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public void setPlayerProfile(PlayerProfile profile) {
|
||||
Preconditions.checkNotNull(profile, "profile");
|
||||
this.profile = CraftPlayerProfile.asAuthlibCopy(profile);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PlayerProfile getPlayerProfile() {
|
||||
return profile != null ? CraftPlayerProfile.asBukkitCopy(profile) : null;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
public BlockFace getRotation() {
|
||||
BlockData blockData = getBlockData();
|
||||
return (blockData instanceof Rotatable) ? ((Rotatable) blockData).getRotation() : ((Directional) blockData).getFacing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(BlockFace rotation) {
|
||||
BlockData blockData = getBlockData();
|
||||
if (blockData instanceof Rotatable) {
|
||||
((Rotatable) blockData).setRotation(rotation);
|
||||
} else {
|
||||
((Directional) blockData).setFacing(rotation);
|
||||
}
|
||||
setBlockData(blockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkullType getSkullType() {
|
||||
switch (getType()) {
|
||||
case SKELETON_SKULL:
|
||||
case SKELETON_WALL_SKULL:
|
||||
return SkullType.SKELETON;
|
||||
case WITHER_SKELETON_SKULL:
|
||||
case WITHER_SKELETON_WALL_SKULL:
|
||||
return SkullType.WITHER;
|
||||
case ZOMBIE_HEAD:
|
||||
case ZOMBIE_WALL_HEAD:
|
||||
return SkullType.ZOMBIE;
|
||||
case PLAYER_HEAD:
|
||||
case PLAYER_WALL_HEAD:
|
||||
return SkullType.PLAYER;
|
||||
case CREEPER_HEAD:
|
||||
case CREEPER_WALL_HEAD:
|
||||
return SkullType.CREEPER;
|
||||
case DRAGON_HEAD:
|
||||
case DRAGON_WALL_HEAD:
|
||||
return SkullType.DRAGON;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown SkullType for " + getType());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkullType(SkullType skullType) {
|
||||
throw new UnsupportedOperationException("Must change block type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(TileEntitySkull skull) {
|
||||
super.applyTo(skull);
|
||||
|
||||
if (getSkullType() == SkullType.PLAYER) {
|
||||
skull.setGameProfile(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.BlockPropertyStructureMode;
|
||||
import net.minecraft.server.EnumBlockMirror;
|
||||
import net.minecraft.server.EnumBlockRotation;
|
||||
import net.minecraft.server.TileEntityStructure;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Structure;
|
||||
import org.bukkit.block.structure.Mirror;
|
||||
import org.bukkit.block.structure.StructureRotation;
|
||||
import org.bukkit.block.structure.UsageMode;
|
||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructure> implements Structure {
|
||||
|
||||
private static final int MAX_SIZE = 32;
|
||||
|
||||
public CraftStructureBlock(Block block) {
|
||||
super(block, TileEntityStructure.class);
|
||||
}
|
||||
|
||||
public CraftStructureBlock(Material material, TileEntityStructure structure) {
|
||||
super(material, structure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStructureName() {
|
||||
return getSnapshot().getStructureName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStructureName(String name) {
|
||||
Preconditions.checkArgument(name != null, "Structure Name cannot be null");
|
||||
getSnapshot().setStructureName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return getSnapshot().author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAuthor(String author) {
|
||||
Preconditions.checkArgument(author != null && !author.isEmpty(), "Author name cannot be null nor empty");
|
||||
getSnapshot().author = author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAuthor(LivingEntity entity) {
|
||||
Preconditions.checkArgument(entity != null, "Structure Block author entity cannot be null");
|
||||
getSnapshot().setAuthor(((CraftLivingEntity) entity).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getRelativePosition() {
|
||||
return new BlockVector(getSnapshot().relativePosition.getX(), getSnapshot().relativePosition.getY(), getSnapshot().relativePosition.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRelativePosition(BlockVector vector) {
|
||||
Validate.isTrue(isBetween(vector.getBlockX(), -MAX_SIZE, MAX_SIZE), "Structure Size (X) must be between -" + MAX_SIZE + " and " + MAX_SIZE);
|
||||
Validate.isTrue(isBetween(vector.getBlockY(), -MAX_SIZE, MAX_SIZE), "Structure Size (Y) must be between -" + MAX_SIZE + " and " + MAX_SIZE);
|
||||
Validate.isTrue(isBetween(vector.getBlockZ(), -MAX_SIZE, MAX_SIZE), "Structure Size (Z) must be between -" + MAX_SIZE + " and " + MAX_SIZE);
|
||||
getSnapshot().relativePosition = new BlockPosition(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getStructureSize() {
|
||||
return new BlockVector(getSnapshot().size.getX(), getSnapshot().size.getY(), getSnapshot().size.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStructureSize(BlockVector vector) {
|
||||
Validate.isTrue(isBetween(vector.getBlockX(), 0, MAX_SIZE), "Structure Size (X) must be between 0 and " + MAX_SIZE);
|
||||
Validate.isTrue(isBetween(vector.getBlockY(), 0, MAX_SIZE), "Structure Size (Y) must be between 0 and " + MAX_SIZE);
|
||||
Validate.isTrue(isBetween(vector.getBlockZ(), 0, MAX_SIZE), "Structure Size (Z) must be between 0 and " + MAX_SIZE);
|
||||
getSnapshot().size = new BlockPosition(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMirror(Mirror mirror) {
|
||||
getSnapshot().mirror = EnumBlockMirror.valueOf(mirror.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mirror getMirror() {
|
||||
return Mirror.valueOf(getSnapshot().mirror.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(StructureRotation rotation) {
|
||||
getSnapshot().rotation = EnumBlockRotation.valueOf(rotation.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructureRotation getRotation() {
|
||||
return StructureRotation.valueOf(getSnapshot().rotation.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsageMode(UsageMode mode) {
|
||||
getSnapshot().setUsageMode(BlockPropertyStructureMode.valueOf(mode.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsageMode getUsageMode() {
|
||||
return UsageMode.valueOf(getSnapshot().getUsageMode().name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreEntities(boolean flag) {
|
||||
getSnapshot().ignoreEntities = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoreEntities() {
|
||||
return getSnapshot().ignoreEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowAir(boolean showAir) {
|
||||
getSnapshot().showAir = showAir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowAir() {
|
||||
return getSnapshot().showAir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoundingBoxVisible(boolean showBoundingBox) {
|
||||
getSnapshot().showBoundingBox = showBoundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBoundingBoxVisible() {
|
||||
return getSnapshot().showBoundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntegrity(float integrity) {
|
||||
Validate.isTrue(isBetween(integrity, 0.0f, 1.0f), "Integrity must be between 0.0f and 1.0f");
|
||||
getSnapshot().integrity = integrity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getIntegrity() {
|
||||
return getSnapshot().integrity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeed(long seed) {
|
||||
getSnapshot().seed = seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
return getSnapshot().seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadata) {
|
||||
Validate.notNull(metadata, "Structure metadata cannot be null");
|
||||
if (getUsageMode() == UsageMode.DATA) {
|
||||
getSnapshot().metadata = metadata;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMetadata() {
|
||||
return getSnapshot().metadata;
|
||||
}
|
||||
|
||||
private static boolean isBetween(int num, int min, int max) {
|
||||
return num >= min && num <= max;
|
||||
}
|
||||
|
||||
private static boolean isBetween(float num, float min, float max) {
|
||||
return num >= min && num <= max;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Ageable;
|
||||
|
||||
public abstract class CraftAgeable extends CraftBlockData implements Ageable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger AGE = getInteger("age");
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return get(AGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(int age) {
|
||||
set(AGE, age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAge() {
|
||||
return getMax(AGE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.AnaloguePowerable;
|
||||
|
||||
public abstract class CraftAnaloguePowerable extends CraftBlockData implements AnaloguePowerable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger POWER = getInteger("power");
|
||||
|
||||
@Override
|
||||
public int getPower() {
|
||||
return get(POWER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(int power) {
|
||||
set(POWER, power);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumPower() {
|
||||
return getMax(POWER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Attachable;
|
||||
|
||||
public abstract class CraftAttachable extends CraftBlockData implements Attachable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean ATTACHED = getBoolean("attached");
|
||||
|
||||
@Override
|
||||
public boolean isAttached() {
|
||||
return get(ATTACHED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttached(boolean attached) {
|
||||
set(ATTACHED, attached);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Bisected;
|
||||
|
||||
public class CraftBisected extends CraftBlockData implements Bisected {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> HALF = getEnum("half");
|
||||
|
||||
@Override
|
||||
public Half getHalf() {
|
||||
return get(HALF, Half.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHalf(Half half) {
|
||||
set(HALF, half);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,537 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import net.minecraft.server.ArgumentBlock;
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.BlockDataAbstract;
|
||||
import net.minecraft.server.BlockStateBoolean;
|
||||
import net.minecraft.server.BlockStateEnum;
|
||||
import net.minecraft.server.BlockStateInteger;
|
||||
import net.minecraft.server.EnumDirection;
|
||||
import net.minecraft.server.IBlockData;
|
||||
import net.minecraft.server.IBlockState;
|
||||
import net.minecraft.server.INamable;
|
||||
import net.minecraft.server.IRegistry;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public class CraftBlockData implements BlockData {
|
||||
|
||||
private IBlockData state;
|
||||
private Map<IBlockState<?>, Comparable<?>> parsedStates;
|
||||
|
||||
protected CraftBlockData() {
|
||||
throw new AssertionError("Template Constructor");
|
||||
}
|
||||
|
||||
protected CraftBlockData(IBlockData state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial() {
|
||||
return CraftMagicNumbers.getMaterial(state.getBlock());
|
||||
}
|
||||
|
||||
public IBlockData getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a given BlockStateEnum's value as its Bukkit counterpart.
|
||||
*
|
||||
* @param nms the NMS state to convert
|
||||
* @param bukkit the Bukkit class
|
||||
* @param <B> the type
|
||||
* @return the matching Bukkit type
|
||||
*/
|
||||
protected <B extends Enum<B>> B get(BlockStateEnum<?> nms, Class<B> bukkit) {
|
||||
return toBukkit(state.get(nms), bukkit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert all values from the given BlockStateEnum to their appropriate
|
||||
* Bukkit counterpart.
|
||||
*
|
||||
* @param nms the NMS state to get values from
|
||||
* @param bukkit the bukkit class to convert the values to
|
||||
* @param <B> the bukkit class type
|
||||
* @return an immutable Set of values in their appropriate Bukkit type
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <B extends Enum<B>> Set<B> getValues(BlockStateEnum<?> nms, Class<B> bukkit) {
|
||||
ImmutableSet.Builder<B> values = ImmutableSet.builder();
|
||||
|
||||
for (Enum<?> e : nms.d()) {
|
||||
values.add(toBukkit(e, bukkit));
|
||||
}
|
||||
|
||||
return values.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a given {@link BlockStateEnum} with the matching enum from Bukkit.
|
||||
*
|
||||
* @param nms the NMS BlockStateEnum to set
|
||||
* @param bukkit the matching Bukkit Enum
|
||||
* @param <B> the Bukkit type
|
||||
* @param <N> the NMS type
|
||||
*/
|
||||
protected <B extends Enum<B>, N extends Enum<N> & INamable> void set(BlockStateEnum<N> nms, Enum<B> bukkit) {
|
||||
this.parsedStates = null;
|
||||
this.state = this.state.set(nms, toNMS(bukkit, nms.b()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData merge(BlockData data) {
|
||||
CraftBlockData craft = (CraftBlockData) data;
|
||||
Preconditions.checkArgument(craft.parsedStates != null, "Data not created via string parsing");
|
||||
Preconditions.checkArgument(this.state.getBlock() == craft.state.getBlock(), "States have different types (got %s, expected %s)", data, this);
|
||||
|
||||
CraftBlockData clone = (CraftBlockData) this.clone();
|
||||
clone.parsedStates = null;
|
||||
|
||||
for (IBlockState parsed : craft.parsedStates.keySet()) {
|
||||
clone.state = clone.state.set(parsed, craft.state.get(parsed));
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(BlockData data) {
|
||||
if (data == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(data instanceof CraftBlockData)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CraftBlockData craft = (CraftBlockData) data;
|
||||
if (this.state.getBlock() != craft.state.getBlock()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fastpath an exact match
|
||||
boolean exactMatch = this.equals(data);
|
||||
|
||||
// If that failed, do a merge and check
|
||||
if (!exactMatch && craft.parsedStates != null) {
|
||||
return this.merge(data).equals(this);
|
||||
}
|
||||
|
||||
return exactMatch;
|
||||
}
|
||||
|
||||
private static final Map<Class, BiMap<Enum<?>, Enum<?>>> classMappings = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Convert an NMS Enum (usually a BlockStateEnum) to its appropriate Bukkit
|
||||
* enum from the given class.
|
||||
*
|
||||
* @throws IllegalStateException if the Enum could not be converted
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <B extends Enum<B>> B toBukkit(Enum<?> nms, Class<B> bukkit) {
|
||||
Enum<?> converted;
|
||||
BiMap<Enum<?>, Enum<?>> nmsToBukkit = classMappings.get(nms.getClass());
|
||||
|
||||
if (nmsToBukkit != null) {
|
||||
converted = nmsToBukkit.get(nms);
|
||||
if (converted != null) {
|
||||
return (B) converted;
|
||||
}
|
||||
}
|
||||
|
||||
if (nms instanceof EnumDirection) {
|
||||
converted = CraftBlock.notchToBlockFace((EnumDirection) nms);
|
||||
} else {
|
||||
converted = bukkit.getEnumConstants()[nms.ordinal()];
|
||||
}
|
||||
|
||||
Preconditions.checkState(converted != null, "Could not convert enum %s->%s", nms, bukkit);
|
||||
|
||||
if (nmsToBukkit == null) {
|
||||
nmsToBukkit = HashBiMap.create();
|
||||
classMappings.put(nms.getClass(), nmsToBukkit);
|
||||
}
|
||||
|
||||
nmsToBukkit.put(nms, converted);
|
||||
|
||||
return (B) converted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a given Bukkit enum to its matching NMS enum type.
|
||||
*
|
||||
* @param bukkit the Bukkit enum to convert
|
||||
* @param nms the NMS class
|
||||
* @return the matching NMS type
|
||||
* @throws IllegalStateException if the Enum could not be converted
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <N extends Enum<N> & INamable> N toNMS(Enum<?> bukkit, Class<N> nms) {
|
||||
Enum<?> converted;
|
||||
BiMap<Enum<?>, Enum<?>> nmsToBukkit = classMappings.get(nms);
|
||||
|
||||
if (nmsToBukkit != null) {
|
||||
converted = nmsToBukkit.inverse().get(bukkit);
|
||||
if (converted != null) {
|
||||
return (N) converted;
|
||||
}
|
||||
}
|
||||
|
||||
if (bukkit instanceof BlockFace) {
|
||||
converted = CraftBlock.blockFaceToNotch((BlockFace) bukkit);
|
||||
} else {
|
||||
converted = nms.getEnumConstants()[bukkit.ordinal()];
|
||||
}
|
||||
|
||||
Preconditions.checkState(converted != null, "Could not convert enum %s->%s", nms, bukkit);
|
||||
|
||||
if (nmsToBukkit == null) {
|
||||
nmsToBukkit = HashBiMap.create();
|
||||
classMappings.put(nms, nmsToBukkit);
|
||||
}
|
||||
|
||||
nmsToBukkit.put(converted, bukkit);
|
||||
|
||||
return (N) converted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of a given state.
|
||||
*
|
||||
* @param ibs the state to check
|
||||
* @param <T> the type
|
||||
* @return the current value of the given state
|
||||
*/
|
||||
protected <T extends Comparable<T>> T get(IBlockState<T> ibs) {
|
||||
// Straight integer or boolean getter
|
||||
return this.state.get(ibs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the specified state's value.
|
||||
*
|
||||
* @param ibs the state to set
|
||||
* @param v the new value
|
||||
* @param <T> the state's type
|
||||
* @param <V> the value's type. Must match the state's type.
|
||||
*/
|
||||
public <T extends Comparable<T>, V extends T> void set(IBlockState<T> ibs, V v) {
|
||||
// Straight integer or boolean setter
|
||||
this.parsedStates = null;
|
||||
this.state = this.state.set(ibs, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsString() {
|
||||
return toString(((BlockDataAbstract) state).getStateMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsString(boolean hideUnspecified) {
|
||||
return (hideUnspecified && parsedStates != null) ? toString(parsedStates) : getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData clone() {
|
||||
try {
|
||||
return (BlockData) super.clone();
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
throw new AssertionError("Clone not supported", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftBlockData{" + state.toString() + "}";
|
||||
}
|
||||
|
||||
// Mimicked from BlockDataAbstract#toString()
|
||||
public String toString(Map<IBlockState<?>, Comparable<?>> states) {
|
||||
StringBuilder stateString = new StringBuilder(IRegistry.BLOCK.getKey(state.getBlock()).toString());
|
||||
|
||||
if (!states.isEmpty()) {
|
||||
stateString.append('[');
|
||||
stateString.append(states.entrySet().stream().map(BlockDataAbstract.STATE_TO_VALUE).collect(Collectors.joining(",")));
|
||||
stateString.append(']');
|
||||
}
|
||||
|
||||
return stateString.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof CraftBlockData && state.equals(((CraftBlockData) obj).state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return state.hashCode();
|
||||
}
|
||||
|
||||
protected static BlockStateBoolean getBoolean(String name) {
|
||||
throw new AssertionError("Template Method");
|
||||
}
|
||||
|
||||
protected static BlockStateBoolean getBoolean(String name, boolean optional) {
|
||||
throw new AssertionError("Template Method");
|
||||
}
|
||||
|
||||
protected static BlockStateEnum<?> getEnum(String name) {
|
||||
throw new AssertionError("Template Method");
|
||||
}
|
||||
|
||||
protected static BlockStateInteger getInteger(String name) {
|
||||
throw new AssertionError("Template Method");
|
||||
}
|
||||
|
||||
protected static BlockStateBoolean getBoolean(Class<? extends Block> block, String name) {
|
||||
return (BlockStateBoolean) getState(block, name, false);
|
||||
}
|
||||
|
||||
protected static BlockStateBoolean getBoolean(Class<? extends Block> block, String name, boolean optional) {
|
||||
return (BlockStateBoolean) getState(block, name, optional);
|
||||
}
|
||||
|
||||
protected static BlockStateEnum<?> getEnum(Class<? extends Block> block, String name) {
|
||||
return (BlockStateEnum<?>) getState(block, name, false);
|
||||
}
|
||||
|
||||
protected static BlockStateInteger getInteger(Class<? extends Block> block, String name) {
|
||||
return (BlockStateInteger) getState(block, name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specified {@link IBlockState} from a given block's class with a
|
||||
* given name
|
||||
*
|
||||
* @param block the class to retrieve the state from
|
||||
* @param name the name of the state to retrieve
|
||||
* @param optional if the state can be null
|
||||
* @return the specified state or null
|
||||
* @throws IllegalStateException if the state is null and {@code optional}
|
||||
* is false.
|
||||
*/
|
||||
private static IBlockState<?> getState(Class<? extends Block> block, String name, boolean optional) {
|
||||
IBlockState<?> state = null;
|
||||
|
||||
for (Block instance : (Iterable<Block>) IRegistry.BLOCK) { // Eclipse fail
|
||||
if (instance.getClass() == block) {
|
||||
if (state == null) {
|
||||
state = instance.getStates().a(name);
|
||||
} else {
|
||||
IBlockState<?> newState = instance.getStates().a(name);
|
||||
|
||||
Preconditions.checkState(state == newState, "State mistmatch %s,%s", state, newState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Preconditions.checkState(optional || state != null, "Null state for %s,%s", block, name);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum value allowed by the BlockStateInteger.
|
||||
*
|
||||
* @param state the state to check
|
||||
* @return the minimum value allowed
|
||||
*/
|
||||
protected static int getMin(BlockStateInteger state) {
|
||||
return state.min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum value allowed by the BlockStateInteger.
|
||||
*
|
||||
* @param state the state to check
|
||||
* @return the maximum value allowed
|
||||
*/
|
||||
protected static int getMax(BlockStateInteger state) {
|
||||
return state.max;
|
||||
}
|
||||
|
||||
//
|
||||
private static final Map<Class<? extends Block>, Function<IBlockData, CraftBlockData>> MAP = new HashMap<>();
|
||||
|
||||
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.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.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.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.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);
|
||||
register(net.minecraft.server.BlockChestTrapped.class, org.bukkit.craftbukkit.block.impl.CraftChestTrapped::new);
|
||||
register(net.minecraft.server.BlockChorusFlower.class, org.bukkit.craftbukkit.block.impl.CraftChorusFlower::new);
|
||||
register(net.minecraft.server.BlockChorusFruit.class, org.bukkit.craftbukkit.block.impl.CraftChorusFruit::new);
|
||||
register(net.minecraft.server.BlockCobbleWall.class, org.bukkit.craftbukkit.block.impl.CraftCobbleWall::new);
|
||||
register(net.minecraft.server.BlockCocoa.class, org.bukkit.craftbukkit.block.impl.CraftCocoa::new);
|
||||
register(net.minecraft.server.BlockCommand.class, org.bukkit.craftbukkit.block.impl.CraftCommand::new);
|
||||
register(net.minecraft.server.BlockConduit.class, org.bukkit.craftbukkit.block.impl.CraftConduit::new);
|
||||
register(net.minecraft.server.BlockCoralDead.class, org.bukkit.craftbukkit.block.impl.CraftCoralDead::new);
|
||||
register(net.minecraft.server.BlockCoralFan.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan::new);
|
||||
register(net.minecraft.server.BlockCoralFanAbstract.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanAbstract::new);
|
||||
register(net.minecraft.server.BlockCoralFanWall.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanWall::new);
|
||||
register(net.minecraft.server.BlockCoralFanWallAbstract.class, org.bukkit.craftbukkit.block.impl.CraftCoralFanWallAbstract::new);
|
||||
register(net.minecraft.server.BlockCoralPlant.class, org.bukkit.craftbukkit.block.impl.CraftCoralPlant::new);
|
||||
register(net.minecraft.server.BlockCrops.class, org.bukkit.craftbukkit.block.impl.CraftCrops::new);
|
||||
register(net.minecraft.server.BlockDaylightDetector.class, org.bukkit.craftbukkit.block.impl.CraftDaylightDetector::new);
|
||||
register(net.minecraft.server.BlockDirtSnow.class, org.bukkit.craftbukkit.block.impl.CraftDirtSnow::new);
|
||||
register(net.minecraft.server.BlockDispenser.class, org.bukkit.craftbukkit.block.impl.CraftDispenser::new);
|
||||
register(net.minecraft.server.BlockDoor.class, org.bukkit.craftbukkit.block.impl.CraftDoor::new);
|
||||
register(net.minecraft.server.BlockDropper.class, org.bukkit.craftbukkit.block.impl.CraftDropper::new);
|
||||
register(net.minecraft.server.BlockEndRod.class, org.bukkit.craftbukkit.block.impl.CraftEndRod::new);
|
||||
register(net.minecraft.server.BlockEnderChest.class, org.bukkit.craftbukkit.block.impl.CraftEnderChest::new);
|
||||
register(net.minecraft.server.BlockEnderPortalFrame.class, org.bukkit.craftbukkit.block.impl.CraftEnderPortalFrame::new);
|
||||
register(net.minecraft.server.BlockFence.class, org.bukkit.craftbukkit.block.impl.CraftFence::new);
|
||||
register(net.minecraft.server.BlockFenceGate.class, org.bukkit.craftbukkit.block.impl.CraftFenceGate::new);
|
||||
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.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.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.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.BlockLeaves.class, org.bukkit.craftbukkit.block.impl.CraftLeaves::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.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);
|
||||
register(net.minecraft.server.BlockNetherWart.class, org.bukkit.craftbukkit.block.impl.CraftNetherWart::new);
|
||||
register(net.minecraft.server.BlockNote.class, org.bukkit.craftbukkit.block.impl.CraftNote::new);
|
||||
register(net.minecraft.server.BlockObserver.class, org.bukkit.craftbukkit.block.impl.CraftObserver::new);
|
||||
register(net.minecraft.server.BlockPiston.class, org.bukkit.craftbukkit.block.impl.CraftPiston::new);
|
||||
register(net.minecraft.server.BlockPistonExtension.class, org.bukkit.craftbukkit.block.impl.CraftPistonExtension::new);
|
||||
register(net.minecraft.server.BlockPistonMoving.class, org.bukkit.craftbukkit.block.impl.CraftPistonMoving::new);
|
||||
register(net.minecraft.server.BlockPortal.class, org.bukkit.craftbukkit.block.impl.CraftPortal::new);
|
||||
register(net.minecraft.server.BlockPotatoes.class, org.bukkit.craftbukkit.block.impl.CraftPotatoes::new);
|
||||
register(net.minecraft.server.BlockPoweredRail.class, org.bukkit.craftbukkit.block.impl.CraftPoweredRail::new);
|
||||
register(net.minecraft.server.BlockPressurePlateBinary.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateBinary::new);
|
||||
register(net.minecraft.server.BlockPressurePlateWeighted.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateWeighted::new);
|
||||
register(net.minecraft.server.BlockPumpkinCarved.class, org.bukkit.craftbukkit.block.impl.CraftPumpkinCarved::new);
|
||||
register(net.minecraft.server.BlockRedstoneComparator.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneComparator::new);
|
||||
register(net.minecraft.server.BlockRedstoneLamp.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneLamp::new);
|
||||
register(net.minecraft.server.BlockRedstoneOre.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneOre::new);
|
||||
register(net.minecraft.server.BlockRedstoneTorch.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorch::new);
|
||||
register(net.minecraft.server.BlockRedstoneTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorchWall::new);
|
||||
register(net.minecraft.server.BlockRedstoneWire.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneWire::new);
|
||||
register(net.minecraft.server.BlockReed.class, org.bukkit.craftbukkit.block.impl.CraftReed::new);
|
||||
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.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.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);
|
||||
register(net.minecraft.server.BlockStairs.class, org.bukkit.craftbukkit.block.impl.CraftStairs::new);
|
||||
register(net.minecraft.server.BlockStem.class, org.bukkit.craftbukkit.block.impl.CraftStem::new);
|
||||
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.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure::new);
|
||||
register(net.minecraft.server.BlockTNT.class, org.bukkit.craftbukkit.block.impl.CraftTNT::new);
|
||||
register(net.minecraft.server.BlockTallPlantFlower.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower::new);
|
||||
register(net.minecraft.server.BlockTallPlantShearable.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantShearable::new);
|
||||
register(net.minecraft.server.BlockTallSeaGrass.class, org.bukkit.craftbukkit.block.impl.CraftTallSeaGrass::new);
|
||||
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);
|
||||
register(net.minecraft.server.BlockTripwire.class, org.bukkit.craftbukkit.block.impl.CraftTripwire::new);
|
||||
register(net.minecraft.server.BlockTripwireHook.class, org.bukkit.craftbukkit.block.impl.CraftTripwireHook::new);
|
||||
register(net.minecraft.server.BlockTurtleEgg.class, org.bukkit.craftbukkit.block.impl.CraftTurtleEgg::new);
|
||||
register(net.minecraft.server.BlockVine.class, org.bukkit.craftbukkit.block.impl.CraftVine::new);
|
||||
register(net.minecraft.server.BlockWallSign.class, org.bukkit.craftbukkit.block.impl.CraftWallSign::new);
|
||||
register(net.minecraft.server.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new);
|
||||
register(net.minecraft.server.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall::new);
|
||||
register(net.minecraft.server.BlockWoodButton.class, org.bukkit.craftbukkit.block.impl.CraftWoodButton::new);
|
||||
//</editor-fold>
|
||||
}
|
||||
|
||||
private static void register(Class<? extends Block> nms, Function<IBlockData, CraftBlockData> bukkit) {
|
||||
Preconditions.checkState(MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
|
||||
}
|
||||
|
||||
public static CraftBlockData newData(Material material, String data) {
|
||||
Preconditions.checkArgument(material == null || material.isBlock(), "Cannot get data for not block %s", material);
|
||||
|
||||
IBlockData blockData;
|
||||
Block block = CraftMagicNumbers.getBlock(material);
|
||||
Map<IBlockState<?>, Comparable<?>> parsed = null;
|
||||
|
||||
// Data provided, use it
|
||||
if (data != null) {
|
||||
try {
|
||||
// Material provided, force that material in
|
||||
if (block != null) {
|
||||
data = IRegistry.BLOCK.getKey(block) + data;
|
||||
}
|
||||
|
||||
StringReader reader = new StringReader(data);
|
||||
ArgumentBlock arg = new ArgumentBlock(reader, false).a(false);
|
||||
Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data: " + data);
|
||||
|
||||
blockData = arg.getBlockData();
|
||||
parsed = arg.getStateMap();
|
||||
} catch (CommandSyntaxException ex) {
|
||||
throw new IllegalArgumentException("Could not parse data: " + data, ex);
|
||||
}
|
||||
} else {
|
||||
blockData = block.getBlockData();
|
||||
}
|
||||
|
||||
CraftBlockData craft = fromData(blockData);
|
||||
craft.parsedStates = parsed;
|
||||
return craft;
|
||||
}
|
||||
|
||||
// Paper start - optimize creating BlockData to not need a map lookup
|
||||
static {
|
||||
// Initialize cached data for all IBlockData instances after registration
|
||||
Block.REGISTRY_ID.iterator().forEachRemaining(IBlockData::createCraftBlockData);
|
||||
}
|
||||
public static CraftBlockData fromData(IBlockData data) {
|
||||
return data.createCraftBlockData();
|
||||
}
|
||||
|
||||
public static CraftBlockData createData(IBlockData data) {
|
||||
// Paper end
|
||||
return MAP.getOrDefault(data.getBlock().getClass(), CraftBlockData::new).apply(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Directional;
|
||||
|
||||
public abstract class CraftDirectional extends CraftBlockData implements Directional {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum("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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Levelled;
|
||||
|
||||
public abstract class CraftLevelled extends CraftBlockData implements Levelled {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger LEVEL = getInteger("level");
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return get(LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int level) {
|
||||
set(LEVEL, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumLevel() {
|
||||
return getMax(LEVEL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Lightable;
|
||||
|
||||
public abstract class CraftLightable extends CraftBlockData implements Lightable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean("lit");
|
||||
|
||||
@Override
|
||||
public boolean isLit() {
|
||||
return get(LIT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLit(boolean lit) {
|
||||
set(LIT, lit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.MultipleFacing;
|
||||
|
||||
public abstract class CraftMultipleFacing extends CraftBlockData implements MultipleFacing {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean[] FACES = new net.minecraft.server.BlockStateBoolean[]{
|
||||
getBoolean("north", true), getBoolean("east", true), getBoolean("south", true), getBoolean("west", true), getBoolean("up", true), getBoolean("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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Openable;
|
||||
|
||||
public abstract class CraftOpenable extends CraftBlockData implements Openable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean OPEN = getBoolean("open");
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return get(OPEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOpen(boolean open) {
|
||||
set(OPEN, open);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Orientable;
|
||||
|
||||
public class CraftOrientable extends CraftBlockData implements Orientable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> AXIS = getEnum("axis");
|
||||
|
||||
@Override
|
||||
public org.bukkit.Axis getAxis() {
|
||||
return get(AXIS, org.bukkit.Axis.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAxis(org.bukkit.Axis axis) {
|
||||
set(AXIS, axis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<org.bukkit.Axis> getAxes() {
|
||||
return getValues(AXIS, org.bukkit.Axis.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Powerable;
|
||||
|
||||
public abstract class CraftPowerable extends CraftBlockData implements Powerable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean("powered");
|
||||
|
||||
@Override
|
||||
public boolean isPowered() {
|
||||
return get(POWERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPowered(boolean powered) {
|
||||
set(POWERED, powered);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Rail;
|
||||
|
||||
public abstract class CraftRail extends CraftBlockData implements Rail {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> SHAPE = getEnum("shape");
|
||||
|
||||
@Override
|
||||
public Shape getShape() {
|
||||
return get(SHAPE, Shape.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShape(Shape shape) {
|
||||
set(SHAPE, shape);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<Shape> getShapes() {
|
||||
return getValues(SHAPE, Shape.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
|
||||
public abstract class CraftRotatable extends CraftBlockData implements Rotatable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger ROTATION = getInteger("rotation");
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.BlockFace getRotation() {
|
||||
int data = get(ROTATION);
|
||||
switch (data) {
|
||||
case 0x0:
|
||||
return org.bukkit.block.BlockFace.SOUTH;
|
||||
case 0x1:
|
||||
return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST;
|
||||
case 0x2:
|
||||
return org.bukkit.block.BlockFace.SOUTH_WEST;
|
||||
case 0x3:
|
||||
return org.bukkit.block.BlockFace.WEST_SOUTH_WEST;
|
||||
case 0x4:
|
||||
return org.bukkit.block.BlockFace.WEST;
|
||||
case 0x5:
|
||||
return org.bukkit.block.BlockFace.WEST_NORTH_WEST;
|
||||
case 0x6:
|
||||
return org.bukkit.block.BlockFace.NORTH_WEST;
|
||||
case 0x7:
|
||||
return org.bukkit.block.BlockFace.NORTH_NORTH_WEST;
|
||||
case 0x8:
|
||||
return org.bukkit.block.BlockFace.NORTH;
|
||||
case 0x9:
|
||||
return org.bukkit.block.BlockFace.NORTH_NORTH_EAST;
|
||||
case 0xA:
|
||||
return org.bukkit.block.BlockFace.NORTH_EAST;
|
||||
case 0xB:
|
||||
return org.bukkit.block.BlockFace.EAST_NORTH_EAST;
|
||||
case 0xC:
|
||||
return org.bukkit.block.BlockFace.EAST;
|
||||
case 0xD:
|
||||
return org.bukkit.block.BlockFace.EAST_SOUTH_EAST;
|
||||
case 0xE:
|
||||
return org.bukkit.block.BlockFace.SOUTH_EAST;
|
||||
case 0xF:
|
||||
return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown rotation " + data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(org.bukkit.block.BlockFace rotation) {
|
||||
int val;
|
||||
switch (rotation) {
|
||||
case SOUTH:
|
||||
val = 0x0;
|
||||
break;
|
||||
case SOUTH_SOUTH_WEST:
|
||||
val = 0x1;
|
||||
break;
|
||||
case SOUTH_WEST:
|
||||
val = 0x2;
|
||||
break;
|
||||
case WEST_SOUTH_WEST:
|
||||
val = 0x3;
|
||||
break;
|
||||
case WEST:
|
||||
val = 0x4;
|
||||
break;
|
||||
case WEST_NORTH_WEST:
|
||||
val = 0x5;
|
||||
break;
|
||||
case NORTH_WEST:
|
||||
val = 0x6;
|
||||
break;
|
||||
case NORTH_NORTH_WEST:
|
||||
val = 0x7;
|
||||
break;
|
||||
case NORTH:
|
||||
val = 0x8;
|
||||
break;
|
||||
case NORTH_NORTH_EAST:
|
||||
val = 0x9;
|
||||
break;
|
||||
case NORTH_EAST:
|
||||
val = 0xA;
|
||||
break;
|
||||
case EAST_NORTH_EAST:
|
||||
val = 0xB;
|
||||
break;
|
||||
case EAST:
|
||||
val = 0xC;
|
||||
break;
|
||||
case EAST_SOUTH_EAST:
|
||||
val = 0xD;
|
||||
break;
|
||||
case SOUTH_EAST:
|
||||
val = 0xE;
|
||||
break;
|
||||
case SOUTH_SOUTH_EAST:
|
||||
val = 0xF;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal rotation " + rotation);
|
||||
}
|
||||
set(ROTATION, val);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Snowable;
|
||||
|
||||
public abstract class CraftSnowable extends CraftBlockData implements Snowable {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean SNOWY = getBoolean("snowy");
|
||||
|
||||
@Override
|
||||
public boolean isSnowy() {
|
||||
return get(SNOWY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnowy(boolean snowy) {
|
||||
set(SNOWY, snowy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data;
|
||||
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftWaterlogged extends CraftBlockData implements Waterlogged {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean("waterlogged");
|
||||
|
||||
@Override
|
||||
public boolean isWaterlogged() {
|
||||
return get(WATERLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWaterlogged(boolean waterlogged) {
|
||||
set(WATERLOGGED, waterlogged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Bed;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftBed extends CraftBlockData implements Bed {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> PART = getEnum("part");
|
||||
private static final net.minecraft.server.BlockStateBoolean OCCUPIED = getBoolean("occupied");
|
||||
|
||||
@Override
|
||||
public Part getPart() {
|
||||
return get(PART, Part.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPart(Part part) {
|
||||
set(PART, part);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOccupied() {
|
||||
return get(OCCUPIED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.BrewingStand;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftBrewingStand extends CraftBlockData implements BrewingStand {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean[] HAS_BOTTLE = new net.minecraft.server.BlockStateBoolean[]{
|
||||
getBoolean("has_bottle_0"), getBoolean("has_bottle_1"), getBoolean("has_bottle_2")
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean hasBottle(int bottle) {
|
||||
return get(HAS_BOTTLE[bottle]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBottle(int bottle, boolean has) {
|
||||
set(HAS_BOTTLE[bottle], has);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<Integer> getBottles() {
|
||||
com.google.common.collect.ImmutableSet.Builder<Integer> bottles = com.google.common.collect.ImmutableSet.builder();
|
||||
|
||||
for (int index = 0; index < getMaximumBottles(); index++) {
|
||||
if (hasBottle(index)) {
|
||||
bottles.add(index);
|
||||
}
|
||||
}
|
||||
|
||||
return bottles.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumBottles() {
|
||||
return HAS_BOTTLE.length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.BubbleColumn;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftBubbleColumn extends CraftBlockData implements BubbleColumn {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean DRAG = getBoolean("drag");
|
||||
|
||||
@Override
|
||||
public boolean isDrag() {
|
||||
return get(DRAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrag(boolean drag) {
|
||||
set(DRAG, drag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Cake;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftCake extends CraftBlockData implements Cake {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger BITES = getInteger("bites");
|
||||
|
||||
@Override
|
||||
public int getBites() {
|
||||
return get(BITES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBites(int bites) {
|
||||
set(BITES, bites);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumBites() {
|
||||
return getMax(BITES);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Chest;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftChest extends CraftBlockData implements Chest {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> TYPE = getEnum("type");
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return get(TYPE, Type.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
set(TYPE, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.CommandBlock;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftCommandBlock extends CraftBlockData implements CommandBlock {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean CONDITIONAL = getBoolean("conditional");
|
||||
|
||||
@Override
|
||||
public boolean isConditional() {
|
||||
return get(CONDITIONAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConditional(boolean conditional) {
|
||||
set(CONDITIONAL, conditional);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Comparator;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftComparator extends CraftBlockData implements Comparator {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> MODE = getEnum("mode");
|
||||
|
||||
@Override
|
||||
public Mode getMode() {
|
||||
return get(MODE, Mode.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMode(Mode mode) {
|
||||
set(MODE, mode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.DaylightDetector;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftDaylightDetector extends CraftBlockData implements DaylightDetector {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean INVERTED = getBoolean("inverted");
|
||||
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return get(INVERTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
set(INVERTED, inverted);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftDispenser extends CraftBlockData implements Dispenser {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean TRIGGERED = getBoolean("triggered");
|
||||
|
||||
@Override
|
||||
public boolean isTriggered() {
|
||||
return get(TRIGGERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTriggered(boolean triggered) {
|
||||
set(TRIGGERED, triggered);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Door;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftDoor extends CraftBlockData implements Door {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> HINGE = getEnum("hinge");
|
||||
|
||||
@Override
|
||||
public Hinge getHinge() {
|
||||
return get(HINGE, Hinge.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHinge(Hinge hinge) {
|
||||
set(HINGE, hinge);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.EndPortalFrame;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftEndPortalFrame extends CraftBlockData implements EndPortalFrame {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean EYE = getBoolean("eye");
|
||||
|
||||
@Override
|
||||
public boolean hasEye() {
|
||||
return get(EYE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEye(boolean eye) {
|
||||
set(EYE, eye);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Farmland;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftFarmland extends CraftBlockData implements Farmland {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger MOISTURE = getInteger("moisture");
|
||||
|
||||
@Override
|
||||
public int getMoisture() {
|
||||
return get(MOISTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoisture(int moisture) {
|
||||
set(MOISTURE, moisture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumMoisture() {
|
||||
return getMax(MOISTURE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Gate;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftGate extends CraftBlockData implements Gate {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean IN_WALL = getBoolean("in_wall");
|
||||
|
||||
@Override
|
||||
public boolean isInWall() {
|
||||
return get(IN_WALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInWall(boolean inWall) {
|
||||
set(IN_WALL, inWall);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Hopper;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftHopper extends CraftBlockData implements Hopper {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean ENABLED = getBoolean("enabled");
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return get(ENABLED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
set(ENABLED, enabled);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.block.data.type.Jukebox;
|
||||
|
||||
public abstract class CraftJukebox extends CraftBlockData implements Jukebox {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean HAS_RECORD = getBoolean("has_record");
|
||||
|
||||
@Override
|
||||
public boolean hasRecord() {
|
||||
return get(HAS_RECORD);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Leaves;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public class CraftLeaves extends CraftBlockData implements Leaves {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger DISTANCE = getInteger("distance");
|
||||
private static final net.minecraft.server.BlockStateBoolean PERSISTENT = getBoolean("persistent");
|
||||
|
||||
@Override
|
||||
public boolean isPersistent() {
|
||||
return get(PERSISTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPersistent(boolean persistent) {
|
||||
set(PERSISTENT, persistent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDistance() {
|
||||
return get(DISTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDistance(int distance) {
|
||||
set(DISTANCE, distance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.NoteBlock;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftNoteBlock extends CraftBlockData implements NoteBlock {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> INSTRUMENT = getEnum("instrument");
|
||||
private static final net.minecraft.server.BlockStateInteger NOTE = getInteger("note");
|
||||
|
||||
@Override
|
||||
public org.bukkit.Instrument getInstrument() {
|
||||
return get(INSTRUMENT, org.bukkit.Instrument.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstrument(org.bukkit.Instrument instrument) {
|
||||
set(INSTRUMENT, instrument);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.Note getNote() {
|
||||
return new org.bukkit.Note(get(NOTE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNote(org.bukkit.Note note) {
|
||||
set(NOTE, (int) note.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Piston;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftPiston extends CraftBlockData implements Piston {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean EXTENDED = getBoolean("extended");
|
||||
|
||||
@Override
|
||||
public boolean isExtended() {
|
||||
return get(EXTENDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtended(boolean extended) {
|
||||
set(EXTENDED, extended);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.PistonHead;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftPistonHead extends CraftBlockData implements PistonHead {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean SHORT = getBoolean("short");
|
||||
|
||||
@Override
|
||||
public boolean isShort() {
|
||||
return get(SHORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(boolean _short) {
|
||||
set(SHORT, _short);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.RedstoneWire;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftRedstoneWire extends CraftBlockData implements RedstoneWire {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> NORTH = getEnum("north");
|
||||
private static final net.minecraft.server.BlockStateEnum<?> EAST = getEnum("east");
|
||||
private static final net.minecraft.server.BlockStateEnum<?> SOUTH = getEnum("south");
|
||||
private static final net.minecraft.server.BlockStateEnum<?> WEST = getEnum("west");
|
||||
|
||||
@Override
|
||||
public Connection getFace(org.bukkit.block.BlockFace face) {
|
||||
switch (face) {
|
||||
case NORTH:
|
||||
return get(NORTH, Connection.class);
|
||||
case EAST:
|
||||
return get(EAST, Connection.class);
|
||||
case SOUTH:
|
||||
return get(SOUTH, Connection.class);
|
||||
case WEST:
|
||||
return get(WEST, Connection.class);
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot have face " + face);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFace(org.bukkit.block.BlockFace face, Connection connection) {
|
||||
switch (face) {
|
||||
case NORTH:
|
||||
set(NORTH, connection);
|
||||
break;
|
||||
case EAST:
|
||||
set(EAST, connection);
|
||||
break;
|
||||
case SOUTH:
|
||||
set(SOUTH, connection);
|
||||
break;
|
||||
case WEST:
|
||||
set(WEST, connection);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot have face " + face);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<org.bukkit.block.BlockFace> getAllowedFaces() {
|
||||
return com.google.common.collect.ImmutableSet.of(org.bukkit.block.BlockFace.NORTH, org.bukkit.block.BlockFace.EAST, org.bukkit.block.BlockFace.SOUTH, org.bukkit.block.BlockFace.WEST);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Repeater;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftRepeater extends CraftBlockData implements Repeater {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger DELAY = getInteger("delay");
|
||||
private static final net.minecraft.server.BlockStateBoolean LOCKED = getBoolean("locked");
|
||||
|
||||
@Override
|
||||
public int getDelay() {
|
||||
return get(DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDelay(int delay) {
|
||||
set(DELAY, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumDelay() {
|
||||
return getMin(DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumDelay() {
|
||||
return getMax(DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked() {
|
||||
return get(LOCKED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocked(boolean locked) {
|
||||
set(LOCKED, locked);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Sapling;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftSapling extends CraftBlockData implements Sapling {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger STAGE = getInteger("stage");
|
||||
|
||||
@Override
|
||||
public int getStage() {
|
||||
return get(STAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStage(int stage) {
|
||||
set(STAGE, stage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumStage() {
|
||||
return getMax(STAGE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.SeaPickle;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftSeaPickle extends CraftBlockData implements SeaPickle {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger PICKLES = getInteger("pickles");
|
||||
|
||||
@Override
|
||||
public int getPickles() {
|
||||
return get(PICKLES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPickles(int pickles) {
|
||||
set(PICKLES, pickles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumPickles() {
|
||||
return getMin(PICKLES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumPickles() {
|
||||
return getMax(PICKLES);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Slab;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftSlab extends CraftBlockData implements Slab {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> TYPE = getEnum("type");
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return get(TYPE, Type.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
set(TYPE, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Snow;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public class CraftSnow extends CraftBlockData implements Snow {
|
||||
|
||||
private static final net.minecraft.server.BlockStateInteger LAYERS = getInteger("layers");
|
||||
|
||||
@Override
|
||||
public int getLayers() {
|
||||
return get(LAYERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayers(int layers) {
|
||||
set(LAYERS, layers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumLayers() {
|
||||
return getMin(LAYERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumLayers() {
|
||||
return getMax(LAYERS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Stairs;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftStairs extends CraftBlockData implements Stairs {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> SHAPE = getEnum("shape");
|
||||
|
||||
@Override
|
||||
public Shape getShape() {
|
||||
return get(SHAPE, Shape.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShape(Shape shape) {
|
||||
set(SHAPE, shape);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.StructureBlock;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftStructureBlock extends CraftBlockData implements StructureBlock {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> MODE = getEnum("mode");
|
||||
|
||||
@Override
|
||||
public Mode getMode() {
|
||||
return get(MODE, Mode.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMode(Mode mode) {
|
||||
set(MODE, mode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.Switch;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftSwitch extends CraftBlockData implements Switch {
|
||||
|
||||
private static final net.minecraft.server.BlockStateEnum<?> FACE = getEnum("face");
|
||||
|
||||
@Override
|
||||
public Face getFace() {
|
||||
return get(FACE, Face.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFace(Face face) {
|
||||
set(FACE, face);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.bukkit.craftbukkit.block.data.type;
|
||||
|
||||
import org.bukkit.block.data.type.TNT;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
|
||||
public abstract class CraftTNT extends CraftBlockData implements TNT {
|
||||
|
||||
private static final net.minecraft.server.BlockStateBoolean UNSTABLE = getBoolean("unstable");
|
||||
|
||||
@Override
|
||||
public boolean isUnstable() {
|
||||
return get(UNSTABLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnstable(boolean unstable) {
|
||||
set(UNSTABLE, unstable);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user