Add and apply .editorconfig from P2 (#1195)

* Consistenty use javax annotations.
 - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax
 - Cleaning up of import order in #1195
 - Must be merged before #1195

* Add and apply .editorconfig from P2
 - Does not rearrange entries

* Address some comments

* add back some javadoc comments

* Address final comments

Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
dordsor21
2021-07-24 16:34:05 +01:00
committed by GitHub
parent 3b4beba7d6
commit 8c0195970b
1143 changed files with 143599 additions and 9952 deletions

View File

@ -19,11 +19,11 @@
package com.sk89q.worldedit.world;
import com.fastasyncworldedit.core.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Platform;
import com.fastasyncworldedit.core.function.mask.BlockMaskBuilder;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2;
@ -37,9 +37,9 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import javax.annotation.Nullable;
import java.nio.file.Path;
import java.util.PriorityQueue;
import javax.annotation.Nullable;
/**
* An abstract implementation of {@link World}.
@ -164,6 +164,7 @@ public abstract class AbstractWorld implements World {
}
private class QueuedEffect implements Comparable<QueuedEffect> {
private final Vector3 position;
private final BlockType blockType;
private final double priority;
@ -183,6 +184,7 @@ public abstract class AbstractWorld implements World {
public int compareTo(@Nullable QueuedEffect other) {
return Double.compare(priority, other != null ? other.priority : 0);
}
}
}

View File

@ -29,11 +29,14 @@ import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
public interface DataFixer {
final class FixType<T> {
private FixType() {
}
}
final class FixTypes {
private FixTypes() {
}
@ -43,6 +46,7 @@ public interface DataFixer {
public static FixType<String> BLOCK_STATE = new FixType<>();
public static FixType<String> BIOME = new FixType<>();
public static FixType<String> ITEM_TYPE = new FixType<>();
}
default <T> T fixUp(FixType<T> type, T original) {
@ -50,4 +54,5 @@ public interface DataFixer {
}
<T> T fixUp(FixType<T> type, T original, int srcVer);
}

View File

@ -49,6 +49,7 @@ public interface NbtValued {
}
//FAWE start
/**
* Get the object's NBT data (tile entity data). The returned tag, if
* modified in any way, should be sent to {@link #setNbtData(CompoundTag)}
@ -89,12 +90,10 @@ public interface NbtValued {
* </p>
*
* @return compound tag, or null
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
* for details
*/
@NonAbstractForCompatibility(
delegateName = "getNbtData",
delegateParams = { }
delegateName = "getNbtData",
delegateParams = {}
)
@Nullable
default LazyReference<CompoundBinaryTag> getNbtReference() {
@ -108,8 +107,6 @@ public interface NbtValued {
* Get the object's NBT data (tile entity data).
*
* @return compound tag, or null
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
* for details
*/
@Nullable
default CompoundBinaryTag getNbt() {
@ -121,12 +118,10 @@ public interface NbtValued {
* Set the object's NBT data (tile entity data).
*
* @param nbtData NBT data, or null if no data
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
* for details
*/
@NonAbstractForCompatibility(
delegateName = "setNbtData",
delegateParams = { CompoundTag.class }
delegateName = "setNbtData",
delegateParams = {CompoundTag.class}
)
default void setNbtReference(@Nullable LazyReference<CompoundBinaryTag> nbtData) {
DeprecationUtil.checkDelegatingOverride(getClass());

View File

@ -48,10 +48,10 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
/**
* A null implementation of {@link World} that drops all changes and
@ -75,7 +75,8 @@ public class NullWorld extends AbstractWorld {
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws
WorldEditException {
return false;
}
@ -94,6 +95,7 @@ public class NullWorld extends AbstractWorld {
public boolean clearContainerBlockContents(BlockVector3 position) {
return false;
}
@Override
public boolean fullySupports3DBiomes() {
return false;
@ -240,6 +242,7 @@ public class NullWorld extends AbstractWorld {
}
@Override
public void flush() {}
public void flush() {
}
//FAWE end
}

View File

@ -24,8 +24,8 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType;
import java.util.OptionalLong;
import javax.annotation.Nullable;
import java.util.OptionalLong;
/**
* Regeneration options for {@link World#regenerate(Region, Extent, RegenOptions)}.
@ -73,8 +73,10 @@ public abstract class RegenOptions {
public abstract Builder regenBiomes(boolean regenBiomes);
//FAWE start
/**
* Defines the {@code BiomeType} the regenerator should use for regeneration. Defaults to {@code null}.
*
* @param biomeType the {@code BiomeType} to be used for regeneration
* @return this builder
*/
@ -112,7 +114,8 @@ public abstract class RegenOptions {
}
//FAWE start
@Nullable public abstract BiomeType getBiomeType();
@Nullable
public abstract BiomeType getBiomeType();
public boolean hasBiomeType() {
return getBiomeType() != null;

View File

@ -48,10 +48,10 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.weather.WeatherType;
import javax.annotation.Nullable;
import java.nio.file.Path;
import java.util.Locale;
import java.util.Set;
import javax.annotation.Nullable;
/**
* Represents a world (dimension).
@ -122,13 +122,14 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* <p>On implementations where the world is not simulated, the
* {@code notifyAndLight} parameter has no effect either way.</p>
*
* @param position position of the block
* @param block block to set
* @param position position of the block
* @param block block to set
* @param notifyAndLight true to to notify and light
* @return true if the block was successfully set (return value may not be accurate)
*/
@Deprecated
default <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
default <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws
WorldEditException {
return setBlock(position, block, notifyAndLight ? SideEffectSet.defaults() : SideEffectSet.none());
}
@ -142,18 +143,19 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* {@link Platform#getSupportedSideEffects()} for a list of supported side effects.
* Non-supported side effects will be ignored.</p>
*
* @param position position of the block
* @param block block to set
* @param position position of the block
* @param block block to set
* @param sideEffects which side effects to perform
* @return true if the block was successfully set (return value may not be accurate)
*/
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException;
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws
WorldEditException;
/**
* Notifies the simulation that the block at the given location has
* been changed and it must be re-lighted (and issue other events).
*
* @param position position of the block
* @param position position of the block
* @param previousType the type of the previous block that was there
* @return true if the block was successfully notified
*/
@ -165,12 +167,13 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
/**
* Applies a set of side effects on the given block.
*
* @param position position of the block
* @param previousType the type of the previous block that was there
* @param position position of the block
* @param previousType the type of the previous block that was there
* @param sideEffectSet which side effects to perform
* @return a set of side effects that were applied
*/
Set<SideEffect> applySideEffects(BlockVector3 position, BlockState previousType, SideEffectSet sideEffectSet) throws WorldEditException;
Set<SideEffect> applySideEffects(BlockVector3 position, BlockState previousType, SideEffectSet sideEffectSet) throws
WorldEditException;
/**
* Get the light level at the given block.
@ -194,8 +197,8 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* Drop an item at the given position.
*
* @param position the position
* @param item the item to drop
* @param count the number of individual stacks to drop (number of item entities)
* @param item the item to drop
* @param count the number of individual stacks to drop (number of item entities)
*/
void dropItem(Vector3 position, BaseItemStack item, int count);
@ -203,7 +206,7 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* Drop one stack of the item at the given position.
*
* @param position the position
* @param item the item to drop
* @param item the item to drop
* @see #dropItem(Vector3, BaseItemStack, int) shortcut method to specify the number of stacks
*/
void dropItem(Vector3 position, BaseItemStack item);
@ -218,7 +221,7 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
/**
* Gets whether the given {@link BlockState} can be placed here.
*
* @param position The position
* @param position The position
* @param blockState The blockstate
* @return If it can be placed
*/
@ -229,7 +232,7 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
/**
* Regenerate an area.
*
* @param region the region
* @param region the region
* @param editSession the {@link EditSession}
* @return true if re-generation was successful
*/
@ -251,16 +254,14 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
/**
* Regenerate an area.
*
* @param region the region
* @param extent the {@link Extent}
* @param region the region
* @param extent the {@link Extent}
* @param options the regeneration options
* @return true if regeneration was successful
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
* for details
*/
@NonAbstractForCompatibility(
delegateName = "regenerate",
delegateParams = { Region.class, EditSession.class }
delegateParams = {Region.class, EditSession.class}
)
default boolean regenerate(Region region, Extent extent, RegenOptions options) {
DeprecationUtil.checkDelegatingOverride(getClass());
@ -275,13 +276,14 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
/**
* Generate a tree at the given position.
*
* @param type the tree type
* @param type the tree type
* @param editSession the {@link EditSession}
* @param position the position
* @param position the position
* @return true if generation was successful
* @throws MaxChangedBlocksException thrown if too many blocks were changed
*/
boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException;
boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws
MaxChangedBlocksException;
/**
* Load the chunk at the given position if it isn't loaded.
@ -314,8 +316,8 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* Play the given effect.
*
* @param position the position
* @param type the effect type
* @param data the effect data
* @param type the effect type
* @param data the effect data
* @return true if the effect was played
*/
boolean playEffect(Vector3 position, int type, int data);
@ -323,10 +325,10 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
/**
* Queue a block break effect.
*
* @param server the server
* @param position the position
* @param server the server
* @param position the position
* @param blockType the block type
* @param priority the priority
* @param priority the priority
* @return true if the effect was played
*/
boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority);
@ -356,7 +358,7 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* Sets the weather type of the world.
*
* @param weatherType The weather type
* @param duration The duration of the weather
* @param duration The duration of the weather
*/
void setWeather(WeatherType weatherType, long duration);
@ -396,12 +398,14 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
/**
* Send a fake chunk to a player.
*
* @param player may be null to send to everyone
* @param packet the chunk packet
*/
void sendFakeChunk(@Nullable Player player, ChunkPacket packet);
@Override @Nullable
@Override
@Nullable
default BiomeType getBiome(BlockVector3 position) {
return null;
}

View File

@ -33,4 +33,5 @@ public class WorldUnloadedException extends WorldEditException {
public WorldUnloadedException() {
super(Caption.of("worldedit.error.world-unloaded"));
}
}

View File

@ -35,7 +35,7 @@ public interface BiomeData {
*
* @return the biome's name
* @deprecated This method does not work on the server.
* Use {@link BiomeRegistry#getRichName(BiomeType)}.
* Use {@link BiomeRegistry#getRichName(BiomeType)}.
*/
@Deprecated
String getName();

View File

@ -19,11 +19,11 @@
package com.sk89q.worldedit.world.biome;
import com.fastasyncworldedit.core.registry.RegistryItem;
import com.sk89q.worldedit.function.pattern.BiomePattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.fastasyncworldedit.core.registry.RegistryItem;
/**
* All the types of biomes in the game.
@ -93,4 +93,5 @@ public class BiomeType implements RegistryItem, Keyed, BiomePattern {
public BiomeType applyBiome(BlockVector3 position) {
return this;
}
}

View File

@ -19,8 +19,8 @@
package com.sk89q.worldedit.world.biome;
import java.util.Collection;
import javax.annotation.Nullable;
import java.util.Collection;
/**
* Stores a list of common {@link BiomeType BiomeTypes}.
@ -29,88 +29,172 @@ import javax.annotation.Nullable;
*/
@SuppressWarnings("unused")
public final class BiomeTypes {
@Nullable public static final BiomeType BADLANDS = get("minecraft:badlands");
@Nullable public static final BiomeType BADLANDS_PLATEAU = get("minecraft:badlands_plateau");
@Nullable public static final BiomeType BAMBOO_JUNGLE = get("minecraft:bamboo_jungle");
@Nullable public static final BiomeType BAMBOO_JUNGLE_HILLS = get("minecraft:bamboo_jungle_hills");
@Nullable public static final BiomeType BASALT_DELTAS = get("minecraft:basalt_deltas");
@Nullable public static final BiomeType BEACH = get("minecraft:beach");
@Nullable public static final BiomeType BIRCH_FOREST = get("minecraft:birch_forest");
@Nullable public static final BiomeType BIRCH_FOREST_HILLS = get("minecraft:birch_forest_hills");
@Nullable public static final BiomeType COLD_OCEAN = get("minecraft:cold_ocean");
@Nullable public static final BiomeType CRIMSON_FOREST = get("minecraft:crimson_forest");
@Nullable public static final BiomeType DARK_FOREST = get("minecraft:dark_forest");
@Nullable public static final BiomeType DARK_FOREST_HILLS = get("minecraft:dark_forest_hills");
@Nullable public static final BiomeType DEEP_COLD_OCEAN = get("minecraft:deep_cold_ocean");
@Nullable public static final BiomeType DEEP_FROZEN_OCEAN = get("minecraft:deep_frozen_ocean");
@Nullable public static final BiomeType DEEP_LUKEWARM_OCEAN = get("minecraft:deep_lukewarm_ocean");
@Nullable public static final BiomeType DEEP_OCEAN = get("minecraft:deep_ocean");
@Nullable public static final BiomeType DEEP_WARM_OCEAN = get("minecraft:deep_warm_ocean");
@Nullable public static final BiomeType DESERT = get("minecraft:desert");
@Nullable public static final BiomeType DESERT_HILLS = get("minecraft:desert_hills");
@Nullable public static final BiomeType DESERT_LAKES = get("minecraft:desert_lakes");
@Nullable public static final BiomeType DRIPSTONE_CAVES = get("minecraft:dripstone_caves");
@Nullable public static final BiomeType END_BARRENS = get("minecraft:end_barrens");
@Nullable public static final BiomeType END_HIGHLANDS = get("minecraft:end_highlands");
@Nullable public static final BiomeType END_MIDLANDS = get("minecraft:end_midlands");
@Nullable public static final BiomeType ERODED_BADLANDS = get("minecraft:eroded_badlands");
@Nullable public static final BiomeType FLOWER_FOREST = get("minecraft:flower_forest");
@Nullable public static final BiomeType FOREST = get("minecraft:forest");
@Nullable public static final BiomeType FROZEN_OCEAN = get("minecraft:frozen_ocean");
@Nullable public static final BiomeType FROZEN_RIVER = get("minecraft:frozen_river");
@Nullable public static final BiomeType GIANT_SPRUCE_TAIGA = get("minecraft:giant_spruce_taiga");
@Nullable public static final BiomeType GIANT_SPRUCE_TAIGA_HILLS = get("minecraft:giant_spruce_taiga_hills");
@Nullable public static final BiomeType GIANT_TREE_TAIGA = get("minecraft:giant_tree_taiga");
@Nullable public static final BiomeType GIANT_TREE_TAIGA_HILLS = get("minecraft:giant_tree_taiga_hills");
@Nullable public static final BiomeType GRAVELLY_MOUNTAINS = get("minecraft:gravelly_mountains");
@Nullable public static final BiomeType ICE_SPIKES = get("minecraft:ice_spikes");
@Nullable public static final BiomeType JUNGLE = get("minecraft:jungle");
@Nullable public static final BiomeType JUNGLE_EDGE = get("minecraft:jungle_edge");
@Nullable public static final BiomeType JUNGLE_HILLS = get("minecraft:jungle_hills");
@Nullable public static final BiomeType LUKEWARM_OCEAN = get("minecraft:lukewarm_ocean");
@Nullable public static final BiomeType LUSH_CAVES = get("minecraft:lush_caves");
@Nullable public static final BiomeType MODIFIED_BADLANDS_PLATEAU = get("minecraft:modified_badlands_plateau");
@Nullable public static final BiomeType MODIFIED_GRAVELLY_MOUNTAINS = get("minecraft:modified_gravelly_mountains");
@Nullable public static final BiomeType MODIFIED_JUNGLE = get("minecraft:modified_jungle");
@Nullable public static final BiomeType MODIFIED_JUNGLE_EDGE = get("minecraft:modified_jungle_edge");
@Nullable public static final BiomeType MODIFIED_WOODED_BADLANDS_PLATEAU = get("minecraft:modified_wooded_badlands_plateau");
@Nullable public static final BiomeType MOUNTAIN_EDGE = get("minecraft:mountain_edge");
@Nullable public static final BiomeType MOUNTAINS = get("minecraft:mountains");
@Nullable public static final BiomeType MUSHROOM_FIELD_SHORE = get("minecraft:mushroom_field_shore");
@Nullable public static final BiomeType MUSHROOM_FIELDS = get("minecraft:mushroom_fields");
@Nullable @Deprecated public static final BiomeType NETHER = get("minecraft:nether");
@Nullable public static final BiomeType NETHER_WASTES = get("minecraft:nether_wastes");
@Nullable public static final BiomeType OCEAN = get("minecraft:ocean");
@Nullable public static final BiomeType PLAINS = get("minecraft:plains");
@Nullable public static final BiomeType RIVER = get("minecraft:river");
@Nullable public static final BiomeType SAVANNA = get("minecraft:savanna");
@Nullable public static final BiomeType SAVANNA_PLATEAU = get("minecraft:savanna_plateau");
@Nullable public static final BiomeType SHATTERED_SAVANNA = get("minecraft:shattered_savanna");
@Nullable public static final BiomeType SHATTERED_SAVANNA_PLATEAU = get("minecraft:shattered_savanna_plateau");
@Nullable public static final BiomeType SMALL_END_ISLANDS = get("minecraft:small_end_islands");
@Nullable public static final BiomeType SNOWY_BEACH = get("minecraft:snowy_beach");
@Nullable public static final BiomeType SNOWY_MOUNTAINS = get("minecraft:snowy_mountains");
@Nullable public static final BiomeType SNOWY_TAIGA = get("minecraft:snowy_taiga");
@Nullable public static final BiomeType SNOWY_TAIGA_HILLS = get("minecraft:snowy_taiga_hills");
@Nullable public static final BiomeType SNOWY_TAIGA_MOUNTAINS = get("minecraft:snowy_taiga_mountains");
@Nullable public static final BiomeType SNOWY_TUNDRA = get("minecraft:snowy_tundra");
@Nullable public static final BiomeType SOUL_SAND_VALLEY = get("minecraft:soul_sand_valley");
@Nullable public static final BiomeType STONE_SHORE = get("minecraft:stone_shore");
@Nullable public static final BiomeType SUNFLOWER_PLAINS = get("minecraft:sunflower_plains");
@Nullable public static final BiomeType SWAMP = get("minecraft:swamp");
@Nullable public static final BiomeType SWAMP_HILLS = get("minecraft:swamp_hills");
@Nullable public static final BiomeType TAIGA = get("minecraft:taiga");
@Nullable public static final BiomeType TAIGA_HILLS = get("minecraft:taiga_hills");
@Nullable public static final BiomeType TAIGA_MOUNTAINS = get("minecraft:taiga_mountains");
@Nullable public static final BiomeType TALL_BIRCH_FOREST = get("minecraft:tall_birch_forest");
@Nullable public static final BiomeType TALL_BIRCH_HILLS = get("minecraft:tall_birch_hills");
@Nullable public static final BiomeType THE_END = get("minecraft:the_end");
@Nullable public static final BiomeType THE_VOID = get("minecraft:the_void");
@Nullable public static final BiomeType WARM_OCEAN = get("minecraft:warm_ocean");
@Nullable public static final BiomeType WARPED_FOREST = get("minecraft:warped_forest");
@Nullable public static final BiomeType WOODED_BADLANDS_PLATEAU = get("minecraft:wooded_badlands_plateau");
@Nullable public static final BiomeType WOODED_HILLS = get("minecraft:wooded_hills");
@Nullable public static final BiomeType WOODED_MOUNTAINS = get("minecraft:wooded_mountains");
@Nullable
public static final BiomeType BADLANDS = get("minecraft:badlands");
@Nullable
public static final BiomeType BADLANDS_PLATEAU = get("minecraft:badlands_plateau");
@Nullable
public static final BiomeType BAMBOO_JUNGLE = get("minecraft:bamboo_jungle");
@Nullable
public static final BiomeType BAMBOO_JUNGLE_HILLS = get("minecraft:bamboo_jungle_hills");
@Nullable
public static final BiomeType BASALT_DELTAS = get("minecraft:basalt_deltas");
@Nullable
public static final BiomeType BEACH = get("minecraft:beach");
@Nullable
public static final BiomeType BIRCH_FOREST = get("minecraft:birch_forest");
@Nullable
public static final BiomeType BIRCH_FOREST_HILLS = get("minecraft:birch_forest_hills");
@Nullable
public static final BiomeType COLD_OCEAN = get("minecraft:cold_ocean");
@Nullable
public static final BiomeType CRIMSON_FOREST = get("minecraft:crimson_forest");
@Nullable
public static final BiomeType DARK_FOREST = get("minecraft:dark_forest");
@Nullable
public static final BiomeType DARK_FOREST_HILLS = get("minecraft:dark_forest_hills");
@Nullable
public static final BiomeType DEEP_COLD_OCEAN = get("minecraft:deep_cold_ocean");
@Nullable
public static final BiomeType DEEP_FROZEN_OCEAN = get("minecraft:deep_frozen_ocean");
@Nullable
public static final BiomeType DEEP_LUKEWARM_OCEAN = get("minecraft:deep_lukewarm_ocean");
@Nullable
public static final BiomeType DEEP_OCEAN = get("minecraft:deep_ocean");
@Nullable
public static final BiomeType DEEP_WARM_OCEAN = get("minecraft:deep_warm_ocean");
@Nullable
public static final BiomeType DESERT = get("minecraft:desert");
@Nullable
public static final BiomeType DESERT_HILLS = get("minecraft:desert_hills");
@Nullable
public static final BiomeType DESERT_LAKES = get("minecraft:desert_lakes");
@Nullable
public static final BiomeType DRIPSTONE_CAVES = get("minecraft:dripstone_caves");
@Nullable
public static final BiomeType END_BARRENS = get("minecraft:end_barrens");
@Nullable
public static final BiomeType END_HIGHLANDS = get("minecraft:end_highlands");
@Nullable
public static final BiomeType END_MIDLANDS = get("minecraft:end_midlands");
@Nullable
public static final BiomeType ERODED_BADLANDS = get("minecraft:eroded_badlands");
@Nullable
public static final BiomeType FLOWER_FOREST = get("minecraft:flower_forest");
@Nullable
public static final BiomeType FOREST = get("minecraft:forest");
@Nullable
public static final BiomeType FROZEN_OCEAN = get("minecraft:frozen_ocean");
@Nullable
public static final BiomeType FROZEN_RIVER = get("minecraft:frozen_river");
@Nullable
public static final BiomeType GIANT_SPRUCE_TAIGA = get("minecraft:giant_spruce_taiga");
@Nullable
public static final BiomeType GIANT_SPRUCE_TAIGA_HILLS = get("minecraft:giant_spruce_taiga_hills");
@Nullable
public static final BiomeType GIANT_TREE_TAIGA = get("minecraft:giant_tree_taiga");
@Nullable
public static final BiomeType GIANT_TREE_TAIGA_HILLS = get("minecraft:giant_tree_taiga_hills");
@Nullable
public static final BiomeType GRAVELLY_MOUNTAINS = get("minecraft:gravelly_mountains");
@Nullable
public static final BiomeType ICE_SPIKES = get("minecraft:ice_spikes");
@Nullable
public static final BiomeType JUNGLE = get("minecraft:jungle");
@Nullable
public static final BiomeType JUNGLE_EDGE = get("minecraft:jungle_edge");
@Nullable
public static final BiomeType JUNGLE_HILLS = get("minecraft:jungle_hills");
@Nullable
public static final BiomeType LUKEWARM_OCEAN = get("minecraft:lukewarm_ocean");
@Nullable
public static final BiomeType LUSH_CAVES = get("minecraft:lush_caves");
@Nullable
public static final BiomeType MODIFIED_BADLANDS_PLATEAU = get("minecraft:modified_badlands_plateau");
@Nullable
public static final BiomeType MODIFIED_GRAVELLY_MOUNTAINS = get("minecraft:modified_gravelly_mountains");
@Nullable
public static final BiomeType MODIFIED_JUNGLE = get("minecraft:modified_jungle");
@Nullable
public static final BiomeType MODIFIED_JUNGLE_EDGE = get("minecraft:modified_jungle_edge");
@Nullable
public static final BiomeType MODIFIED_WOODED_BADLANDS_PLATEAU = get("minecraft:modified_wooded_badlands_plateau");
@Nullable
public static final BiomeType MOUNTAIN_EDGE = get("minecraft:mountain_edge");
@Nullable
public static final BiomeType MOUNTAINS = get("minecraft:mountains");
@Nullable
public static final BiomeType MUSHROOM_FIELD_SHORE = get("minecraft:mushroom_field_shore");
@Nullable
public static final BiomeType MUSHROOM_FIELDS = get("minecraft:mushroom_fields");
@Nullable
@Deprecated
public static final BiomeType NETHER = get("minecraft:nether");
@Nullable
public static final BiomeType NETHER_WASTES = get("minecraft:nether_wastes");
@Nullable
public static final BiomeType OCEAN = get("minecraft:ocean");
@Nullable
public static final BiomeType PLAINS = get("minecraft:plains");
@Nullable
public static final BiomeType RIVER = get("minecraft:river");
@Nullable
public static final BiomeType SAVANNA = get("minecraft:savanna");
@Nullable
public static final BiomeType SAVANNA_PLATEAU = get("minecraft:savanna_plateau");
@Nullable
public static final BiomeType SHATTERED_SAVANNA = get("minecraft:shattered_savanna");
@Nullable
public static final BiomeType SHATTERED_SAVANNA_PLATEAU = get("minecraft:shattered_savanna_plateau");
@Nullable
public static final BiomeType SMALL_END_ISLANDS = get("minecraft:small_end_islands");
@Nullable
public static final BiomeType SNOWY_BEACH = get("minecraft:snowy_beach");
@Nullable
public static final BiomeType SNOWY_MOUNTAINS = get("minecraft:snowy_mountains");
@Nullable
public static final BiomeType SNOWY_TAIGA = get("minecraft:snowy_taiga");
@Nullable
public static final BiomeType SNOWY_TAIGA_HILLS = get("minecraft:snowy_taiga_hills");
@Nullable
public static final BiomeType SNOWY_TAIGA_MOUNTAINS = get("minecraft:snowy_taiga_mountains");
@Nullable
public static final BiomeType SNOWY_TUNDRA = get("minecraft:snowy_tundra");
@Nullable
public static final BiomeType SOUL_SAND_VALLEY = get("minecraft:soul_sand_valley");
@Nullable
public static final BiomeType STONE_SHORE = get("minecraft:stone_shore");
@Nullable
public static final BiomeType SUNFLOWER_PLAINS = get("minecraft:sunflower_plains");
@Nullable
public static final BiomeType SWAMP = get("minecraft:swamp");
@Nullable
public static final BiomeType SWAMP_HILLS = get("minecraft:swamp_hills");
@Nullable
public static final BiomeType TAIGA = get("minecraft:taiga");
@Nullable
public static final BiomeType TAIGA_HILLS = get("minecraft:taiga_hills");
@Nullable
public static final BiomeType TAIGA_MOUNTAINS = get("minecraft:taiga_mountains");
@Nullable
public static final BiomeType TALL_BIRCH_FOREST = get("minecraft:tall_birch_forest");
@Nullable
public static final BiomeType TALL_BIRCH_HILLS = get("minecraft:tall_birch_hills");
@Nullable
public static final BiomeType THE_END = get("minecraft:the_end");
@Nullable
public static final BiomeType THE_VOID = get("minecraft:the_void");
@Nullable
public static final BiomeType WARM_OCEAN = get("minecraft:warm_ocean");
@Nullable
public static final BiomeType WARPED_FOREST = get("minecraft:warped_forest");
@Nullable
public static final BiomeType WOODED_BADLANDS_PLATEAU = get("minecraft:wooded_badlands_plateau");
@Nullable
public static final BiomeType WOODED_HILLS = get("minecraft:wooded_hills");
@Nullable
public static final BiomeType WOODED_MOUNTAINS = get("minecraft:wooded_mountains");
private BiomeTypes() {
}

View File

@ -25,10 +25,10 @@ import com.sk89q.worldedit.util.WeightedChoice.Choice;
import com.sk89q.worldedit.util.function.LevenshteinDistance;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Function;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
@ -46,8 +46,8 @@ public final class Biomes {
/**
* Find a biome that matches the given input name.
*
* @param biomes a list of biomes
* @param name the name to test
* @param biomes a list of biomes
* @param name the name to test
* @param registry a biome registry
* @return a biome or null
* @deprecated This uses the outdated name system. Find names by comparing with their ID instead.

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
@ -27,17 +28,16 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.OutputExtent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.TagStringIO;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
@ -59,10 +59,12 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
//FAWE end
//FAWE start
/**
* Construct a block with the given type and default data.
* @deprecated Just use the BlockType.getDefaultState()
*
* @param blockType The block type
* @deprecated Just use the BlockType.getDefaultState()
*/
@Deprecated
public BaseBlock(BlockType blockType) {
@ -71,6 +73,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
//FAWE end
//FAWE start - made public from protected
/**
* Construct a block with a state.
*
@ -83,10 +86,11 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
//FAWE end
//FAWE start - deprecated upstream method and replaced CompoundTag with LR
/**
* Construct a block with the given ID, data value and NBT data structure.
*
* @param state The block state
* @param state The block state
* @param nbtData NBT data, which must be provided
*/
@Deprecated
@ -99,7 +103,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
/**
* Construct a block with the given ID, data value and NBT data structure.
*
* @param state The block state
* @param state The block state
* @param nbtData NBT data, which must be provided
*/
protected BaseBlock(BlockState state, LazyReference<CompoundBinaryTag> nbtData) {
@ -109,10 +113,11 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
}
//FAWE start
/**
* Construct a block with the given ID and data value.
*
* @param id ID value
* @param id ID value
* @param data data value
*/
@Deprecated

View File

@ -26,6 +26,7 @@ package com.sk89q.worldedit.world.block;
*/
@SuppressWarnings("unused")
public final class BlockCategories {
public static final BlockCategory ACACIA_LOGS = get("minecraft:acacia_logs");
public static final BlockCategory ANVIL = get("minecraft:anvil");
public static final BlockCategory BAMBOO_PLANTABLE_ON = get("minecraft:bamboo_plantable_on");
@ -57,7 +58,8 @@ public final class BlockCategories {
public static final BlockCategory DEEPSLATE_ORE_REPLACEABLES = get("minecraft:deepslate_ore_replaceables");
public static final BlockCategory DIAMOND_ORES = get("minecraft:diamond_ores");
public static final BlockCategory DIRT = get("minecraft:dirt");
@Deprecated public static final BlockCategory DIRT_LIKE = get("minecraft:dirt_like");
@Deprecated
public static final BlockCategory DIRT_LIKE = get("minecraft:dirt_like");
public static final BlockCategory DOORS = get("minecraft:doors");
public static final BlockCategory DRAGON_IMMUNE = get("minecraft:dragon_immune");
public static final BlockCategory DRIPSTONE_REPLACEABLE_BLOCKS = get("minecraft:dripstone_replaceable_blocks");
@ -163,4 +165,5 @@ public final class BlockCategories {
}
return entry;
}
}

View File

@ -32,6 +32,7 @@ import java.util.Set;
* blocks such as wool into separate ids.
*/
public class BlockCategory extends Category<BlockType> implements Keyed {
//FAWE start
private boolean[] flatMap;
//FAWE end
@ -73,4 +74,5 @@ public class BlockCategory extends Category<BlockType> implements Keyed {
return flatMap.length > typeId && flatMap[typeId];
//FAWE end
}
}

View File

@ -19,8 +19,10 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.queue.ITileInput;
import com.fastasyncworldedit.core.command.SuggestInputParseException;
import com.fastasyncworldedit.core.function.mask.SingleBlockStateMask;
import com.fastasyncworldedit.core.queue.ITileInput;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.fastasyncworldedit.core.util.MutableCharSequence;
import com.fastasyncworldedit.core.util.StringMan;
import com.fastasyncworldedit.core.world.block.BlanketBaseBlock;
@ -36,23 +38,21 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.extent.OutputExtent;
import com.sk89q.worldedit.function.mask.Mask;
import com.fastasyncworldedit.core.function.mask.SingleBlockStateMask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import javax.annotation.Nonnull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
/**
* An immutable class that represents the state a block can be in.
@ -89,8 +89,9 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
/**
* Returns a temporary BlockState for a given internal id.
* @deprecated Magic Numbers
*
* @return BlockState
* @deprecated Magic Numbers
*/
@Deprecated
public static BlockState getFromInternalId(int combinedId) throws InputParseException {
@ -104,6 +105,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
/**
* Returns a temporary BlockState for a given type and string.
*
* @param state String e.g., minecraft:water[level=4]
* @return BlockState
*/
@ -116,7 +118,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
*
* <p>It's faster if a BlockType is provided compared to parsing the string.</p>
*
* @param type BlockType e.g., BlockTypes.STONE (or null)
* @param type BlockType e.g., BlockTypes.STONE (or null)
* @param state String e.g., minecraft:water[level=4]
* @return BlockState
*/
@ -129,7 +131,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
*
* <p>It's faster if a BlockType is provided compared to parsing the string.</p>
*
* @param type BlockType e.g., BlockTypes.STONE (or null)
* @param type BlockType e.g., BlockTypes.STONE (or null)
* @param state String e.g., minecraft:water[level=4]
* @return BlockState
*/
@ -148,7 +150,8 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
type = BlockTypes.get(key);
if (type == null) {
String input = key.toString();
throw new SuggestInputParseException("Does not match a valid block type: " + input, input, () -> Stream.of(BlockTypesCache.values)
throw new SuggestInputParseException("Does not match a valid block type: " + input, input, () -> Stream.of(
BlockTypesCache.values)
.filter(b -> StringMan.blockStateMatches(input, b.getId()))
.map(BlockType::getId)
.sorted(StringMan.blockStateComparator(input))
@ -207,14 +210,22 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
// Suggest property
String input = charSequence.toString();
BlockType finalType = type;
throw new SuggestInputParseException("Invalid property " + key + ":" + input + " for type " + type, input, () ->
finalType.getProperties().stream()
.map(Property::getName)
.filter(p -> StringMan.blockStateMatches(input, p))
.sorted(StringMan.blockStateComparator(input))
.collect(Collectors.toList()));
throw new SuggestInputParseException(
"Invalid property " + key + ":" + input + " for type " + type,
input,
() ->
finalType.getProperties().stream()
.map(Property::getName)
.filter(p -> StringMan.blockStateMatches(input, p))
.sorted(StringMan.blockStateComparator(input))
.collect(Collectors.toList())
);
} else {
throw new SuggestInputParseException("No operator for " + state, "", () -> Collections.singletonList("="));
throw new SuggestInputParseException(
"No operator for " + state,
"",
() -> Collections.singletonList("=")
);
}
}
property = null;
@ -319,7 +330,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
return this;
}
BlockState newState = this;
for (Property<?> prop: ot.getProperties()) {
for (Property<?> prop : ot.getProperties()) {
PropertyKey key = prop.getKey();
if (blockType.hasProperty(key)) {
newState = newState.with(key, other.getState(key));
@ -396,7 +407,13 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
if (blockType == BlockTypes.__RESERVED__) {
return this.material = blockType.getMaterial();
}
this.material = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this);
this.material = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.GAME_HOOKS)
.getRegistries()
.getBlockRegistry()
.getMaterial(this);
if (this.material.hasContainer()) {
this.compoundInput = CompoundInput.CONTAINER;
}

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.queue.ITileInput;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.blocks.TileEntityBlock;
import com.sk89q.worldedit.extent.OutputExtent;
@ -28,10 +29,9 @@ import com.sk89q.worldedit.internal.util.DeprecationUtil;
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import java.util.Locale;
import java.util.Map;
@ -49,6 +49,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
BlockType getBlockType();
//FAWE start
/**
* Magic number (legacy uses).
*/
@ -86,7 +87,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
* Returns a BlockState with the given state and value applied.
*
* @param property The state
* @param value The value
* @param value The value
* @return The modified state, or same if could not be applied
*/
<V> B with(final Property<V> property, final V value);
@ -95,7 +96,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
* Returns a BlockStateHolder with the given state and value applied.
*
* @param property The property key
* @param value The value
* @param value The value
* @return The modified state, or same if could not be applied
*/
<V> B with(final PropertyKey property, final V value);
@ -146,6 +147,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
BaseBlock toBaseBlock();
//FAWE start
/**
* Gets a {@link BaseBlock} from this BlockStateHolder.
*
@ -167,8 +169,8 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
* for details
*/
@NonAbstractForCompatibility(
delegateName = "toBaseBlock",
delegateParams = { CompoundTag.class }
delegateName = "toBaseBlock",
delegateParams = {CompoundTag.class}
)
default BaseBlock toBaseBlock(LazyReference<CompoundBinaryTag> compoundTag) {
DeprecationUtil.checkDelegatingOverride(getClass());
@ -203,11 +205,12 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
return this.getBlockType().getId();
} else {
String properties = getStates().entrySet().stream()
.map(entry -> entry.getKey().getName()
+ "="
+ entry.getValue().toString().toLowerCase(Locale.ROOT))
.collect(Collectors.joining(","));
.map(entry -> entry.getKey().getName()
+ "="
+ entry.getValue().toString().toLowerCase(Locale.ROOT))
.collect(Collectors.joining(","));
return this.getBlockType().getId() + "[" + properties + "]";
}
}
}

View File

@ -19,12 +19,13 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;
import com.fastasyncworldedit.core.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.BlockVector3;
@ -32,7 +33,6 @@ import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.item.ItemType;
@ -41,6 +41,7 @@ import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -48,7 +49,6 @@ import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkArgument;
@ -62,7 +62,7 @@ public class BlockType implements Keyed, Pattern {
private final String id;
private final BlockTypesCache.Settings settings;
private final LazyReference<FuzzyBlockState> emptyFuzzy
= LazyReference.from(() -> new FuzzyBlockState(this));
= LazyReference.from(() -> new FuzzyBlockState(this));
//FAWE start
private final LazyReference<Integer> legacyId = LazyReference.from(() -> computeLegacy(0));
@ -106,7 +106,7 @@ public class BlockType implements Keyed, Pattern {
public Component getRichName() {
return WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getBlockRegistry().getRichName(this);
.getRegistries().getBlockRegistry().getRichName(this);
}
//FAWE start
@ -148,12 +148,20 @@ public class BlockType implements Keyed, Pattern {
if (settings.stateOrdinals == null) {
return settings.defaultState;
} else if (propertyId >= settings.stateOrdinals.length || propertyId < 0) {
LOGGER.error("Attempted to load blockstate with id {} of type {} outside of state ordinals length. Using default state.", propertyId, getId());
LOGGER.error(
"Attempted to load blockstate with id {} of type {} outside of state ordinals length. Using default state.",
propertyId,
getId()
);
return settings.defaultState;
}
int ordinal = settings.stateOrdinals[propertyId];
if (ordinal >= BlockTypesCache.states.length || ordinal < 0) {
LOGGER.error("Attempted to load blockstate with ordinal {} of type {} outside of states length. Using default state. Using default state.", ordinal, getId());
LOGGER.error(
"Attempted to load blockstate with ordinal {} of type {} outside of states length. Using default state. Using default state.",
ordinal,
getId()
);
return settings.defaultState;
}
return BlockTypesCache.states[ordinal];
@ -244,7 +252,8 @@ public class BlockType implements Keyed, Pattern {
if (settings.stateOrdinals == null) {
return Collections.singletonList(getDefaultState());
}
return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> BlockTypesCache.states[i]).collect(Collectors.toList());
return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> BlockTypesCache.states[i]).collect(
Collectors.toList());
//FAWE end
}
@ -311,7 +320,7 @@ public class BlockType implements Keyed, Pattern {
/**
* Gets the legacy ID. Needed for legacy reasons.
*
* <p>
* DO NOT USE THIS.
*
* @return legacy id or 0, if unknown
@ -326,7 +335,7 @@ public class BlockType implements Keyed, Pattern {
/**
* Gets the legacy data. Needed for legacy reasons.
*
* <p>
* DO NOT USE THIS.
*
* @return legacy data or 0, if unknown
@ -364,6 +373,7 @@ public class BlockType implements Keyed, Pattern {
}
//FAWE start
/**
* The internal index of this type.
*

View File

@ -1,5 +1,6 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.fastasyncworldedit.core.util.MathMan;
import com.fastasyncworldedit.core.world.block.BlockID;
import com.google.common.primitives.Booleans;
@ -9,7 +10,6 @@ import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BlockRegistry;
import com.sk89q.worldedit.world.registry.Registries;
@ -20,8 +20,8 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -29,12 +29,14 @@ import java.util.Set;
import java.util.stream.Collectors;
public class BlockTypesCache {
/*
-----------------------------------------------------
Settings
-----------------------------------------------------
*/
protected static final class Settings {
protected final int internalId;
protected final BlockState defaultState;
protected final AbstractProperty<?>[] propertiesMapArr;
@ -55,7 +57,8 @@ public class BlockTypesCache {
}
int maxInternalStateId = 0;
Map<String, ? extends Property<?>> properties = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getProperties(type);
Map<String, ? extends Property<?>> properties = WorldEdit.getInstance().getPlatformManager().queryCapability(
Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getProperties(type);
if (!properties.isEmpty()) {
// Ensure the properties are registered
int maxOrdinal = 0;
@ -91,7 +94,13 @@ public class BlockTypesCache {
}
this.permutations = maxInternalStateId;
this.blockMaterial = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(type);
this.blockMaterial = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.GAME_HOOKS)
.getRegistries()
.getBlockRegistry()
.getMaterial(type);
if (!propertiesList.isEmpty()) {
this.stateOrdinals = generateStateOrdinals(internalId, states.size(), maxInternalStateId, propertiesList);
@ -101,8 +110,13 @@ public class BlockTypesCache {
if (ordinal != -1) {
int stateId = internalId + (propId << BIT_OFFSET);
CompoundTag defaultNBT = blockMaterial.getDefaultTile();
BlockState state = defaultNBT != null ? new BlockState(type, stateId, ordinal, blockMaterial.getDefaultTile()) :
new BlockState(type, stateId, ordinal);
BlockState state = defaultNBT != null ? new BlockState(
type,
stateId,
ordinal,
blockMaterial.getDefaultTile()
) :
new BlockState(type, stateId, ordinal);
states.add(state);
}
}
@ -111,8 +125,13 @@ public class BlockTypesCache {
this.defaultState = states.get(this.stateOrdinals[defaultPropId]);
} else {
CompoundTag defaultNBT = blockMaterial.getDefaultTile();
this.defaultState = defaultNBT != null ? new BlockState(type, internalId, states.size(), blockMaterial.getDefaultTile()) :
new BlockState(type, internalId, states.size());
this.defaultState = defaultNBT != null ? new BlockState(
type,
internalId,
states.size(),
blockMaterial.getDefaultTile()
) :
new BlockState(type, internalId, states.size());
states.add(this.defaultState);
}
}
@ -128,6 +147,7 @@ public class BlockTypesCache {
}
return id;
}
}
@ -192,7 +212,9 @@ public class BlockTypesCache {
Registries registries = platform.getRegistries();
BlockRegistry blockReg = registries.getBlockRegistry();
Collection<String> blocks = blockReg.values();
Map<String, String> blockMap = blocks.stream().collect(Collectors.toMap(item -> item.charAt(item.length() - 1) == ']' ? item.substring(0, item.indexOf('[')) : item, item -> item));
Map<String, String> blockMap = blocks.stream().collect(Collectors.toMap(item -> item.charAt(item.length() - 1) == ']'
? item.substring(0, item.indexOf('['))
: item, item -> item));
int size = blockMap.size() + 1;
Field[] idFields = BlockID.class.getDeclaredFields();
@ -230,7 +252,6 @@ public class BlockTypesCache {
String defaultState = entry.getValue();
// Skip already registered ids
for (; values[internalId] != null; internalId++) {
;
}
BlockType type = register(defaultState, internalId, stateList, tickList);
values[internalId] = type;
@ -265,4 +286,5 @@ public class BlockTypesCache {
$NAMESPACES.add(nameSpace);
return existing;
}
}

View File

@ -19,9 +19,9 @@
package com.sk89q.worldedit.world.block;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.registry.state.Property;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import java.util.Collections;
import java.util.HashMap;
@ -101,7 +101,8 @@ public class FuzzyBlockState extends BlockState {
return true;
}
@Override public BaseBlock toBaseBlock() {
@Override
public BaseBlock toBaseBlock() {
if (props == null || props.isEmpty()) {
return super.toBaseBlock();
}
@ -144,6 +145,7 @@ public class FuzzyBlockState extends BlockState {
* Builder for FuzzyBlockState
*/
public static class Builder {
private BlockType type;
private final Map<Property<?>, Object> values = new HashMap<>();
@ -175,8 +177,8 @@ public class FuzzyBlockState extends BlockState {
* Adds a property to the fuzzy BlockState
*
* @param property The property
* @param value The value
* @param <V> The property type
* @param value The value
* @param <V> The property type
* @return The builder, for chaining
*/
public <V> Builder withProperty(Property<V> property, V value) {
@ -211,5 +213,7 @@ public class FuzzyBlockState extends BlockState {
this.values.clear();
return this;
}
}
}

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.chunk;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.math.BlockVector3;
@ -27,7 +28,6 @@ import com.sk89q.worldedit.util.nbt.BinaryTagTypes;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.IntBinaryTag;
import com.sk89q.worldedit.util.nbt.ListBinaryTag;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -35,9 +35,9 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.storage.InvalidFormatException;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
public class AnvilChunk implements Chunk {
@ -54,6 +54,7 @@ public class AnvilChunk implements Chunk {
//FAWE start
/**
* Construct the chunk with a compound tag.
*
@ -102,14 +103,17 @@ public class AnvilChunk implements Chunk {
}
blocks[y] = NbtUtils.getChildTag(sectionTag,
"Blocks", BinaryTagTypes.BYTE_ARRAY).value();
"Blocks", BinaryTagTypes.BYTE_ARRAY
).value();
data[y] = NbtUtils.getChildTag(sectionTag, "Data",
BinaryTagTypes.BYTE_ARRAY).value();
BinaryTagTypes.BYTE_ARRAY
).value();
// 4096 ID block support
if (sectionTag.get("Add") != null) {
blocksAdd[y] = NbtUtils.getChildTag(sectionTag,
"Add", BinaryTagTypes.BYTE_ARRAY).value();
"Add", BinaryTagTypes.BYTE_ARRAY
).value();
}
}
@ -263,9 +267,6 @@ public class AnvilChunk implements Chunk {
}
CompoundBinaryTag values = tileEntities.get(position);
if (values == null) {
return null;
}
return values;
}

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.chunk;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
@ -27,7 +28,6 @@ import com.sk89q.worldedit.util.nbt.BinaryTagTypes;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.IntBinaryTag;
import com.sk89q.worldedit.util.nbt.ListBinaryTag;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -35,9 +35,9 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.storage.InvalidFormatException;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
/**
* The chunk format for Minecraft 1.13 to 1.15
@ -55,6 +55,7 @@ public class AnvilChunk13 implements Chunk {
//FAWE start
/**
* Construct the chunk with a compound tag.
*
@ -122,7 +123,9 @@ public class AnvilChunk13 implements Chunk {
try {
blockState = getBlockStateWith(blockState, property, value);
} catch (IllegalArgumentException e) {
throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().getId() + ", " + property.getName() + ": " + value);
throw new InvalidFormatException("Invalid block state for " + blockState
.getBlockType()
.getId() + ", " + property.getName() + ": " + value);
}
}
}
@ -141,7 +144,8 @@ public class AnvilChunk13 implements Chunk {
}
}
protected void readBlockStates(BlockState[] palette, long[] blockStatesSerialized, BlockState[] chunkSectionBlocks) throws InvalidFormatException {
protected void readBlockStates(BlockState[] palette, long[] blockStatesSerialized, BlockState[] chunkSectionBlocks) throws
InvalidFormatException {
int paletteBits = 4;
while ((1 << paletteBits) < palette.length) {
++paletteBits;
@ -224,9 +228,6 @@ public class AnvilChunk13 implements Chunk {
}
CompoundBinaryTag values = tileEntities.get(position);
if (values == null) {
return null;
}
return values;
}

View File

@ -31,6 +31,7 @@ import com.sk89q.worldedit.world.storage.InvalidFormatException;
public class AnvilChunk16 extends AnvilChunk13 {
//FAWE start
/**
* Construct the chunk with a compound tag.
*
@ -55,7 +56,8 @@ public class AnvilChunk16 extends AnvilChunk13 {
//FAWE end
@Override
protected void readBlockStates(BlockState[] palette, long[] blockStatesSerialized, BlockState[] chunkSectionBlocks) throws InvalidFormatException {
protected void readBlockStates(BlockState[] palette, long[] blockStatesSerialized, BlockState[] chunkSectionBlocks) throws
InvalidFormatException {
PackedIntArrayReader reader = new PackedIntArrayReader(blockStatesSerialized);
for (int blockPos = 0; blockPos < chunkSectionBlocks.length; blockPos++) {
int index = reader.get(blockPos);
@ -65,4 +67,5 @@ public class AnvilChunk16 extends AnvilChunk13 {
chunkSectionBlocks[blockPos] = palette[index];
}
}
}

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.chunk;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.math.BlockVector3;
@ -27,7 +28,6 @@ import com.sk89q.worldedit.util.nbt.BinaryTagTypes;
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
import com.sk89q.worldedit.util.nbt.IntBinaryTag;
import com.sk89q.worldedit.util.nbt.ListBinaryTag;
import com.fastasyncworldedit.core.util.NbtUtils;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -54,6 +54,7 @@ public class OldChunk implements Chunk {
private Map<BlockVector3, CompoundBinaryTag> tileEntities;
//FAWE start
/**
* Construct the chunk with a compound tag.
*
@ -162,9 +163,6 @@ public class OldChunk implements Chunk {
}
CompoundBinaryTag values = tileEntities.get(position);
if (values == null) {
return null;
}
return values;
}

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.world.chunk;
import static com.google.common.base.Preconditions.checkElementIndex;
public class PackedIntArrayReader {
private static final int[] FACTORS = new int[64];
static {

View File

@ -19,9 +19,9 @@
package com.sk89q.worldedit.world.entity;
import com.fastasyncworldedit.core.registry.RegistryItem;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.fastasyncworldedit.core.registry.RegistryItem;
//FAWE start - implements RegistryItem
public class EntityType implements RegistryItem, Keyed {

View File

@ -19,8 +19,8 @@
package com.sk89q.worldedit.world.entity;
import java.util.Locale;
import javax.annotation.Nullable;
import java.util.Locale;
/**
* Stores a list of common {@link EntityType EntityTypes}.
@ -29,120 +29,236 @@ import javax.annotation.Nullable;
*/
@SuppressWarnings("unused")
public final class EntityTypes {
@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 AXOLOTL = get("minecraft:axolotl");
@Nullable public static final EntityType BAT = get("minecraft:bat");
@Nullable public static final EntityType BEE = get("minecraft:bee");
@Nullable public static final EntityType BLAZE = get("minecraft:blaze");
@Nullable public static final EntityType BOAT = get("minecraft:boat");
@Nullable public static final EntityType CAT = get("minecraft:cat");
@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 FOX = get("minecraft:fox");
@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 GLOW_ITEM_FRAME = get("minecraft:glow_item_frame");
@Nullable public static final EntityType GLOW_SQUID = get("minecraft:glow_squid");
@Nullable public static final EntityType GOAT = get("minecraft:goat");
@Nullable public static final EntityType GUARDIAN = get("minecraft:guardian");
@Nullable public static final EntityType HOGLIN = get("minecraft:hoglin");
@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 MARKER = get("minecraft:marker");
@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 PANDA = get("minecraft:panda");
@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 PIGLIN = get("minecraft:piglin");
@Nullable public static final EntityType PIGLIN_BRUTE = get("minecraft:piglin_brute");
@Nullable public static final EntityType PILLAGER = get("minecraft:pillager");
@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 RAVAGER = get("minecraft:ravager");
@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 STRIDER = get("minecraft:strider");
@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 TRADER_LLAMA = get("minecraft:trader_llama");
@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 WANDERING_TRADER = get("minecraft:wandering_trader");
@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 ZOGLIN = get("minecraft:zoglin");
@Nullable public static final EntityType ZOMBIE = get("minecraft:zombie");
@Nullable public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse");
@Deprecated @Nullable public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman");
@Nullable public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager");
@Nullable public static final EntityType ZOMBIFIED_PIGLIN = get("minecraft:zombified_piglin");
@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 AXOLOTL = get("minecraft:axolotl");
@Nullable
public static final EntityType BAT = get("minecraft:bat");
@Nullable
public static final EntityType BEE = get("minecraft:bee");
@Nullable
public static final EntityType BLAZE = get("minecraft:blaze");
@Nullable
public static final EntityType BOAT = get("minecraft:boat");
@Nullable
public static final EntityType CAT = get("minecraft:cat");
@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 FOX = get("minecraft:fox");
@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 GLOW_ITEM_FRAME = get("minecraft:glow_item_frame");
@Nullable
public static final EntityType GLOW_SQUID = get("minecraft:glow_squid");
@Nullable
public static final EntityType GOAT = get("minecraft:goat");
@Nullable
public static final EntityType GUARDIAN = get("minecraft:guardian");
@Nullable
public static final EntityType HOGLIN = get("minecraft:hoglin");
@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 MARKER = get("minecraft:marker");
@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 PANDA = get("minecraft:panda");
@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 PIGLIN = get("minecraft:piglin");
@Nullable
public static final EntityType PIGLIN_BRUTE = get("minecraft:piglin_brute");
@Nullable
public static final EntityType PILLAGER = get("minecraft:pillager");
@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 RAVAGER = get("minecraft:ravager");
@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 STRIDER = get("minecraft:strider");
@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 TRADER_LLAMA = get("minecraft:trader_llama");
@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 WANDERING_TRADER = get("minecraft:wandering_trader");
@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 ZOGLIN = get("minecraft:zoglin");
@Nullable
public static final EntityType ZOMBIE = get("minecraft:zombie");
@Nullable
public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse");
@Deprecated
@Nullable
public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman");
@Nullable
public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager");
@Nullable
public static final EntityType ZOMBIFIED_PIGLIN = get("minecraft:zombified_piglin");
private EntityTypes() {
}
@ -161,76 +277,146 @@ public final class EntityTypes {
id = id.substring(10);
}
switch (id) {
case "AreaEffectCloud": return "area_effect_cloud";
case "ArmorStand": return "armor_stand";
case "CaveSpider": return "cave_spider";
case "MinecartChest": return "chest_minecart";
case "DragonFireball": return "dragon_fireball";
case "ThrownEgg": return "egg";
case "EnderDragon": return "ender_dragon";
case "ThrownEnderpearl": return "ender_pearl";
case "FallingSand": return "falling_block";
case "FireworksRocketEntity": return "fireworks_rocket";
case "MinecartFurnace": return "furnace_minecart";
case "MinecartHopper": return "hopper_minecart";
case "EntityHorse": return "horse";
case "ItemFrame": return "item_frame";
case "LeashKnot": return "leash_knot";
case "LightningBolt": return "lightning_bolt";
case "LavaSlime": return "magma_cube";
case "MinecartRideable": return "minecart";
case "MushroomCow": return "mooshroom";
case "Ozelot": return "ocelot";
case "PolarBear": return "polar_bear";
case "ThrownPotion": return "potion";
case "ShulkerBullet": return "shulker_bullet";
case "SmallFireball": return "small_fireball";
case "MinecartSpawner": return "spawner_minecart";
case "SpectralArrow": return "spectral_arrow";
case "PrimedTnt": return "tnt";
case "MinecartTNT": return "tnt_minecart";
case "VillagerGolem": return "villager_golem";
case "WitherBoss": return "wither";
case "WitherSkull": return "wither_skull";
case "PigZombie": return "zombie_pigman";
case "XPOrb": return "experience_orb";
case "ThrownExpBottle": return "experience_bottle";
case "EyeOfEnderSignal": return "eye_of_ender";
case "EnderCrystal": return "end_crystal";
case "MinecartCommandBlock": return "command_block_minecart";
case "SnowMan": return "snow_golem";
case "areaeffectcloud": return "area_effect_cloud";
case "armorstand": return "armor_stand";
case "cavespider": return "cave_spider";
case "minecartchest": return "chest_minecart";
case "dragonfireball": return "dragon_fireball";
case "thrownegg": return "egg";
case "enderdragon": return "ender_dragon";
case "thrownenderpearl": return "ender_pearl";
case "fallingsand": return "falling_block";
case "fireworksrocketentity": return "fireworks_rocket";
case "minecartfurnace": return "furnace_minecart";
case "minecarthopper": return "hopper_minecart";
case "entityhorse": return "horse";
case "itemframe": return "item_frame";
case "leashknot": return "leash_knot";
case "lightningbolt": return "lightning_bolt";
case "lavaslime": return "magma_cube";
case "minecartrideable": return "minecart";
case "mushroomcow": return "mooshroom";
case "ozelot": return "ocelot";
case "polarbear": return "polar_bear";
case "thrownpotion": return "potion";
case "shulkerbullet": return "shulker_bullet";
case "smallfireball": return "small_fireball";
case "minecartspawner": return "spawner_minecart";
case "spectralarrow": return "spectral_arrow";
case "primedtnt": return "tnt";
case "minecarttnt": return "tnt_minecart";
case "villagergolem": return "villager_golem";
case "witherboss": return "wither";
case "witherskull": return "wither_skull";
case "pigzombie": return "zombie_pigman";
case "AreaEffectCloud":
return "area_effect_cloud";
case "ArmorStand":
return "armor_stand";
case "CaveSpider":
return "cave_spider";
case "MinecartChest":
return "chest_minecart";
case "DragonFireball":
return "dragon_fireball";
case "ThrownEgg":
return "egg";
case "EnderDragon":
return "ender_dragon";
case "ThrownEnderpearl":
return "ender_pearl";
case "FallingSand":
return "falling_block";
case "FireworksRocketEntity":
return "fireworks_rocket";
case "MinecartFurnace":
return "furnace_minecart";
case "MinecartHopper":
return "hopper_minecart";
case "EntityHorse":
return "horse";
case "ItemFrame":
return "item_frame";
case "LeashKnot":
return "leash_knot";
case "LightningBolt":
return "lightning_bolt";
case "LavaSlime":
return "magma_cube";
case "MinecartRideable":
return "minecart";
case "MushroomCow":
return "mooshroom";
case "Ozelot":
return "ocelot";
case "PolarBear":
return "polar_bear";
case "ThrownPotion":
return "potion";
case "ShulkerBullet":
return "shulker_bullet";
case "SmallFireball":
return "small_fireball";
case "MinecartSpawner":
return "spawner_minecart";
case "SpectralArrow":
return "spectral_arrow";
case "PrimedTnt":
return "tnt";
case "MinecartTNT":
return "tnt_minecart";
case "VillagerGolem":
return "villager_golem";
case "WitherBoss":
return "wither";
case "WitherSkull":
return "wither_skull";
case "PigZombie":
return "zombie_pigman";
case "XPOrb":
return "experience_orb";
case "ThrownExpBottle":
return "experience_bottle";
case "EyeOfEnderSignal":
return "eye_of_ender";
case "EnderCrystal":
return "end_crystal";
case "MinecartCommandBlock":
return "command_block_minecart";
case "SnowMan":
return "snow_golem";
case "areaeffectcloud":
return "area_effect_cloud";
case "armorstand":
return "armor_stand";
case "cavespider":
return "cave_spider";
case "minecartchest":
return "chest_minecart";
case "dragonfireball":
return "dragon_fireball";
case "thrownegg":
return "egg";
case "enderdragon":
return "ender_dragon";
case "thrownenderpearl":
return "ender_pearl";
case "fallingsand":
return "falling_block";
case "fireworksrocketentity":
return "fireworks_rocket";
case "minecartfurnace":
return "furnace_minecart";
case "minecarthopper":
return "hopper_minecart";
case "entityhorse":
return "horse";
case "itemframe":
return "item_frame";
case "leashknot":
return "leash_knot";
case "lightningbolt":
return "lightning_bolt";
case "lavaslime":
return "magma_cube";
case "minecartrideable":
return "minecart";
case "mushroomcow":
return "mooshroom";
case "ozelot":
return "ocelot";
case "polarbear":
return "polar_bear";
case "thrownpotion":
return "potion";
case "shulkerbullet":
return "shulker_bullet";
case "smallfireball":
return "small_fireball";
case "minecartspawner":
return "spawner_minecart";
case "spectralarrow":
return "spectral_arrow";
case "primedtnt":
return "tnt";
case "minecarttnt":
return "tnt_minecart";
case "villagergolem":
return "villager_golem";
case "witherboss":
return "wither";
case "witherskull":
return "wither_skull";
case "pigzombie":
return "zombie_pigman";
case "xporb":
case "xp_orb":
return "experience_orb";
@ -243,17 +429,23 @@ public final class EntityTypes {
case "endercrystal":
case "ender_crystal":
return "end_crystal";
case "fireworks_rocket": return "firework_rocket";
case "fireworks_rocket":
return "firework_rocket";
case "minecartcommandblock":
case "commandblock_minecart":
return "command_block_minecart";
case "snowman":
return "snow_golem";
case "villager_golem": return "iron_golem";
case "evocation_fangs": return "evoker_fangs";
case "evocation_illager": return "evoker";
case "vindication_illager": return "vindicator";
case "illusion_illager": return "illusioner";
case "villager_golem":
return "iron_golem";
case "evocation_fangs":
return "evoker_fangs";
case "evocation_illager":
return "evoker";
case "vindication_illager":
return "vindicator";
case "illusion_illager":
return "illusioner";
default: {
if (Character.isUpperCase(id.charAt(0))) {
return convertEntityId(id.toLowerCase(Locale.ROOT));

View File

@ -44,4 +44,5 @@ public final class FluidCategories {
public static FluidCategory get(final String id) {
return FluidCategory.REGISTRY.get(id);
}
}

View File

@ -45,4 +45,5 @@ public class FluidCategory extends Category<FluidType> implements Keyed {
// .queryCapability(Capability.GAME_HOOKS).getRegistries()
// .getBlockCategoryRegistry().getCategorisedByName(this.id);
}
}

View File

@ -19,9 +19,9 @@
package com.sk89q.worldedit.world.fluid;
import com.fastasyncworldedit.core.registry.RegistryItem;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.fastasyncworldedit.core.registry.RegistryItem;
/**
* Minecraft now has a 'fluid' system. This is a
@ -79,4 +79,5 @@ public class FluidType implements RegistryItem, Keyed {
public boolean equals(Object obj) {
return obj instanceof FluidType && this.id.equals(((FluidType) obj).id);
}
}

View File

@ -47,4 +47,5 @@ public final class FluidTypes {
public static FluidType get(final String id) {
return FluidType.REGISTRY.get(id);
}
}

View File

@ -26,6 +26,7 @@ package com.sk89q.worldedit.world.item;
*/
@SuppressWarnings("unused")
public final class ItemCategories {
public static final ItemCategory ACACIA_LOGS = get("minecraft:acacia_logs");
public static final ItemCategory ANVIL = get("minecraft:anvil");
public static final ItemCategory ARROWS = get("minecraft:arrows");
@ -53,7 +54,8 @@ public final class ItemCategories {
public static final ItemCategory FLOWERS = get("minecraft:flowers");
public static final ItemCategory FOX_FOOD = get("minecraft:fox_food");
public static final ItemCategory FREEZE_IMMUNE_WEARABLES = get("minecraft:freeze_immune_wearables");
@Deprecated public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials");
@Deprecated
public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials");
public static final ItemCategory GOLD_ORES = get("minecraft:gold_ores");
public static final ItemCategory IGNORED_BY_PIGLIN_BABIES = get("minecraft:ignored_by_piglin_babies");
public static final ItemCategory IRON_ORES = get("minecraft:iron_ores");
@ -110,4 +112,5 @@ public final class ItemCategories {
}
return entry;
}
}

View File

@ -57,4 +57,5 @@ public class ItemCategory extends Category<ItemType> implements Keyed {
public boolean contains(BaseItem baseItem) {
return this.getAll().contains(baseItem.getType());
}
}

View File

@ -19,13 +19,13 @@
package com.sk89q.worldedit.world.item;
import com.fastasyncworldedit.core.registry.RegistryItem;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.fastasyncworldedit.core.registry.RegistryItem;
import com.sk89q.worldedit.util.GuavaUtil;
import com.sk89q.worldedit.util.concurrency.LazyReference;
import com.sk89q.worldedit.util.formatting.text.Component;
@ -45,19 +45,19 @@ public class ItemType implements RegistryItem, Keyed {
@SuppressWarnings("deprecation")
private final LazyReference<String> name = LazyReference.from(() -> {
String name = GuavaUtil.firstNonNull(
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getName(this),
""
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getName(this),
""
);
return name.isEmpty() ? getId() : name;
});
private final LazyReference<Component> richName = LazyReference.from(() ->
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getRichName(this)
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getRichName(this)
);
private final LazyReference<ItemMaterial> itemMaterial = LazyReference.from(() ->
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getMaterial(this)
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getMaterial(this)
);
//FAWE start
private BlockType blockType;
@ -163,4 +163,5 @@ public class ItemType implements RegistryItem, Keyed {
public boolean equals(Object obj) {
return obj instanceof ItemType && this.id.equals(((ItemType) obj).id);
}
}

View File

@ -44,7 +44,7 @@ public interface BiomeRegistry {
* @param biome the biome
* @return a data object or null if information is not known
* @deprecated This method no longer returns any useful information.
* Use {@link #getRichName(BiomeType)} for the name of the biome.
* Use {@link #getRichName(BiomeType)} for the name of the biome.
*/
@Deprecated
@Nullable

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.jnbt.CompoundTag;
import javax.annotation.Nullable;
/**
@ -163,8 +164,10 @@ public interface BlockMaterial {
boolean hasContainer();
//FAWE start
/**
* Get the opacity of the block.
*
* @return opacity
*/
int getLightOpacity();
@ -186,6 +189,7 @@ public interface BlockMaterial {
/**
* Get the map color.
*
* @return or 0
*/
int getMapColor();

View File

@ -89,6 +89,7 @@ public interface BlockRegistry {
OptionalInt getInternalBlockStateId(BlockState state);
//FAWE start
/**
* Register all blocks.
*/

View File

@ -34,13 +34,13 @@ import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.util.io.ResourceLoader;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
/**
* Provides block data based on the built-in block database that is bundled
@ -65,7 +65,11 @@ public final class BundledBlockData {
* Create a new instance.
*/
private BundledBlockData() {
this.resourceLoader = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.CONFIGURATION).getResourceLoader();
this.resourceLoader = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.CONFIGURATION)
.getResourceLoader();
try {
loadFromResource();
@ -97,7 +101,11 @@ public final class BundledBlockData {
//FAWE end
Gson gson = gsonBuilder.create();
URL url = null;
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
final int dataVersion = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.WORLD_EDITING)
.getDataVersion();
if (dataVersion >= Constants.DATA_VERSION_MC_1_17) {
url = resourceLoader.getResource(BundledBlockData.class, "blocks.117.json");
} else if (dataVersion >= Constants.DATA_VERSION_MC_1_16) {
@ -113,7 +121,8 @@ public final class BundledBlockData {
}
LOGGER.debug("Using {} for bundled block data.", url);
String data = Resources.toString(url, Charset.defaultCharset());
List<BlockEntry> entries = gson.fromJson(data, new TypeToken<List<BlockEntry>>() {}.getType());
List<BlockEntry> entries = gson.fromJson(data, new TypeToken<List<BlockEntry>>() {
}.getType());
for (BlockEntry entry : entries) {
idMap.put(entry.id, entry);
@ -164,6 +173,7 @@ public final class BundledBlockData {
}
public static class BlockEntry {
//FAWE start - made public
public String id;
public String localizedName;

View File

@ -49,7 +49,7 @@ public class BundledBlockRegistry implements BlockRegistry {
return TextComponent.of(blockEntry.localizedName);
}
return Caption.of(
TranslationManager.makeTranslationKey("block", blockType.getId())
TranslationManager.makeTranslationKey("block", blockType.getId())
);
}

View File

@ -32,13 +32,13 @@ import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.util.io.ResourceLoader;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
/**
* Provides item data based on the built-in item database that is bundled
@ -63,7 +63,11 @@ public final class BundledItemData {
* Create a new instance.
*/
private BundledItemData() {
this.resourceLoader = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.CONFIGURATION).getResourceLoader();
this.resourceLoader = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.CONFIGURATION)
.getResourceLoader();
try {
loadFromResource();
@ -82,7 +86,11 @@ public final class BundledItemData {
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
Gson gson = gsonBuilder.create();
URL url = null;
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
final int dataVersion = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.WORLD_EDITING)
.getDataVersion();
if (dataVersion >= Constants.DATA_VERSION_MC_1_17) {
url = resourceLoader.getResource(BundledBlockData.class, "items.117.json");
} else if (dataVersion >= Constants.DATA_VERSION_MC_1_16) {
@ -98,7 +106,8 @@ public final class BundledItemData {
}
LOGGER.debug("Using {} for bundled item data.", url);
String data = Resources.toString(url, Charset.defaultCharset());
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {}.getType());
List<ItemEntry> entries = gson.fromJson(data, new TypeToken<List<ItemEntry>>() {
}.getType());
for (ItemEntry entry : entries) {
idMap.put(entry.id, entry);
@ -150,11 +159,13 @@ public final class BundledItemData {
}
public static class ItemEntry {
private String id;
private String unlocalizedName;
public String localizedName;
private int maxDamage;
private int maxStackSize;
}
}

View File

@ -48,7 +48,7 @@ public class BundledItemRegistry implements ItemRegistry {
return TextComponent.of(itemEntry.localizedName);
}
return Caption.of(
TranslationManager.makeTranslationKey("item", itemType.getId())
TranslationManager.makeTranslationKey("item", itemType.getId())
);
}
@ -76,4 +76,5 @@ public class BundledItemRegistry implements ItemRegistry {
public ItemMaterial getMaterial(ItemType itemType) {
return new PassthroughItemMaterial(BundledItemData.getInstance().getMaterialById(itemType.getId()));
}
}

View File

@ -40,4 +40,5 @@ public interface CategoryRegistry<T extends Keyed> {
default Set<T> getAll(final Category<T> category) {
return getCategorisedByName(category.getId());
}
}

View File

@ -20,11 +20,7 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes;
import java.util.Collection;
import java.util.Collections;
import javax.annotation.Nullable;
/**

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.world.registry;
public interface ItemMaterial {
/**
* Gets the the maximum quantity of this item that can be in a single stack.
*
@ -33,4 +34,5 @@ public interface ItemMaterial {
* @return the maximum damage, or 0 if not applicable
*/
int getMaxDamage();
}

View File

@ -70,6 +70,7 @@ public interface ItemRegistry {
ItemMaterial getMaterial(ItemType itemType);
//FAWE start
/**
* Register all items.
*/

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.registry;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.HashMultimap;
@ -35,7 +36,6 @@ import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.Vector3;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.util.io.ResourceLoader;
import com.sk89q.worldedit.world.DataFixer;
@ -47,12 +47,12 @@ import com.sk89q.worldedit.world.item.ItemTypes;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
public final class LegacyMapper {
@ -74,7 +74,11 @@ public final class LegacyMapper {
* Create a new instance.
*/
private LegacyMapper() {
this.resourceLoader = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.CONFIGURATION).getResourceLoader();
this.resourceLoader = WorldEdit
.getInstance()
.getPlatformManager()
.queryCapability(Capability.CONFIGURATION)
.getResourceLoader();
try {
loadFromResource();
@ -97,7 +101,8 @@ public final class LegacyMapper {
throw new IOException("Could not find legacy.json");
}
String data = Resources.toString(url, Charset.defaultCharset());
LegacyDataFile dataFile = gson.fromJson(data, new TypeToken<LegacyDataFile>() {}.getType());
LegacyDataFile dataFile = gson.fromJson(data, new TypeToken<LegacyDataFile>() {
}.getType());
DataFixer fixer = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataFixer();
ParserContext parserContext = new ParserContext();
@ -123,7 +128,7 @@ public final class LegacyMapper {
}
} catch (InputParseException f) {
BlockFactory blockFactory = WorldEdit.getInstance().getBlockFactory();
//FAWE end
//FAWE end
// if fixer is available, try using that first, as some old blocks that were renamed share names with new blocks
if (fixer != null) {
@ -154,7 +159,7 @@ public final class LegacyMapper {
//FAWE start
if (state != null) {
blockArr[combinedId] = state.getInternalId();
blockStateToLegacyId4Data.put(state.getInternalId(), (Integer) combinedId);
blockStateToLegacyId4Data.put(state.getInternalId(), combinedId);
blockStateToLegacyId4Data.putIfAbsent(state.getInternalBlockTypeId(), combinedId);
}
}
@ -313,7 +318,7 @@ public final class LegacyMapper {
@Deprecated
public int[] getLegacyFromBlock(BlockState blockState) {
Integer combinedId = getLegacyCombined(blockState);
return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF };
return combinedId == null ? null : new int[]{combinedId >> 4, combinedId & 0xF};
}
public static LegacyMapper getInstance() {
@ -325,7 +330,10 @@ public final class LegacyMapper {
@SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
private static class LegacyDataFile {
private Map<String, String> blocks;
private Map<String, String> items;
}
}

View File

@ -41,7 +41,7 @@ public class NullBiomeRegistry implements BiomeRegistry {
@Override
public Component getRichName(BiomeType biomeType) {
return Caption.of(
TranslationManager.makeTranslationKey("biome", biomeType.getId())
TranslationManager.makeTranslationKey("biome", biomeType.getId())
);
}

View File

@ -30,4 +30,5 @@ public class NullBlockCategoryRegistry implements BlockCategoryRegistry {
public Set<BlockType> getCategorisedByName(String category) {
return Collections.emptySet();
}
}

View File

@ -30,4 +30,5 @@ public class NullItemCategoryRegistry implements ItemCategoryRegistry {
public Set<ItemType> getCategorisedByName(String category) {
return Collections.emptySet();
}
}

View File

@ -42,4 +42,5 @@ public class PassthroughItemMaterial implements ItemMaterial {
public int getMaxDamage() {
return itemMaterial.getMaxDamage();
}
}

View File

@ -259,4 +259,5 @@ class SimpleBlockMaterial implements BlockMaterial {
public void setHasContainer(boolean hasContainer) {
this.hasContainer = hasContainer;
}
}

View File

@ -38,4 +38,5 @@ public class SimpleItemMaterial implements ItemMaterial {
public int getMaxDamage() {
return maxDamage;
}
}

View File

@ -52,7 +52,7 @@ public class Snapshot implements Comparable<Snapshot> {
/**
* Construct a snapshot restoration operation.
*
* @param repo a repository
* @param repo a repository
* @param snapshot a snapshot name
*/
public Snapshot(SnapshotRepository repo, String snapshot) {
@ -64,8 +64,8 @@ public class Snapshot implements Comparable<Snapshot> {
* Get a chunk store.
*
* @return a chunk store
* @throws IOException if there is an error loading the chunk store
* @throws DataException if there is an error loading the chunk store
* @throws IOException if there is an error loading the chunk store
* @throws DataException if there is an error loading the chunk store
*/
public ChunkStore getChunkStore() throws IOException, DataException {
ChunkStore chunkStore = internalGetChunkStore();
@ -80,7 +80,7 @@ public class Snapshot implements Comparable<Snapshot> {
* Get a chunk store.
*
* @return a chunk store
* @throws IOException if there is an error loading the chunk store
* @throws IOException if there is an error loading the chunk store
* @throws DataException if there is an error loading the chunk store
*/
private ChunkStore internalGetChunkStore() throws IOException, DataException {
@ -208,7 +208,7 @@ public class Snapshot implements Comparable<Snapshot> {
int ourIndex = name.indexOf('/');
int theirIndex = o.name.indexOf('/');
return name.substring(Math.min(ourIndex, 0))
.compareTo(o.name.substring(Math.min(theirIndex, 0)));
.compareTo(o.name.substring(Math.min(theirIndex, 0)));
} else {
return date.compareTo(o.date);
}
@ -223,4 +223,5 @@ public class Snapshot implements Comparable<Snapshot> {
public int hashCode() {
return file.hashCode();
}
}

View File

@ -19,9 +19,9 @@
package com.sk89q.worldedit.world.snapshot;
import javax.annotation.Nullable;
import java.io.File;
import java.util.Calendar;
import javax.annotation.Nullable;
/**
* A name parser attempts to make sense of a filename for a snapshot.

View File

@ -23,6 +23,7 @@ package com.sk89q.worldedit.world.snapshot;
import com.sk89q.worldedit.world.storage.MissingWorldException;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FilenameFilter;
import java.time.ZoneOffset;
@ -32,7 +33,6 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import javax.annotation.Nullable;
/**
* A repository contains zero or more snapshots.
@ -215,9 +215,9 @@ public class SnapshotRepository {
if (file.isFile()) {
String lowerCaseFileName = file.getName().toLowerCase(Locale.ROOT);
return lowerCaseFileName.endsWith(".zip")
|| lowerCaseFileName.endsWith(".tar.bz2")
|| lowerCaseFileName.endsWith(".tar.gz")
|| lowerCaseFileName.endsWith(".tar");
|| lowerCaseFileName.endsWith(".tar.bz2")
|| lowerCaseFileName.endsWith(".tar.gz")
|| lowerCaseFileName.endsWith(".tar");
}
return false;
}

View File

@ -55,9 +55,9 @@ public class SnapshotRestore {
/**
* Construct the snapshot restore operation.
*
* @param chunkStore The {@link ChunkStore} to restore from
* @param chunkStore The {@link ChunkStore} to restore from
* @param editSession The {@link EditSession} to restore to
* @param region The {@link Region} to restore to
* @param region The {@link Region} to restore to
*/
public SnapshotRestore(ChunkStore chunkStore, EditSession editSession, Region region) {
this.chunkStore = chunkStore;

View File

@ -59,4 +59,5 @@ public interface Snapshot extends Closeable {
*/
@Override
void close() throws IOException;
}

View File

@ -24,7 +24,7 @@ import java.util.Comparator;
public class SnapshotComparator {
private static final Comparator<Snapshot> COMPARATOR =
Comparator.comparing(Snapshot::getInfo);
Comparator.comparing(Snapshot::getInfo);
public static Comparator<Snapshot> getInstance() {
return COMPARATOR;
@ -32,4 +32,5 @@ public class SnapshotComparator {
private SnapshotComparator() {
}
}

View File

@ -64,17 +64,17 @@ public interface SnapshotDatabase {
default Stream<Snapshot> getSnapshotsBefore(String worldName, ZonedDateTime date) throws IOException {
return takeWhile(
// sorted from oldest -> newest, so all `before` are at the front
getSnapshotsOldestFirst(worldName),
snap -> snap.getInfo().getDateTime().isBefore(date)
// sorted from oldest -> newest, so all `before` are at the front
getSnapshotsOldestFirst(worldName),
snap -> snap.getInfo().getDateTime().isBefore(date)
);
}
default Stream<Snapshot> getSnapshotsAfter(String worldName, ZonedDateTime date) throws IOException {
return takeWhile(
// sorted from newest -> oldest, so all `after` are at the front
getSnapshotsNewestFirst(worldName),
snap -> snap.getInfo().getDateTime().isAfter(date)
// sorted from newest -> oldest, so all `after` are at the front
getSnapshotsNewestFirst(worldName),
snap -> snap.getInfo().getDateTime().isAfter(date)
);
}

View File

@ -68,7 +68,7 @@ public final class SnapshotInfo implements Comparable<SnapshotInfo> {
}
SnapshotInfo that = (SnapshotInfo) o;
return Objects.equals(name, that.name)
&& Objects.equals(dateTime, that.dateTime);
&& Objects.equals(dateTime, that.dateTime);
}
@Override
@ -79,16 +79,17 @@ public final class SnapshotInfo implements Comparable<SnapshotInfo> {
@Override
public String toString() {
return "SnapshotInfo{"
+ "name='" + name + '\''
+ ",date=" + dateTime
+ '}';
+ "name='" + name + '\''
+ ",date=" + dateTime
+ '}';
}
@Override
public int compareTo(SnapshotInfo o) {
return ComparisonChain.start()
.compare(dateTime, o.dateTime)
.compare(name, o.name)
.result();
.compare(dateTime, o.dateTime)
.compare(name, o.name)
.result();
}
}

View File

@ -51,9 +51,9 @@ public class SnapshotRestore {
/**
* Construct the snapshot restore operation.
*
* @param snapshot The {@link Snapshot} to restore from
* @param snapshot The {@link Snapshot} to restore from
* @param editSession The {@link EditSession} to restore to
* @param region The {@link Region} to restore to
* @param region The {@link Region} to restore to
*/
public SnapshotRestore(Snapshot snapshot, EditSession editSession, Region region) {
this.snapshot = snapshot;

View File

@ -35,6 +35,7 @@ import com.sk89q.worldedit.world.snapshot.experimental.Snapshot;
import com.sk89q.worldedit.world.snapshot.experimental.SnapshotDatabase;
import com.sk89q.worldedit.world.snapshot.experimental.SnapshotInfo;
import javax.annotation.Nullable;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
@ -46,7 +47,6 @@ import java.util.Objects;
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkArgument;
@ -58,22 +58,22 @@ public class FileSystemSnapshotDatabase implements SnapshotDatabase {
private static final String SCHEME = "snapfs";
private static final List<SnapshotDateTimeParser> DATE_TIME_PARSERS =
new ImmutableList.Builder<SnapshotDateTimeParser>()
.add(FileNameDateTimeParser.getInstance())
.addAll(ServiceLoader.load(SnapshotDateTimeParser.class))
.add(ModificationDateTimeParser.getInstance())
.build();
new ImmutableList.Builder<SnapshotDateTimeParser>()
.add(FileNameDateTimeParser.getInstance())
.addAll(ServiceLoader.load(SnapshotDateTimeParser.class))
.add(ModificationDateTimeParser.getInstance())
.build();
public static ZonedDateTime tryParseDate(Path path) {
return tryParseDateInternal(path)
.orElseThrow(() -> new IllegalStateException("Could not detect date of " + path));
.orElseThrow(() -> new IllegalStateException("Could not detect date of " + path));
}
private static Optional<ZonedDateTime> tryParseDateInternal(Path path) {
return DATE_TIME_PARSERS.stream()
.map(parser -> parser.detectDateTime(path))
.filter(Objects::nonNull)
.findFirst();
.map(parser -> parser.detectDateTime(path))
.filter(Objects::nonNull)
.findFirst();
}
public static URI createUri(String name) {
@ -81,8 +81,8 @@ public class FileSystemSnapshotDatabase implements SnapshotDatabase {
}
public static FileSystemSnapshotDatabase maybeCreate(
Path root,
ArchiveNioSupport archiveNioSupport
Path root,
ArchiveNioSupport archiveNioSupport
) throws IOException {
Files.createDirectories(root);
return new FileSystemSnapshotDatabase(root, archiveNioSupport);
@ -118,7 +118,7 @@ public class FileSystemSnapshotDatabase implements SnapshotDatabase {
private Snapshot createSnapshot(Path idPath, Path ioPath, @Nullable Closer closeCallback) {
return new FolderSnapshot(
createSnapshotInfo(idPath, ioPath), ioPath, closeCallback
createSnapshotInfo(idPath, ioPath), ioPath, closeCallback
);
}
@ -217,32 +217,32 @@ public class FileSystemSnapshotDatabase implements SnapshotDatabase {
with some files, e.g. world.qux.zip/world.qux is invalid, but world.qux.zip/world isn't.
*/
return SafeFiles.noLeakFileList(root)
.flatMap(IOFunction.unchecked(entry -> {
String worldEntry = getWorldEntry(worldName, entry);
if (worldEntry != null) {
return Stream.of(worldEntry);
}
String fileName = SafeFiles.canonicalFileName(entry);
if (fileName.equals(worldName)
&& Files.isDirectory(entry)
&& !Files.exists(entry.resolve("level.dat"))) {
// world dir with timestamp entries
return listTimestampedEntries(worldName, entry)
.map(id -> worldName + "/" + id);
}
return getTimestampedEntries(worldName, entry);
}))
.map(IOFunction.unchecked(id ->
getSnapshot(id)
.orElseThrow(() ->
new AssertionError("Could not find discovered snapshot: " + id)
)
));
.flatMap(IOFunction.unchecked(entry -> {
String worldEntry = getWorldEntry(worldName, entry);
if (worldEntry != null) {
return Stream.of(worldEntry);
}
String fileName = SafeFiles.canonicalFileName(entry);
if (fileName.equals(worldName)
&& Files.isDirectory(entry)
&& !Files.exists(entry.resolve("level.dat"))) {
// world dir with timestamp entries
return listTimestampedEntries(worldName, entry)
.map(id -> worldName + "/" + id);
}
return getTimestampedEntries(worldName, entry);
}))
.map(IOFunction.unchecked(id ->
getSnapshot(id)
.orElseThrow(() ->
new AssertionError("Could not find discovered snapshot: " + id)
)
));
}
private Stream<String> listTimestampedEntries(String worldName, Path directory) throws IOException {
return SafeFiles.noLeakFileList(directory)
.flatMap(IOFunction.unchecked(entry -> getTimestampedEntries(worldName, entry)));
.flatMap(IOFunction.unchecked(entry -> getTimestampedEntries(worldName, entry)));
}
private Stream<String> getTimestampedEntries(String worldName, Path entry) throws IOException {
@ -255,7 +255,7 @@ public class FileSystemSnapshotDatabase implements SnapshotDatabase {
if (Files.isDirectory(entry)) {
// timestamped directory, find worlds inside
return listWorldEntries(worldName, entry)
.map(id -> fileName + "/" + id);
.map(id -> fileName + "/" + id);
}
if (!Files.isRegularFile(entry)) {
// not an archive either?
@ -266,16 +266,16 @@ public class FileSystemSnapshotDatabase implements SnapshotDatabase {
// timestamped archive
ArchiveDir dir = asArchive.get();
return listWorldEntries(worldName, dir.getPath())
.map(id -> fileName + "/" + id)
.onClose(IORunnable.unchecked(dir::close));
.map(id -> fileName + "/" + id)
.onClose(IORunnable.unchecked(dir::close));
}
return Stream.of();
}
private Stream<String> listWorldEntries(String worldName, Path directory) throws IOException {
return SafeFiles.noLeakFileList(directory)
.map(IOFunction.unchecked(entry -> getWorldEntry(worldName, entry)))
.filter(Objects::nonNull);
.map(IOFunction.unchecked(entry -> getWorldEntry(worldName, entry)))
.filter(Objects::nonNull);
}
private String getWorldEntry(String worldName, Path entry) throws IOException {

View File

@ -32,6 +32,7 @@ import com.sk89q.worldedit.world.storage.McRegionChunkStore;
import com.sk89q.worldedit.world.storage.McRegionReader;
import com.sk89q.worldedit.world.storage.MissingChunkException;
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
@ -40,7 +41,6 @@ import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream;
import java.util.zip.GZIPInputStream;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkState;
@ -68,11 +68,11 @@ public class FolderSnapshot implements Snapshot {
// Might be in a DIM* folder
try (Stream<Path> paths = Files.list(folder)) {
Optional<Path> path = paths
.filter(Files::isDirectory)
.filter(p -> p.getFileName().toString().startsWith("DIM"))
.map(p -> p.resolve("region"))
.filter(Files::isDirectory)
.findFirst();
.filter(Files::isDirectory)
.filter(p -> p.getFileName().toString().startsWith("DIM"))
.map(p -> p.resolve("region"))
.filter(Files::isDirectory)
.findFirst();
if (path.isPresent()) {
return path.get();
}
@ -80,12 +80,12 @@ public class FolderSnapshot implements Snapshot {
// Might be its own region folder, check if the appropriate files exist
try (Stream<Path> paths = Files.list(folder)) {
if (paths
.filter(Files::isRegularFile)
.anyMatch(p -> {
String fileName = p.getFileName().toString();
return fileName.startsWith("r") &&
(fileName.endsWith(".mca") || fileName.endsWith(".mcr"));
})) {
.filter(Files::isRegularFile)
.anyMatch(p -> {
String fileName = p.getFileName().toString();
return fileName.startsWith("r") &&
(fileName.endsWith(".mca") || fileName.endsWith(".mcr"));
})) {
return folder;
}
}
@ -139,14 +139,14 @@ public class FolderSnapshot implements Snapshot {
throw new MissingChunkException();
}
return ChunkStoreHelper.readCompoundTag(() ->
new GZIPInputStream(Files.newInputStream(chunkFile))
new GZIPInputStream(Files.newInputStream(chunkFile))
);
}
Path regionFile = regFolder.get().resolve(McRegionChunkStore.getFilename(pos));
if (!Files.exists(regionFile)) {
// Try mcr as well
regionFile = regionFile.resolveSibling(
regionFile.getFileName().toString().replace(".mca", ".mcr")
regionFile.getFileName().toString().replace(".mca", ".mcr")
);
if (!Files.exists(regionFile)) {
throw new MissingChunkException();
@ -164,4 +164,5 @@ public class FolderSnapshot implements Snapshot {
closeCallback.close();
}
}
}

View File

@ -80,7 +80,7 @@ public abstract class ChunkStore implements Closeable {
* @param position the position of the chunk
* @return tag
* @throws DataException thrown on data error
* @throws IOException thrown on I/O error
* @throws IOException thrown on I/O error
*/
public abstract CompoundTag getChunkTag(BlockVector2 position, World world) throws DataException, IOException;
@ -90,8 +90,8 @@ public abstract class ChunkStore implements Closeable {
* @param position the position of the chunk
* @return a chunk
* @throws ChunkStoreException thrown if there is an error from the chunk store
* @throws DataException thrown on data error
* @throws IOException thrown on I/O error
* @throws DataException thrown on data error
* @throws IOException thrown on I/O error
*/
public Chunk getChunk(BlockVector2 position, World world) throws DataException, IOException {
CompoundTag rootTag = getChunkTag(position, world);

View File

@ -54,7 +54,7 @@ public class ChunkStoreHelper {
Tag tag = nbt.readNamedTag().getTag();
if (!(tag instanceof CompoundTag)) {
throw new ChunkStoreException("CompoundTag expected for chunk; got "
+ tag.getClass().getName());
+ tag.getClass().getName());
}
return (CompoundTag) tag;
@ -79,7 +79,10 @@ public class ChunkStoreHelper {
tag = (CompoundTag) entry.getValue();
break;
} else {
throw new ChunkStoreException("CompoundTag expected for 'Level'; got " + entry.getValue().getClass().getName());
throw new ChunkStoreException("CompoundTag expected for 'Level'; got " + entry
.getValue()
.getClass()
.getName());
}
}
}
@ -94,11 +97,17 @@ public class ChunkStoreHelper {
}
final Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
final int currentDataVersion = platform.getDataVersion();
if (tag.getValue().containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks
if (tag
.getValue()
.containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks
final DataFixer dataFixer = platform.getDataFixer();
if (dataFixer != null) {
//FAWE start - use Adventure
tag = (CompoundTag) ((CompoundTag) AdventureNBTConverter.fromAdventure(dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag.asBinaryTag(), dataVersion))).getValue().get("Level");
tag = (CompoundTag) ((CompoundTag) AdventureNBTConverter.fromAdventure(dataFixer.fixUp(
DataFixer.FixTypes.CHUNK,
rootTag.asBinaryTag(),
dataVersion
))).getValue().get("Level");
//FAWE end
dataVersion = currentDataVersion;
}
@ -120,4 +129,5 @@ public class ChunkStoreHelper {
private ChunkStoreHelper() {
}
}

View File

@ -46,8 +46,8 @@ public class FileLegacyChunkStore extends LegacyChunkStore {
/**
* Get the input stream for a chunk file.
*
* @param f1 the first part of the pathname
* @param f2 the second part of the pathname
* @param f1 the first part of the pathname
* @param f2 the second part of the pathname
* @param name the name of the file
* @return an input stream
* @throws DataException if there is an error getting data for this chunk

View File

@ -74,7 +74,7 @@ public class FileMcRegionChunkStore extends McRegionChunkStore {
@Override
public boolean isValid() {
return new File(path, "region").isDirectory()
|| new File(path, "DIM-1" + File.separator + "region").isDirectory();
|| new File(path, "DIM-1" + File.separator + "region").isDirectory();
}
}

View File

@ -39,7 +39,7 @@ public abstract class LegacyChunkStore extends ChunkStore {
/**
* Get the filename of a chunk.
*
* @param position chunk position
* @param position chunk position
* @param separator folder separator character
* @return pathname
*/
@ -77,7 +77,7 @@ public abstract class LegacyChunkStore extends ChunkStore {
+ "." + Integer.toString(z, 36) + ".dat";
return ChunkStoreHelper.readCompoundTag(() ->
new GZIPInputStream(getInputStream(folder1, folder2, filename))
new GZIPInputStream(getInputStream(folder1, folder2, filename))
);
}
@ -88,8 +88,8 @@ public abstract class LegacyChunkStore extends ChunkStore {
/**
* Get the input stream for a chunk file.
*
* @param f1 the first part of the path
* @param f2 the second part of the path
* @param f1 the first part of the path
* @param f2 the second part of the path
* @param name the name
* @return an input stream
* @throws IOException if there is an error getting the chunk data

View File

@ -75,7 +75,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
/**
* Get the input stream for a chunk file.
*
* @param name the name of the chunk file
* @param name the name of the chunk file
* @param worldName the world name
* @return an input stream
* @throws IOException if there is an error getting the chunk data

View File

@ -115,7 +115,7 @@ public class McRegionReader {
*
* @param position chunk position
* @return an input stream
* @throws IOException if there is an error getting the chunk data
* @throws IOException if there is an error getting the chunk data
* @throws DataException if there is an error getting the chunk data
*/
public synchronized InputStream getChunkInputStream(BlockVector2 position) throws IOException, DataException {
@ -190,4 +190,5 @@ public class McRegionReader {
public void close() throws IOException {
stream.close();
}
}

View File

@ -51,4 +51,5 @@ public class MissingWorldException extends ChunkStoreException {
public String getWorldName() {
return worldName;
}
}

View File

@ -40,8 +40,8 @@ public final class NBTConversions {
*
* <p>For values that are unavailable, their values will be 0.</p>
*
* @param extent the extent
* @param positionTag the position tag
* @param extent the extent
* @param positionTag the position tag
* @param directionTag the direction tag
* @return a location
*/
@ -52,7 +52,8 @@ public final class NBTConversions {
return new Location(
extent,
positionTag.asDouble(0), positionTag.asDouble(1), positionTag.asDouble(2),
directionTag.getFloat(0), directionTag.getFloat(1));
directionTag.getFloat(0), directionTag.getFloat(1)
);
}
}

View File

@ -46,8 +46,8 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
* the folder to not look into a subdirectory.
*
* @param zipFile the ZIP file to open
* @param folder the folder to look into in the ZIP
* @throws IOException if there is an error opening the zip
* @param folder the folder to look into in the ZIP
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public TrueZipLegacyChunkStore(File zipFile, String folder) throws IOException, ZipException {
@ -62,7 +62,7 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
* be detected.
*
* @param zipFile the ZIP file to open
* @throws IOException if there is an error opening the zip
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public TrueZipLegacyChunkStore(File zipFile) throws IOException, ZipException {
@ -74,11 +74,11 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
/**
* Get the input stream for a chunk file.
*
* @param f1 the first part of the filename
* @param f2 the second part of the filename
* @param f1 the first part of the filename
* @param f2 the second part of the filename
* @param name the name of the file
* @return an input stream
* @throws IOException if there is an error getting the chunk data
* @throws IOException if there is an error getting the chunk data
* @throws DataException if there is an error getting the chunk data
*/
@Override

View File

@ -48,8 +48,8 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
* the folder to not look into a subdirectory.
*
* @param zipFile the ZIP file
* @param folder the folder to look into
* @throws IOException if there is an error opening the zip
* @param folder the folder to look into
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public TrueZipMcRegionChunkStore(File zipFile, String folder) throws IOException, ZipException {
@ -64,7 +64,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
* be detected.
*
* @param zipFile the ZIP file
* @throws IOException if there is an error opening the zip
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public TrueZipMcRegionChunkStore(File zipFile) throws IOException, ZipException {
@ -76,10 +76,10 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
/**
* Get the input stream for a chunk file.
*
* @param name the name
* @param name the name
* @param worldName the world name
* @return an input stream
* @throws IOException if there is an error getting the chunk data
* @throws IOException if there is an error getting the chunk data
* @throws DataException if there is an error getting the chunk data
*/
@Override

View File

@ -44,8 +44,8 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
* the folder to not look into a subdirectory.
*
* @param zipFile the zip file
* @param folder the folder
* @throws IOException if there is an error opening the zip
* @param folder the folder
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public ZippedLegacyChunkStore(File zipFile, String folder) throws IOException, ZipException {
@ -59,7 +59,7 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
* be detected.
*
* @param zipFile the zip file
* @throws IOException if there is an error opening the zip
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public ZippedLegacyChunkStore(File zipFile) throws IOException, ZipException {
@ -69,11 +69,11 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
/**
* Get the input stream for a chunk file.
*
* @param f1 the first part of the path
* @param f2 the second part of the path
* @param f1 the first part of the path
* @param f2 the second part of the path
* @param name the name of the file
* @return an input stream
* @throws IOException if there is an error getting the chunk data
* @throws IOException if there is an error getting the chunk data
* @throws DataException if there is an error getting the chunk data
*/
@Override

View File

@ -47,8 +47,8 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
* the folder to not look into a subdirectory.
*
* @param zipFile the ZIP file
* @param folder the folder
* @throws IOException if there is an error opening the zip
* @param folder the folder
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public ZippedMcRegionChunkStore(File zipFile, String folder) throws IOException, ZipException {
@ -63,7 +63,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
* be detected.
*
* @param zipFile the ZIP file
* @throws IOException if there is an error opening the zip
* @throws IOException if there is an error opening the zip
* @throws ZipException if there is an error opening the zip
*/
public ZippedMcRegionChunkStore(File zipFile) throws IOException, ZipException {
@ -159,4 +159,5 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
return false;
}
}

View File

@ -26,7 +26,7 @@ public class WeatherType implements Keyed {
public static final Registry<WeatherType> REGISTRY = new Registry<>("weather type");
private String id;
private final String id;
public WeatherType(String id) {
this.id = id;

View File

@ -42,4 +42,5 @@ public final class WeatherTypes {
public static WeatherType get(final String id) {
return WeatherType.REGISTRY.get(id);
}
}