some hasty refactoring

This commit is contained in:
Jesse Boyd
2018-08-28 02:56:28 +10:00
parent a61c856adc
commit abd886acd7
55 changed files with 1238 additions and 819 deletions

View File

@ -54,5 +54,4 @@ public interface BiomeRegistry {
*/
@Nullable
BiomeData getData(BaseBiome biome);
}

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.Collection;
@ -44,6 +45,11 @@ public interface BlockRegistry {
@Nullable
BlockMaterial getMaterial(BlockType blockType);
@Nullable
default BlockMaterial getMaterial(BlockState state) {
return getMaterial(state.getBlockType());
}
/**
* Get an unmodifiable map of states for this block.
*

View File

@ -26,7 +26,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -142,7 +141,7 @@ public class LegacyMapper {
public BlockState getBlockFromLegacy(String input) {
if (input.startsWith("minecraft:")) input = input.substring(10);
return BlockState.get(blockArr[getCombinedId(input)]);
return BlockState.getFromInternalId(blockArr[getCombinedId(input)]);
}
@Nullable
@ -181,7 +180,7 @@ public class LegacyMapper {
try {
int internalId = blockArr[combinedId];
if (internalId == 0) return null;
return BlockState.get(internalId);
return BlockState.getFromInternalId(internalId);
} catch (IndexOutOfBoundsException ignore) {
return null;
}
@ -191,7 +190,7 @@ public class LegacyMapper {
extra = extraId4DataToStateId.get(combinedId & 0xFF0);
}
if (extra != null) {
return BlockState.get(extra);
return BlockState.getFromInternalId(extra);
}
return null;
}