Merging upstream changes

This commit is contained in:
matt
2019-03-26 13:27:09 -04:00
parent 85bfd16d7c
commit 0d88a6bce2
23 changed files with 1708 additions and 1768 deletions

View File

@ -230,7 +230,11 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
@Override
public int hashCode() {
return getOrdinal();
int ret = toImmutableState().hashCode() << 3;
if (hasNbtData()) {
ret += getNbtData().hashCode();
}
return ret;
}
@Override

View File

@ -116,7 +116,8 @@ public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePat
Map<Property<?>, Object> getStates();
/**
* @deprecated use masks - not try to this fuzzy/non fuzzy state nonsense
* Checks if the type is the same, and if the matched states are the same.
*
* @param o other block
* @return true if equal
*/
@ -148,7 +149,9 @@ public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePat
if (getStates().isEmpty()) {
return this.getBlockType().getId();
} else {
String properties = getStates().entrySet().stream().map(entry -> entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase()).collect(Collectors.joining(","));
String properties =
getStates().entrySet().stream().map(entry -> entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase()).collect(Collectors.joining(
","));
return this.getBlockType().getId() + "[" + properties + "]";
}
}

View File

@ -1,5 +0,0 @@
package com.sk89q.worldedit.world.block;
public class BlockStateRegistry {
}

View File

