|
@@ -26,23 +26,17 @@ package me.shedaniel.rei.plugin;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
|
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
|
-import me.shedaniel.math.Point;
|
|
|
|
import me.shedaniel.math.Rectangle;
|
|
import me.shedaniel.math.Rectangle;
|
|
-import me.shedaniel.rei.RoughlyEnoughItemsCore;
|
|
|
|
import me.shedaniel.rei.api.*;
|
|
import me.shedaniel.rei.api.*;
|
|
import me.shedaniel.rei.api.fluid.FluidSupportProvider;
|
|
import me.shedaniel.rei.api.fluid.FluidSupportProvider;
|
|
import me.shedaniel.rei.api.plugins.REIPluginV0;
|
|
import me.shedaniel.rei.api.plugins.REIPluginV0;
|
|
-import me.shedaniel.rei.api.widgets.Panel;
|
|
|
|
-import me.shedaniel.rei.api.widgets.Tooltip;
|
|
|
|
-import me.shedaniel.rei.gui.RecipeViewingScreen;
|
|
|
|
-import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
|
|
|
|
-import me.shedaniel.rei.impl.ClientHelperImpl;
|
|
|
|
-import me.shedaniel.rei.impl.RenderingEntry;
|
|
|
|
|
|
+import me.shedaniel.rei.plugin.autocrafting.DefaultRecipeBookHandler;
|
|
import me.shedaniel.rei.plugin.beacon.DefaultBeaconBaseCategory;
|
|
import me.shedaniel.rei.plugin.beacon.DefaultBeaconBaseCategory;
|
|
import me.shedaniel.rei.plugin.beacon.DefaultBeaconBaseDisplay;
|
|
import me.shedaniel.rei.plugin.beacon.DefaultBeaconBaseDisplay;
|
|
import me.shedaniel.rei.plugin.blasting.DefaultBlastingDisplay;
|
|
import me.shedaniel.rei.plugin.blasting.DefaultBlastingDisplay;
|
|
import me.shedaniel.rei.plugin.brewing.DefaultBrewingCategory;
|
|
import me.shedaniel.rei.plugin.brewing.DefaultBrewingCategory;
|
|
import me.shedaniel.rei.plugin.brewing.DefaultBrewingDisplay;
|
|
import me.shedaniel.rei.plugin.brewing.DefaultBrewingDisplay;
|
|
|
|
+import me.shedaniel.rei.plugin.brewing.RegisteredBrewingRecipe;
|
|
import me.shedaniel.rei.plugin.campfire.DefaultCampfireCategory;
|
|
import me.shedaniel.rei.plugin.campfire.DefaultCampfireCategory;
|
|
import me.shedaniel.rei.plugin.campfire.DefaultCampfireDisplay;
|
|
import me.shedaniel.rei.plugin.campfire.DefaultCampfireDisplay;
|
|
import me.shedaniel.rei.plugin.composting.DefaultCompostingCategory;
|
|
import me.shedaniel.rei.plugin.composting.DefaultCompostingCategory;
|
|
@@ -73,7 +67,6 @@ import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
|
import net.minecraft.client.MinecraftClient;
|
|
import net.minecraft.client.MinecraftClient;
|
|
import net.minecraft.client.gui.screen.ingame.*;
|
|
import net.minecraft.client.gui.screen.ingame.*;
|
|
import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
|
|
import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
|
|
-import net.minecraft.client.util.math.MatrixStack;
|
|
|
|
import net.minecraft.enchantment.Enchantment;
|
|
import net.minecraft.enchantment.Enchantment;
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
|
import net.minecraft.fluid.Fluid;
|
|
import net.minecraft.fluid.Fluid;
|
|
@@ -82,18 +75,20 @@ import net.minecraft.potion.PotionUtil;
|
|
import net.minecraft.recipe.*;
|
|
import net.minecraft.recipe.*;
|
|
import net.minecraft.tag.BlockTags;
|
|
import net.minecraft.tag.BlockTags;
|
|
import net.minecraft.tag.Tag;
|
|
import net.minecraft.tag.Tag;
|
|
-import net.minecraft.text.LiteralText;
|
|
|
|
import net.minecraft.util.Identifier;
|
|
import net.minecraft.util.Identifier;
|
|
|
|
+import net.minecraft.util.Lazy;
|
|
import net.minecraft.util.math.MathHelper;
|
|
import net.minecraft.util.math.MathHelper;
|
|
import net.minecraft.util.registry.Registry;
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
|
+import org.jetbrains.annotations.ApiStatus;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.NotNull;
|
|
-import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
@Environment(EnvType.CLIENT)
|
|
public class DefaultPlugin implements REIPluginV0 {
|
|
public class DefaultPlugin implements REIPluginV0 {
|
|
-
|
|
|
|
|
|
+ private static final Logger LOGGER = LogManager.getFormatterLogger("REI/DefaultPlugin");
|
|
public static final Identifier CRAFTING = new Identifier("minecraft", "plugins/crafting");
|
|
public static final Identifier CRAFTING = new Identifier("minecraft", "plugins/crafting");
|
|
public static final Identifier SMELTING = new Identifier("minecraft", "plugins/smelting");
|
|
public static final Identifier SMELTING = new Identifier("minecraft", "plugins/smelting");
|
|
public static final Identifier SMOKING = new Identifier("minecraft", "plugins/smoking");
|
|
public static final Identifier SMOKING = new Identifier("minecraft", "plugins/smoking");
|
|
@@ -110,15 +105,21 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
public static final Identifier INFO = new Identifier("roughlyenoughitems", "plugins/information");
|
|
public static final Identifier INFO = new Identifier("roughlyenoughitems", "plugins/information");
|
|
private static final Identifier DISPLAY_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/display.png");
|
|
private static final Identifier DISPLAY_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/display.png");
|
|
private static final Identifier DISPLAY_TEXTURE_DARK = new Identifier("roughlyenoughitems", "textures/gui/display_dark.png");
|
|
private static final Identifier DISPLAY_TEXTURE_DARK = new Identifier("roughlyenoughitems", "textures/gui/display_dark.png");
|
|
- private static final List<DefaultBrewingDisplay> BREWING_DISPLAYS = Lists.newArrayList();
|
|
|
|
|
|
+ private static final List<Lazy<DefaultBrewingDisplay>> BREWING_DISPLAYS = Lists.newArrayList();
|
|
private static final List<DefaultInformationDisplay> INFO_DISPLAYS = Lists.newArrayList();
|
|
private static final List<DefaultInformationDisplay> INFO_DISPLAYS = Lists.newArrayList();
|
|
|
|
|
|
public static Identifier getDisplayTexture() {
|
|
public static Identifier getDisplayTexture() {
|
|
- return REIHelper.getInstance().isDarkThemeEnabled() ? DISPLAY_TEXTURE_DARK : DISPLAY_TEXTURE;
|
|
|
|
|
|
+ return REIHelper.getInstance().getDefaultDisplayTexture();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Deprecated
|
|
|
|
+ @ApiStatus.ScheduledForRemoval
|
|
|
|
+ public static void registerBrewingDisplay(DefaultBrewingDisplay recipe) {
|
|
|
|
+ BREWING_DISPLAYS.add(new Lazy<>(() -> recipe));
|
|
}
|
|
}
|
|
|
|
|
|
- public static void registerBrewingDisplay(DefaultBrewingDisplay display) {
|
|
|
|
- BREWING_DISPLAYS.add(display);
|
|
|
|
|
|
+ public static void registerBrewingRecipe(RegisteredBrewingRecipe recipe) {
|
|
|
|
+ BREWING_DISPLAYS.add(new Lazy<>(() -> new DefaultBrewingDisplay(recipe.input, recipe.ingredient, recipe.output)));
|
|
}
|
|
}
|
|
|
|
|
|
public static void registerInfoDisplay(DefaultInformationDisplay display) {
|
|
public static void registerInfoDisplay(DefaultInformationDisplay display) {
|
|
@@ -137,9 +138,6 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void registerEntries(EntryRegistry entryRegistry) {
|
|
public void registerEntries(EntryRegistry entryRegistry) {
|
|
- if (!ConfigObject.getInstance().isLoadingDefaultPlugin()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
for (Item item : Registry.ITEM) {
|
|
for (Item item : Registry.ITEM) {
|
|
List<ItemStack> stacks = null;
|
|
List<ItemStack> stacks = null;
|
|
try {
|
|
try {
|
|
@@ -169,32 +167,10 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
if (!fluid.getDefaultState().isEmpty() && fluid.getDefaultState().isStill())
|
|
if (!fluid.getDefaultState().isEmpty() && fluid.getDefaultState().isStill())
|
|
entryRegistry.registerEntry(EntryStack.create(fluid));
|
|
entryRegistry.registerEntry(EntryStack.create(fluid));
|
|
}
|
|
}
|
|
- entryRegistry.registerEntry(new RenderingEntry() {
|
|
|
|
- private Identifier id = new Identifier("roughlyenoughitems", "textures/gui/kirb.png");
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void render(MatrixStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) {
|
|
|
|
- MinecraftClient.getInstance().getTextureManager().bindTexture(id);
|
|
|
|
- drawTexturedQuad(matrices.peek().getModel(), bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), getZOffset(), 0, 1, 0, 1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public boolean isEmpty() {
|
|
|
|
- return !((ClientHelperImpl) ClientHelper.getInstance()).isAprilFools.get();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public @Nullable Tooltip getTooltip(Point point) {
|
|
|
|
- return Tooltip.create(new LiteralText("Kibby"));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void registerPluginCategories(RecipeHelper recipeHelper) {
|
|
public void registerPluginCategories(RecipeHelper recipeHelper) {
|
|
- if (!ConfigObject.getInstance().isLoadingDefaultPlugin()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
recipeHelper.registerCategories(
|
|
recipeHelper.registerCategories(
|
|
new DefaultCraftingCategory(),
|
|
new DefaultCraftingCategory(),
|
|
new DefaultCookingCategory(SMELTING, EntryStack.create(Items.FURNACE), "category.rei.smelting"),
|
|
new DefaultCookingCategory(SMELTING, EntryStack.create(Items.FURNACE), "category.rei.smelting"),
|
|
@@ -213,9 +189,6 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
|
|
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
|
|
- if (!ConfigObject.getInstance().isLoadingDefaultPlugin()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
recipeHelper.registerRecipes(CRAFTING, ShapelessRecipe.class, DefaultShapelessDisplay::new);
|
|
recipeHelper.registerRecipes(CRAFTING, ShapelessRecipe.class, DefaultShapelessDisplay::new);
|
|
recipeHelper.registerRecipes(CRAFTING, ShapedRecipe.class, DefaultShapedDisplay::new);
|
|
recipeHelper.registerRecipes(CRAFTING, ShapedRecipe.class, DefaultShapedDisplay::new);
|
|
recipeHelper.registerRecipes(SMELTING, SmeltingRecipe.class, DefaultSmeltingDisplay::new);
|
|
recipeHelper.registerRecipes(SMELTING, SmeltingRecipe.class, DefaultSmeltingDisplay::new);
|
|
@@ -224,8 +197,8 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
recipeHelper.registerRecipes(CAMPFIRE, CampfireCookingRecipe.class, DefaultCampfireDisplay::new);
|
|
recipeHelper.registerRecipes(CAMPFIRE, CampfireCookingRecipe.class, DefaultCampfireDisplay::new);
|
|
recipeHelper.registerRecipes(STONE_CUTTING, StonecuttingRecipe.class, DefaultStoneCuttingDisplay::new);
|
|
recipeHelper.registerRecipes(STONE_CUTTING, StonecuttingRecipe.class, DefaultStoneCuttingDisplay::new);
|
|
recipeHelper.registerRecipes(SMITHING, SmithingRecipe.class, DefaultSmithingDisplay::new);
|
|
recipeHelper.registerRecipes(SMITHING, SmithingRecipe.class, DefaultSmithingDisplay::new);
|
|
- for (DefaultBrewingDisplay display : BREWING_DISPLAYS) {
|
|
|
|
- recipeHelper.registerDisplay(display);
|
|
|
|
|
|
+ for (Lazy<DefaultBrewingDisplay> display : BREWING_DISPLAYS) {
|
|
|
|
+ recipeHelper.registerDisplay(display.get());
|
|
}
|
|
}
|
|
for (Map.Entry<Item, Integer> entry : AbstractFurnaceBlockEntity.createFuelTimeMap().entrySet()) {
|
|
for (Map.Entry<Item, Integer> entry : AbstractFurnaceBlockEntity.createFuelTimeMap().entrySet()) {
|
|
recipeHelper.registerDisplay(new DefaultFuelDisplay(EntryStack.create(entry.getKey()), entry.getValue()));
|
|
recipeHelper.registerDisplay(new DefaultFuelDisplay(EntryStack.create(entry.getKey()), entry.getValue()));
|
|
@@ -284,7 +257,7 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
time = System.currentTimeMillis() - time;
|
|
time = System.currentTimeMillis() - time;
|
|
- RoughlyEnoughItemsCore.LOGGER.info("Applied Check Tags for potion in %dms.", time);
|
|
|
|
|
|
+ LOGGER.info("Applied Check Tags for potion in %dms.", time);
|
|
}
|
|
}
|
|
|
|
|
|
private void applyPotionTransformer(EntryStack stack) {
|
|
private void applyPotionTransformer(EntryStack stack) {
|
|
@@ -294,18 +267,9 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void registerBounds(DisplayHelper displayHelper) {
|
|
public void registerBounds(DisplayHelper displayHelper) {
|
|
- if (!ConfigObject.getInstance().isLoadingDefaultPlugin()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
BaseBoundsHandler baseBoundsHandler = BaseBoundsHandler.getInstance();
|
|
BaseBoundsHandler baseBoundsHandler = BaseBoundsHandler.getInstance();
|
|
baseBoundsHandler.registerExclusionZones(AbstractInventoryScreen.class, new DefaultPotionEffectExclusionZones());
|
|
baseBoundsHandler.registerExclusionZones(AbstractInventoryScreen.class, new DefaultPotionEffectExclusionZones());
|
|
baseBoundsHandler.registerExclusionZones(RecipeBookProvider.class, new DefaultRecipeBookExclusionZones());
|
|
baseBoundsHandler.registerExclusionZones(RecipeBookProvider.class, new DefaultRecipeBookExclusionZones());
|
|
- baseBoundsHandler.registerExclusionZones(RecipeViewingScreen.class, () -> {
|
|
|
|
- Panel widget = ((RecipeViewingScreen) MinecraftClient.getInstance().currentScreen).getWorkingStationsBaseWidget();
|
|
|
|
- if (widget == null)
|
|
|
|
- return Collections.emptyList();
|
|
|
|
- return Collections.singletonList(widget.getBounds().clone());
|
|
|
|
- });
|
|
|
|
displayHelper.registerProvider(new DisplayHelper.DisplayBoundsProvider<ContainerScreen<?>>() {
|
|
displayHelper.registerProvider(new DisplayHelper.DisplayBoundsProvider<ContainerScreen<?>>() {
|
|
@Override
|
|
@Override
|
|
public Rectangle getScreenBounds(ContainerScreen<?> screen) {
|
|
public Rectangle getScreenBounds(ContainerScreen<?> screen) {
|
|
@@ -317,35 +281,12 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
return ContainerScreen.class;
|
|
return ContainerScreen.class;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- displayHelper.registerProvider(new DisplayHelper.DisplayBoundsProvider<RecipeViewingScreen>() {
|
|
|
|
- @Override
|
|
|
|
- public Rectangle getScreenBounds(RecipeViewingScreen screen) {
|
|
|
|
- return screen.getBounds();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Class<?> getBaseSupportedClass() {
|
|
|
|
- return RecipeViewingScreen.class;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- displayHelper.registerProvider(new DisplayHelper.DisplayBoundsProvider<VillagerRecipeViewingScreen>() {
|
|
|
|
- @Override
|
|
|
|
- public Rectangle getScreenBounds(VillagerRecipeViewingScreen screen) {
|
|
|
|
- return screen.bounds;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Class<?> getBaseSupportedClass() {
|
|
|
|
- return VillagerRecipeViewingScreen.class;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void registerOthers(RecipeHelper recipeHelper) {
|
|
public void registerOthers(RecipeHelper recipeHelper) {
|
|
- if (!ConfigObject.getInstance().isLoadingDefaultPlugin()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ recipeHelper.registerAutoCraftingHandler(new DefaultRecipeBookHandler());
|
|
|
|
+
|
|
recipeHelper.registerWorkingStations(CRAFTING, EntryStack.create(Items.CRAFTING_TABLE));
|
|
recipeHelper.registerWorkingStations(CRAFTING, EntryStack.create(Items.CRAFTING_TABLE));
|
|
recipeHelper.registerWorkingStations(SMELTING, EntryStack.create(Items.FURNACE));
|
|
recipeHelper.registerWorkingStations(SMELTING, EntryStack.create(Items.FURNACE));
|
|
recipeHelper.registerWorkingStations(SMOKING, EntryStack.create(Items.SMOKER));
|
|
recipeHelper.registerWorkingStations(SMOKING, EntryStack.create(Items.SMOKER));
|
|
@@ -357,7 +298,7 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
recipeHelper.registerWorkingStations(COMPOSTING, EntryStack.create(Items.COMPOSTER));
|
|
recipeHelper.registerWorkingStations(COMPOSTING, EntryStack.create(Items.COMPOSTER));
|
|
recipeHelper.registerWorkingStations(SMITHING, EntryStack.create(Items.SMITHING_TABLE));
|
|
recipeHelper.registerWorkingStations(SMITHING, EntryStack.create(Items.SMITHING_TABLE));
|
|
recipeHelper.registerWorkingStations(BEACON, EntryStack.create(Items.BEACON));
|
|
recipeHelper.registerWorkingStations(BEACON, EntryStack.create(Items.BEACON));
|
|
- Tag<Item> axes = MinecraftClient.getInstance().getNetworkHandler().getTagManager().items().get(new Identifier("fabric", "axes"));
|
|
|
|
|
|
+ Tag<Item> axes = MinecraftClient.getInstance().getNetworkHandler().getTagManager().getItems().getTag(new Identifier("fabric", "axes"));
|
|
if (axes != null) {
|
|
if (axes != null) {
|
|
for (Item item : axes.values()) {
|
|
for (Item item : axes.values()) {
|
|
recipeHelper.registerWorkingStations(STRIPPING, EntryStack.create(item));
|
|
recipeHelper.registerWorkingStations(STRIPPING, EntryStack.create(item));
|
|
@@ -373,7 +314,7 @@ public class DefaultPlugin implements REIPluginV0 {
|
|
recipeHelper.registerScreenClickArea(new Rectangle(78, 32, 28, 23), FurnaceScreen.class, SMELTING);
|
|
recipeHelper.registerScreenClickArea(new Rectangle(78, 32, 28, 23), FurnaceScreen.class, SMELTING);
|
|
recipeHelper.registerScreenClickArea(new Rectangle(78, 32, 28, 23), SmokerScreen.class, SMOKING);
|
|
recipeHelper.registerScreenClickArea(new Rectangle(78, 32, 28, 23), SmokerScreen.class, SMOKING);
|
|
recipeHelper.registerScreenClickArea(new Rectangle(78, 32, 28, 23), BlastFurnaceScreen.class, BLASTING);
|
|
recipeHelper.registerScreenClickArea(new Rectangle(78, 32, 28, 23), BlastFurnaceScreen.class, BLASTING);
|
|
- FluidSupportProvider.INSTANCE.registerFluidProvider(new FluidSupportProvider.FluidProvider() {
|
|
|
|
|
|
+ FluidSupportProvider.getInstance().registerFluidProvider(new FluidSupportProvider.FluidProvider() {
|
|
@Override
|
|
@Override
|
|
public @NotNull EntryStack itemToFluid(@NotNull EntryStack itemStack) {
|
|
public @NotNull EntryStack itemToFluid(@NotNull EntryStack itemStack) {
|
|
Item item = itemStack.getItem();
|
|
Item item = itemStack.getItem();
|