Update to Minecraft 1.13-pre7

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2018-07-15 10:00:00 +10:00
parent d1e91a8adb
commit 7e0a66fdd5
608 changed files with 17788 additions and 9378 deletions

View File

@@ -0,0 +1,200 @@
package com.mojang.brigadier.tree;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.mojang.brigadier.AmbiguityConsumer;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.RedirectModifier;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.context.CommandContextBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import net.minecraft.server.CommandListenerWrapper; // CraftBukkit
public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
private Map<String, CommandNode<S>> children = Maps.newLinkedHashMap();
private Map<String, LiteralCommandNode<S>> literals = Maps.newLinkedHashMap();
private Map<String, ArgumentCommandNode<S, ?>> arguments = Maps.newLinkedHashMap();
private final Predicate<S> requirement;
private final CommandNode<S> redirect;
private final RedirectModifier<S> modifier;
private final boolean forks;
private Command<S> command;
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
this.command = command;
this.requirement = requirement;
this.redirect = redirect;
this.modifier = modifier;
this.forks = forks;
}
public Command<S> getCommand() {
return command;
}
public Collection<CommandNode<S>> getChildren() {
return children.values();
}
public CommandNode<S> getChild(final String name) {
return children.get(name);
}
public CommandNode<S> getRedirect() {
return redirect;
}
public RedirectModifier<S> getRedirectModifier() {
return modifier;
}
public boolean canUse(final S source) {
// CraftBukkit start
if (source instanceof CommandListenerWrapper) {
try {
((CommandListenerWrapper) source).currentCommand = this;
return requirement.test(source);
} finally {
((CommandListenerWrapper) source).currentCommand = null;
}
}
// CraftBukkit end
return requirement.test(source);
}
public void addChild(final CommandNode<S> node) {
if (node instanceof RootCommandNode) {
throw new UnsupportedOperationException("Cannot add a RootCommandNode as a child to any other CommandNode");
}
final CommandNode<S> child = children.get(node.getName());
if (child != null) {
// We've found something to merge onto
if (node.getCommand() != null) {
child.command = node.getCommand();
}
for (final CommandNode<S> grandchild : node.getChildren()) {
child.addChild(grandchild);
}
} else {
children.put(node.getName(), node);
if (node instanceof LiteralCommandNode) {
literals.put(node.getName(), (LiteralCommandNode<S>) node);
} else if (node instanceof ArgumentCommandNode) {
arguments.put(node.getName(), (ArgumentCommandNode<S, ?>) node);
}
}
children = children.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
public void findAmbiguities(final AmbiguityConsumer<S> consumer) {
Set<String> matches = Sets.newHashSet();
for (final CommandNode<S> child : children.values()) {
for (final CommandNode<S> sibling : children.values()) {
if (child == sibling) {
continue;
}
for (final String input : child.getExamples()) {
if (sibling.isValidInput(input)) {
matches.add(input);
}
}
if (matches.size() > 0) {
consumer.ambiguous(this, child, sibling, matches);
matches = Sets.newHashSet();
}
}
child.findAmbiguities(consumer);
}
}
protected abstract boolean isValidInput(final String input);
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof CommandNode)) return false;
final CommandNode<S> that = (CommandNode<S>) o;
if (!children.equals(that.children)) return false;
if (command != null ? !command.equals(that.command) : that.command != null) return false;
return true;
}
@Override
public int hashCode() {
return 31 * children.hashCode() + (command != null ? command.hashCode() : 0);
}
public Predicate<S> getRequirement() {
return requirement;
}
public abstract String getName();
public abstract String getUsageText();
public abstract void parse(StringReader reader, CommandContextBuilder<S> contextBuilder) throws CommandSyntaxException;
public abstract CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) throws CommandSyntaxException;
public abstract ArgumentBuilder<S, ?> createBuilder();
protected abstract String getSortedKey();
public Collection<? extends CommandNode<S>> getRelevantNodes(final StringReader input) {
if (literals.size() > 0) {
final int cursor = input.getCursor();
while (input.canRead() && input.peek() != ' ') {
input.skip();
}
final String text = input.getString().substring(cursor, input.getCursor());
input.setCursor(cursor);
final LiteralCommandNode<S> literal = literals.get(text);
if (literal != null) {
return Collections.singleton(literal);
} else {
return arguments.values();
}
} else {
return arguments.values();
}
}
@Override
public int compareTo(final CommandNode<S> o) {
return ComparisonChain
.start()
.compareTrueFirst(this instanceof LiteralCommandNode, o instanceof LiteralCommandNode)
.compare(getSortedKey(), o.getSortedKey())
.result();
}
public boolean isFork() {
return forks;
}
public abstract Collection<String> getExamples();
}

View File

