mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 08:38:34 +00:00
Working now
This commit is contained in:
@ -19,22 +19,29 @@
|
||||
|
||||
package com.sk89q.worldedit.world.biome;
|
||||
|
||||
import com.sk89q.worldedit.registry.RegistryItem;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
/**
|
||||
* All the types of biomes in the game.
|
||||
*/
|
||||
public class BiomeType {
|
||||
public class BiomeType implements RegistryItem {
|
||||
|
||||
public static final NamespacedRegistry<BiomeType> REGISTRY = new NamespacedRegistry<>("biome type");
|
||||
private final int internalId;
|
||||
private final String id;
|
||||
|
||||
protected BiomeType(String id, int internalId) {
|
||||
public BiomeType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private int internalId;
|
||||
|
||||
@Override
|
||||
public void setInternalId(int internalId) {
|
||||
this.internalId = internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInternalId() {
|
||||
return internalId;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.biome;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -107,28 +108,15 @@ public class BiomeTypes {
|
||||
private BiomeTypes() {
|
||||
}
|
||||
|
||||
private static List<BiomeType> biomes = new ArrayList<>();
|
||||
private static List<BiomeType> biomesLocked = Collections.unmodifiableList(biomes);
|
||||
|
||||
private static BiomeType register(final String id) {
|
||||
BiomeType biome = new BiomeType(id, biomes.size());
|
||||
biomes.add(biome);
|
||||
return register(biome);
|
||||
}
|
||||
|
||||
public static BiomeType register(final BiomeType biome) {
|
||||
return BiomeType.REGISTRY.register(biome.getId(), biome);
|
||||
}
|
||||
|
||||
public static @Nullable BiomeType get(final String id) {
|
||||
return BiomeType.REGISTRY.get(id);
|
||||
}
|
||||
|
||||
public static BiomeType get(int internalId) {
|
||||
return biomes.get(internalId);
|
||||
return BiomeType.REGISTRY.getByInternalId(internalId);
|
||||
}
|
||||
|
||||
public static List<BiomeType> values() {
|
||||
return biomesLocked;
|
||||
public static Collection<BiomeType> values() {
|
||||
return BiomeType.REGISTRY.values();
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
// Suggest property
|
||||
String input = charSequence.toString();
|
||||
BlockType finalType = type;
|
||||
throw new SuggestInputParseException("Invalid property " + type + " | " + input, input, () ->
|
||||
throw new SuggestInputParseException("Invalid property " + charSequence + ":" + input + " for type " + type, input, () ->
|
||||
finalType.getProperties().stream()
|
||||
.map(p -> p.getName())
|
||||
.filter(p -> p.startsWith(input))
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||
import com.sk89q.worldedit.function.pattern.FawePattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
@ -48,10 +49,13 @@ public class BlockType implements FawePattern {
|
||||
private final String id;
|
||||
private final BlockTypes.Settings settings;
|
||||
|
||||
private boolean initItemType;
|
||||
private ItemType itemType;
|
||||
|
||||
protected BlockType(String id, int internalId, List<BlockState> states) {
|
||||
this.settings = new BlockTypes.Settings(this, id, internalId, states);
|
||||
int i = id.indexOf("[");
|
||||
this.id = i == -1 ? id : id.substring(0, i);
|
||||
this.settings = new BlockTypes.Settings(this, id, internalId, states);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -94,9 +98,9 @@ public class BlockType implements FawePattern {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BlockState withPropertyId(int internalPropertiesId) {
|
||||
if (internalPropertiesId == 0) return getDefaultState();
|
||||
return BlockState.getFromInternalId(getInternalId() + (internalPropertiesId << BlockTypes.BIT_OFFSET));
|
||||
public BlockState withPropertyId(int propertyId) {
|
||||
if (settings.stateOrdinals == null) return settings.defaultState;
|
||||
return BlockTypes.states[settings.stateOrdinals[propertyId]];
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -237,7 +241,11 @@ public class BlockType implements FawePattern {
|
||||
*/
|
||||
@Nullable
|
||||
public ItemType getItemType() {
|
||||
return settings.itemType;
|
||||
if(!initItemType) {
|
||||
initItemType = true;
|
||||
itemType = ItemTypes.get(getId());
|
||||
}
|
||||
return itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,9 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.world.entity;
|
||||
|
||||
import com.sk89q.worldedit.registry.RegistryItem;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
public class EntityType {
|
||||
public class EntityType implements RegistryItem {
|
||||
|
||||
public static final NamespacedRegistry<EntityType> REGISTRY = new NamespacedRegistry<>("entity type");
|
||||
|
||||
@ -39,6 +40,18 @@ public class EntityType {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
private int internalId;
|
||||
|
||||
@Override
|
||||
public void setInternalId(int internalId) {
|
||||
this.internalId = internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInternalId() {
|
||||
return internalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this item, or the ID if the name cannot be found.
|
||||
*
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.world.fluid;
|
||||
|
||||
import com.sk89q.worldedit.registry.RegistryItem;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
|
||||
/**
|
||||
* Minecraft now has a 'fluid' system. This is a
|
||||
* stub class to represent what it may be in the future.
|
||||
*/
|
||||
public class FluidType {
|
||||
public class FluidType implements RegistryItem {
|
||||
|
||||
public static final NamespacedRegistry<FluidType> REGISTRY = new NamespacedRegistry<>("fluid type");
|
||||
|
||||
@ -44,6 +45,18 @@ public class FluidType {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
private int internalId;
|
||||
|
||||
@Override
|
||||
public void setInternalId(int internalId) {
|
||||
this.internalId = internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInternalId() {
|
||||
return internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
|
@ -34,6 +34,7 @@ import java.util.Set;
|
||||
public class ItemCategory extends Category<ItemType> {
|
||||
|
||||
public static final NamespacedRegistry<ItemCategory> REGISTRY = new NamespacedRegistry<>("item tag");
|
||||
private int internalId;
|
||||
|
||||
public ItemCategory(final String id) {
|
||||
super(id);
|
||||
@ -56,4 +57,5 @@ public class ItemCategory extends Category<ItemType> {
|
||||
public boolean contains(BaseItem baseItem) {
|
||||
return this.getAll().contains(baseItem.getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,40 +22,44 @@ package com.sk89q.worldedit.world.item;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.registry.RegistryItem;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemType {
|
||||
public class ItemType implements RegistryItem {
|
||||
|
||||
public static final NamespacedRegistry<ItemType> REGISTRY = new NamespacedRegistry<>("item type");
|
||||
|
||||
private String id;
|
||||
private BlockType blockType;
|
||||
private int internalId;
|
||||
private boolean initBlockType;
|
||||
private BaseItem defaultState;
|
||||
|
||||
protected ItemType(String id) {
|
||||
public ItemType(String id) {
|
||||
// If it has no namespace, assume minecraft.
|
||||
if (!id.contains(":")) {
|
||||
id = "minecraft:" + id;
|
||||
}
|
||||
this.id = id;
|
||||
this.blockType = BlockTypes.get(this.id);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getInternalId() {
|
||||
return this.internalId;
|
||||
}
|
||||
|
||||
|
||||
private int internalId;
|
||||
|
||||
@Override
|
||||
public void setInternalId(int internalId) {
|
||||
this.internalId = internalId;
|
||||
this.internalId = internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInternalId() {
|
||||
return internalId;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,6 +97,10 @@ public class ItemType {
|
||||
}
|
||||
|
||||
public void setBlockType(BlockType blockType) {
|
||||
if (!initBlockType) {
|
||||
initBlockType = true;
|
||||
this.blockType = BlockTypes.get(this.id);
|
||||
}
|
||||
this.blockType = blockType;
|
||||
}
|
||||
|
||||
|
@ -19,22 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.world.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
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.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
public final class ItemTypes {
|
||||
|
||||
@Nullable public static final ItemType ACACIA_BOAT = get("minecraft:acacia_boat");
|
||||
@ -831,24 +821,6 @@ public final class ItemTypes {
|
||||
private ItemTypes() {
|
||||
}
|
||||
|
||||
private static ItemType register(final String id) {
|
||||
return register(new ItemType(id));
|
||||
}
|
||||
|
||||
public static ItemType register(final ItemType item) {
|
||||
if(sortedRegistry == null)
|
||||
sortedRegistry = new ArrayList<>();
|
||||
if(!sortedRegistry.contains(item))sortedRegistry.add(item);
|
||||
// return ItemType.REGISTRY.register(item.getId(), item);
|
||||
return internalRegister(item);
|
||||
}
|
||||
|
||||
private static ArrayList<ItemType> sortedRegistry;
|
||||
|
||||
public static ItemType[] values() {
|
||||
return sortedRegistry.toArray(new ItemType[sortedRegistry.size()]);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemType parse(String input) {
|
||||
input = input.toLowerCase();
|
||||
@ -866,30 +838,20 @@ public final class ItemTypes {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ItemType internalRegister(final ItemType type) {
|
||||
type.setInternalId(sortedRegistry.indexOf(type));
|
||||
type.setDefaultState(new BaseItemStack(type, 1));
|
||||
return ItemType.REGISTRY.register(type.getId(), type);
|
||||
}
|
||||
|
||||
public static final @Nullable ItemType get(String id) {
|
||||
return ItemType.REGISTRY.get(id);
|
||||
}
|
||||
|
||||
public static final @Nullable ItemType get(BlockType type) {
|
||||
ItemType item = get(type.getId());
|
||||
if (item != null && item.getBlockType() == null) {
|
||||
item.setBlockType(type);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static final ItemType get(final int ordinal) {
|
||||
return values()[ordinal];
|
||||
return ItemType.REGISTRY.getByInternalId(ordinal);
|
||||
}
|
||||
|
||||
public static int size() {
|
||||
return values().length;
|
||||
return ItemType.REGISTRY.size();
|
||||
}
|
||||
|
||||
public static Collection<ItemType> values() {
|
||||
return ItemType.REGISTRY.values();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user