3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Fixed the item parser not using the ItemRegistry

Dieser Commit ist enthalten in:
Matthew Miller 2018-12-23 19:02:58 +10:00
Ursprung c5d9aadab8
Commit 6312bcecf6
4 geänderte Dateien mit 6 neuen und 44 gelöschten Zeilen

Datei anzeigen

@ -23,9 +23,9 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
public class DefaultItemParser extends InputParser<BaseItem> { public class DefaultItemParser extends InputParser<BaseItem> {
@ -53,8 +53,10 @@ public class DefaultItemParser extends InputParser<BaseItem> {
} }
if (item == null) { if (item == null) {
item = WorldEdit.getInstance().getPlatformManager() ItemType type = ItemTypes.get(input.toLowerCase());
.queryCapability(Capability.GAME_HOOKS).getRegistries().getItemRegistry().createFromId(input.toLowerCase()); if (type != null) {
item = new BaseItem(type);
}
} }
if (item == null) { if (item == null) {

Datei anzeigen

@ -19,22 +19,10 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import javax.annotation.Nullable;
/** /**
* A item registry that uses {@link BundledItemRegistry} to serve information * A item registry that uses {@link BundledItemRegistry} to serve information
* about items. * about items.
*/ */
public class BundledItemRegistry implements ItemRegistry { public class BundledItemRegistry implements ItemRegistry {
@Nullable
@Override
public BaseItem createFromId(String id) {
ItemType itemType = ItemTypes.get(id);
return itemType == null ? null : new BaseItem(itemType);
}
} }

Datei anzeigen

@ -19,19 +19,6 @@
package com.sk89q.worldedit.world.registry; package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BaseItem;
import javax.annotation.Nullable;
public interface ItemRegistry { public interface ItemRegistry {
/**
* Create a new item using its ID.
*
* @param id the id
* @return the item, which may be null if no item exists
*/
@Nullable
BaseItem createFromId(String id);
} }

Datei anzeigen

@ -19,23 +19,8 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.ItemRegistry; import com.sk89q.worldedit.world.registry.ItemRegistry;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nullable;
public class ForgeItemRegistry implements ItemRegistry { public class ForgeItemRegistry implements ItemRegistry {
@Nullable
@Override
public BaseItem createFromId(String id) {
Item match = Item.REGISTRY.getObject(new ResourceLocation(id));
if (match != null) {
return new BaseItem(ItemTypes.get(id));
} else {
return null;
}
}
} }