diff options
Diffstat (limited to 'src/main/java/me/shedaniel')
15 files changed, 217 insertions, 89 deletions
diff --git a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java index 2bb33bfc4..79a2fe97b 100644 --- a/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java +++ b/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsPlugin.java @@ -1,12 +1,11 @@ package me.shedaniel.rei; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import me.shedaniel.rei.api.IRecipePlugin; -import net.minecraft.util.ResourceLocation; +import me.shedaniel.rei.api.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.dimdev.riftloader.ModInfo; @@ -27,14 +26,13 @@ import java.util.zip.ZipEntry; public class RoughlyEnoughItemsPlugin { public static final Logger LOGGER = LogManager.getFormatterLogger("REI"); - private static final Map<String, IRecipePlugin> plugins = Maps.newHashMap(); + private static final Map<Identifier, IRecipePlugin> plugins = Maps.newHashMap(); private static JsonParser parser = new JsonParser(); - private static List<String> disablingPlugins; private static boolean loaded = false; - public static IRecipePlugin registerPlugin(String resourceLocation, IRecipePlugin plugin) { - plugins.put(resourceLocation, plugin); - RoughlyEnoughItemsPlugin.LOGGER.info("REI: Registered Plugin from %s by %s.", resourceLocation.toString(), plugin.getClass().getSimpleName()); + public static IRecipePlugin registerPlugin(Identifier identifier, IRecipePlugin plugin) { + plugins.put(identifier, plugin); + RoughlyEnoughItemsPlugin.LOGGER.info("REI: Registered Plugin from %s by %s.", identifier.toString(), plugin.getClass().getSimpleName()); plugin.onFirstLoad(RoughlyEnoughItemsCore.getPluginDisabler()); return plugin; } @@ -43,24 +41,18 @@ public class RoughlyEnoughItemsPlugin { return new LinkedList<>(plugins.values()); } - public static String getPluginResourceLocation(IRecipePlugin plugin) { - for(String resourceLocation : plugins.keySet()) - if (plugins.get(resourceLocation).equals(plugin)) - return resourceLocation; + public static Identifier getIdentifier(IRecipePlugin plugin) { + for(Identifier identifier : plugins.keySet()) + if (plugins.get(identifier).equals(plugin)) + return identifier; return null; } - public static void disablePlugin(ResourceLocation location) { - if (disablingPlugins.stream().noneMatch(location1 -> {return location.toString().equals(location1);})) - disablingPlugins.add(location.toString()); - } - public static void discoverPlugins() { if (loaded) return; loaded = true; LOGGER.info("REI: Discovering Plugins."); - disablingPlugins = Lists.newArrayList(); Collection<ModInfo> modInfoCollection = RiftLoader.instance.getMods(); modInfoCollection.forEach(modInfo -> { try { @@ -78,11 +70,7 @@ public class RoughlyEnoughItemsPlugin { RoughlyEnoughItemsPlugin.LOGGER.error("REI: Failed to load plugin file from %s. (%s)", (Object) modInfo.id, (Object) e.getLocalizedMessage()); } }); - new LinkedList<>(plugins.keySet()).stream().filter(location -> disablingPlugins.contains(location)).forEach(location -> { - plugins.remove(location); - LOGGER.info("REI: Disabled REI plugin %s.", location.toString()); - }); - LOGGER.info("REI: Discovered %d REI Plugins%s", plugins.size(), (plugins.size() > 0 ? ": " + String.join(", ", plugins.keySet().stream().collect(Collectors.toList())) : ".")); + LOGGER.info("REI: Discovered %d REI Plugins%s", plugins.size(), (plugins.size() > 0 ? ": " + String.join(", ", plugins.keySet().stream().map(Identifier::toString).collect(Collectors.toList())) : ".")); } private static void loadPluginInfo(ModInfo modInfo, Reader reader) throws Exception { @@ -96,7 +84,7 @@ public class RoughlyEnoughItemsPlugin { } private static void parseAndRegisterPlugin(String modId, JsonObject jsonObject) throws Exception { - String location = modId + ":" + jsonObject.getAsJsonPrimitive("id").getAsString(); + Identifier location = new Identifier(modId, jsonObject.getAsJsonPrimitive("id").getAsString()); Class<?> aClass = Class.forName(jsonObject.getAsJsonPrimitive("initializer").getAsString()); IRecipePlugin plugin = IRecipePlugin.class.cast(aClass.newInstance()); registerPlugin(location, plugin); diff --git a/src/main/java/me/shedaniel/rei/api/IPluginDisabler.java b/src/main/java/me/shedaniel/rei/api/IPluginDisabler.java index 836cd3e6f..260cdfc4e 100644 --- a/src/main/java/me/shedaniel/rei/api/IPluginDisabler.java +++ b/src/main/java/me/shedaniel/rei/api/IPluginDisabler.java @@ -1,23 +1,21 @@ package me.shedaniel.rei.api; -import net.minecraft.util.ResourceLocation; - public interface IPluginDisabler { - default public void disablePluginFunctions(ResourceLocation plugin, PluginFunction... functions) { + default public void disablePluginFunctions(Identifier plugin, PluginFunction... functions) { for(PluginFunction function : functions) disablePluginFunction(plugin, function); } - default public void enablePluginFunctions(ResourceLocation plugin, PluginFunction... functions) { + default public void enablePluginFunctions(Identifier plugin, PluginFunction... functions) { for(PluginFunction function : functions) enablePluginFunction(plugin, function); } - public void disablePluginFunction(ResourceLocation plugin, PluginFunction function); + public void disablePluginFunction(Identifier plugin, PluginFunction function); - public void enablePluginFunction(ResourceLocation plugin, PluginFunction function); + public void enablePluginFunction(Identifier plugin, PluginFunction function); - public boolean isFunctionEnabled(ResourceLocation plugin, PluginFunction function); + public boolean isFunctionEnabled(Identifier plugin, PluginFunction function); } diff --git a/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java b/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java index ca531ca21..90d85c184 100644 --- a/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java +++ b/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java @@ -8,7 +8,6 @@ import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import java.awt.*; import java.util.Arrays; @@ -18,7 +17,7 @@ import java.util.function.Supplier; public interface IRecipeCategory<T extends IRecipeDisplay> { - public ResourceLocation getResourceLocation(); + public Identifier getIdentifier(); public ItemStack getCategoryIcon(); diff --git a/src/main/java/me/shedaniel/rei/api/IRecipeDisplay.java b/src/main/java/me/shedaniel/rei/api/IRecipeDisplay.java index ae0800f1c..002ca830f 100644 --- a/src/main/java/me/shedaniel/rei/api/IRecipeDisplay.java +++ b/src/main/java/me/shedaniel/rei/api/IRecipeDisplay.java @@ -3,7 +3,6 @@ package me.shedaniel.rei.api; import com.google.common.collect.Lists; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; import java.util.List; @@ -19,6 +18,6 @@ public interface IRecipeDisplay<T extends IRecipe> { return Lists.newArrayList(); } - public ResourceLocation getRecipeCategory(); + public Identifier getRecipeCategory(); } diff --git a/src/main/java/me/shedaniel/rei/api/Identifier.java b/src/main/java/me/shedaniel/rei/api/Identifier.java new file mode 100644 index 000000000..0a3f944ed --- /dev/null +++ b/src/main/java/me/shedaniel/rei/api/Identifier.java @@ -0,0 +1,137 @@ +package me.shedaniel.rei.api; + +import com.google.gson.*; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import net.minecraft.util.JsonUtils; +import net.minecraft.util.text.TextComponentTranslation; +import org.apache.commons.lang3.StringUtils; + +import javax.annotation.Nullable; +import java.lang.reflect.Type; + +public class Identifier implements Comparable<Identifier> { + + private static final SimpleCommandExceptionType COMMAND_EXCEPTION_TYPE = new SimpleCommandExceptionType(new TextComponentTranslation("argument.id.invalid", new Object[0])); + protected final String namespace; + protected final String path; + + protected Identifier(String[] resourceNames) { + this.namespace = StringUtils.isEmpty(resourceNames[0]) ? "minecraft" : resourceNames[0]; + this.path = resourceNames[1]; + + if (!this.namespace.chars().allMatch((p_195825_0_) -> { + return p_195825_0_ == 95 || p_195825_0_ == 45 || p_195825_0_ >= 97 && p_195825_0_ <= 122 || p_195825_0_ >= 48 && p_195825_0_ <= 57 || p_195825_0_ == 46; + })) { + throw new IllegalArgumentException("Non [a-z0-9_.-] character in namespace of location: " + this.namespace + ':' + this.path); + } else if (!this.path.chars().allMatch((p_195827_0_) -> { + return p_195827_0_ == 95 || p_195827_0_ == 45 || p_195827_0_ >= 97 && p_195827_0_ <= 122 || p_195827_0_ >= 48 && p_195827_0_ <= 57 || p_195827_0_ == 47 || p_195827_0_ == 46; + })) { + throw new IllegalArgumentException("Non [a-z0-9/._-] character in path of location: " + this.namespace + ':' + this.path); + } + } + + public Identifier(String resourceName) { + this(decompose(resourceName, ':')); + } + + public Identifier(String namespaceIn, String pathIn) { + this(new String[]{namespaceIn, pathIn}); + } + + public static Identifier of(String resourceName, char split) { + return new Identifier(decompose(resourceName, split)); + } + + @Nullable + public static Identifier makeIdentifier(String string) { + try { + return new Identifier(string); + } catch (IllegalArgumentException var2) { + return null; + } + } + + protected static String[] decompose(String p_195823_0_, char p_195823_1_) { + String[] astring = new String[]{"minecraft", p_195823_0_}; + int i = p_195823_0_.indexOf(p_195823_1_); + + if (i >= 0) { + astring[1] = p_195823_0_.substring(i + 1, p_195823_0_.length()); + + if (i >= 1) { + astring[0] = p_195823_0_.substring(0, i); + } + } + + return astring; + } + + public static Identifier read(StringReader reader) throws CommandSyntaxException { + int i = reader.getCursor(); + + while (reader.canRead() && isValidPathCharacter(reader.peek())) + reader.skip(); + + String s = reader.getString().substring(i, reader.getCursor()); + + try { + return new Identifier(s); + } catch (IllegalArgumentException var4) { + reader.setCursor(i); + throw COMMAND_EXCEPTION_TYPE.createWithContext(reader); + } + } + + public static boolean isValidPathCharacter(char charIn) { + return charIn >= '0' && charIn <= '9' || charIn >= 'a' && charIn <= 'z' || charIn == '_' || charIn == ':' || charIn == '/' || charIn == '.' || charIn == '-'; + } + + public String getPath() { + return this.path; + } + + public String getNamespace() { + return this.namespace; + } + + public String toString() { + return this.namespace + ':' + this.path; + } + + public boolean equals(Object p_equals_1_) { + if (this == p_equals_1_) { + return true; + } else if (!(p_equals_1_ instanceof Identifier)) { + return false; + } else { + Identifier identifier = (Identifier) p_equals_1_; + return this.namespace.equals(identifier.namespace) && this.path.equals(identifier.path); + } + } + + public int hashCode() { + return 31 * this.namespace.hashCode() + this.path.hashCode(); + } + + public int compareTo(Identifier p_compareTo_1_) { + int i = this.path.compareTo(p_compareTo_1_.path); + + if (i == 0) { + i = this.namespace.compareTo(p_compareTo_1_.namespace); + } + + return i; + } + + public static class Serializer implements JsonDeserializer<Identifier>, JsonSerializer<Identifier> { + public Identifier deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { + return new Identifier(JsonUtils.getString(p_deserialize_1_, "location")); + } + + public JsonElement serialize(Identifier p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_) { + return new JsonPrimitive(p_serialize_1_.toString()); + } + } +} diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelper.java b/src/main/java/me/shedaniel/rei/client/RecipeHelper.java index 79128d814..f3885dd70 100644 --- a/src/main/java/me/shedaniel/rei/client/RecipeHelper.java +++ b/src/main/java/me/shedaniel/rei/client/RecipeHelper.java @@ -7,7 +7,6 @@ import me.shedaniel.rei.RoughlyEnoughItemsPlugin; import me.shedaniel.rei.api.*; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.RecipeManager; -import net.minecraft.util.ResourceLocation; import java.awt.*; import java.util.*; @@ -16,10 +15,10 @@ import java.util.stream.Collectors; public class RecipeHelper { - private final Map<ResourceLocation, List<IRecipeDisplay>> recipeCategoryListMap = Maps.newHashMap(); + private final Map<Identifier, List<IRecipeDisplay>> recipeCategoryListMap = Maps.newHashMap(); private final List<IRecipeCategory> categories = Lists.newArrayList(); - private final Map<ResourceLocation, SpeedCraftAreaSupplier> speedCraftAreaSupplierMap = Maps.newHashMap(); - private final Map<ResourceLocation, List<SpeedCraftFunctional>> speedCraftFunctionalMap = Maps.newHashMap(); + private final Map<Identifier, SpeedCraftAreaSupplier> speedCraftAreaSupplierMap = Maps.newHashMap(); + private final Map<Identifier, List<SpeedCraftFunctional>> speedCraftFunctionalMap = Maps.newHashMap(); private RecipeManager recipeManager; public static RecipeHelper getInstance() { @@ -57,19 +56,19 @@ public class RecipeHelper { public void registerCategory(IRecipeCategory category) { categories.add(category); - recipeCategoryListMap.put(category.getResourceLocation(), Lists.newLinkedList()); + recipeCategoryListMap.put(category.getIdentifier(), Lists.newLinkedList()); } - public void registerDisplay(ResourceLocation categoryIdentifier, IRecipeDisplay display) { + public void registerDisplay(Identifier categoryIdentifier, IRecipeDisplay display) { if (!recipeCategoryListMap.containsKey(categoryIdentifier)) return; recipeCategoryListMap.get(categoryIdentifier).add(display); } public Map<IRecipeCategory, List<IRecipeDisplay>> getRecipesFor(ItemStack stack) { - Map<ResourceLocation, List<IRecipeDisplay>> categoriesMap = new HashMap<>(); - categories.forEach(f -> categoriesMap.put(f.getResourceLocation(), Lists.newArrayList())); - for(Map.Entry<ResourceLocation, List<IRecipeDisplay>> entry : recipeCategoryListMap.entrySet()) { + Map<Identifier, List<IRecipeDisplay>> categoriesMap = new HashMap<>(); + categories.forEach(f -> categoriesMap.put(f.getIdentifier(), Lists.newArrayList())); + for(Map.Entry<Identifier, List<IRecipeDisplay>> entry : recipeCategoryListMap.entrySet()) { IRecipeCategory category = getCategory(entry.getKey()); for(IRecipeDisplay recipeDisplay : entry.getValue()) for(ItemStack outputStack : (List<ItemStack>) recipeDisplay.getOutput()) @@ -78,14 +77,14 @@ public class RecipeHelper { } Map<IRecipeCategory, List<IRecipeDisplay>> recipeCategoryListMap = Maps.newLinkedHashMap(); categories.forEach(category -> { - if (categoriesMap.containsKey(category.getResourceLocation()) && !categoriesMap.get(category.getResourceLocation()).isEmpty()) - recipeCategoryListMap.put(category, categoriesMap.get(category.getResourceLocation())); + if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty()) + recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier())); }); return recipeCategoryListMap; } - private IRecipeCategory getCategory(ResourceLocation resourceLocation) { - return categories.stream().filter(category -> category.getResourceLocation().equals(resourceLocation)).findFirst().orElse(null); + private IRecipeCategory getCategory(Identifier identifier) { + return categories.stream().filter(category -> category.getIdentifier().equals(identifier)).findFirst().orElse(null); } public RecipeManager getRecipeManager() { @@ -93,9 +92,9 @@ public class RecipeHelper { } public Map<IRecipeCategory, List<IRecipeDisplay>> getUsagesFor(ItemStack stack) { - Map<ResourceLocation, List<IRecipeDisplay>> categoriesMap = new HashMap<>(); - categories.forEach(f -> categoriesMap.put(f.getResourceLocation(), Lists.newArrayList())); - for(Map.Entry<ResourceLocation, List<IRecipeDisplay>> entry : recipeCategoryListMap.entrySet()) { + Map<Identifier, List<IRecipeDisplay>> categoriesMap = new HashMap<>(); + categories.forEach(f -> categoriesMap.put(f.getIdentifier(), Lists.newArrayList())); + for(Map.Entry<Identifier, List<IRecipeDisplay>> entry : recipeCategoryListMap.entrySet()) { IRecipeCategory category = getCategory(entry.getKey()); for(IRecipeDisplay recipeDisplay : entry.getValue()) { boolean found = false; @@ -114,8 +113,8 @@ public class RecipeHelper { } Map<IRecipeCategory, List<IRecipeDisplay>> recipeCategoryListMap = Maps.newLinkedHashMap(); categories.forEach(category -> { - if (categoriesMap.containsKey(category.getResourceLocation()) && !categoriesMap.get(category.getResourceLocation()).isEmpty()) - recipeCategoryListMap.put(category, categoriesMap.get(category.getResourceLocation())); + if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty()) + recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier())); }); return recipeCategoryListMap; } @@ -125,24 +124,24 @@ public class RecipeHelper { } public SpeedCraftAreaSupplier getSpeedCraftButtonArea(IRecipeCategory category) { - if (!speedCraftAreaSupplierMap.containsKey(category.getResourceLocation())) + if (!speedCraftAreaSupplierMap.containsKey(category.getIdentifier())) return bounds -> { return new Rectangle((int) bounds.getMaxX() - 16, (int) bounds.getMaxY() - 16, 10, 10); }; - return speedCraftAreaSupplierMap.get(category.getResourceLocation()); + return speedCraftAreaSupplierMap.get(category.getIdentifier()); } - public void registerSpeedCraftButtonArea(ResourceLocation category, SpeedCraftAreaSupplier rectangle) { + public void registerSpeedCraftButtonArea(Identifier category, SpeedCraftAreaSupplier rectangle) { speedCraftAreaSupplierMap.put(category, rectangle); } public List<SpeedCraftFunctional> getSpeedCraftFunctional(IRecipeCategory category) { - if (speedCraftFunctionalMap.get(category.getResourceLocation()) == null) + if (speedCraftFunctionalMap.get(category.getIdentifier()) == null) return Lists.newArrayList(); - return speedCraftFunctionalMap.get(category.getResourceLocation()); + return speedCraftFunctionalMap.get(category.getIdentifier()); } - public void registerSpeedCraftFunctional(ResourceLocation category, SpeedCraftFunctional functional) { + public void registerSpeedCraftFunctional(Identifier category, SpeedCraftFunctional functional) { List<SpeedCraftFunctional> list = speedCraftFunctionalMap.containsKey(category) ? new LinkedList<>(speedCraftFunctionalMap.get(category)) : Lists.newLinkedList(); list.add(functional); speedCraftFunctionalMap.put(category, list); @@ -160,22 +159,22 @@ public class RecipeHelper { return second.getPriority() - first.getPriority(); }); RoughlyEnoughItemsCore.LOGGER.info("Loading %d REI plugins: %s", plugins.size(), String.join(", ", plugins.stream().map(plugin -> { - String resourceLocation = RoughlyEnoughItemsPlugin.getPluginResourceLocation(plugin); - return resourceLocation == null ? "NULL" : resourceLocation; + Identifier identifier = RoughlyEnoughItemsPlugin.getIdentifier(plugin); + return identifier == null ? "NULL" : identifier.toString(); }).collect(Collectors.toList()))); Collections.reverse(plugins); RoughlyEnoughItemsCore.getItemRegisterer().getModifiableItemList().clear(); IPluginDisabler pluginDisabler = RoughlyEnoughItemsCore.getPluginDisabler(); plugins.forEach(plugin -> { - String location = RoughlyEnoughItemsPlugin.getPluginResourceLocation(plugin); - ResourceLocation resourceLocation = new ResourceLocation(location == null ? "null" : location); - if (pluginDisabler.isFunctionEnabled(resourceLocation, PluginFunction.REGISTER_ITEMS)) + Identifier location = RoughlyEnoughItemsPlugin.getIdentifier(plugin); + Identifier identifier = location == null ? new Identifier("null") : location; + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_ITEMS)) plugin.registerItems(RoughlyEnoughItemsCore.getItemRegisterer()); - if (pluginDisabler.isFunctionEnabled(resourceLocation, PluginFunction.REGISTER_CATEGORIES)) + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_CATEGORIES)) plugin.registerPluginCategories(this); - if (pluginDisabler.isFunctionEnabled(resourceLocation, PluginFunction.REGISTER_RECIPE_DISPLAYS)) + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_RECIPE_DISPLAYS)) plugin.registerRecipeDisplays(this); - if (pluginDisabler.isFunctionEnabled(resourceLocation, PluginFunction.REGISTER_SPEED_CRAFT)) + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_SPEED_CRAFT)) plugin.registerSpeedCraft(this); }); RoughlyEnoughItemsCore.LOGGER.info("Registered REI Categories: " + String.join(", ", categories.stream().map(category -> { diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java index 541c6476c..6b3844614 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingCategory.java @@ -1,6 +1,7 @@ package me.shedaniel.rei.plugin; import me.shedaniel.rei.api.IRecipeCategory; +import me.shedaniel.rei.api.Identifier; import me.shedaniel.rei.gui.widget.IWidget; import me.shedaniel.rei.gui.widget.ItemSlotWidget; import me.shedaniel.rei.gui.widget.RecipeBaseWidget; @@ -25,7 +26,7 @@ public class DefaultBrewingCategory implements IRecipeCategory<DefaultBrewingDis private static final ResourceLocation DISPLAY_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/display.png"); @Override - public ResourceLocation getResourceLocation() { + public Identifier getIdentifier() { return DefaultPlugin.BREWING; } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingDisplay.java index d97638310..fc4a85572 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultBrewingDisplay.java @@ -1,12 +1,12 @@ package me.shedaniel.rei.plugin; import me.shedaniel.rei.api.IRecipeDisplay; +import me.shedaniel.rei.api.Identifier; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; import java.util.ArrayList; import java.util.Arrays; @@ -39,7 +39,7 @@ public class DefaultBrewingDisplay implements IRecipeDisplay { } @Override - public ResourceLocation getRecipeCategory() { + public Identifier getRecipeCategory() { return DefaultPlugin.BREWING; } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultCraftingCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultCraftingCategory.java index 32eda67c4..51cc69286 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultCraftingCategory.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultCraftingCategory.java @@ -2,6 +2,7 @@ package me.shedaniel.rei.plugin; import com.google.common.collect.Lists; import me.shedaniel.rei.api.IRecipeCategory; +import me.shedaniel.rei.api.Identifier; import me.shedaniel.rei.gui.widget.IWidget; import me.shedaniel.rei.gui.widget.ItemSlotWidget; import me.shedaniel.rei.gui.widget.RecipeBaseWidget; @@ -24,7 +25,7 @@ public class DefaultCraftingCategory implements IRecipeCategory<DefaultCraftingD private static final ResourceLocation DISPLAY_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/display.png"); @Override - public ResourceLocation getResourceLocation() { + public Identifier getIdentifier() { return DefaultPlugin.CRAFTING; } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultCraftingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/DefaultCraftingDisplay.java index a2c1c6eab..69a30ebfa 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultCraftingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultCraftingDisplay.java @@ -1,13 +1,13 @@ package me.shedaniel.rei.plugin; import me.shedaniel.rei.api.IRecipeDisplay; +import me.shedaniel.rei.api.Identifier; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; public interface DefaultCraftingDisplay<T> extends IRecipeDisplay<IRecipe> { @Override - default ResourceLocation getRecipeCategory() { + default Identifier getRecipeCategory() { return DefaultPlugin.CRAFTING; } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java index 52f1a296a..5f2f44e23 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java @@ -19,7 +19,6 @@ import net.minecraft.item.crafting.FurnaceRecipe; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.item.crafting.ShapelessRecipe; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.IRegistry; import java.util.HashMap; @@ -28,9 +27,9 @@ import java.util.Map; public class DefaultPlugin implements IRecipePlugin { - static final ResourceLocation CRAFTING = new ResourceLocation("roughlyenoughitems", "plugins/crafting"); - static final ResourceLocation SMELTING = new ResourceLocation("roughlyenoughitems", "plugins/smelting"); - static final ResourceLocation BREWING = new ResourceLocation("roughlyenoughitems", "plugins/brewing"); + static final Identifier CRAFTING = new Identifier("roughlyenoughitems", "plugins/crafting"); + static final Identifier SMELTING = new Identifier("roughlyenoughitems", "plugins/smelting"); + static final Identifier BREWING = new Identifier("roughlyenoughitems", "plugins/brewing"); static final List<DefaultBrewingDisplay> BREWING_DISPLAYS = Lists.newArrayList(); @@ -41,10 +40,10 @@ public class DefaultPlugin implements IRecipePlugin { @Override public void onFirstLoad(IPluginDisabler pluginDisabler) { if (!ConfigHelper.getInstance().isLoadingDefaultPlugin()) { - pluginDisabler.disablePluginFunction(new ResourceLocation("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_ITEMS); - pluginDisabler.disablePluginFunction(new ResourceLocation("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_CATEGORIES); - pluginDisabler.disablePluginFunction(new ResourceLocation("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_RECIPE_DISPLAYS); - pluginDisabler.disablePluginFunction(new ResourceLocation("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_SPEED_CRAFT); + pluginDisabler.disablePluginFunction(new Identifier("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_ITEMS); + pluginDisabler.disablePluginFunction(new Identifier("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_CATEGORIES); + pluginDisabler.disablePluginFunction(new Identifier("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_RECIPE_DISPLAYS); + pluginDisabler.disablePluginFunction(new Identifier("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_SPEED_CRAFT); } } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java b/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java index 7865ff928..b4b5134d7 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingCategory.java @@ -1,6 +1,7 @@ package me.shedaniel.rei.plugin; import me.shedaniel.rei.api.IRecipeCategory; +import me.shedaniel.rei.api.Identifier; import me.shedaniel.rei.gui.widget.IWidget; import me.shedaniel.rei.gui.widget.ItemSlotWidget; import me.shedaniel.rei.gui.widget.RecipeBaseWidget; @@ -24,7 +25,7 @@ public class DefaultSmeltingCategory implements IRecipeCategory<DefaultSmeltingD private static final ResourceLocation DISPLAY_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/display.png"); @Override - public ResourceLocation getResourceLocation() { + public Identifier getIdentifier() { return DefaultPlugin.SMELTING; } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingDisplay.java b/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingDisplay.java index b9af46f31..8419487f5 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingDisplay.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultSmeltingDisplay.java @@ -2,11 +2,11 @@ package me.shedaniel.rei.plugin; import com.google.common.collect.Lists; import me.shedaniel.rei.api.IRecipeDisplay; +import me.shedaniel.rei.api.Identifier; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipe; import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.ResourceLocation; import java.util.Arrays; import java.util.List; @@ -50,7 +50,7 @@ public class DefaultSmeltingDisplay implements IRecipeDisplay<FurnaceRecipe> { } @Override - public ResourceLocation g |