@@ -1,74 +1,33 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityPainting.EnumArt;
import com.google.common.base.Preconditions;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import net.minecraft.server.MinecraftKey;
import net.minecraft.server.Paintings;
import org.bukkit.Art;
// Safety class, will break if either side changes
public class CraftArt {
private static final BiMap<Paintings, Art> artwork;
public static Art NotchToBukkit(EnumArt art) {
switch (art) {
case KEBAB: return Art.KEBAB;
case AZTEC: return Art.AZTEC;
case ALBAN: return Art.ALBAN;
case AZTEC_2: return Art.AZTEC2;
case BOMB: return Art.BOMB;
case PLANT: return Art.PLANT;
case WASTELAND: return Art.WASTELAND;
case POOL: return Art.POOL;
case COURBET: return Art.COURBET;
case SEA: return Art.SEA;
case SUNSET: return Art.SUNSET;
case CREEBET: return Art.CREEBET;
case WANDERER: return Art.WANDERER;
case GRAHAM: return Art.GRAHAM;
case MATCH: return Art.MATCH;
case BUST: return Art.BUST;
case STAGE: return Art.STAGE;
case VOID: return Art.VOID;
case SKULL_AND_ROSES: return Art.SKULL_AND_ROSES;
case FIGHTERS: return Art.FIGHTERS;
case POINTER: return Art.POINTER;
case PIGSCENE: return Art.PIGSCENE;
case BURNING_SKULL: return Art.BURNINGSKULL;
case SKELETON: return Art.SKELETON;
case DONKEY_KONG: return Art.DONKEYKONG;
case WITHER: return Art.WITHER;
default:
throw new AssertionError(art);
static {
ImmutableBiMap.Builder<Paintings, Art> artworkBuilder = ImmutableBiMap.builder();
for (MinecraftKey key : Paintings.a.keySet()) {
artworkBuilder.put(Paintings.a.get(key), Art.getByName(key.getKey()));
}
artwork = artworkBuilder.build();
}
public static EnumArt BukkitToNotch(Art art) {
switch (art) {
case KEBAB: return EnumArt.KEBAB;
case AZTEC: return EnumArt.AZTEC;
case ALBAN: return EnumArt.ALBAN;
case AZTEC2: return EnumArt.AZTEC_2;
case BOMB: return EnumArt.BOMB;
case PLANT: return EnumArt.PLANT;
case WASTELAND: return EnumArt.WASTELAND;
case POOL: return EnumArt.POOL;
case COURBET: return EnumArt.COURBET;
case SEA: return EnumArt.SEA;
case SUNSET: return EnumArt.SUNSET;
case CREEBET: return EnumArt.CREEBET;
case WANDERER: return EnumArt.WANDERER;
case GRAHAM: return EnumArt.GRAHAM;
case MATCH: return EnumArt.MATCH;
case BUST: return EnumArt.BUST;
case STAGE: return EnumArt.STAGE;
case VOID: return EnumArt.VOID;
case SKULL_AND_ROSES: return EnumArt.SKULL_AND_ROSES;
case FIGHTERS: return EnumArt.FIGHTERS;
case POINTER: return EnumArt.POINTER;
case PIGSCENE: return EnumArt.PIGSCENE;
case BURNINGSKULL: return EnumArt.BURNING_SKULL;
case SKELETON: return EnumArt.SKELETON;
case DONKEYKONG: return EnumArt.DONKEY_KONG;
case WITHER: return EnumArt.WITHER;
default:
throw new AssertionError(art);
}
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;
}
}

View File

@@ -20,7 +20,7 @@ public class CraftChunk implements Chunk {
private final int x;
private final int z;
private static final byte[] emptyData = new byte[2048];
private static final short[] emptyBlockIDs = new short[4096];
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) {
@@ -69,7 +69,7 @@ public class CraftChunk implements Chunk {
}
public Block getBlock(int x, int y, int z) {
return new CraftBlock(this, (getX() << 4) | (x & 0xF), y, (getZ() << 4) | (z & 0xF));
return new CraftBlock(worldServer, new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z));
}
public Entity[] getEntities() {
@@ -133,7 +133,7 @@ public class CraftChunk implements Chunk {
@Override
public boolean isSlimeChunk() {
// 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk
return getHandle().a(987234911L).nextInt(10) == 0;
return SeededRandom.a(getX(), getZ(), getWorld().getSeed(), 987234911L).nextInt(10) == 0;
}
public boolean unload(boolean save) {
@@ -152,8 +152,7 @@ public class CraftChunk implements Chunk {
net.minecraft.server.Chunk chunk = getHandle();
ChunkSection[] cs = chunk.getSections();
short[][] sectionBlockIDs = new short[cs.length][];
byte[][] sectionBlockData = new byte[cs.length][];
DataPaletteBlock[] sectionBlockIDs = new DataPaletteBlock[cs.length];
byte[][] sectionSkyLights = new byte[cs.length][];
byte[][] sectionEmitLights = new byte[cs.length][];
boolean[] sectionEmpty = new boolean[cs.length];
@@ -161,28 +160,20 @@ public class CraftChunk implements Chunk {
for (int i = 0; i < cs.length; i++) {
if (cs[i] == null) { // Section is empty?
sectionBlockIDs[i] = emptyBlockIDs;
sectionBlockData[i] = emptyData;
sectionSkyLights[i] = emptySkyLight;
sectionEmitLights[i] = emptyData;
sectionEmpty[i] = true;
} else { // Not empty
short[] blockids = new short[4096];
NBTTagCompound data = new NBTTagCompound();
cs[i].getBlocks().b(data, "Spigot", "Magic");
byte[] rawIds = new byte[4096];
NibbleArray data = new NibbleArray();
cs[i].getBlocks().exportData(rawIds, data);
byte[] dataValues = sectionBlockData[i] = data.asBytes();
// Copy base IDs
for (int j = 0; j < 4096; j++) {
blockids[j] = (short) (rawIds[j] & 0xFF);
}
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] = emptyData;
sectionSkyLights[i] = emptySkyLight;
} else {
sectionSkyLights[i] = new byte[2048];
System.arraycopy(cs[i].getSkyLightArray().asBytes(), 0, sectionSkyLights[i], 0, 2048);
@@ -192,57 +183,46 @@ public class CraftChunk implements Chunk {
}
}
int[] hmap = null;
HeightMap hmap = null;
if (includeMaxBlockY) {
hmap = new int[256]; // Get copy of height map
System.arraycopy(chunk.heightMap, 0, hmap, 0, 256);
hmap = new HeightMap(null, HeightMap.Type.LIGHT_BLOCKING);
hmap.a(chunk.heightMap.get(HeightMap.Type.LIGHT_BLOCKING).b());
}
BiomeBase[] biome = null;
double[] biomeTemp = null;
double[] biomeRain = null;
if (includeBiome || includeBiomeTempRain) {
WorldChunkManager wcm = chunk.world.getWorldChunkManager();
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), wcm);
biome[i] = chunk.getBiome(new BlockPosition(i & 0xF, 0, i >> 4));
}
}
if (includeBiomeTempRain) {
biomeTemp = new double[256];
biomeRain = new double[256];
float[] dat = getTemperatures(wcm, getX() << 4, getZ() << 4);
for (int i = 0; i < 256; i++) {
biomeTemp[i] = dat[i];
}
/* Removed 15w46a
dat = wcm.getWetness(null, getX() << 4, getZ() << 4, 16, 16);
for (int i = 0; i < 256; i++) {
biomeRain[i] = dat[i];
}
*/
}
}
World world = getWorld();
return new CraftChunkSnapshot(getX(), getZ(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionBlockData, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome, biomeTemp, biomeRain);
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;
double[] biomeRain = null;
if (includeBiome || includeBiomeTempRain) {
WorldChunkManager wcm = world.getHandle().getWorldChunkManager();
WorldChunkManager wcm = world.getHandle().getChunkProvider().getChunkGenerator().getWorldChunkManager();
if (includeBiome) {
biome = new BiomeBase[256];
@@ -253,44 +233,33 @@ public class CraftChunk implements Chunk {
if (includeBiomeTempRain) {
biomeTemp = new double[256];
biomeRain = new double[256];
float[] dat = getTemperatures(wcm, x << 4, z << 4);
for (int i = 0; i < 256; i++) {
biomeTemp[i] = dat[i];
}
/* Removed 15w46a
dat = wcm.getWetness(null, x << 4, z << 4, 16, 16);
for (int i = 0; i < 256; i++) {
biomeRain[i] = dat[i];
}
*/
}
}
/* Fill with empty data */
int hSection = world.getMaxHeight() >> 4;
short[][] blockIDs = new short[hSection][];
DataPaletteBlock[] blockIDs = new DataPaletteBlock[hSection];
byte[][] skyLight = new byte[hSection][];
byte[][] emitLight = new byte[hSection][];
byte[][] blockData = new byte[hSection][];
boolean[] empty = new boolean[hSection];
for (int i = 0; i < hSection; i++) {
blockIDs[i] = emptyBlockIDs;
skyLight[i] = emptySkyLight;
emitLight[i] = emptyData;
blockData[i] = emptyData;
empty[i] = true;
}
return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, blockData, skyLight, emitLight, empty, new int[256], biome, biomeTemp, biomeRain);
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(null, chunkX, chunkZ, 16, 16);
BiomeBase[] biomes = chunkmanager.getBiomes(chunkX, chunkZ, 16, 16);
float[] temps = new float[biomes.length];
for (int i = 0; i < biomes.length; i++) {

View File

@@ -3,9 +3,15 @@ package org.bukkit.craftbukkit;
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
@@ -14,31 +20,27 @@ import net.minecraft.server.BiomeBase;
public class CraftChunkSnapshot implements ChunkSnapshot {
private final int x, z;
private final String worldname;
private final short[][] blockids; /* Block IDs, by section */
private final byte[][] blockdata;
private final DataPaletteBlock<IBlockData>[] blockids;
private final byte[][] skylight;
private final byte[][] emitlight;
private final boolean[] empty;
private final int[] hmap; // Height map
private final HeightMap hmap; // Height map
private final long captureFulltime;
private final BiomeBase[] biome;
private final double[] biomeTemp;
private final double[] biomeRain;
CraftChunkSnapshot(int x, int z, String wname, long wtime, short[][] sectionBlockIDs, byte[][] sectionBlockData, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, int[] hmap, BiomeBase[] biome, double[] biomeTemp, double[] biomeRain) {
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.blockdata = sectionBlockData;
this.skylight = sectionSkyLights;
this.emitlight = sectionEmitLights;
this.empty = sectionEmpty;
this.hmap = hmap;
this.biome = biome;
this.biomeTemp = biomeTemp;
this.biomeRain = biomeRain;
}
public int getX() {
@@ -55,16 +57,17 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
@Override
public Material getBlockType(int x, int y, int z) {
return Material.getMaterial(getBlockTypeId(x, y, z));
return CraftMagicNumbers.getMaterial(blockids[y >> 4].a(x, y & 0xF, z).getBlock());
}
public final int getBlockTypeId(int x, int y, int z) {
return blockids[y >> 4][((y & 0xF) << 8) | (z << 4) | x];
@Override
public final BlockData getBlockData(int x, int y, int z) {
return CraftBlockData.fromData(blockids[y >> 4].a(x, y & 0xF, z));
}
public final int getBlockData(int x, int y, int z) {
int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1);
return (blockdata[y >> 4][off] >> ((x & 1) << 2)) & 0xF;
@Override
public final int getData(int x, int y, int z) {
return CraftMagicNumbers.toLegacyData(blockids[y >> 4].a(x, y & 0xF, z));
}
public final int getBlockSkyLight(int x, int y, int z) {
@@ -78,7 +81,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
}
public final int getHighestBlockYAt(int x, int z) {
return hmap[z << 4 | x];
return hmap.a(x, z);
}
public final Biome getBiome(int x, int z) {
@@ -89,10 +92,6 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
return biomeTemp[z << 4 | x];
}
public final double getRawBiomeRainfall(int x, int z) {
return biomeRain[z << 4 | x];
}
public final long getCaptureFullTime() {
return captureFulltime;
}

View File

@@ -12,6 +12,7 @@ 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> {
@@ -22,7 +23,8 @@ public class CraftCrashReport implements CrashReportCallable<Object> {
value.append("\n Plugins: {");
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
PluginDescriptionFile description = plugin.getDescription();
value.append(' ').append(description.getFullName()).append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(',');
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));

View File

@@ -1,9 +1,12 @@
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 {
@@ -18,7 +21,7 @@ public class CraftEffect {
break;
case RECORD_PLAY:
Validate.isTrue(((Material) data).isRecord(), "Invalid record type!");
datavalue = ((Material) data).getId();
datavalue = Item.getId(CraftMagicNumbers.getItem((Material) data));
break;
case SMOKE:
switch((BlockFace) data) { // TODO: Verify (Where did these values come from...?)
@@ -56,7 +59,7 @@ public class CraftEffect {
break;
case STEP_SOUND:
Validate.isTrue(((Material) data).isBlock(), "Material is not a block!");
datavalue = ((Material) data).getId();
datavalue = Block.getCombinedId(CraftMagicNumbers.getBlock((Material) data).getBlockData());
break;
default:
datavalue = 0;

View File

@@ -9,6 +9,7 @@ import java.util.UUID;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.WhiteListEntry;
import net.minecraft.server.WorldNBTStorage;
import org.bukkit.BanList;
@@ -115,9 +116,9 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
public void setWhitelisted(boolean value) {
if (value) {
server.getHandle().addWhitelist(profile);
server.getHandle().getWhitelist().add(new WhiteListEntry(profile));
} else {
server.getHandle().removeWhitelist(profile);
server.getHandle().getWhitelist().remove(profile);
}
}

View File

@@ -1,41 +1,151 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.Block;
import net.minecraft.server.EnumParticle;
import net.minecraft.server.IBlockData;
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.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 class CraftParticle {
public enum CraftParticle {
public static EnumParticle toNMS(Particle bukkit) {
return EnumParticle.valueOf(bukkit.name());
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);
}
}
}
public static Particle toBukkit(EnumParticle nms) {
return Particle.valueOf(nms.name());
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 int[] toData(Particle particle, Object obj) {
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 = net.minecraft.server.Particle.REGISTRY.get(particles.get(canonical));
Preconditions.checkArgument(nms != null, "No NMS particle %s", particle);
if (particle.getDataType().equals(Void.class)) {
return new int[0];
return (ParticleType) nms;
}
Preconditions.checkArgument(obj != null, "Particle %s requires data, null provided", particle);
if (particle.getDataType().equals(ItemStack.class)) {
if (obj == null) {
return new int[]{0, 0};
}
ItemStack itemStack = (ItemStack) obj;
return new int[]{itemStack.getType().getId(), itemStack.getDurability()};
return new ParticleParamItem((net.minecraft.server.Particle<ParticleParamItem>) nms, CraftItemStack.asNMSCopy(itemStack));
}
if (particle.getDataType().equals(MaterialData.class)) {
if (obj == null) {
return new int[]{0};
}
if (particle.getDataType() == MaterialData.class) {
MaterialData data = (MaterialData) obj;
return new int[]{data.getItemTypeId() + ((int)(data.getData()) << 12)};
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(), color.getGreen(), color.getBlue(), 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());
}
}

View File

@@ -8,6 +8,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@@ -17,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
@@ -52,7 +54,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.conversations.Conversable;
import org.bukkit.craftbukkit.boss.CraftBossBar;
import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.generator.CraftChunkData;
import org.bukkit.craftbukkit.help.SimpleHelpMap;
@@ -122,14 +123,28 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.MapMaker;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.base64.Base64;
import java.util.HashMap;
import jline.console.ConsoleReader;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.command.BukkitCommandWrapper;
import org.bukkit.craftbukkit.command.CraftCommandMap;
import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
import org.bukkit.craftbukkit.tag.CraftBlockTag;
import org.bukkit.craftbukkit.tag.CraftItemTag;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.event.server.TabCompleteEvent;
@@ -140,7 +155,7 @@ public final class CraftServer implements Server {
private final Logger logger = Logger.getLogger("Minecraft");
private final ServicesManager servicesManager = new SimpleServicesManager();
private final CraftScheduler scheduler = new CraftScheduler();
private final SimpleCommandMap commandMap = new SimpleCommandMap(this);
private final CraftCommandMap commandMap = new CraftCommandMap(this);
private final SimpleHelpMap helpMap = new SimpleHelpMap(this);
private final StandardMessenger messenger = new StandardMessenger();
private final SimplePluginManager pluginManager = new SimplePluginManager(this, commandMap);
@@ -168,7 +183,6 @@ public final class CraftServer implements Server {
private boolean printSaveWarning;
private CraftIconCache icon;
private boolean overrideAllCommandBlockCommands = false;
private boolean unrestrictedAdvancements;
private final List<CraftPlayer> playerView;
public int reloadCount;
@@ -245,7 +259,6 @@ public final class CraftServer implements Server {
saveCommandsConfig();
overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*");
unrestrictedAdvancements = commandsConfiguration.getBoolean("unrestricted-advancements");
pluginManager.useTimings(configuration.getBoolean("settings.plugin-profiling"));
monsterSpawn = configuration.getInt("spawn-limits.monsters");
animalSpawn = configuration.getInt("spawn-limits.animals");
@@ -258,14 +271,6 @@ public final class CraftServer implements Server {
loadIcon();
}
public boolean getPermissionOverride(ICommandListener listener) {
while (listener instanceof CommandListenerWrapper) {
listener = ((CommandListenerWrapper) listener).base;
}
return unrestrictedAdvancements && listener instanceof AdvancementRewards.AdvancementCommandListener;
}
public boolean getCommandBlockOverride(String command) {
return overrideAllCommandBlockCommands || commandsConfiguration.getStringList("command-block-overrides").contains(command);
}
@@ -337,6 +342,7 @@ public final class CraftServer implements Server {
DefaultPermissions.registerCorePermissions();
CraftDefaultPermissions.registerCorePermissions();
helpMap.initializeCommands();
syncCommands();
}
}
@@ -345,9 +351,43 @@ public final class CraftServer implements Server {
}
private void setVanillaCommands() {
Map<String, ICommand> commands = new CommandDispatcher(console).getCommands();
for (ICommand cmd : commands.values()) {
commandMap.register("minecraft", new VanillaCommandWrapper((CommandAbstract) cmd, LocaleI18n.get(cmd.getUsage(null))));
CommandDispatcher dispatcher = console.getCommandDispatcher();
// Build a list of all Vanilla commands and create wrappers
for (CommandNode<CommandListenerWrapper> cmd : dispatcher.a().getRoot().getChildren()) {
commandMap.register("minecraft", new VanillaCommandWrapper(dispatcher, cmd));
}
}
private void syncCommands() {
// Clear existing commands
CommandDispatcher dispatcher = console.commandDispatcher = new CommandDispatcher();
// Register all commands, vanilla ones will be using the old dispatcher references
for (Map.Entry<String, Command> entry : commandMap.getKnownCommands().entrySet()) {
String label = entry.getKey();
Command command = entry.getValue();
if (command instanceof VanillaCommandWrapper) {
LiteralCommandNode<CommandListenerWrapper> node = (LiteralCommandNode<CommandListenerWrapper>) ((VanillaCommandWrapper) command).vanillaCommand;
if (!node.getLiteral().equals(label)) {
LiteralCommandNode<CommandListenerWrapper> clone = new LiteralCommandNode(label, node.getCommand(), node.getRequirement(), node.getRedirect(), node.getRedirectModifier(), node.isFork());
for (CommandNode<CommandListenerWrapper> child : node.getChildren()) {
clone.addChild(child);
}
node = clone;
}
dispatcher.a().getRoot().addChild(node);
} else {
new BukkitCommandWrapper(this, entry.getValue()).register(dispatcher.a(), label);
}
}
// Refresh commands
for (EntityPlayer player : getHandle().players) {
dispatcher.a(player);
}
}
@@ -837,23 +877,23 @@ public final class CraftServer implements Server {
generator = getGenerator(name);
}
Convertable converter = new WorldLoaderServer(getWorldContainer(), getHandle().getServer().dataConverterManager);
Convertable converter = new WorldLoaderServer(getWorldContainer().toPath(), getWorldContainer().toPath().resolveSibling("../backups"), getHandle().getServer().dataConverterManager);
if (converter.isConvertable(name)) {
getLogger().info("Converting world '" + name + "'");
converter.convert(name, new IProgressUpdate() {
private long b = System.currentTimeMillis();
public void a(String s) {}
public void a(IChatBaseComponent ichatbasecomponent) {}
public void a(int i) {
if (System.currentTimeMillis() - this.b >= 1000L) {
this.b = System.currentTimeMillis();
MinecraftServer.LOGGER.info("Converting... " + i + "%");
MinecraftServer.LOGGER.info("Converting... {}%", Integer.valueOf(i));
}
}
public void c(String s) {}
public void c(IChatBaseComponent ichatbasecomponent) {}
});
}
@@ -870,12 +910,15 @@ public final class CraftServer implements Server {
} while(used);
boolean hardcore = false;
IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true, getHandle().getServer().dataConverterManager);
IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, getServer(), getHandle().getServer().dataConverterManager);
WorldData worlddata = sdm.getWorldData();
WorldSettings worldSettings = null;
if (worlddata == null) {
worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
worldSettings.setGeneratorSettings(creator.generatorSettings());
JsonElement parsedSettings = new JsonParser().parse(creator.generatorSettings());
if (parsedSettings.isJsonObject()) {
worldSettings.setGeneratorSettings(parsedSettings.getAsJsonObject());
}
worlddata = new WorldData(worldSettings, name);
}
worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
@@ -888,7 +931,6 @@ public final class CraftServer implements Server {
if (worldSettings != null) {
internal.a(worldSettings);
}
internal.scoreboard = getScoreboardManager().getMainScoreboard().getHandle();
internal.tracker = new EntityTracker(internal);
internal.addIWorldAccess(new WorldManager(console, internal));
@@ -962,7 +1004,7 @@ public final class CraftServer implements Server {
if (save) {
try {
handle.save(true, null);
handle.saveLevel();
handle.close();
} catch (ExceptionWorldConflict ex) {
getLogger().log(Level.SEVERE, null, ex);
}
@@ -1075,19 +1117,12 @@ public final class CraftServer implements Server {
@Override
public void clearRecipes() {
CraftingManager.recipes = new RegistryMaterials();
RecipesFurnace.getInstance().recipes.clear();
RecipesFurnace.getInstance().customRecipes.clear();
RecipesFurnace.getInstance().customExperience.clear();
console.getCraftingManager().recipes.clear();
}
@Override
public void resetRecipes() {
CraftingManager.recipes = new RegistryMaterials();
CraftingManager.init();
RecipesFurnace.getInstance().recipes = new RecipesFurnace().recipes;
RecipesFurnace.getInstance().customRecipes.clear();
RecipesFurnace.getInstance().customExperience.clear();
console.getCraftingManager().a(console.getResourceManager());
}
@Override
@@ -1192,7 +1227,7 @@ public final class CraftServer implements Server {
@Deprecated
public CraftMapView getMap(short id) {
PersistentCollection collection = console.worlds.get(0).worldMaps;
WorldMap worldmap = (WorldMap) collection.get(WorldMap.class, "map_" + id);
WorldMap worldmap = (WorldMap) collection.get(WorldMap::new, "map_" + id);
if (worldmap == null) {
return null;
}
@@ -1203,8 +1238,8 @@ public final class CraftServer implements Server {
public CraftMapView createMap(World world) {
Validate.notNull(world, "World cannot be null");
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Items.MAP, 1, -1);
WorldMap worldmap = Items.FILLED_MAP.getSavedMap(stack, ((CraftWorld) world).getHandle());
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Items.MAP, 1);
WorldMap worldmap = ItemWorldMap.getSavedMap(stack, ((CraftWorld) world).getHandle());
return worldmap.mapView;
}
@@ -1522,15 +1557,15 @@ public final class CraftServer implements Server {
return warningState;
}
public List<String> tabComplete(net.minecraft.server.ICommandListener sender, String message, BlockPosition pos, boolean forceCommand) {
if (!(sender instanceof EntityPlayer)) {
public List<String> tabComplete(CommandSender sender, String message, WorldServer world, Vec3D pos, boolean forceCommand) {
if (!(sender instanceof Player)) {
return ImmutableList.of();
}
List<String> offers;
Player player = ((EntityPlayer) sender).getBukkitEntity();
Player player = (Player) sender;
if (message.startsWith("/") || forceCommand) {
offers = tabCompleteCommand(player, message, pos);
offers = tabCompleteCommand(player, message, world, pos);
} else {
offers = tabCompleteChat(player, message);
}
@@ -1541,7 +1576,7 @@ public final class CraftServer implements Server {
return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();
}
public List<String> tabCompleteCommand(Player player, String message, BlockPosition pos) {
public List<String> tabCompleteCommand(Player player, String message, WorldServer world, Vec3D pos) {
List<String> completions = null;
try {
if (message.startsWith("/")) {
@@ -1551,7 +1586,7 @@ public final class CraftServer implements Server {
if (pos == null) {
completions = getCommandMap().tabComplete(player, message);
} else {
completions = getCommandMap().tabComplete(player, message, new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
completions = getCommandMap().tabComplete(player, message, new Location(world.getWorld(), pos.x, pos.y, pos.z));
}
} catch (CommandException ex) {
player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
@@ -1660,8 +1695,15 @@ public final class CraftServer implements Server {
@Override
public Entity getEntity(UUID uuid) {
Validate.notNull(uuid, "UUID cannot be null");
net.minecraft.server.Entity entity = console.a(uuid); // PAIL: getEntity
return entity == null ? null : entity.getBukkitEntity();
for (WorldServer world : getServer().worlds) {
net.minecraft.server.Entity entity = world.getEntity(uuid);
if (entity != null) {
return entity.getBukkitEntity();
}
}
return null;
}
@Override
@@ -1674,7 +1716,7 @@ public final class CraftServer implements Server {
@Override
public Iterator<org.bukkit.advancement.Advancement> advancementIterator() {
return Iterators.unmodifiableIterator(Iterators.transform(console.getAdvancementData().c().iterator(), new Function<Advancement, org.bukkit.advancement.Advancement>() { // PAIL: rename
return Iterators.unmodifiableIterator(Iterators.transform(console.getAdvancementData().b().iterator(), new Function<Advancement, org.bukkit.advancement.Advancement>() { // PAIL: rename
@Override
public org.bukkit.advancement.Advancement apply(Advancement advancement) {
return advancement.bukkit;
@@ -1682,6 +1724,55 @@ public final class CraftServer implements Server {
}));
}
@Override
public BlockData createBlockData(org.bukkit.Material material) {
Validate.isTrue(material != null, "Must provide material");
return createBlockData(material, (String) null);
}
@Override
public BlockData createBlockData(org.bukkit.Material material, Consumer<BlockData> consumer) {
BlockData data = createBlockData(material);
if (consumer != null) {
consumer.accept(data);
}
return data;
}
@Override
public BlockData createBlockData(String data) throws IllegalArgumentException {
Validate.isTrue(data != null, "Must provide data");
return createBlockData(null, data);
}
@Override
public BlockData createBlockData(org.bukkit.Material material, String data) {
Validate.isTrue(material != null || data != null, "Must provide one of material or data");
return CraftBlockData.newData(material, data);
}
@Override
@SuppressWarnings("unchecked")
public <T extends Keyed> org.bukkit.Tag<T> getTag(String registry, NamespacedKey tag, Class<T> clazz) {
switch (registry) {
case org.bukkit.Tag.REGISTRY_BLOCKS:
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type");
return (org.bukkit.Tag<T>) new CraftBlockTag(console.getTagRegistry().a().b(CraftNamespacedKey.toMinecraft(tag)));
case org.bukkit.Tag.REGISTRY_ITEMS:
Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type");
return (org.bukkit.Tag<T>) new CraftItemTag(console.getTagRegistry().b().b(CraftNamespacedKey.toMinecraft(tag)));
default:
throw new IllegalArgumentException();
}
}
@Deprecated
@Override
public UnsafeValues getUnsafe() {

View File

@@ -10,6 +10,12 @@ 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"),
@@ -18,24 +24,38 @@ public enum CraftSound {
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_CLOTH_BREAK("block.cloth.break"),
BLOCK_CLOTH_FALL("block.cloth.fall"),
BLOCK_CLOTH_HIT("block.cloth.hit"),
BLOCK_CLOTH_PLACE("block.cloth.place"),
BLOCK_CLOTH_STEP("block.cloth.step"),
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_ENDERCHEST_CLOSE("block.enderchest.close"),
BLOCK_ENDERCHEST_OPEN("block.enderchest.open"),
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"),
@@ -72,29 +92,31 @@ public enum CraftSound {
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_PRESSUREPLATE_CLICK_OFF("block.metal_pressureplate.click_off"),
BLOCK_METAL_PRESSUREPLATE_CLICK_ON("block.metal_pressureplate.click_on"),
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_BASEDRUM("block.note.basedrum"),
BLOCK_NOTE_BASS("block.note.bass"),
BLOCK_NOTE_BELL("block.note.bell"),
BLOCK_NOTE_CHIME("block.note.chime"),
BLOCK_NOTE_FLUTE("block.note.flute"),
BLOCK_NOTE_GUITAR("block.note.guitar"),
BLOCK_NOTE_HARP("block.note.harp"),
BLOCK_NOTE_HAT("block.note.hat"),
BLOCK_NOTE_PLING("block.note.pling"),
BLOCK_NOTE_SNARE("block.note.snare"),
BLOCK_NOTE_XYLOPHONE("block.note.xylophone"),
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"),
@@ -103,11 +125,11 @@ public enum CraftSound {
BLOCK_SAND_STEP("block.sand.step"),
BLOCK_SHULKER_BOX_CLOSE("block.shulker_box.close"),
BLOCK_SHULKER_BOX_OPEN("block.shulker_box.open"),
BLOCK_SLIME_BREAK("block.slime.break"),
BLOCK_SLIME_FALL("block.slime.fall"),
BLOCK_SLIME_HIT("block.slime.hit"),
BLOCK_SLIME_PLACE("block.slime.place"),
BLOCK_SLIME_STEP("block.slime.step"),
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"),
@@ -119,33 +141,42 @@ public enum CraftSound {
BLOCK_STONE_FALL("block.stone.fall"),
BLOCK_STONE_HIT("block.stone.hit"),
BLOCK_STONE_PLACE("block.stone.place"),
BLOCK_STONE_PRESSUREPLATE_CLICK_OFF("block.stone_pressureplate.click_off"),
BLOCK_STONE_PRESSUREPLATE_CLICK_ON("block.stone_pressureplate.click_on"),
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_WATERLILY_PLACE("block.waterlily.place"),
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_BUTTON_CLICK_OFF("block.wood_button.click_off"),
BLOCK_WOOD_BUTTON_CLICK_ON("block.wood_button.click_on"),
BLOCK_WOOD_FALL("block.wood.fall"),
BLOCK_WOOD_HIT("block.wood.hit"),
BLOCK_WOOD_PLACE("block.wood.place"),
BLOCK_WOOD_PRESSUREPLATE_CLICK_OFF("block.wood_pressureplate.click_off"),
BLOCK_WOOD_PRESSUREPLATE_CLICK_ON("block.wood_pressureplate.click_on"),
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_ARMORSTAND_BREAK("entity.armorstand.break"),
ENTITY_ARMORSTAND_FALL("entity.armorstand.fall"),
ENTITY_ARMORSTAND_HIT("entity.armorstand.hit"),
ENTITY_ARMORSTAND_PLACE("entity.armorstand.place"),
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"),
@@ -161,9 +192,6 @@ public enum CraftSound {
ENTITY_BLAZE_SHOOT("entity.blaze.shoot"),
ENTITY_BOAT_PADDLE_LAND("entity.boat.paddle_land"),
ENTITY_BOAT_PADDLE_WATER("entity.boat.paddle_water"),
ENTITY_BOBBER_RETRIEVE("entity.bobber.retrieve"),
ENTITY_BOBBER_SPLASH("entity.bobber.splash"),
ENTITY_BOBBER_THROW("entity.bobber.throw"),
ENTITY_CAT_AMBIENT("entity.cat.ambient"),
ENTITY_CAT_DEATH("entity.cat.death"),
ENTITY_CAT_HISS("entity.cat.hiss"),
@@ -175,6 +203,10 @@ public enum CraftSound {
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"),
@@ -183,11 +215,31 @@ public enum CraftSound {
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"),
@@ -197,44 +249,47 @@ public enum CraftSound {
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_ENDERDRAGON_AMBIENT("entity.enderdragon.ambient"),
ENTITY_ENDERDRAGON_DEATH("entity.enderdragon.death"),
ENTITY_ENDERDRAGON_FIREBALL_EXPLODE("entity.enderdragon_fireball.explode"),
ENTITY_ENDERDRAGON_FLAP("entity.enderdragon.flap"),
ENTITY_ENDERDRAGON_GROWL("entity.enderdragon.growl"),
ENTITY_ENDERDRAGON_HURT("entity.enderdragon.hurt"),
ENTITY_ENDERDRAGON_SHOOT("entity.enderdragon.shoot"),
ENTITY_ENDEREYE_DEATH("entity.endereye.death"),
ENTITY_ENDEREYE_LAUNCH("entity.endereye.launch"),
ENTITY_ENDERMEN_AMBIENT("entity.endermen.ambient"),
ENTITY_ENDERMEN_DEATH("entity.endermen.death"),
ENTITY_ENDERMEN_HURT("entity.endermen.hurt"),
ENTITY_ENDERMEN_SCREAM("entity.endermen.scream"),
ENTITY_ENDERMEN_STARE("entity.endermen.stare"),
ENTITY_ENDERMEN_TELEPORT("entity.endermen.teleport"),
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_ENDERPEARL_THROW("entity.enderpearl.throw"),
ENTITY_EVOCATION_FANGS_ATTACK("entity.evocation_fangs.attack"),
ENTITY_EVOCATION_ILLAGER_AMBIENT("entity.evocation_illager.ambient"),
ENTITY_EVOCATION_ILLAGER_CAST_SPELL("entity.evocation_illager.cast_spell"),
ENTITY_EVOCATION_ILLAGER_DEATH("entity.evocation_illager.death"),
ENTITY_EVOCATION_ILLAGER_HURT("entity.evocation_illager.hurt"),
ENTITY_EVOCATION_ILLAGER_PREPARE_ATTACK("entity.evocation_illager.prepare_attack"),
ENTITY_EVOCATION_ILLAGER_PREPARE_SUMMON("entity.evocation_illager.prepare_summon"),
ENTITY_EVOCATION_ILLAGER_PREPARE_WOLOLO("entity.evocation_illager.prepare_wololo"),
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_BLAST("entity.firework.blast"),
ENTITY_FIREWORK_BLAST_FAR("entity.firework.blast_far"),
ENTITY_FIREWORK_LARGE_BLAST("entity.firework.large_blast"),
ENTITY_FIREWORK_LARGE_BLAST_FAR("entity.firework.large_blast_far"),
ENTITY_FIREWORK_LAUNCH("entity.firework.launch"),
ENTITY_FIREWORK_SHOOT("entity.firework.shoot"),
ENTITY_FIREWORK_TWINKLE("entity.firework.twinkle"),
ENTITY_FIREWORK_TWINKLE_FAR("entity.firework.twinkle_far"),
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"),
@@ -280,32 +335,33 @@ public enum CraftSound {
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_ILLUSION_ILLAGER_AMBIENT("entity.illusion_illager.ambient"),
ENTITY_ILLUSION_ILLAGER_CAST_SPELL("entity.illusion_illager.cast_spell"),
ENTITY_ILLUSION_ILLAGER_DEATH("entity.illusion_illager.death"),
ENTITY_ILLUSION_ILLAGER_HURT("entity.illusion_illager.hurt"),
ENTITY_ILLUSION_ILLAGER_MIRROR_MOVE("entity.illusion_illager.mirror_move"),
ENTITY_ILLUSION_ILLAGER_PREPARE_BLINDNESS("entity.illusion_illager.prepare_blindness"),
ENTITY_ILLUSION_ILLAGER_PREPARE_MIRROR("entity.illusion_illager.prepare_mirror"),
ENTITY_IRONGOLEM_ATTACK("entity.irongolem.attack"),
ENTITY_IRONGOLEM_DEATH("entity.irongolem.death"),
ENTITY_IRONGOLEM_HURT("entity.irongolem.hurt"),
ENTITY_IRONGOLEM_STEP("entity.irongolem.step"),
ENTITY_ITEMFRAME_ADD_ITEM("entity.itemframe.add_item"),
ENTITY_ITEMFRAME_BREAK("entity.itemframe.break"),
ENTITY_ITEMFRAME_PLACE("entity.itemframe.place"),
ENTITY_ITEMFRAME_REMOVE_ITEM("entity.itemframe.remove_item"),
ENTITY_ITEMFRAME_ROTATE_ITEM("entity.itemframe.rotate_item"),
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_LEASHKNOT_BREAK("entity.leashknot.break"),
ENTITY_LEASHKNOT_PLACE("entity.leashknot.place"),
ENTITY_LIGHTNING_IMPACT("entity.lightning.impact"),
ENTITY_LIGHTNING_THUNDER("entity.lightning.thunder"),
ENTITY_LINGERINGPOTION_THROW("entity.lingeringpotion.throw"),
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"),
@@ -315,10 +371,13 @@ public enum CraftSound {
ENTITY_LLAMA_SPIT("entity.llama.spit"),
ENTITY_LLAMA_STEP("entity.llama.step"),
ENTITY_LLAMA_SWAG("entity.llama.swag"),
ENTITY_MAGMACUBE_DEATH("entity.magmacube.death"),
ENTITY_MAGMACUBE_HURT("entity.magmacube.hurt"),
ENTITY_MAGMACUBE_JUMP("entity.magmacube.jump"),
ENTITY_MAGMACUBE_SQUISH("entity.magmacube.squish"),
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"),
@@ -335,15 +394,17 @@ public enum CraftSound {
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_ENDERDRAGON("entity.parrot.imitate.enderdragon"),
ENTITY_PARROT_IMITATE_ENDERMAN("entity.parrot.imitate.enderman"),
ENTITY_PARROT_IMITATE_ENDERMITE("entity.parrot.imitate.endermite"),
ENTITY_PARROT_IMITATE_EVOCATION_ILLAGER("entity.parrot.imitate.evocation_illager"),
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_ILLUSION_ILLAGER("entity.parrot.imitate.illusion_illager"),
ENTITY_PARROT_IMITATE_MAGMACUBE("entity.parrot.imitate.magmacube"),
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"),
@@ -352,7 +413,7 @@ public enum CraftSound {
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_VINDICATION_ILLAGER("entity.parrot.imitate.vindication_illager"),
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"),
@@ -361,6 +422,12 @@ public enum CraftSound {
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"),
@@ -382,18 +449,30 @@ public enum CraftSound {
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_BABY_AMBIENT("entity.polar_bear.baby_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"),
@@ -416,28 +495,30 @@ public enum CraftSound {
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_SMALL_MAGMACUBE_DEATH("entity.small_magmacube.death"),
ENTITY_SMALL_MAGMACUBE_HURT("entity.small_magmacube.hurt"),
ENTITY_SMALL_MAGMACUBE_SQUISH("entity.small_magmacube.squish"),
ENTITY_SMALL_SLIME_DEATH("entity.small_slime.death"),
ENTITY_SMALL_SLIME_HURT("entity.small_slime.hurt"),
ENTITY_SMALL_SLIME_JUMP("entity.small_slime.jump"),
ENTITY_SMALL_SLIME_SQUISH("entity.small_slime.squish"),
ENTITY_SLIME_SQUISH_SMALL("entity.slime.squish_small"),
ENTITY_SNOWBALL_THROW("entity.snowball.throw"),
ENTITY_SNOWMAN_AMBIENT("entity.snowman.ambient"),
ENTITY_SNOWMAN_DEATH("entity.snowman.death"),
ENTITY_SNOWMAN_HURT("entity.snowman.hurt"),
ENTITY_SNOWMAN_SHOOT("entity.snowman.shoot"),
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"),
@@ -447,11 +528,28 @@ public enum CraftSound {
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"),
@@ -460,11 +558,11 @@ public enum CraftSound {
ENTITY_VILLAGER_DEATH("entity.villager.death"),
ENTITY_VILLAGER_HURT("entity.villager.hurt"),
ENTITY_VILLAGER_NO("entity.villager.no"),
ENTITY_VILLAGER_TRADING("entity.villager.trading"),
ENTITY_VILLAGER_TRADE("entity.villager.trade"),
ENTITY_VILLAGER_YES("entity.villager.yes"),
ENTITY_VINDICATION_ILLAGER_AMBIENT("entity.vindication_illager.ambient"),
ENTITY_VINDICATION_ILLAGER_DEATH("entity.vindication_illager.death"),
ENTITY_VINDICATION_ILLAGER_HURT("entity.vindication_illager.hurt"),
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"),
@@ -490,19 +588,21 @@ public enum CraftSound {
ENTITY_WOLF_STEP("entity.wolf.step"),
ENTITY_WOLF_WHINE("entity.wolf.whine"),
ENTITY_ZOMBIE_AMBIENT("entity.zombie.ambient"),
ENTITY_ZOMBIE_ATTACK_DOOR_WOOD("entity.zombie.attack_door_wood"),
ENTITY_ZOMBIE_ATTACK_IRON_DOOR("entity.zombie.attack_iron_door"),
ENTITY_ZOMBIE_BREAK_DOOR_WOOD("entity.zombie.break_door_wood"),
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_PIG_AMBIENT("entity.zombie_pig.ambient"),
ENTITY_ZOMBIE_PIG_ANGRY("entity.zombie_pig.angry"),
ENTITY_ZOMBIE_PIG_DEATH("entity.zombie_pig.death"),
ENTITY_ZOMBIE_PIG_HURT("entity.zombie_pig.hurt"),
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"),
@@ -517,12 +617,16 @@ public enum CraftSound {
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"),
@@ -533,25 +637,34 @@ public enum CraftSound {
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"),
RECORD_11("record.11"),
RECORD_13("record.13"),
RECORD_BLOCKS("record.blocks"),
RECORD_CAT("record.cat"),
RECORD_CHIRP("record.chirp"),
RECORD_FAR("record.far"),
RECORD_MALL("record.mall"),
RECORD_MELLOHI("record.mellohi"),
RECORD_STAL("record.stal"),
RECORD_STRAD("record.strad"),
RECORD_WAIT("record.wait"),
RECORD_WARD("record.ward"),
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"),

View File

@@ -1,94 +1,141 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityTypes;
import net.minecraft.server.EntityTypes.MonsterEggInfo;
import net.minecraft.server.StatisticList;
import org.bukkit.Statistic;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import com.google.common.base.CaseFormat;
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.Item;
import net.minecraft.server.MinecraftKey;
import net.minecraft.server.RegistryMaterials;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftStatistic {
private static final BiMap<String, org.bukkit.Statistic> statistics;
public enum CraftStatistic {
DAMAGE_DEALT("damage_dealt"),
DAMAGE_TAKEN("damage_taken"),
DEATHS("deaths"),
MOB_KILLS("mob_kills"),
PLAYER_KILLS("player_kills"),
FISH_CAUGHT("fish_caught"),
ANIMALS_BRED("animals_bred"),
LEAVE_GAME("leave_game"),
JUMP("jump"),
DROP_COUNT("drop"),
DROP("dropped"),
PICKUP("picked_up"),
PLAY_ONE_MINUTE("play_one_minute"),
WALK_ONE_CM("walk_one_cm"),
WALK_ON_WATER_ONE_CM("walk_on_water_one_cm"),
FALL_ONE_CM("fall_one_cm"),
SNEAK_TIME("sneak_time"),
CLIMB_ONE_CM("climb_one_cm"),
FLY_ONE_CM("fly_one_cm"),
WALK_UNDER_WATER_ONE_CM("walk_under_water_one_cm"),
MINECART_ONE_CM("minecart_one_cm"),
BOAT_ONE_CM("boat_one_cm"),
PIG_ONE_CM("pig_one_cm"),
HORSE_ONE_CM("horse_one_cm"),
SPRINT_ONE_CM("sprint_one_cm"),
CROUCH_ONE_CM("crouch_one_cm"),
AVIATE_ONE_CM("aviate_one_cm"),
MINE_BLOCK("mined"),
USE_ITEM("used"),
BREAK_ITEM("broken"),
CRAFT_ITEM("crafted"),
KILL_ENTITY("killed"),
ENTITY_KILLED_BY("killed_by"),
TIME_SINCE_DEATH("time_since_death"),
TALKED_TO_VILLAGER("talked_to_villager"),
TRADED_WITH_VILLAGER("traded_with_villager"),
CAKE_SLICES_EATEN("eat_cake_slice"),
CAULDRON_FILLED("fill_cauldron"),
CAULDRON_USED("use_cauldron"),
ARMOR_CLEANED("clean_armor"),
BANNER_CLEANED("clean_banner"),
BREWINGSTAND_INTERACTION("interact_with_brewingstand"),
BEACON_INTERACTION("interact_with_beacon"),
DROPPER_INSPECTED("inspect_dropper"),
HOPPER_INSPECTED("inspect_hopper"),
DISPENSER_INSPECTED("inspect_dispenser"),
NOTEBLOCK_PLAYED("play_noteblock"),
NOTEBLOCK_TUNED("tune_noteblock"),
FLOWER_POTTED("pot_flower"),
TRAPPED_CHEST_TRIGGERED("trigger_trapped_chest"),
ENDERCHEST_OPENED("open_enderchest"),
ITEM_ENCHANTED("enchant_item"),
RECORD_PLAYED("play_record"),
FURNACE_INTERACTION("interact_with_furnace"),
CRAFTING_TABLE_INTERACTION("interact_with_crafting_table"),
CHEST_OPENED("open_chest"),
SLEEP_IN_BED("sleep_in_bed"),
SHULKER_BOX_OPENED("open_shulker_box"),
TIME_SINCE_REST("time_since_rest"),
SWIM_ONE_CM("swim_one_cm");
private final MinecraftKey minecraftKey;
private final org.bukkit.Statistic bukkit;
private static final BiMap<MinecraftKey, org.bukkit.Statistic> statistics;
static {
ImmutableBiMap.Builder<String, org.bukkit.Statistic> statisticBuilder = ImmutableBiMap.<String, org.bukkit.Statistic>builder();
for (Statistic statistic : Statistic.values()) {
if (statistic == Statistic.PLAY_ONE_TICK) {
statisticBuilder.put("stat.playOneMinute", statistic);
} else {
statisticBuilder.put("stat." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, statistic.name()), statistic);
}
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() {}
private CraftStatistic(String minecraftKey) {
this.minecraftKey = new MinecraftKey(minecraftKey);
public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.server.Statistic statistic) {
return getBukkitStatisticByName(statistic.name);
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 getBukkitStatisticByName(String name) {
if (name.startsWith("stat.killEntity.")) {
name = "stat.killEntity";
public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.server.Statistic<?> statistic) {
RegistryMaterials statRegistry = statistic.a().a();
MinecraftKey nmsKey = StatisticList.REGISTRY.b(statistic.a());
if (statRegistry == StatisticList.REGISTRY_CUSTOM) {
nmsKey = (MinecraftKey) statistic.b();
}
if (name.startsWith("stat.entityKilledBy.")) {
name = "stat.entityKilledBy";
}
if (name.startsWith("stat.breakItem.")) {
name = "stat.breakItem";
}
if (name.startsWith("stat.useItem.")) {
name = "stat.useItem";
}
if (name.startsWith("stat.mineBlock.")) {
name = "stat.mineBlock";
}
if (name.startsWith("stat.craftItem.")) {
name = "stat.craftItem";
}
if (name.startsWith("stat.drop.")) {
name = "stat.drop";
}
if (name.startsWith("stat.pickup.")) {
name = "stat.pickup";
}
return statistics.get(name);
return statistics.get(nmsKey);
}
public static net.minecraft.server.Statistic getNMSStatistic(org.bukkit.Statistic statistic) {
return StatisticList.getStatistic(statistics.inverse().get(statistic));
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.a(CraftMagicNumbers.getBlock(material)); // PAIL: getMineBlockStatistic
return StatisticList.BLOCK_MINED.b(CraftMagicNumbers.getBlock(material));
}
if (stat == Statistic.CRAFT_ITEM) {
return StatisticList.a(CraftMagicNumbers.getItem(material)); // PAIL: getCraftItemStatistic
return StatisticList.ITEM_CRAFTED.b(CraftMagicNumbers.getItem(material));
}
if (stat == Statistic.USE_ITEM) {
return StatisticList.b(CraftMagicNumbers.getItem(material)); // PAIL: getUseItemStatistic
return StatisticList.ITEM_USED.b(CraftMagicNumbers.getItem(material));
}
if (stat == Statistic.BREAK_ITEM) {
return StatisticList.c(CraftMagicNumbers.getItem(material)); // PAIL: getBreakItemStatistic
return StatisticList.ITEM_BROKEN.b(CraftMagicNumbers.getItem(material));
}
if (stat == Statistic.PICKUP) {
return StatisticList.d(CraftMagicNumbers.getItem(material)); // PAIL: getPickupStatistic
return StatisticList.ITEM_PICKED_UP.b(CraftMagicNumbers.getItem(material));
}
if (stat == Statistic.DROP) {
return StatisticList.e(CraftMagicNumbers.getItem(material)); // PAIL: getDropItemStatistic
return StatisticList.ITEM_DROPPED.b(CraftMagicNumbers.getItem(material));
}
} catch (ArrayIndexOutOfBoundsException e) {
return null;
@@ -97,39 +144,31 @@ public class CraftStatistic {
}
public static net.minecraft.server.Statistic getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) {
MonsterEggInfo monsteregginfo = (MonsterEggInfo) EntityTypes.eggInfo.get(new MinecraftKey(entity.getName()));
if (entity.getName() != null) {
EntityTypes<?> nmsEntity = EntityTypes.REGISTRY.get(new MinecraftKey(entity.getName()));
if (monsteregginfo != null) {
if (stat == org.bukkit.Statistic.KILL_ENTITY) {
return monsteregginfo.killEntityStatistic;
return net.minecraft.server.StatisticList.ENTITY_KILLED.b(nmsEntity);
}
if (stat == org.bukkit.Statistic.ENTITY_KILLED_BY) {
return monsteregginfo.killedByEntityStatistic;
return net.minecraft.server.StatisticList.ENTITY_KILLED_BY.b(nmsEntity);
}
}
return null;
}
public static EntityType getEntityTypeFromStatistic(net.minecraft.server.Statistic statistic) {
String statisticString = statistic.name;
return EntityType.fromName(statisticString.substring(statisticString.lastIndexOf(".") + 1));
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) {
String statisticString = statistic.name;
String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
if (item != null) {
return Material.getMaterial(Item.getId(item));
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic<?> statistic) {
if (statistic.b() instanceof Item) {
return CraftMagicNumbers.getMaterial((Item) statistic.b());
}
Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
if (block != null) {
return Material.getMaterial(Block.getId(block));
}
try {
return Material.getMaterial(Integer.parseInt(val));
} catch (NumberFormatException e) {
return null;
if (statistic.b() instanceof Block) {
return CraftMagicNumbers.getMaterial((Block) statistic.b());
}
return null;
}
}

View File

@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,8 +32,10 @@ import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.block.CraftBlockState;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.entity.*;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.metadata.BlockMetadataStore;
@@ -92,11 +95,7 @@ public class CraftWorld implements World {
}
public Block getBlockAt(int x, int y, int z) {
return getChunkAt(x >> 4, z >> 4).getBlock(x & 0xF, y, z & 0xF);
}
public int getBlockTypeIdAt(int x, int y, int z) {
return CraftMagicNumbers.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
return CraftBlock.at(world, new BlockPosition(x, y, z));
}
public int getHighestBlockYAt(int x, int z) {
@@ -104,7 +103,7 @@ public class CraftWorld implements World {
loadChunk(x >> 4, z >> 4);
}
return world.getHighestBlockYAt(new BlockPosition(x, 0, z)).getY();
return world.getHighestBlockYAt(HeightMap.Type.LIGHT_BLOCKING, new BlockPosition(x, 0, z)).getY();
}
public Location getSpawnLocation() {
@@ -219,7 +218,7 @@ public class CraftWorld implements World {
net.minecraft.server.Chunk chunk = null;
chunk = world.getChunkProviderServer().chunkGenerator.getOrCreateChunk(x, z);
chunk = Futures.getUnchecked(world.getChunkProviderServer().generateChunk(x, z));
PlayerChunk playerChunk = world.getPlayerChunkMap().getChunk(x, z);
if (playerChunk != null) {
playerChunk.chunk = chunk;
@@ -229,7 +228,6 @@ public class CraftWorld implements World {
world.getChunkProviderServer().chunks.put(chunkKey, chunk);
chunk.addEntities();
chunk.loadNearby(world.getChunkProviderServer(), world.getChunkProviderServer().chunkGenerator, true);
refreshChunk(x, z);
}
@@ -286,7 +284,6 @@ public class CraftWorld implements World {
public org.bukkit.entity.Item dropItem(Location loc, ItemStack item) {
Validate.notNull(item, "Cannot drop a Null item.");
Validate.isTrue(item.getTypeId() != 0, "Cannot drop AIR.");
EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), CraftItemStack.asNMSCopy(item));
entity.pickupDelay = 10;
world.addEntity(entity, SpawnReason.CUSTOM);
@@ -346,6 +343,8 @@ public class CraftWorld implements World {
((EntityTippedArrow) arrow).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
arrow = new EntitySpectralArrow(world);
} else if (Trident.class.isAssignableFrom(clazz)){
arrow = new EntityThrownTrident(world);
} else {
arrow = new EntityTippedArrow(world);
}
@@ -390,30 +389,22 @@ public class CraftWorld implements World {
gen = new WorldGenTaiga1();
break;
case JUNGLE:
IBlockData iblockdata1 = Blocks.LOG.getBlockData().set(BlockLog1.VARIANT, BlockWood.EnumLogVariant.JUNGLE);
IBlockData iblockdata2 = Blocks.LEAVES.getBlockData().set(BlockLeaves1.VARIANT, BlockWood.EnumLogVariant.JUNGLE).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
gen = new WorldGenJungleTree(true, 10, 20, iblockdata1, iblockdata2); // Magic values as in BlockSapling
gen = new WorldGenJungleTree(true, 10, 20, Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData());
break;
case SMALL_JUNGLE:
iblockdata1 = Blocks.LOG.getBlockData().set(BlockLog1.VARIANT, BlockWood.EnumLogVariant.JUNGLE);
iblockdata2 = Blocks.LEAVES.getBlockData().set(BlockLeaves1.VARIANT, BlockWood.EnumLogVariant.JUNGLE).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
gen = new WorldGenTrees(true, 4 + rand.nextInt(7), iblockdata1, iblockdata2, false);
gen = new WorldGenTrees(true, 4 + rand.nextInt(7), Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData(), false);
break;
case COCOA_TREE:
iblockdata1 = Blocks.LOG.getBlockData().set(BlockLog1.VARIANT, BlockWood.EnumLogVariant.JUNGLE);
iblockdata2 = Blocks.LEAVES.getBlockData().set(BlockLeaves1.VARIANT, BlockWood.EnumLogVariant.JUNGLE).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
gen = new WorldGenTrees(true, 4 + rand.nextInt(7), iblockdata1, iblockdata2, true);
gen = new WorldGenJungleTree(true, 10, 20, Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData());
break;
case JUNGLE_BUSH:
iblockdata1 = Blocks.LOG.getBlockData().set(BlockLog1.VARIANT, BlockWood.EnumLogVariant.JUNGLE);
iblockdata2 = Blocks.LEAVES.getBlockData().set(BlockLeaves1.VARIANT, BlockWood.EnumLogVariant.OAK).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
gen = new WorldGenGroundBush(iblockdata1, iblockdata2);
gen = new WorldGenGroundBush(Blocks.JUNGLE_LOG.getBlockData(), Blocks.OAK_LEAVES.getBlockData());
break;
case RED_MUSHROOM:
gen = new WorldGenHugeMushroom(Blocks.RED_MUSHROOM_BLOCK);
gen = new WorldGenHugeMushroomRed();
break;
case BROWN_MUSHROOM:
gen = new WorldGenHugeMushroom(Blocks.BROWN_MUSHROOM_BLOCK);
gen = new WorldGenHugeMushroomBrown();
break;
case SWAMP:
gen = new WorldGenSwampTree();
@@ -431,7 +422,7 @@ public class CraftWorld implements World {
gen = new WorldGenForest(true, true);
break;
case CHORUS_PLANT:
BlockChorusFlower.a(world, pos, rand, 8);
((BlockChorusFlower) Blocks.CHORUS_FLOWER).a(world, pos, rand, 8);
return true;
case TREE:
default:
@@ -439,7 +430,7 @@ public class CraftWorld implements World {
break;
}
return gen.generate(world, rand, pos);
return gen.generate(world, world.worldProvider.getChunkGenerator(), rand, pos, new WorldGenFeatureEmptyConfiguration());
}
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
@@ -455,12 +446,10 @@ public class CraftWorld implements World {
int z = blockstate.getZ();
BlockPosition position = new BlockPosition(x, y, z);
net.minecraft.server.IBlockData oldBlock = world.getType(position);
int typeId = blockstate.getTypeId();
int data = blockstate.getRawData();
int flag = ((CraftBlockState)blockstate).getFlag();
delegate.setTypeIdAndData(x, y, z, typeId, data);
int flag = ((CraftBlockState) blockstate).getFlag();
delegate.setBlockData(x, y, z, blockstate.getBlockData());
net.minecraft.server.IBlockData newBlock = world.getType(position);
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, flag);
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag);
}
world.capturedBlockStates.clear();
return true;
@@ -565,10 +554,6 @@ public class CraftWorld implements World {
return getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
public int getBlockTypeIdAt(Location location) {
return getBlockTypeIdAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
public int getHighestBlockYAt(Location location) {
return getHighestBlockYAt(location.getBlockX(), location.getBlockZ());
}
@@ -603,8 +588,8 @@ public class CraftWorld implements World {
net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(new BlockPosition(x, 0, z));
if (chunk != null) {
byte[] biomevals = chunk.getBiomeIndex();
biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte) BiomeBase.REGISTRY_ID.a(bb);
BiomeBase[] biomevals = chunk.getBiomeIndex();
biomevals[((z & 0xF) << 4) | (x & 0xF)] = bb;
chunk.markDirty(); // SPIGOT-2890
}
@@ -881,15 +866,23 @@ public class CraftWorld implements World {
Validate.notNull(material, "Material cannot be null");
Validate.isTrue(material.isBlock(), "Material must be a block");
EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).fromLegacyData(data));
EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).getBlockData());
entity.ticksLived = 1;
world.addEntity(entity, SpawnReason.CUSTOM);
return (FallingBlock) entity.getBukkitEntity();
}
public FallingBlock spawnFallingBlock(Location location, int blockId, byte blockData) throws IllegalArgumentException {
return spawnFallingBlock(location, org.bukkit.Material.getMaterial(blockId), blockData);
@Override
public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException {
Validate.notNull(location, "Location cannot be null");
Validate.notNull(data, "Material cannot be null");
EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState());
entity.ticksLived = 1;
world.addEntity(entity, SpawnReason.CUSTOM);
return (FallingBlock) entity.getBukkitEntity();
}
@SuppressWarnings("unchecked")
@@ -923,6 +916,8 @@ public class CraftWorld implements World {
((EntityTippedArrow) entity).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
entity = new EntitySpectralArrow(world);
} else if (Trident.class.isAssignableFrom(clazz)) {
entity = new EntityThrownTrident(world);
} else {
entity = new EntityTippedArrow(world);
}
@@ -1060,6 +1055,8 @@ public class CraftWorld implements World {
entity = new EntityZombieHusk(world);
} else if (ZombieVillager.class.isAssignableFrom(clazz)) {
entity = new EntityZombieVillager(world);
} else if (Drowned.class.isAssignableFrom(clazz)) {
entity = new EntityDrowned(world);
} else {
entity = new EntityZombie(world);
}
@@ -1111,6 +1108,22 @@ public class CraftWorld implements World {
} else if (Vindicator.class.isAssignableFrom(clazz)) {
entity = new EntityVindicator(world);
}
} else if (Turtle.class.isAssignableFrom(clazz)) {
entity = new EntityTurtle(world);
} else if (Phantom.class.isAssignableFrom(clazz)) {
entity = new EntityPhantom(world);
} else if (Fish.class.isAssignableFrom(clazz)) {
if (Cod.class.isAssignableFrom(clazz)) {
entity = new EntityCod(world);
} else if (PufferFish.class.isAssignableFrom(clazz)) {
entity = new EntityPufferFish(world);
} else if (Salmon.class.isAssignableFrom(clazz)) {
entity = new EntitySalmon(world);
} else if (TropicalFish.class.isAssignableFrom(clazz)) {
entity = new EntityTropicalFish(world);
}
} else if (Dolphin.class.isAssignableFrom(clazz)) {
entity = new EntityDolphin(world);
}
if (entity != null) {
@@ -1118,7 +1131,6 @@ public class CraftWorld implements World {
entity.setHeadRotation(yaw); // SPIGOT-3587
}
} else if (Hanging.class.isAssignableFrom(clazz)) {
Block block = getBlockAt(location);
BlockFace face = BlockFace.SELF;
int width = 16; // 1 full block, also painting smallest size.
@@ -1135,8 +1147,8 @@ public class CraftWorld implements World {
BlockFace[] faces = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
final BlockPosition pos = new BlockPosition((int) x, (int) y, (int) z);
for (BlockFace dir : faces) {
net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(block.getRelative(dir));
if (nmsBlock.getBlockData().getMaterial().isBuildable() || BlockDiodeAbstract.isDiode(nmsBlock.getBlockData())) {
IBlockData nmsBlock = world.getType(pos.shift(CraftBlock.blockFaceToNotch(dir)));
if (nmsBlock.getMaterial().isBuildable() || BlockDiodeAbstract.isDiode(nmsBlock)) {
boolean taken = false;
AxisAlignedBB bb = EntityHanging.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).opposite(), width, height);
List<net.minecraft.server.Entity> list = (List<net.minecraft.server.Entity>) world.getEntities(null, bb);
@@ -1207,7 +1219,7 @@ public class CraftWorld implements World {
Preconditions.checkArgument(entity != null, "Cannot spawn null entity");
if (entity instanceof EntityInsentient) {
((EntityInsentient) entity).prepare(getHandle().D(new BlockPosition(entity)), (GroupDataEntity) null);
((EntityInsentient) entity).prepare(getHandle().getDamageScaler(new BlockPosition(entity)), (GroupDataEntity) null, null);
}
if (function != null) {
@@ -1428,12 +1440,18 @@ public class CraftWorld implements World {
double y = loc.getY();
double z = loc.getZ();
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, SoundCategory.valueOf(category.name()), x, y, z, volume, pitch);
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch);
world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension, packet);
}
public String getGameRuleValue(String rule) {
return getHandle().getGameRules().get(rule);
// In method contract for some reason
if (rule == null) {
return null;
}
GameRules.GameRuleValue value = getHandle().getGameRules().get(rule);
return value != null ? value.a() : "";
}
public boolean setGameRuleValue(String rule, String value) {
@@ -1442,16 +1460,16 @@ public class CraftWorld implements World {
if (!isGameRule(rule)) return false;
getHandle().getGameRules().set(rule, value);
getHandle().getGameRules().set(rule, value, getHandle().getMinecraftServer());
return true;
}
public String[] getGameRules() {
return getHandle().getGameRules().getGameRules();
return GameRules.getGameRules().keySet().toArray(new String[GameRules.getGameRules().size()]);
}
public boolean isGameRule(String rule) {
return getHandle().getGameRules().contains(rule);
return GameRules.getGameRules().containsKey(rule);
}
@Override
@@ -1525,14 +1543,11 @@ public class CraftWorld implements World {
}
getHandle().sendParticles(
null, // Sender
CraftParticle.toNMS(particle), // Particle
true, // Extended range
CraftParticle.toNMS(particle, data), // Particle
x, y, z, // Position
count, // Count
offsetX, offsetY, offsetZ, // Random offset
extra, // Speed?
CraftParticle.toData(particle, data)
extra // Speed?
);
}

View File

@@ -145,6 +145,12 @@ public class Main {
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 {
// 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'});
@@ -169,11 +175,11 @@ public class Main {
useConsole = false;
}
if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
Date buildDate = new SimpleDateFormat("yyyyMMdd-HHmm").parse(Main.class.getPackage().getImplementationVendor());
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -14);
deadline.add(Calendar.DAY_OF_YEAR, -3);
if (buildDate.before(deadline.getTime())) {
System.err.println("*** Error, this build is outdated ***");
System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/ ***");
@@ -182,6 +188,8 @@ public class Main {
}
}
System.err.println("*** WARNING: This is a development build. It is not meant for production server usage! Please keep backups and update frequently.");
System.out.println("Loading libraries, please wait...");
MinecraftServer.main(options);
} catch (Throwable t) {

View File

@@ -30,7 +30,7 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
public void load(TileEntityBanner banner) {
super.load(banner);
base = DyeColor.getByDyeData((byte) banner.color.getInvColorIndex());
base = DyeColor.getByWoolData((byte) banner.color.getColorIndex());
patterns = new ArrayList<Pattern>();
if (banner.patterns != null) {
@@ -90,7 +90,7 @@ public class CraftBanner extends CraftBlockEntityState<TileEntityBanner> impleme
public void applyTo(TileEntityBanner banner) {
super.applyTo(banner);
banner.color = EnumColor.fromInvColorIndex(base.getDyeData());
banner.color = EnumColor.fromColorIndex(base.getWoolData());
NBTTagList newPatterns = new NBTTagList();

View File

@@ -10,6 +10,7 @@ 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;
@@ -87,11 +88,11 @@ public class CraftBeacon extends CraftContainer<TileEntityBeacon> implements Bea
@Override
public String getCustomName() {
TileEntityBeacon beacon = this.getSnapshot();
return beacon.hasCustomName() ? beacon.getName() : null;
return beacon.hasCustomName() ? CraftChatMessage.fromComponent(beacon.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(name);
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
}

View File

@@ -10,8 +10,6 @@ import org.bukkit.block.Block;
public class CraftBed extends CraftBlockEntityState<TileEntityBed> implements Bed {
private DyeColor color;
public CraftBed(Block block) {
super(block, TileEntityBed.class);
}
@@ -20,29 +18,48 @@ public class CraftBed extends CraftBlockEntityState<TileEntityBed> implements Be
super(material, te);
}
@Override
public void load(TileEntityBed bed) {
super.load(bed);
color = DyeColor.getByWoolData((byte) bed.a().getColorIndex());
}
@Override
public DyeColor getColor() {
return color;
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.SILVER;
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) {
Preconditions.checkArgument(color != null, "color");
this.color = color;
}
@Override
public void applyTo(TileEntityBed bed) {
super.applyTo(bed);
bed.a(EnumColor.fromColorIndex(color.getWoolData()));
throw new UnsupportedOperationException("Must set block type to appropriate bed colour");
}
}

View File

@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -16,7 +17,10 @@ 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.CraftChunk;
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.inventory.ItemStack;
@@ -25,40 +29,44 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.util.BlockVector;
public class CraftBlock implements Block {
private final CraftChunk chunk;
private final int x;
private final int y;
private final int z;
private final net.minecraft.server.GeneratorAccess world;
private final BlockPosition position;
public CraftBlock(CraftChunk chunk, int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
this.chunk = chunk;
public CraftBlock(GeneratorAccess world, BlockPosition position) {
this.world = world;
this.position = position;
}
public static CraftBlock at(GeneratorAccess world, BlockPosition position) {
return new CraftBlock(world, position);
}
private net.minecraft.server.Block getNMSBlock() {
return CraftMagicNumbers.getBlock(this); // TODO: UPDATE THIS
return getNMS().getBlock();
}
private static net.minecraft.server.Block getNMSBlock(int type) {
return CraftMagicNumbers.getBlock(type);
protected net.minecraft.server.IBlockData getNMS() {
return world.getType(position);
}
public World getWorld() {
return chunk.getWorld();
return world.getMinecraftWorld().getWorld();
}
public CraftWorld getCraftWorld() {
return (CraftWorld) getWorld();
}
public Location getLocation() {
return new Location(getWorld(), x, y, z);
return new Location(getWorld(), position.getX(), position.getY(), position.getZ());
}
public Location getLocation(Location loc) {
if (loc != null) {
loc.setWorld(getWorld());
loc.setX(x);
loc.setY(y);
loc.setZ(z);
loc.setX(position.getX());
loc.setY(position.getY());
loc.setZ(position.getZ());
loc.setYaw(0);
loc.setPitch(0);
}
@@ -67,23 +75,23 @@ public class CraftBlock implements Block {
}
public BlockVector getVector() {
return new BlockVector(x, y, z);
return new BlockVector(getX(), getY(), getZ());
}
public int getX() {
return x;
return position.getX();
}
public int getY() {
return y;
return position.getY();
}
public int getZ() {
return z;
return position.getZ();
}
public Chunk getChunk() {
return chunk;
return getWorld().getChunkAt(this);
}
public void setData(final byte data) {
@@ -99,19 +107,21 @@ public class CraftBlock implements Block {
}
private void setData(final byte data, int flag) {
net.minecraft.server.World world = chunk.getHandle().getWorld();
BlockPosition position = new BlockPosition(x, y, z);
IBlockData blockData = world.getType(position);
world.setTypeAndData(position, blockData.getBlock().fromLegacyData(data), flag);
world.setTypeAndData(position, CraftMagicNumbers.getBlock(getType(), data), flag);
}
private IBlockData getData0() {
return chunk.getHandle().getBlockData(new BlockPosition(x, y, z));
return world.getType(position);
}
public byte getData() {
IBlockData blockData = chunk.getHandle().getBlockData(new BlockPosition(x, y, z));
return (byte) blockData.getBlock().toLegacyData(blockData);
IBlockData blockData = world.getType(position);
return CraftMagicNumbers.toLegacyData(blockData);
}
@Override
public BlockData getBlockData() {
return CraftBlockData.fromData(getData0());
}
public void setType(final Material type) {
@@ -120,34 +130,36 @@ public class CraftBlock implements Block {
@Override
public void setType(Material type, boolean applyPhysics) {
setTypeId(type.getId(), applyPhysics);
setTypeAndData(type, (byte) 0, applyPhysics);
}
public boolean setTypeId(final int type) {
return setTypeId(type, true);
@Override
public void setBlockData(BlockData data) {
setBlockData(data, true);
}
public boolean setTypeId(final int type, final boolean applyPhysics) {
net.minecraft.server.Block block = getNMSBlock(type);
return setTypeIdAndData(type, (byte) block.toLegacyData(block.getBlockData()), applyPhysics);
@Override
public void setBlockData(BlockData data, boolean applyPhysics) {
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
}
public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) {
IBlockData blockData = getNMSBlock(type).fromLegacyData(data);
BlockPosition position = new BlockPosition(x, y, z);
public boolean setTypeAndData(final Material type, final byte data, final boolean applyPhysics) {
return setTypeAndData(CraftMagicNumbers.getBlock(type, data), 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 (type != 0 && blockData.getBlock() instanceof BlockTileEntity && type != getTypeId()) {
chunk.getHandle().getWorld().setTypeAndData(position, Blocks.AIR.getBlockData(), 0);
if (!blockData.isAir() && blockData.getBlock() instanceof BlockTileEntity && blockData.getBlock() != getNMSBlock()) {
world.setTypeAndData(position, Blocks.AIR.getBlockData(), 0);
}
if (applyPhysics) {
return chunk.getHandle().getWorld().setTypeAndData(position, blockData, 3);
return world.setTypeAndData(position, blockData, 3);
} else {
IBlockData old = chunk.getHandle().getBlockData(position);
boolean success = chunk.getHandle().getWorld().setTypeAndData(position, blockData, 18); // NOTIFY | NO_OBSERVER
IBlockData old = world.getType(position);
boolean success = world.setTypeAndData(position, blockData, 18); // NOTIFY | NO_OBSERVER
if (success) {
chunk.getHandle().getWorld().notify(
world.getMinecraftWorld().notify(
position,
old,
blockData,
@@ -159,25 +171,19 @@ public class CraftBlock implements Block {
}
public Material getType() {
return Material.getMaterial(getTypeId());
}
@Deprecated
@Override
public int getTypeId() {
return CraftMagicNumbers.getId(chunk.getHandle().getBlockData(new BlockPosition(this.x, this.y, this.z)).getBlock());
return CraftMagicNumbers.getMaterial(world.getType(position).getBlock());
}
public byte getLightLevel() {
return (byte) chunk.getHandle().getWorld().getLightLevel(new BlockPosition(this.x, this.y, this.z));
return (byte) world.getMinecraftWorld().getLightLevel(position);
}
public byte getLightFromSky() {
return (byte) chunk.getHandle().getWorld().getBrightness(EnumSkyBlock.SKY, new BlockPosition(this.x, this.y, this.z));
return (byte) world.getBrightness(EnumSkyBlock.SKY, position);
}
public byte getLightFromBlocks() {
return (byte) chunk.getHandle().getWorld().getBrightness(EnumSkyBlock.BLOCK, new BlockPosition(this.x, this.y, this.z));
return (byte) world.getBrightness(EnumSkyBlock.BLOCK, position);
}
@@ -218,7 +224,7 @@ public class CraftBlock implements Block {
@Override
public String toString() {
return "CraftBlock{" + "chunk=" + chunk + ",x=" + x + ",y=" + y + ",z=" + z + ",type=" + getType() + ",data=" + getData() + '}';
return "CraftBlock{pos=" + position + ",type=" + getType() + ",data=" + getData() + '}';
}
public static BlockFace notchToBlockFace(EnumDirection notch) {
@@ -265,13 +271,11 @@ public class CraftBlock implements Block {
switch (material) {
case SIGN:
case SIGN_POST:
case WALL_SIGN:
return new CraftSign(this);
case CHEST:
case TRAPPED_CHEST:
return new CraftChest(this);
case BURNING_FURNACE:
case FURNACE:
return new CraftFurnace(this);
case DISPENSER:
@@ -282,28 +286,65 @@ public class CraftBlock implements Block {
return new CraftEndGateway(this);
case HOPPER:
return new CraftHopper(this);
case MOB_SPAWNER:
case SPAWNER:
return new CraftCreatureSpawner(this);
case NOTE_BLOCK:
return new CraftNoteBlock(this);
case JUKEBOX:
return new CraftJukebox(this);
case BREWING_STAND:
return new CraftBrewingStand(this);
case SKULL:
case CREEPER_HEAD:
case CREEPER_WALL_HEAD:
case DRAGON_HEAD:
case DRAGON_WALL_HEAD:
case PISTON_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:
case COMMAND_CHAIN:
case COMMAND_REPEATING:
case COMMAND_BLOCK:
case CHAIN_COMMAND_BLOCK:
case REPEATING_COMMAND_BLOCK:
return new CraftCommandBlock(this);
case BEACON:
return new CraftBeacon(this);
case BANNER:
case WALL_BANNER:
case STANDING_BANNER:
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 FLOWER_POT:
return new CraftFlowerPot(this);
case STRUCTURE_BLOCK:
return new CraftStructureBlock(this);
case WHITE_SHULKER_BOX:
@@ -314,7 +355,7 @@ public class CraftBlock implements Block {
case LIME_SHULKER_BOX:
case PINK_SHULKER_BOX:
case GRAY_SHULKER_BOX:
case SILVER_SHULKER_BOX:
case LIGHT_GRAY_SHULKER_BOX:
case CYAN_SHULKER_BOX:
case PURPLE_SHULKER_BOX:
case BLUE_SHULKER_BOX:
@@ -323,20 +364,35 @@ public class CraftBlock implements Block {
case RED_SHULKER_BOX:
case BLACK_SHULKER_BOX:
return new CraftShulkerBox(this);
case ENCHANTMENT_TABLE:
case ENCHANTING_TABLE:
return new CraftEnchantingTable(this);
case ENDER_CHEST:
return new CraftEnderChest(this);
case DAYLIGHT_DETECTOR:
case DAYLIGHT_DETECTOR_INVERTED:
return new CraftDaylightDetector(this);
case REDSTONE_COMPARATOR_OFF:
case REDSTONE_COMPARATOR_ON:
case COMPARATOR:
return new CraftComparator(this);
case BED_BLOCK:
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 = chunk.getCraftWorld().getTileEntityAt(x, y, z);
TileEntity tileEntity = world.getTileEntity(position);
if (tileEntity != null) {
// block with unhandled TileEntity:
return new CraftBlockEntityState<TileEntity>(this, (Class<TileEntity>) tileEntity.getClass());
@@ -348,11 +404,11 @@ public class CraftBlock implements Block {
}
public Biome getBiome() {
return getWorld().getBiome(x, z);
return getWorld().getBiome(getX(), getZ());
}
public void setBiome(Biome bio) {
getWorld().setBiome(x, z, bio);
getWorld().setBiome(getX(), getZ(), bio);
}
public static Biome biomeBaseToBiome(BiomeBase base) {
@@ -372,19 +428,19 @@ public class CraftBlock implements Block {
}
public double getTemperature() {
return getWorld().getTemperature(x, z);
return getWorld().getTemperature(getX(), getZ());
}
public double getHumidity() {
return getWorld().getHumidity(x, z);
return getWorld().getHumidity(getX(), getZ());
}
public boolean isBlockPowered() {
return chunk.getHandle().getWorld().getBlockPower(new BlockPosition(x, y, z)) > 0;
return world.getMinecraftWorld().getBlockPower(position) > 0;
}
public boolean isBlockIndirectlyPowered() {
return chunk.getHandle().getWorld().isBlockIndirectlyPowered(new BlockPosition(x, y, z));
return world.getMinecraftWorld().isBlockIndirectlyPowered(position);
}
@Override
@@ -393,20 +449,20 @@ public class CraftBlock implements Block {
if (!(o instanceof CraftBlock)) return false;
CraftBlock other = (CraftBlock) o;
return this.x == other.x && this.y == other.y && this.z == other.z && this.getWorld().equals(other.getWorld());
return this.position.equals(other.position) && this.getWorld().equals(other.getWorld());
}
@Override
public int hashCode() {
return this.y << 24 ^ this.x ^ this.z ^ this.getWorld().hashCode();
return this.position.hashCode() ^ this.getWorld().hashCode();
}
public boolean isBlockFacePowered(BlockFace face) {
return chunk.getHandle().getWorld().isBlockFacePowered(new BlockPosition(x, y, z), blockFaceToNotch(face));
return world.getMinecraftWorld().isBlockFacePowered(position, blockFaceToNotch(face));
}
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
int power = chunk.getHandle().getWorld().getBlockFacePower(new BlockPosition(x, y, z), blockFaceToNotch(face));
int power = world.getMinecraftWorld().getBlockFacePower(position, blockFaceToNotch(face));
Block relative = getRelative(face);
if (relative.getType() == Material.REDSTONE_WIRE) {
@@ -418,8 +474,11 @@ public class CraftBlock implements Block {
public int getBlockPower(BlockFace face) {
int power = 0;
BlockRedstoneWire wire = Blocks.REDSTONE_WIRE;
net.minecraft.server.World world = chunk.getHandle().getWorld();
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(world, new BlockPosition(x, y - 1, z), power);
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = wire.getPower(world, new BlockPosition(x, y + 1, z), power);
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = wire.getPower(world, new BlockPosition(x + 1, y, z), power);
@@ -438,31 +497,30 @@ public class CraftBlock implements Block {
}
public boolean isLiquid() {
return (getType() == Material.WATER) || (getType() == Material.STATIONARY_WATER) || (getType() == Material.LAVA) || (getType() == Material.STATIONARY_LAVA);
return (getType() == Material.WATER) || (getType() == Material.LAVA);
}
public PistonMoveReaction getPistonMoveReaction() {
return PistonMoveReaction.getById(getNMSBlock().h(getNMSBlock().fromLegacyData(getData())).ordinal());
return PistonMoveReaction.getById(getNMS().getPushReaction().ordinal());
}
private boolean itemCausesDrops(ItemStack item) {
net.minecraft.server.Block block = this.getNMSBlock();
net.minecraft.server.Item itemType = item != null ? net.minecraft.server.Item.getById(item.getTypeId()) : null;
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();
byte data = getData();
boolean result = false;
if (block != null && block != Blocks.AIR) {
block.dropNaturally(chunk.getHandle().getWorld(), new BlockPosition(x, y, z), block.fromLegacyData(data), 1.0F, 0);
block.dropNaturally(getNMS(), world.getMinecraftWorld(), position, 1.0F, 0);
result = true;
}
setTypeId(Material.AIR.getId());
setType(Material.AIR);
return result;
}
@@ -470,7 +528,7 @@ public class CraftBlock implements Block {
if (itemCausesDrops(item)) {
return breakNaturally();
} else {
return setTypeId(Material.AIR.getId());
return setTypeAndData(Material.AIR, (byte) 0, true);
}
}
@@ -481,21 +539,20 @@ public class CraftBlock implements Block {
if (block != Blocks.AIR) {
IBlockData data = getData0();
// based on nms.Block.dropNaturally
int count = block.getDropCount(0, chunk.getHandle().getWorld().random);
int count = block.getDropCount(data, 0, world.getMinecraftWorld(), position, world.getMinecraftWorld().random);
for (int i = 0; i < count; ++i) {
Item item = block.getDropType(data, chunk.getHandle().getWorld().random, 0);
if (item != Items.a) {
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 (Blocks.SKULL == block) {
net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(data));
TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().getWorld().getTileEntity(new BlockPosition(x, y, z));
if (block instanceof BlockSkullAbstract) {
net.minecraft.server.ItemStack nmsStack = block.a((IBlockAccess) world, position, data);
TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(position);
if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
nmsStack.setTag(new NBTTagCompound());
if ((block == Blocks.PLAYER_HEAD || block == Blocks.PLAYER_WALL_HEAD) && tileentityskull.getGameProfile() != null) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
nmsStack.getTag().set("SkullOwner", nbttagcompound);
nmsStack.getOrCreateTag().set("SkullOwner", nbttagcompound);
}
drops.add(CraftItemStack.asBukkitCopy(nmsStack));
@@ -504,10 +561,10 @@ public class CraftBlock implements 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.INK_SACK, 1, (short) 3));
drops.add(new ItemStack(Material.COCOA_BEANS, 1));
}
} else {
drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data)));
drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1));
}
}
}
@@ -524,18 +581,18 @@ public class CraftBlock implements Block {
}
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
chunk.getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
}
public List<MetadataValue> getMetadata(String metadataKey) {
return chunk.getCraftWorld().getBlockMetadata().getMetadata(this, metadataKey);
return getCraftWorld().getBlockMetadata().getMetadata(this, metadataKey);
}
public boolean hasMetadata(String metadataKey) {
return chunk.getCraftWorld().getBlockMetadata().hasMetadata(this, metadataKey);
return getCraftWorld().getBlockMetadata().hasMetadata(this, metadataKey);
}
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
chunk.getCraftWorld().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin);
getCraftWorld().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin);
}
}

View File

@@ -3,6 +3,7 @@ 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;
@@ -23,7 +24,7 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
this.tileEntity = tileEntityClass.cast(world.getTileEntityAt(this.getX(), this.getY(), this.getZ()));
// copy tile entity data:
this.snapshot = this.createSnapshot(tileEntity);
this.snapshot = this.createSnapshot(tileEntity, world.getHandle());
this.load(snapshot);
}
@@ -34,17 +35,17 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
this.tileEntity = tileEntity;
// copy tile entity data:
this.snapshot = this.createSnapshot(tileEntity);
this.snapshot = this.createSnapshot(tileEntity, null);
this.load(snapshot);
}
private T createSnapshot(T tileEntity) {
private T createSnapshot(T tileEntity, World world) {
if (tileEntity == null) {
return null;
}
NBTTagCompound nbtTagCompound = tileEntity.save(new NBTTagCompound());
T snapshot = (T) TileEntity.create(null, nbtTagCompound);
T snapshot = (T) TileEntity.create(nbtTagCompound, world);
return snapshot;
}

View File

@@ -7,8 +7,10 @@ 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;
@@ -16,6 +18,7 @@ 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 {
@@ -24,8 +27,7 @@ public class CraftBlockState implements BlockState {
private final int x;
private final int y;
private final int z;
protected int type;
protected MaterialData data;
protected IBlockData data;
protected int flag;
public CraftBlockState(final Block block) {
@@ -33,11 +35,9 @@ public class CraftBlockState implements BlockState {
this.x = block.getX();
this.y = block.getY();
this.z = block.getZ();
this.type = block.getTypeId();
this.data = ((CraftBlock) block).getNMS();
this.chunk = (CraftChunk) block.getChunk();
this.flag = 3;
createData(block.getData());
}
public CraftBlockState(final Block block, int flag) {
@@ -47,17 +47,17 @@ public class CraftBlockState implements BlockState {
public CraftBlockState(Material material) {
world = null;
type = material.getId();
data = CraftMagicNumbers.getBlock(material).getBlockData();
chunk = null;
x = y = z = 0;
}
public static CraftBlockState getBlockState(net.minecraft.server.World world, int x, int y, int z) {
return new CraftBlockState(world.getWorld().getBlockAt(x, y, z));
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, int x, int y, int z, int flag) {
return new CraftBlockState(world.getWorld().getBlockAt(x, y, z), flag);
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() {
@@ -82,14 +82,32 @@ public class CraftBlockState implements BlockState {
return chunk;
}
public void setData(IBlockData data) {
this.data = data;
}
public IBlockData getHandle() {
return this.data;
}
@Override
public BlockData getBlockData() {
return CraftBlockData.fromData(data);
}
@Override
public void setBlockData(BlockData data) {
this.data = ((CraftBlockData) data).getState();
}
public void setData(final MaterialData data) {
Material mat = getType();
if ((mat == null) || (mat.getData() == null)) {
this.data = data;
this.data = CraftMagicNumbers.getBlock(data);
} else {
if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) {
this.data = data;
this.data = CraftMagicNumbers.getBlock(data);
} else {
throw new IllegalArgumentException("Provided data is not of type "
+ mat.getData().getName() + ", found " + data.getClass().getName());
@@ -98,24 +116,17 @@ public class CraftBlockState implements BlockState {
}
public MaterialData getData() {
return data;
return CraftMagicNumbers.getMaterial(data);
}
public void setType(final Material type) {
setTypeId(type.getId());
}
public boolean setTypeId(final int type) {
if (this.type != type) {
this.type = type;
createData((byte) 0);
if (this.getType() != type) {
this.data = CraftMagicNumbers.getBlock(type).getBlockData();
}
return true;
}
public Material getType() {
return Material.getMaterial(getTypeId());
return CraftMagicNumbers.getMaterial(data.getBlock());
}
public void setFlag(int flag) {
@@ -126,17 +137,13 @@ public class CraftBlockState implements BlockState {
return flag;
}
public int getTypeId() {
return type;
}
public byte getLightLevel() {
return getBlock().getLightLevel();
}
public Block getBlock() {
public CraftBlock getBlock() {
requirePlaced();
return world.getBlockAt(x, y, z);
return (CraftBlock) world.getBlockAt(x, y, z);
}
public boolean update() {
@@ -151,7 +158,7 @@ public class CraftBlockState implements BlockState {
if (!isPlaced()) {
return true;
}
Block block = getBlock();
CraftBlock block = getBlock();
if (block.getType() != getType()) {
if (!force) {
@@ -160,34 +167,25 @@ public class CraftBlockState implements BlockState {
}
BlockPosition pos = new BlockPosition(x, y, z);
IBlockData newBlock = CraftMagicNumbers.getBlock(getType()).fromLegacyData(getRawData());
block.setTypeIdAndData(getTypeId(), getRawData(), applyPhysics);
IBlockData newBlock = this.data;
block.setTypeAndData(newBlock, applyPhysics);
world.getHandle().notify(
pos,
CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData()),
block.getNMS(),
newBlock,
3
);
// Update levers etc
if (applyPhysics && getData() instanceof Attachable) {
world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock(), false);
world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock());
}
return true;
}
private void createData(final byte data) {
Material mat = getType();
if (mat == null || mat.getData() == null) {
this.data = new MaterialData(type, data);
} else {
this.data = mat.getNewData(data);
}
}
public byte getRawData() {
return data.getData();
return CraftMagicNumbers.toLegacyData(data);
}
public Location getLocation() {
@@ -208,7 +206,7 @@ public class CraftBlockState implements BlockState {
}
public void setRawData(byte data) {
this.data.setData(data);
this.data = CraftMagicNumbers.getBlock(getType(), data);
}
@Override
@@ -232,9 +230,6 @@ public class CraftBlockState implements BlockState {
if (this.z != other.z) {
return false;
}
if (this.type != other.type) {
return false;
}
if (this.data != other.data && (this.data == null || !this.data.equals(other.data))) {
return false;
}
@@ -248,7 +243,6 @@ public class CraftBlockState implements BlockState {
hash = 73 * hash + this.x;
hash = 73 * hash + this.y;
hash = 73 * hash + this.z;
hash = 73 * hash + this.type;
hash = 73 * hash + (this.data != null ? this.data.hashCode() : 0);
return hash;
}

View File

@@ -5,6 +5,7 @@ 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 {
@@ -54,12 +55,12 @@ public class CraftBrewingStand extends CraftContainer<TileEntityBrewingStand> im
@Override
public String getCustomName() {
TileEntityBrewingStand brewingStand = this.getSnapshot();
return brewingStand.hasCustomName() ? brewingStand.getName() : null;
return brewingStand.hasCustomName() ? CraftChatMessage.fromComponent(brewingStand.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(name);
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override

View File

@@ -1,6 +1,10 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.BlockChest;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.Blocks;
import net.minecraft.server.ITileInventory;
import net.minecraft.server.InventoryLargeChest;
import net.minecraft.server.TileEntityChest;
import org.bukkit.Material;
@@ -48,30 +52,10 @@ public class CraftChest extends CraftLootable<TileEntityChest> implements Chest
int z = this.getZ();
CraftWorld world = (CraftWorld) this.getWorld();
int id;
if (world.getBlockTypeIdAt(x, y, z) == Material.CHEST.getId()) {
id = Material.CHEST.getId();
} else if (world.getBlockTypeIdAt(x, y, z) == Material.TRAPPED_CHEST.getId()) {
id = Material.TRAPPED_CHEST.getId();
} else {
throw new IllegalStateException("CraftChest is not a chest but is instead " + world.getBlockAt(x, y, z));
}
ITileInventory nms = ((BlockChest) Blocks.CHEST).getInventory(data, world.getHandle(), new BlockPosition(x, y, z), true);
if (world.getBlockTypeIdAt(x - 1, y, z) == id) {
CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x - 1, y, z)));
inventory = new CraftInventoryDoubleChest(left, inventory);
}
if (world.getBlockTypeIdAt(x + 1, y, z) == id) {
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x + 1, y, z)));
inventory = new CraftInventoryDoubleChest(inventory, right);
}
if (world.getBlockTypeIdAt(x, y, z - 1) == id) {
CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x, y, z - 1)));
inventory = new CraftInventoryDoubleChest(left, inventory);
}
if (world.getBlockTypeIdAt(x, y, z + 1) == id) {
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x, y, z + 1)));
inventory = new CraftInventoryDoubleChest(inventory, right);
if (nms instanceof InventoryLargeChest) {
inventory = new CraftInventoryDoubleChest((InventoryLargeChest) nms);
}
return inventory;
}

View File

@@ -4,6 +4,7 @@ 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 {
@@ -23,7 +24,7 @@ public class CraftCommandBlock extends CraftBlockEntityState<TileEntityCommand>
super.load(commandBlock);
command = commandBlock.getCommandBlock().getCommand();
name = commandBlock.getCommandBlock().getName();
name = CraftChatMessage.fromComponent(commandBlock.getCommandBlock().getName());
}
@Override
@@ -51,6 +52,6 @@ public class CraftCommandBlock extends CraftBlockEntityState<TileEntityCommand>
super.applyTo(commandBlock);
commandBlock.getCommandBlock().setCommand(command);
commandBlock.getCommandBlock().setName(name);
commandBlock.getCommandBlock().setName(CraftChatMessage.fromStringOrNull(name));
}
}

View 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);
}
}

View File

@@ -1,6 +1,7 @@
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;
@@ -31,7 +32,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa
throw new IllegalArgumentException("Can't spawn EntityType " + entityType + " from mobspawners!");
}
this.getSnapshot().getSpawner().setMobName(new MinecraftKey(entityType.getName()));
this.getSnapshot().getSpawner().setMobName(EntityTypes.a(entityType.getName()));
}
@Override

View File

@@ -4,6 +4,7 @@ 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 {
@@ -18,12 +19,12 @@ public class CraftEnchantingTable extends CraftBlockEntityState<TileEntityEnchan
@Override
public String getCustomName() {
TileEntityEnchantTable enchant = this.getSnapshot();
return enchant.hasCustomName() ? enchant.getName() : null;
return enchant.hasCustomName() ? CraftChatMessage.fromComponent(enchant.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(name);
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override

View File

@@ -1,46 +0,0 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.ItemStack;
import net.minecraft.server.TileEntityFlowerPot;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.FlowerPot;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.material.MaterialData;
public class CraftFlowerPot extends CraftBlockEntityState<TileEntityFlowerPot> implements FlowerPot {
private MaterialData contents;
public CraftFlowerPot(Block block) {
super(block, TileEntityFlowerPot.class);
}
public CraftFlowerPot(Material material, TileEntityFlowerPot te) {
super(material, te);
}
@Override
public void load(TileEntityFlowerPot pot) {
super.load(pot);
contents = (pot.getItem() == null) ? null : CraftItemStack.asBukkitCopy(pot.getContents()).getData();
}
@Override
public MaterialData getContents() {
return contents;
}
@Override
public void setContents(MaterialData item) {
contents = item;
}
@Override
public void applyTo(TileEntityFlowerPot pot) {
super.applyTo(pot);
pot.setContents(contents == null ? ItemStack.a : CraftItemStack.asNMSCopy(contents.toItemStack(1)));
}
}

View File

@@ -5,6 +5,7 @@ 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 {
@@ -54,12 +55,12 @@ public class CraftFurnace extends CraftContainer<TileEntityFurnace> implements F
@Override
public String getCustomName() {
TileEntityFurnace furnace = this.getSnapshot();
return furnace.hasCustomName() ? furnace.getName() : null;
return furnace.hasCustomName() ? CraftChatMessage.fromComponent(furnace.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(name);
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override

View File

@@ -1,11 +1,12 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.BlockJukeBox;
import net.minecraft.server.BlockJukeBox.TileEntityRecordPlayer;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.Blocks;
import net.minecraft.server.Item;
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;
@@ -13,13 +14,13 @@ import org.bukkit.block.Jukebox;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftJukebox extends CraftBlockEntityState<TileEntityRecordPlayer> implements Jukebox {
public class CraftJukebox extends CraftBlockEntityState<TileEntityJukeBox> implements Jukebox {
public CraftJukebox(final Block block) {
super(block, TileEntityRecordPlayer.class);
super(block, TileEntityJukeBox.class);
}
public CraftJukebox(final Material material, TileEntityRecordPlayer te) {
public CraftJukebox(final Material material, TileEntityJukeBox te) {
super(material, te);
}
@@ -39,7 +40,7 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityRecordPlayer>
Blocks.JUKEBOX.getBlockData()
.set(BlockJukeBox.HAS_RECORD, true), 3);
}
world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record.getId());
world.playEffect(this.getLocation(), Effect.RECORD_PLAY, Item.getId(CraftMagicNumbers.getItem((Material) record)));
}
return result;
@@ -77,12 +78,12 @@ public class CraftJukebox extends CraftBlockEntityState<TileEntityRecordPlayer>
public boolean eject() {
requirePlaced();
TileEntity tileEntity = this.getTileEntityFromWorld();
if (!(tileEntity instanceof TileEntityRecordPlayer)) return false;
if (!(tileEntity instanceof TileEntityJukeBox)) return false;
TileEntityRecordPlayer jukebox = (TileEntityRecordPlayer) tileEntity;
TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity;
boolean result = !jukebox.getRecord().isEmpty();
CraftWorld world = (CraftWorld) this.getWorld();
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), new BlockPosition(getX(), getY(), getZ()), null);
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
return result;
}
}

View File

@@ -4,6 +4,7 @@ import net.minecraft.server.TileEntityLootable;
import org.bukkit.Material;
import org.bukkit.Nameable;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.util.CraftChatMessage;
public abstract class CraftLootable<T extends TileEntityLootable> extends CraftContainer<T> implements Nameable {
@@ -18,12 +19,12 @@ public abstract class CraftLootable<T extends TileEntityLootable> extends CraftC
@Override
public String getCustomName() {
T lootable = this.getSnapshot();
return lootable.hasCustomName() ? lootable.getName() : null;
return lootable.hasCustomName() ? CraftChatMessage.fromComponent(lootable.getCustomName()) : null;
}
@Override
public void setCustomName(String name) {
this.getSnapshot().setCustomName(name);
this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override

View File

@@ -1,83 +0,0 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.TileEntityNote;
import org.bukkit.Instrument;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.block.Block;
import org.bukkit.block.NoteBlock;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftNoteBlock extends CraftBlockEntityState<TileEntityNote> implements NoteBlock {
public CraftNoteBlock(final Block block) {
super(block, TileEntityNote.class);
}
public CraftNoteBlock(final Material material, final TileEntityNote te) {
super(material, te);
}
@Override
public Note getNote() {
return new Note(this.getSnapshot().note);
}
@Override
public byte getRawNote() {
return this.getSnapshot().note;
}
@Override
public void setNote(Note note) {
this.getSnapshot().note = note.getId();
}
@Override
public void setRawNote(byte note) {
this.getSnapshot().note = note;
}
@Override
public boolean play() {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
TileEntityNote note = (TileEntityNote) this.getTileEntityFromWorld();
CraftWorld world = (CraftWorld) this.getWorld();
note.play(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
return true;
} else {
return false;
}
}
@Override
public boolean play(byte instrument, byte note) {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
CraftWorld world = (CraftWorld) this.getWorld();
world.getHandle().playBlockAction(new BlockPosition(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument, note);
return true;
} else {
return false;
}
}
@Override
public boolean play(Instrument instrument, Note note) {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
CraftWorld world = (CraftWorld) this.getWorld();
world.getHandle().playBlockAction(new BlockPosition(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
return true;
} else {
return false;
}
}
}

View File

@@ -12,13 +12,12 @@ import org.bukkit.SkullType;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.block.data.Rotatable;
public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implements Skull {
private static final int MAX_OWNER_LENGTH = 16;
private GameProfile profile;
private SkullType skullType;
private byte rotation;
public CraftSkull(final Block block) {
super(block, TileEntitySkull.class);
@@ -33,26 +32,6 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
super.load(skull);
profile = skull.getGameProfile();
skullType = getSkullType(skull.getSkullType());
rotation = (byte) skull.rotation;
}
static SkullType getSkullType(int id) {
switch (id) {
default:
case 0:
return SkullType.SKELETON;
case 1:
return SkullType.WITHER;
case 2:
return SkullType.ZOMBIE;
case 3:
return SkullType.PLAYER;
case 4:
return SkullType.CREEPER;
case 5:
return SkullType.DRAGON;
}
}
static int getSkullType(SkullType type) {
@@ -73,84 +52,6 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
}
}
static byte getBlockFace(BlockFace rotation) {
switch (rotation) {
case NORTH:
return 0;
case NORTH_NORTH_EAST:
return 1;
case NORTH_EAST:
return 2;
case EAST_NORTH_EAST:
return 3;
case EAST:
return 4;
case EAST_SOUTH_EAST:
return 5;
case SOUTH_EAST:
return 6;
case SOUTH_SOUTH_EAST:
return 7;
case SOUTH:
return 8;
case SOUTH_SOUTH_WEST:
return 9;
case SOUTH_WEST:
return 10;
case WEST_SOUTH_WEST:
return 11;
case WEST:
return 12;
case WEST_NORTH_WEST:
return 13;
case NORTH_WEST:
return 14;
case NORTH_NORTH_WEST:
return 15;
default:
throw new IllegalArgumentException("Invalid BlockFace rotation: " + rotation);
}
}
static BlockFace getBlockFace(byte rotation) {
switch (rotation) {
case 0:
return BlockFace.NORTH;
case 1:
return BlockFace.NORTH_NORTH_EAST;
case 2:
return BlockFace.NORTH_EAST;
case 3:
return BlockFace.EAST_NORTH_EAST;
case 4:
return BlockFace.EAST;
case 5:
return BlockFace.EAST_SOUTH_EAST;
case 6:
return BlockFace.SOUTH_EAST;
case 7:
return BlockFace.SOUTH_SOUTH_EAST;
case 8:
return BlockFace.SOUTH;
case 9:
return BlockFace.SOUTH_SOUTH_WEST;
case 10:
return BlockFace.SOUTH_WEST;
case 11:
return BlockFace.WEST_SOUTH_WEST;
case 12:
return BlockFace.WEST;
case 13:
return BlockFace.WEST_NORTH_WEST;
case 14:
return BlockFace.NORTH_WEST;
case 15:
return BlockFace.NORTH_NORTH_WEST;
default:
throw new AssertionError(rotation);
}
}
@Override
public boolean hasOwner() {
return profile != null;
@@ -172,10 +73,6 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
return false;
}
if (skullType != SkullType.PLAYER) {
skullType = SkullType.PLAYER;
}
this.profile = profile;
return true;
}
@@ -199,47 +96,58 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
public void setOwningPlayer(OfflinePlayer player) {
Preconditions.checkNotNull(player, "player");
if (skullType != SkullType.PLAYER) {
skullType = SkullType.PLAYER;
}
this.profile = new GameProfile(player.getUniqueId(), player.getName());
}
@Override
public BlockFace getRotation() {
return getBlockFace(rotation);
return ((Rotatable) getBlockData()).getRotation();
}
@Override
public void setRotation(BlockFace rotation) {
this.rotation = getBlockFace(rotation);
Rotatable blockData = (Rotatable) getBlockData();
blockData.setRotation(rotation);
setBlockData(blockData);
}
@Override
public SkullType getSkullType() {
return skullType;
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) {
this.skullType = skullType;
if (skullType != SkullType.PLAYER) {
profile = null;
}
throw new UnsupportedOperationException("Must change block type");
}
@Override
public void applyTo(TileEntitySkull skull) {
super.applyTo(skull);
if (skullType == SkullType.PLAYER) {
if (getSkullType() == SkullType.PLAYER) {
skull.setGameProfile(profile);
} else {
skull.setSkullType(getSkullType(skullType));
}
skull.setRotation(rotation);
}
}

View File

@@ -2,6 +2,7 @@ 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;
@@ -30,35 +31,35 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
@Override
public String getStructureName() {
return getSnapshot().a(); // PAIL: rename getStructureName
return getSnapshot().getStructureName();
}
@Override
public void setStructureName(String name) {
Preconditions.checkArgument(name != null, "Structure Name cannot be null");
getSnapshot().a(name); // PAIL: rename setStructureName
getSnapshot().setStructureName(name);
}
@Override
public String getAuthor() {
return getSnapshot().f;
return getSnapshot().author;
}
@Override
public void setAuthor(String author) {
Preconditions.checkArgument(author != null && !author.isEmpty(), "Author name cannot be null nor empty");
getSnapshot().f = author; // PAIL: rename author
getSnapshot().author = author;
}
@Override
public void setAuthor(LivingEntity entity) {
Preconditions.checkArgument(entity != null, "Structure Block author entity cannot be null");
getSnapshot().a(((CraftLivingEntity) entity).getHandle()); // PAIL: rename setAuthor
getSnapshot().setAuthor(((CraftLivingEntity) entity).getHandle());
}
@Override
public BlockVector getRelativePosition() {
return new BlockVector(getSnapshot().h.getX(), getSnapshot().h.getY(), getSnapshot().h.getZ()); // PAIL: rename relativePosition
return new BlockVector(getSnapshot().relativePosition.getX(), getSnapshot().relativePosition.getY(), getSnapshot().relativePosition.getZ());
}
@Override
@@ -66,12 +67,12 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
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().h = new BlockPosition(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // PAIL: rename relativePosition
getSnapshot().relativePosition = new BlockPosition(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
}
@Override
public BlockVector getStructureSize() {
return new BlockVector(getSnapshot().i.getX(), getSnapshot().i.getY(), getSnapshot().i.getZ()); // PAIL: rename size
return new BlockVector(getSnapshot().size.getX(), getSnapshot().size.getY(), getSnapshot().size.getZ());
}
@Override
@@ -79,101 +80,101 @@ public class CraftStructureBlock extends CraftBlockEntityState<TileEntityStructu
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().i = new BlockPosition(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // PAIL: rename size
getSnapshot().size = new BlockPosition(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
}
@Override
public void setMirror(Mirror mirror) {
getSnapshot().j = EnumBlockMirror.valueOf(mirror.name()); // PAIL: rename mirror
getSnapshot().mirror = EnumBlockMirror.valueOf(mirror.name());
}
@Override
public Mirror getMirror() {
return Mirror.valueOf(getSnapshot().j.name()); // PAIL: rename mirror
return Mirror.valueOf(getSnapshot().mirror.name());
}
@Override
public void setRotation(StructureRotation rotation) {
getSnapshot().k = EnumBlockRotation.valueOf(rotation.name()); // PAIL: rename rotation
getSnapshot().rotation = EnumBlockRotation.valueOf(rotation.name());
}
@Override
public StructureRotation getRotation() {
return StructureRotation.valueOf(getSnapshot().k.name()); // PAIL: rename rotation
return StructureRotation.valueOf(getSnapshot().rotation.name());
}
@Override
public void setUsageMode(UsageMode mode) {
getSnapshot().a(TileEntityStructure.UsageMode.valueOf(mode.name())); // PAIL: rename setUsageMode
getSnapshot().setUsageMode(BlockPropertyStructureMode.valueOf(mode.name()));
}
@Override
public UsageMode getUsageMode() {
return UsageMode.valueOf(getSnapshot().k().name()); // PAIL rename getUsageMode
return UsageMode.valueOf(getSnapshot().getUsageMode().name());
}
@Override
public void setIgnoreEntities(boolean flag) {
getSnapshot().m = flag; // PAIL: rename ignoreEntities
getSnapshot().ignoreEntities = flag;
}
@Override
public boolean isIgnoreEntities() {
return getSnapshot().m; // PAIL: rename ignoreEntities
return getSnapshot().ignoreEntities;
}
@Override
public void setShowAir(boolean showAir) {
getSnapshot().o = showAir; // PAIL rename showAir
getSnapshot().showAir = showAir;
}
@Override
public boolean isShowAir() {
return getSnapshot().o; // PAIL: rename showAir
return getSnapshot().showAir;
}
@Override
public void setBoundingBoxVisible(boolean showBoundingBox) {
getSnapshot().p = showBoundingBox; // PAIL: rename boundingBoxVisible
getSnapshot().showBoundingBox = showBoundingBox;
}
@Override
public boolean isBoundingBoxVisible() {
return getSnapshot().p; // PAIL: rename boundingBoxVisible
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().q = integrity; // PAIL: rename integrity
getSnapshot().integrity = integrity;
}
@Override
public float getIntegrity() {
return getSnapshot().q; // PAIL: rename integrity
return getSnapshot().integrity;
}
@Override
public void setSeed(long seed) {
getSnapshot().r = seed; // PAIL: rename seed
getSnapshot().seed = seed;
}
@Override
public long getSeed() {
return getSnapshot().r; // PAIL: rename seed
return getSnapshot().seed;
}
@Override
public void setMetadata(String metadata) {
Validate.notNull(metadata, "Structure metadata cannot be null");
if (getUsageMode() == UsageMode.DATA) {
getSnapshot().g = metadata; // PAIL: rename metadata
getSnapshot().metadata = metadata;
}
}
@Override
public String getMetadata() {
return getSnapshot().g; // PAIL: rename metadata
return getSnapshot().metadata;
}
private static boolean isBetween(int num, int min, int max) {

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,356 @@
package org.bukkit.craftbukkit.block.data;
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.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 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;
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;
}
protected <B extends Enum<B>> B get(BlockStateEnum<?> nms, Class<B> bukkit) {
return toBukkit(state.get(nms), bukkit);
}
@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();
}
protected <B extends Enum<B>, N extends Enum<N> & INamable> void set(BlockStateEnum<N> nms, Enum<B> bukkit) {
this.state = this.state.set(nms, toNMS(bukkit, nms.b()));
}
private static final BiMap<Enum<?>, Enum<?>> nmsToBukkit = HashBiMap.create();
@SuppressWarnings("unchecked")
private static <B extends Enum<B>> B toBukkit(Enum<?> nms, Class<B> bukkit) {
Enum<?> 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);
nmsToBukkit.put(nms, converted);
return (B) converted;
}
@SuppressWarnings("unchecked")
private static <N extends Enum<N> & INamable> N toNMS(Enum<?> bukkit, Class<N> nms) {
Enum<?> 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);
nmsToBukkit.put(converted, bukkit);
return (N) converted;
}
protected <T extends Comparable<T>> T get(IBlockState<T> ibs) {
// Straight integer or boolean getter
return this.state.get(ibs);
}
public <T extends Comparable<T>, V extends T> void set(IBlockState<T> ibs, V v) {
// Straight integer or boolean setter
this.state = this.state.set(ibs, v);
}
@Override
public String getAsString() {
return state.toString();
}
@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() + "}";
}
@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);
}
private static IBlockState<?> getState(Class<? extends Block> block, String name, boolean optional) {
IBlockState<?> state = null;
for (Block instance : (Iterable<Block>) Block.REGISTRY) { // 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;
}
protected static int getMin(BlockStateInteger state) {
return state.min;
}
protected static int getMax(BlockStateInteger state) {
return state.max;
}
//
private static final Map<Class<? extends Block>, Class<? extends CraftBlockData>> MAP = new HashMap<>();
static {
register(net.minecraft.server.BlockAnvil.class, org.bukkit.craftbukkit.block.impl.CraftAnvil.class);
register(net.minecraft.server.BlockBanner.class, org.bukkit.craftbukkit.block.impl.CraftBanner.class);
register(net.minecraft.server.BlockBannerWall.class, org.bukkit.craftbukkit.block.impl.CraftBannerWall.class);
register(net.minecraft.server.BlockBed.class, org.bukkit.craftbukkit.block.impl.CraftBed.class);
register(net.minecraft.server.BlockBeetroot.class, org.bukkit.craftbukkit.block.impl.CraftBeetroot.class);
register(net.minecraft.server.BlockBrewingStand.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand.class);
register(net.minecraft.server.BlockBubbleColumn.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn.class);
register(net.minecraft.server.BlockCactus.class, org.bukkit.craftbukkit.block.impl.CraftCactus.class);
register(net.minecraft.server.BlockCake.class, org.bukkit.craftbukkit.block.impl.CraftCake.class);
register(net.minecraft.server.BlockCarrots.class, org.bukkit.craftbukkit.block.impl.CraftCarrots.class);
register(net.minecraft.server.BlockCauldron.class, org.bukkit.craftbukkit.block.impl.CraftCauldron.class);
register(net.minecraft.server.BlockChest.class, org.bukkit.craftbukkit.block.impl.CraftChest.class);
register(net.minecraft.server.BlockChestTrapped.class, org.bukkit.craftbukkit.block.impl.CraftChestTrapped.class);
register(net.minecraft.server.BlockChorusFlower.class, org.bukkit.craftbukkit.block.impl.CraftChorusFlower.class);
register(net.minecraft.server.BlockChorusFruit.class, org.bukkit.craftbukkit.block.impl.CraftChorusFruit.class);
register(net.minecraft.server.BlockCobbleWall.class, org.bukkit.craftbukkit.block.impl.CraftCobbleWall.class);
register(net.minecraft.server.BlockCocoa.class, org.bukkit.craftbukkit.block.impl.CraftCocoa.class);
register(net.minecraft.server.BlockCommand.class, org.bukkit.craftbukkit.block.impl.CraftCommand.class);
register(net.minecraft.server.BlockCoralFan.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan.class);
register(net.minecraft.server.BlockCrops.class, org.bukkit.craftbukkit.block.impl.CraftCrops.class);
register(net.minecraft.server.BlockDaylightDetector.class, org.bukkit.craftbukkit.block.impl.CraftDaylightDetector.class);
register(net.minecraft.server.BlockDirtSnow.class, org.bukkit.craftbukkit.block.impl.CraftDirtSnow.class);
register(net.minecraft.server.BlockDispenser.class, org.bukkit.craftbukkit.block.impl.CraftDispenser.class);
register(net.minecraft.server.BlockDoor.class, org.bukkit.craftbukkit.block.impl.CraftDoor.class);
register(net.minecraft.server.BlockDropper.class, org.bukkit.craftbukkit.block.impl.CraftDropper.class);
register(net.minecraft.server.BlockEndRod.class, org.bukkit.craftbukkit.block.impl.CraftEndRod.class);
register(net.minecraft.server.BlockEnderChest.class, org.bukkit.craftbukkit.block.impl.CraftEnderChest.class);
register(net.minecraft.server.BlockEnderPortalFrame.class, org.bukkit.craftbukkit.block.impl.CraftEnderPortalFrame.class);
register(net.minecraft.server.BlockFence.class, org.bukkit.craftbukkit.block.impl.CraftFence.class);
register(net.minecraft.server.BlockFenceGate.class, org.bukkit.craftbukkit.block.impl.CraftFenceGate.class);
register(net.minecraft.server.BlockFire.class, org.bukkit.craftbukkit.block.impl.CraftFire.class);
register(net.minecraft.server.BlockFloorSign.class, org.bukkit.craftbukkit.block.impl.CraftFloorSign.class);
register(net.minecraft.server.BlockFluids.class, org.bukkit.craftbukkit.block.impl.CraftFluids.class);
register(net.minecraft.server.BlockFurnace.class, org.bukkit.craftbukkit.block.impl.CraftFurnace.class);
register(net.minecraft.server.BlockGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftGlassPane.class);
register(net.minecraft.server.BlockGlazedTerracotta.class, org.bukkit.craftbukkit.block.impl.CraftGlazedTerracotta.class);
register(net.minecraft.server.BlockGrass.class, org.bukkit.craftbukkit.block.impl.CraftGrass.class);
register(net.minecraft.server.BlockHay.class, org.bukkit.craftbukkit.block.impl.CraftHay.class);
register(net.minecraft.server.BlockHopper.class, org.bukkit.craftbukkit.block.impl.CraftHopper.class);
register(net.minecraft.server.BlockHugeMushroom.class, org.bukkit.craftbukkit.block.impl.CraftHugeMushroom.class);
register(net.minecraft.server.BlockIceFrost.class, org.bukkit.craftbukkit.block.impl.CraftIceFrost.class);
register(net.minecraft.server.BlockIronBars.class, org.bukkit.craftbukkit.block.impl.CraftIronBars.class);
register(net.minecraft.server.BlockJukeBox.class, org.bukkit.craftbukkit.block.impl.CraftJukeBox.class);
register(net.minecraft.server.BlockKelp.class, org.bukkit.craftbukkit.block.impl.CraftKelp.class);
register(net.minecraft.server.BlockLadder.class, org.bukkit.craftbukkit.block.impl.CraftLadder.class);
register(net.minecraft.server.BlockLeaves.class, org.bukkit.craftbukkit.block.impl.CraftLeaves.class);
register(net.minecraft.server.BlockLever.class, org.bukkit.craftbukkit.block.impl.CraftLever.class);
register(net.minecraft.server.BlockLogAbstract.class, org.bukkit.craftbukkit.block.impl.CraftLogAbstract.class);
register(net.minecraft.server.BlockMinecartDetector.class, org.bukkit.craftbukkit.block.impl.CraftMinecartDetector.class);
register(net.minecraft.server.BlockMinecartTrack.class, org.bukkit.craftbukkit.block.impl.CraftMinecartTrack.class);
register(net.minecraft.server.BlockMycel.class, org.bukkit.craftbukkit.block.impl.CraftMycel.class);
register(net.minecraft.server.BlockNetherWart.class, org.bukkit.craftbukkit.block.impl.CraftNetherWart.class);
register(net.minecraft.server.BlockNote.class, org.bukkit.craftbukkit.block.impl.CraftNote.class);
register(net.minecraft.server.BlockObserver.class, org.bukkit.craftbukkit.block.impl.CraftObserver.class);
register(net.minecraft.server.BlockPiston.class, org.bukkit.craftbukkit.block.impl.CraftPiston.class);
register(net.minecraft.server.BlockPistonExtension.class, org.bukkit.craftbukkit.block.impl.CraftPistonExtension.class);
register(net.minecraft.server.BlockPistonMoving.class, org.bukkit.craftbukkit.block.impl.CraftPistonMoving.class);
register(net.minecraft.server.BlockPortal.class, org.bukkit.craftbukkit.block.impl.CraftPortal.class);
register(net.minecraft.server.BlockPotatoes.class, org.bukkit.craftbukkit.block.impl.CraftPotatoes.class);
register(net.minecraft.server.BlockPoweredRail.class, org.bukkit.craftbukkit.block.impl.CraftPoweredRail.class);
register(net.minecraft.server.BlockPressurePlateBinary.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateBinary.class);
register(net.minecraft.server.BlockPressurePlateWeighted.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateWeighted.class);
register(net.minecraft.server.BlockPumpkinCarved.class, org.bukkit.craftbukkit.block.impl.CraftPumpkinCarved.class);
register(net.minecraft.server.BlockRedstoneComparator.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneComparator.class);
register(net.minecraft.server.BlockRedstoneLamp.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneLamp.class);
register(net.minecraft.server.BlockRedstoneOre.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneOre.class);
register(net.minecraft.server.BlockRedstoneTorch.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorch.class);
register(net.minecraft.server.BlockRedstoneTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorchWall.class);
register(net.minecraft.server.BlockRedstoneWire.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneWire.class);
register(net.minecraft.server.BlockReed.class, org.bukkit.craftbukkit.block.impl.CraftReed.class);
register(net.minecraft.server.BlockRepeater.class, org.bukkit.craftbukkit.block.impl.CraftRepeater.class);
register(net.minecraft.server.BlockRotatable.class, org.bukkit.craftbukkit.block.impl.CraftRotatable.class);
register(net.minecraft.server.BlockSapling.class, org.bukkit.craftbukkit.block.impl.CraftSapling.class);
register(net.minecraft.server.BlockSeaPickle.class, org.bukkit.craftbukkit.block.impl.CraftSeaPickle.class);
register(net.minecraft.server.BlockShulkerBox.class, org.bukkit.craftbukkit.block.impl.CraftShulkerBox.class);
register(net.minecraft.server.BlockSkull.class, org.bukkit.craftbukkit.block.impl.CraftSkull.class);
register(net.minecraft.server.BlockSkullPlayer.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayer.class);
register(net.minecraft.server.BlockSkullPlayerWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayerWall.class);
register(net.minecraft.server.BlockSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullWall.class);
register(net.minecraft.server.BlockSnow.class, org.bukkit.craftbukkit.block.impl.CraftSnow.class);
register(net.minecraft.server.BlockSoil.class, org.bukkit.craftbukkit.block.impl.CraftSoil.class);
register(net.minecraft.server.BlockStainedGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftStainedGlassPane.class);
register(net.minecraft.server.BlockStairs.class, org.bukkit.craftbukkit.block.impl.CraftStairs.class);
register(net.minecraft.server.BlockStem.class, org.bukkit.craftbukkit.block.impl.CraftStem.class);
register(net.minecraft.server.BlockStemAttached.class, org.bukkit.craftbukkit.block.impl.CraftStemAttached.class);
register(net.minecraft.server.BlockStepAbstract.class, org.bukkit.craftbukkit.block.impl.CraftStepAbstract.class);
register(net.minecraft.server.BlockStoneButton.class, org.bukkit.craftbukkit.block.impl.CraftStoneButton.class);
register(net.minecraft.server.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure.class);
register(net.minecraft.server.BlockTallPlantFlower.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower.class);
register(net.minecraft.server.BlockTallPlantShearable.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantShearable.class);
register(net.minecraft.server.BlockTallSeaGrass.class, org.bukkit.craftbukkit.block.impl.CraftTallSeaGrass.class);
register(net.minecraft.server.BlockTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftTorchWall.class);
register(net.minecraft.server.BlockTrapdoor.class, org.bukkit.craftbukkit.block.impl.CraftTrapdoor.class);
register(net.minecraft.server.BlockTripwire.class, org.bukkit.craftbukkit.block.impl.CraftTripwire.class);
register(net.minecraft.server.BlockTripwireHook.class, org.bukkit.craftbukkit.block.impl.CraftTripwireHook.class);
register(net.minecraft.server.BlockTurtleEgg.class, org.bukkit.craftbukkit.block.impl.CraftTurtleEgg.class);
register(net.minecraft.server.BlockVine.class, org.bukkit.craftbukkit.block.impl.CraftVine.class);
register(net.minecraft.server.BlockWallSign.class, org.bukkit.craftbukkit.block.impl.CraftWallSign.class);
register(net.minecraft.server.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull.class);
register(net.minecraft.server.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall.class);
register(net.minecraft.server.BlockWoodButton.class, org.bukkit.craftbukkit.block.impl.CraftWoodButton.class);
}
private static void register(Class<? extends Block> nms, Class<? extends CraftBlockData> bukkit) {
Preconditions.checkState(MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
}
public static CraftBlockData newData(Material material, String data) {
IBlockData blockData;
Block block = CraftMagicNumbers.getBlock(material);
// Data provided, use it
if (data != null) {
try {
// Material provided, force that material in
if (block != null) {
data = Block.REGISTRY.b(block) + data;
}
ArgumentBlock arg = new ArgumentBlock(new StringReader(data), false).a(false);
blockData = arg.b();
} catch (CommandSyntaxException ex) {
throw new IllegalArgumentException("Could not parse data: " + data, ex);
}
} else {
blockData = block.getBlockData();
}
return fromData(blockData);
}
public static CraftBlockData fromData(IBlockData data) {
Class<? extends CraftBlockData> craft = MAP.get(data.getBlock().getClass());
if (craft == null) {
craft = CraftBlockData.class;
}
CraftBlockData ret;
try {
ret = craft.getDeclaredConstructor(IBlockData.class).newInstance(data);
} catch (ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
return ret;
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,49 @@
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);
case EAST:
set(EAST, connection);
case SOUTH:
set(SOUTH, connection);
case WEST:
set(WEST, connection);
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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,19 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.TechnicalPiston;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftTechnicalPiston extends CraftBlockData implements TechnicalPiston {
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);
}
}

View File

@@ -0,0 +1,19 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.Tripwire;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftTripwire extends CraftBlockData implements Tripwire {
private static final net.minecraft.server.BlockStateBoolean DISARMED = getBoolean("disarmed");
@Override
public boolean isDisarmed() {
return get(DISARMED);
}
@Override
public void setDisarmed(boolean disarmed) {
set(DISARMED, disarmed);
}
}

View File

@@ -0,0 +1,45 @@
package org.bukkit.craftbukkit.block.data.type;
import org.bukkit.block.data.type.TurtleEgg;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
public abstract class CraftTurtleEgg extends CraftBlockData implements TurtleEgg {
private static final net.minecraft.server.BlockStateInteger EGGS = getInteger("eggs");
private static final net.minecraft.server.BlockStateInteger HATCH = getInteger("hatch");
@Override
public int getEggs() {
return get(EGGS);
}
@Override
public void setEggs(int eggs) {
set(EGGS, eggs);
}
@Override
public int getMinimumEggs() {
return getMin(EGGS);
}
@Override
public int getMaximumEggs() {
return getMax(EGGS);
}
@Override
public int getHatch() {
return get(HATCH);
}
@Override
public void setHatch(int hatch) {
set(HATCH, hatch);
}
@Override
public int getMaximumHatch() {
return getMax(HATCH);
}
}

View File

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

View File

@@ -0,0 +1,118 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftBanner extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Rotatable {
public CraftBanner() {
super();
}
public CraftBanner(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftRotatable
private static final net.minecraft.server.BlockStateInteger ROTATION = getInteger(net.minecraft.server.BlockBanner.class, "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);
}
}

View File

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

View File

@@ -0,0 +1,54 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftBed extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Bed, org.bukkit.block.data.Directional {
public CraftBed() {
super();
}
public CraftBed(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftBed
private static final net.minecraft.server.BlockStateEnum<?> PART = getEnum(net.minecraft.server.BlockBed.class, "part");
private static final net.minecraft.server.BlockStateBoolean OCCUPIED = getBoolean(net.minecraft.server.BlockBed.class, "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);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockBed.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

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

View File

@@ -0,0 +1,49 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftBrewingStand extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.BrewingStand {
public CraftBrewingStand() {
super();
}
public CraftBrewingStand(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftBrewingStand
private static final net.minecraft.server.BlockStateBoolean[] HAS_BOTTLE = new net.minecraft.server.BlockStateBoolean[]{
getBoolean(net.minecraft.server.BlockBrewingStand.class, "has_bottle_0"), getBoolean(net.minecraft.server.BlockBrewingStand.class, "has_bottle_1"), getBoolean(net.minecraft.server.BlockBrewingStand.class, "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;
}
}

View File

@@ -0,0 +1,29 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftBubbleColumn extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.BubbleColumn {
public CraftBubbleColumn() {
super();
}
public CraftBubbleColumn(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftBubbleColumn
private static final net.minecraft.server.BlockStateBoolean DRAG = getBoolean(net.minecraft.server.BlockBubbleColumn.class, "drag");
@Override
public boolean isDrag() {
return get(DRAG);
}
@Override
public void setDrag(boolean drag) {
set(DRAG, drag);
}
}

View File

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

View File

@@ -0,0 +1,34 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftCake extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Cake {
public CraftCake() {
super();
}
public CraftCake(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftCake
private static final net.minecraft.server.BlockStateInteger BITES = getInteger(net.minecraft.server.BlockCake.class, "bites");
@Override
public int getBites() {
return get(BITES);
}
@Override
public void setBites(int bites) {
set(BITES, bites);
}
@Override
public int getMaximumBites() {
return getMax(BITES);
}
}

View File

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

View File

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

View File

@@ -0,0 +1,62 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftChest extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Chest, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged {
public CraftChest() {
super();
}
public CraftChest(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftChest
private static final net.minecraft.server.BlockStateEnum<?> TYPE = getEnum(net.minecraft.server.BlockChest.class, "type");
@Override
public Type getType() {
return get(TYPE, Type.class);
}
@Override
public void setType(Type type) {
set(TYPE, type);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockChest.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockChest.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

@@ -0,0 +1,62 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftChestTrapped extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Chest, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged {
public CraftChestTrapped() {
super();
}
public CraftChestTrapped(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftChest
private static final net.minecraft.server.BlockStateEnum<?> TYPE = getEnum(net.minecraft.server.BlockChestTrapped.class, "type");
@Override
public Type getType() {
return get(TYPE, Type.class);
}
@Override
public void setType(Type type) {
set(TYPE, type);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockChestTrapped.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
// org.bukkit.craftbukkit.block.data.CraftWaterlogged
private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockChestTrapped.class, "waterlogged");
@Override
public boolean isWaterlogged() {
return get(WATERLOGGED);
}
@Override
public void setWaterlogged(boolean waterlogged) {
set(WATERLOGGED, waterlogged);
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,53 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftCocoa extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Cocoa, org.bukkit.block.data.Ageable, org.bukkit.block.data.Directional {
public CraftCocoa() {
super();
}
public CraftCocoa(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.CraftAgeable
private static final net.minecraft.server.BlockStateInteger AGE = getInteger(net.minecraft.server.BlockCocoa.class, "age");
@Override
public int getAge() {
return get(AGE);
}
@Override
public void setAge(int age) {
set(AGE, age);
}
@Override
public int getMaximumAge() {
return getMax(AGE);
}
// org.bukkit.craftbukkit.block.data.CraftDirectional
private static final net.minecraft.server.BlockStateEnum<?> FACING = getEnum(net.minecraft.server.BlockCocoa.class, "facing");
@Override
public org.bukkit.block.BlockFace getFacing() {
return get(FACING, org.bukkit.block.BlockFace.class);
}
@Override
public void setFacing(org.bukkit.block.BlockFace facing) {
set(FACING, facing);
}
@Override
public java.util.Set<org.bukkit.block.BlockFace> getFaces() {
return getValues(FACING, org.bukkit.block.BlockFace.class);
}
}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,48 @@
/**
* Automatically generated file, changes will be lost.
*/
package org.bukkit.craftbukkit.block.impl;
public final class CraftDaylightDetector extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.DaylightDetector, org.bukkit.block.data.AnaloguePowerable {
public CraftDaylightDetector() {
super();
}
public CraftDaylightDetector(net.minecraft.server.IBlockData state) {
super(state);
}
// org.bukkit.craftbukkit.block.data.type.CraftDaylightDetector
private static final net.minecraft.server.BlockStateBoolean INVERTED = getBoolean(net.minecraft.server.BlockDaylightDetector.class, "inverted");
@Override
public boolean isInverted() {
return get(INVERTED);
}
@Override
public void setInverted(boolean inverted) {
set(INVERTED, inverted);
}
// org.bukkit.craftbukkit.block.data.CraftAnaloguePowerable
private static final net.minecraft.server.BlockStateInteger POWER = getInteger(net.minecraft.server.BlockDaylightDetector.class, "power");
@Override
public int getPower() {
return get(POWER);
}
@Override
public void setPower(int power) {
set(POWER, power);
}
@Override
public int getMaximumPower() {
return getMax(POWER);
}
}

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