@ -665,15 +665,15 @@ public class BlockTypes{
public static final BlockType ZOMBIE_HEAD = register("minecraft:zombie_head", state -> state.with(state.getBlockType().getProperty("rotation"), 0));
public static final BlockType ZOMBIE_WALL_HEAD = register("minecraft:zombie_wall_head", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH));
private static BlockType register(String id) {
return register(new BlockType(id));
}
private static BlockType register(String id, Function<BlockState, BlockState> values) {
return register(new BlockType(id, values));
}
public static BlockType register(BlockType type) {
if(sortedRegistry == null) {
sortedRegistry = new ArrayList<>();
@ -685,7 +685,7 @@ public class BlockTypes{
if(!sortedRegistry.contains(type))sortedRegistry.add(type);
return internalRegister(type, sortedRegistry.indexOf(type));
}
private static ArrayList<BlockType> sortedRegistry;
private static ArrayList<BlockState> stateList;
public static BlockType[] values;
@ -693,7 +693,7 @@ public class BlockTypes{
private static Set<String> $NAMESPACES;
@Deprecated public static int BIT_OFFSET; // Used internally
@Deprecated public static int BIT_MASK; // Used internally
private static BlockType internalRegister(BlockType blockType, final int internalId) {
init(blockType, blockType.getId(), internalId, stateList);
if(BlockType.REGISTRY.get(blockType.getId()) == null) BlockType.REGISTRY.register(blockType.getId(), blockType);
@ -703,10 +703,6 @@ public class BlockTypes{
return blockType;
}
private static BlockType[] values() {
return sortedRegistry.toArray(new BlockType[sortedRegistry.size()]);
}
private static void init(BlockType type, String id, int internalId, ArrayList<BlockState> states) {
try {
type.setSettings(new Settings(type, id, internalId, states));
@ -856,7 +852,7 @@ public class BlockTypes{
public static final @Nullable BlockType get(final String id) {
return BlockType.REGISTRY.get(id.toLowerCase());
}
public static final @Nullable BlockType get(final CharSequence id) {
return BlockType.REGISTRY.get(id.toString().toLowerCase());
}

View File

@ -266,10 +266,9 @@ public class AnvilChunk implements Chunk {
if (state.getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
if (tileEntity != null) {
return new BaseBlock(state, tileEntity);
return state.toBaseBlock(tileEntity);
}
}
return state.toBaseBlock();
}

View File

@ -27,7 +27,6 @@ import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
@ -189,7 +188,9 @@ public class OldChunk implements Chunk {
}
if (state.getBlockType().getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position);
if (tileEntity != null) return new BaseBlock(state, tileEntity);
if (tileEntity != null) {
return state.toBaseBlock(tileEntity);
}
}
return state.toBaseBlock();
}

View File

@ -63,4 +63,4 @@ public class EntityType {
return obj instanceof EntityType && this.id.equals(((EntityType) obj).id);
}
}
}

View File

@ -23,113 +23,105 @@ import javax.annotation.Nullable;
public class EntityTypes {
public static final EntityType AREA_EFFECT_CLOUD = register("minecraft:area_effect_cloud");
public static final EntityType ARMOR_STAND = register("minecraft:armor_stand");
public static final EntityType ARROW = register("minecraft:arrow");
public static final EntityType BAT = register("minecraft:bat");
public static final EntityType BLAZE = register("minecraft:blaze");
public static final EntityType BOAT = register("minecraft:boat");
public static final EntityType CAVE_SPIDER = register("minecraft:cave_spider");
public static final EntityType CHEST_MINECART = register("minecraft:chest_minecart");
public static final EntityType CHICKEN = register("minecraft:chicken");
public static final EntityType COD = register("minecraft:cod");
public static final EntityType COMMAND_BLOCK_MINECART = register("minecraft:command_block_minecart");
public static final EntityType COW = register("minecraft:cow");
public static final EntityType CREEPER = register("minecraft:creeper");
public static final EntityType DOLPHIN = register("minecraft:dolphin");
public static final EntityType DONKEY = register("minecraft:donkey");
public static final EntityType DRAGON_FIREBALL = register("minecraft:dragon_fireball");
public static final EntityType DROWNED = register("minecraft:drowned");
public static final EntityType EGG = register("minecraft:egg");
public static final EntityType ELDER_GUARDIAN = register("minecraft:elder_guardian");
public static final EntityType END_CRYSTAL = register("minecraft:end_crystal");
public static final EntityType ENDER_DRAGON = register("minecraft:ender_dragon");
public static final EntityType ENDER_PEARL = register("minecraft:ender_pearl");
public static final EntityType ENDERMAN = register("minecraft:enderman");
public static final EntityType ENDERMITE = register("minecraft:endermite");
public static final EntityType EVOKER = register("minecraft:evoker");
public static final EntityType EVOKER_FANGS = register("minecraft:evoker_fangs");
public static final EntityType EXPERIENCE_BOTTLE = register("minecraft:experience_bottle");
public static final EntityType EXPERIENCE_ORB = register("minecraft:experience_orb");
public static final EntityType EYE_OF_ENDER = register("minecraft:eye_of_ender");
public static final EntityType FALLING_BLOCK = register("minecraft:falling_block");
public static final EntityType FIREBALL = register("minecraft:fireball");
public static final EntityType FIREWORK_ROCKET = register("minecraft:firework_rocket");
public static final EntityType FISHING_BOBBER = register("minecraft:fishing_bobber");
public static final EntityType FURNACE_MINECART = register("minecraft:furnace_minecart");
public static final EntityType GHAST = register("minecraft:ghast");
public static final EntityType GIANT = register("minecraft:giant");
public static final EntityType GUARDIAN = register("minecraft:guardian");
public static final EntityType HOPPER_MINECART = register("minecraft:hopper_minecart");
public static final EntityType HORSE = register("minecraft:horse");
public static final EntityType HUSK = register("minecraft:husk");
public static final EntityType ILLUSIONER = register("minecraft:illusioner");
public static final EntityType IRON_GOLEM = register("minecraft:iron_golem");
public static final EntityType ITEM = register("minecraft:item");
public static final EntityType ITEM_FRAME = register("minecraft:item_frame");
public static final EntityType LEASH_KNOT = register("minecraft:leash_knot");
public static final EntityType LIGHTNING_BOLT = register("minecraft:lightning_bolt");
public static final EntityType LLAMA = register("minecraft:llama");
public static final EntityType LLAMA_SPIT = register("minecraft:llama_spit");
public static final EntityType MAGMA_CUBE = register("minecraft:magma_cube");
public static final EntityType MINECART = register("minecraft:minecart");
public static final EntityType MOOSHROOM = register("minecraft:mooshroom");
public static final EntityType MULE = register("minecraft:mule");
public static final EntityType OCELOT = register("minecraft:ocelot");
public static final EntityType PAINTING = register("minecraft:painting");
public static final EntityType PARROT = register("minecraft:parrot");
public static final EntityType PHANTOM = register("minecraft:phantom");
public static final EntityType PIG = register("minecraft:pig");
public static final EntityType PLAYER = register("minecraft:player");
public static final EntityType POLAR_BEAR = register("minecraft:polar_bear");
public static final EntityType POTION = register("minecraft:potion");
public static final EntityType PUFFERFISH = register("minecraft:pufferfish");
public static final EntityType RABBIT = register("minecraft:rabbit");
public static final EntityType SALMON = register("minecraft:salmon");
public static final EntityType SHEEP = register("minecraft:sheep");
public static final EntityType SHULKER = register("minecraft:shulker");
public static final EntityType SHULKER_BULLET = register("minecraft:shulker_bullet");
public static final EntityType SILVERFISH = register("minecraft:silverfish");
public static final EntityType SKELETON = register("minecraft:skeleton");
public static final EntityType SKELETON_HORSE = register("minecraft:skeleton_horse");
public static final EntityType SLIME = register("minecraft:slime");
public static final EntityType SMALL_FIREBALL = register("minecraft:small_fireball");
public static final EntityType SNOW_GOLEM = register("minecraft:snow_golem");
public static final EntityType SNOWBALL = register("minecraft:snowball");
public static final EntityType SPAWNER_MINECART = register("minecraft:spawner_minecart");
public static final EntityType SPECTRAL_ARROW = register("minecraft:spectral_arrow");
public static final EntityType SPIDER = register("minecraft:spider");
public static final EntityType SQUID = register("minecraft:squid");
public static final EntityType STRAY = register("minecraft:stray");
public static final EntityType TNT = register("minecraft:tnt");
public static final EntityType TNT_MINECART = register("minecraft:tnt_minecart");
public static final EntityType TRIDENT = register("minecraft:trident");
public static final EntityType TROPICAL_FISH = register("minecraft:tropical_fish");
public static final EntityType TURTLE = register("minecraft:turtle");
public static final EntityType VEX = register("minecraft:vex");
public static final EntityType VILLAGER = register("minecraft:villager");
public static final EntityType VINDICATOR = register("minecraft:vindicator");
public static final EntityType WITCH = register("minecraft:witch");
public static final EntityType WITHER = register("minecraft:wither");
public static final EntityType WITHER_SKELETON = register("minecraft:wither_skeleton");
public static final EntityType WITHER_SKULL = register("minecraft:wither_skull");
public static final EntityType WOLF = register("minecraft:wolf");
public static final EntityType ZOMBIE = register("minecraft:zombie");
public static final EntityType ZOMBIE_HORSE = register("minecraft:zombie_horse");
public static final EntityType ZOMBIE_PIGMAN = register("minecraft:zombie_pigman");
public static final EntityType ZOMBIE_VILLAGER = register("minecraft:zombie_villager");
@Nullable public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud");
@Nullable public static final EntityType ARMOR_STAND = get("minecraft:armor_stand");
@Nullable public static final EntityType ARROW = get("minecraft:arrow");
@Nullable public static final EntityType BAT = get("minecraft:bat");
@Nullable public static final EntityType BLAZE = get("minecraft:blaze");
@Nullable public static final EntityType BOAT = get("minecraft:boat");
@Nullable public static final EntityType CAVE_SPIDER = get("minecraft:cave_spider");
@Nullable public static final EntityType CHEST_MINECART = get("minecraft:chest_minecart");
@Nullable public static final EntityType CHICKEN = get("minecraft:chicken");
@Nullable public static final EntityType COD = get("minecraft:cod");
@Nullable public static final EntityType COMMAND_BLOCK_MINECART = get("minecraft:command_block_minecart");
@Nullable public static final EntityType COW = get("minecraft:cow");
@Nullable public static final EntityType CREEPER = get("minecraft:creeper");
@Nullable public static final EntityType DOLPHIN = get("minecraft:dolphin");
@Nullable public static final EntityType DONKEY = get("minecraft:donkey");
@Nullable public static final EntityType DRAGON_FIREBALL = get("minecraft:dragon_fireball");
@Nullable public static final EntityType DROWNED = get("minecraft:drowned");
@Nullable public static final EntityType EGG = get("minecraft:egg");
@Nullable public static final EntityType ELDER_GUARDIAN = get("minecraft:elder_guardian");
@Nullable public static final EntityType END_CRYSTAL = get("minecraft:end_crystal");
@Nullable public static final EntityType ENDER_DRAGON = get("minecraft:ender_dragon");
@Nullable public static final EntityType ENDER_PEARL = get("minecraft:ender_pearl");
@Nullable public static final EntityType ENDERMAN = get("minecraft:enderman");
@Nullable public static final EntityType ENDERMITE = get("minecraft:endermite");
@Nullable public static final EntityType EVOKER = get("minecraft:evoker");
@Nullable public static final EntityType EVOKER_FANGS = get("minecraft:evoker_fangs");
@Nullable public static final EntityType EXPERIENCE_BOTTLE = get("minecraft:experience_bottle");
@Nullable public static final EntityType EXPERIENCE_ORB = get("minecraft:experience_orb");
@Nullable public static final EntityType EYE_OF_ENDER = get("minecraft:eye_of_ender");
@Nullable public static final EntityType FALLING_BLOCK = get("minecraft:falling_block");
@Nullable public static final EntityType FIREBALL = get("minecraft:fireball");
@Nullable public static final EntityType FIREWORK_ROCKET = get("minecraft:firework_rocket");
@Nullable public static final EntityType FISHING_BOBBER = get("minecraft:fishing_bobber");
@Nullable public static final EntityType FURNACE_MINECART = get("minecraft:furnace_minecart");
@Nullable public static final EntityType GHAST = get("minecraft:ghast");
@Nullable public static final EntityType GIANT = get("minecraft:giant");
@Nullable public static final EntityType GUARDIAN = get("minecraft:guardian");
@Nullable public static final EntityType HOPPER_MINECART = get("minecraft:hopper_minecart");
@Nullable public static final EntityType HORSE = get("minecraft:horse");
@Nullable public static final EntityType HUSK = get("minecraft:husk");
@Nullable public static final EntityType ILLUSIONER = get("minecraft:illusioner");
@Nullable public static final EntityType IRON_GOLEM = get("minecraft:iron_golem");
@Nullable public static final EntityType ITEM = get("minecraft:item");
@Nullable public static final EntityType ITEM_FRAME = get("minecraft:item_frame");
@Nullable public static final EntityType LEASH_KNOT = get("minecraft:leash_knot");
@Nullable public static final EntityType LIGHTNING_BOLT = get("minecraft:lightning_bolt");
@Nullable public static final EntityType LLAMA = get("minecraft:llama");
@Nullable public static final EntityType LLAMA_SPIT = get("minecraft:llama_spit");
@Nullable public static final EntityType MAGMA_CUBE = get("minecraft:magma_cube");
@Nullable public static final EntityType MINECART = get("minecraft:minecart");
@Nullable public static final EntityType MOOSHROOM = get("minecraft:mooshroom");
@Nullable public static final EntityType MULE = get("minecraft:mule");
@Nullable public static final EntityType OCELOT = get("minecraft:ocelot");
@Nullable public static final EntityType PAINTING = get("minecraft:painting");
@Nullable public static final EntityType PARROT = get("minecraft:parrot");
@Nullable public static final EntityType PHANTOM = get("minecraft:phantom");
@Nullable public static final EntityType PIG = get("minecraft:pig");
@Nullable public static final EntityType PLAYER = get("minecraft:player");
@Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear");
@Nullable public static final EntityType POTION = get("minecraft:potion");
@Nullable public static final EntityType PUFFERFISH = get("minecraft:pufferfish");
@Nullable public static final EntityType RABBIT = get("minecraft:rabbit");
@Nullable public static final EntityType SALMON = get("minecraft:salmon");
@Nullable public static final EntityType SHEEP = get("minecraft:sheep");
@Nullable public static final EntityType SHULKER = get("minecraft:shulker");
@Nullable public static final EntityType SHULKER_BULLET = get("minecraft:shulker_bullet");
@Nullable public static final EntityType SILVERFISH = get("minecraft:silverfish");
@Nullable public static final EntityType SKELETON = get("minecraft:skeleton");
@Nullable public static final EntityType SKELETON_HORSE = get("minecraft:skeleton_horse");
@Nullable public static final EntityType SLIME = get("minecraft:slime");
@Nullable public static final EntityType SMALL_FIREBALL = get("minecraft:small_fireball");
@Nullable public static final EntityType SNOW_GOLEM = get("minecraft:snow_golem");
@Nullable public static final EntityType SNOWBALL = get("minecraft:snowball");
@Nullable public static final EntityType SPAWNER_MINECART = get("minecraft:spawner_minecart");
@Nullable public static final EntityType SPECTRAL_ARROW = get("minecraft:spectral_arrow");
@Nullable public static final EntityType SPIDER = get("minecraft:spider");
@Nullable public static final EntityType SQUID = get("minecraft:squid");
@Nullable public static final EntityType STRAY = get("minecraft:stray");
@Nullable public static final EntityType TNT = get("minecraft:tnt");
@Nullable public static final EntityType TNT_MINECART = get("minecraft:tnt_minecart");
@Nullable public static final EntityType TRIDENT = get("minecraft:trident");
@Nullable public static final EntityType TROPICAL_FISH = get("minecraft:tropical_fish");
@Nullable public static final EntityType TURTLE = get("minecraft:turtle");
@Nullable public static final EntityType VEX = get("minecraft:vex");
@Nullable public static final EntityType VILLAGER = get("minecraft:villager");
@Nullable public static final EntityType VINDICATOR = get("minecraft:vindicator");
@Nullable public static final EntityType WITCH = get("minecraft:witch");
@Nullable public static final EntityType WITHER = get("minecraft:wither");
@Nullable public static final EntityType WITHER_SKELETON = get("minecraft:wither_skeleton");
@Nullable public static final EntityType WITHER_SKULL = get("minecraft:wither_skull");
@Nullable public static final EntityType WOLF = get("minecraft:wolf");
@Nullable public static final EntityType ZOMBIE = get("minecraft:zombie");
@Nullable public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse");
@Nullable public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman");
@Nullable public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager");
private EntityTypes() {
}
private static EntityType register(final String id) {
return register(new EntityType(id));
}
public static EntityType register(final EntityType entityType) {
return EntityType.REGISTRY.register(entityType.getId(), entityType);
}
public static @Nullable EntityType get(final String id) {
return EntityType.REGISTRY.get(id);
}
@ -201,4 +193,4 @@ public class EntityTypes {
}
}
}
}