Merge pull request #1520 from PepperCode1/mc1.16/reload-listeners
Tweak Reload Listener Classes
This commit is contained in:
commit
b086fbd1f2
5 changed files with 46 additions and 65 deletions
|
@ -3,31 +3,19 @@ package com.simibubi.create.content.contraptions.fluids.recipe;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.resources.ReloadListener;
|
import com.simibubi.create.foundation.utility.ISimpleReloadListener;
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.profiler.IProfiler;
|
|
||||||
import net.minecraft.resources.IResourceManager;
|
|
||||||
|
|
||||||
public class FluidTransferRecipes {
|
public class FluidTransferRecipes {
|
||||||
|
|
||||||
public static List<ItemStack> POTION_ITEMS = new ArrayList<>();
|
public static List<ItemStack> POTION_ITEMS = new ArrayList<>();
|
||||||
public static List<Item> FILLED_BUCKETS = new ArrayList<>();
|
public static List<Item> FILLED_BUCKETS = new ArrayList<>();
|
||||||
|
|
||||||
|
public static final ISimpleReloadListener LISTENER = (resourceManager, profiler) -> {
|
||||||
|
POTION_ITEMS.clear();
|
||||||
public static final ReloadListener<Object> LISTENER = new ReloadListener<Object>() {
|
FILLED_BUCKETS.clear();
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Object prepare(IResourceManager p_212854_1_, IProfiler p_212854_2_) {
|
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void apply(Object p_212853_1_, IResourceManager p_212853_2_, IProfiler p_212853_3_) {
|
|
||||||
POTION_ITEMS.clear();
|
|
||||||
FILLED_BUCKETS.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler
|
||||||
import com.simibubi.create.content.contraptions.processing.HeatCondition;
|
import com.simibubi.create.content.contraptions.processing.HeatCondition;
|
||||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder;
|
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder;
|
||||||
import com.simibubi.create.foundation.fluid.FluidIngredient;
|
import com.simibubi.create.foundation.fluid.FluidIngredient;
|
||||||
|
import com.simibubi.create.foundation.utility.ISimpleReloadListener;
|
||||||
|
|
||||||
import net.minecraft.client.resources.ReloadListener;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
|
@ -24,8 +24,6 @@ import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.potion.PotionBrewing;
|
import net.minecraft.potion.PotionBrewing;
|
||||||
import net.minecraft.potion.PotionUtils;
|
import net.minecraft.potion.PotionUtils;
|
||||||
import net.minecraft.potion.Potions;
|
import net.minecraft.potion.Potions;
|
||||||
import net.minecraft.profiler.IProfiler;
|
|
||||||
import net.minecraft.resources.IResourceManager;
|
|
||||||
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
|
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
|
||||||
import net.minecraftforge.common.brewing.IBrewingRecipe;
|
import net.minecraftforge.common.brewing.IBrewingRecipe;
|
||||||
import net.minecraftforge.common.brewing.VanillaBrewingRecipe;
|
import net.minecraftforge.common.brewing.VanillaBrewingRecipe;
|
||||||
|
@ -133,27 +131,17 @@ public class PotionMixingRecipeManager {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ReloadListener<Object> LISTENER = new ReloadListener<Object>() {
|
public static final ISimpleReloadListener LISTENER = (resourceManager, profiler) -> {
|
||||||
|
ALL.clear();
|
||||||
@Override
|
getAllBrewingRecipes().forEach(recipe -> {
|
||||||
protected Object prepare(IResourceManager p_212854_1_, IProfiler p_212854_2_) {
|
for (Ingredient ingredient : recipe.getIngredients()) {
|
||||||
return new Object();
|
for (ItemStack itemStack : ingredient.getMatchingStacks()) {
|
||||||
}
|
ALL.computeIfAbsent(itemStack.getItem(), t -> new ArrayList<>())
|
||||||
|
.add(recipe);
|
||||||
@Override
|
return;
|
||||||
protected void apply(Object p_212853_1_, IResourceManager p_212853_2_, IProfiler p_212853_3_) {
|
|
||||||
ALL.clear();
|
|
||||||
getAllBrewingRecipes().forEach(recipe -> {
|
|
||||||
for (Ingredient ingredient : recipe.getIngredients()) {
|
|
||||||
for (ItemStack itemStack : ingredient.getMatchingStacks()) {
|
|
||||||
ALL.computeIfAbsent(itemStack.getItem(), t -> new ArrayList<>())
|
|
||||||
.add(recipe);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,20 +3,15 @@ package com.simibubi.create.foundation;
|
||||||
import com.simibubi.create.CreateClient;
|
import com.simibubi.create.CreateClient;
|
||||||
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
||||||
import com.simibubi.create.foundation.block.render.SpriteShifter;
|
import com.simibubi.create.foundation.block.render.SpriteShifter;
|
||||||
|
import com.simibubi.create.foundation.utility.ISimpleReloadListener;
|
||||||
|
|
||||||
import net.minecraft.client.resources.ReloadListener;
|
|
||||||
import net.minecraft.profiler.IProfiler;
|
import net.minecraft.profiler.IProfiler;
|
||||||
import net.minecraft.resources.IResourceManager;
|
import net.minecraft.resources.IResourceManager;
|
||||||
|
|
||||||
public class ResourceReloadHandler extends ReloadListener<Object> {
|
public class ResourceReloadHandler implements ISimpleReloadListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object prepare(IResourceManager resourceManagerIn, IProfiler profilerIn) {
|
public void onReload(IResourceManager resourceManagerIn, IProfiler profilerIn) {
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void apply(Object $, IResourceManager resourceManagerIn, IProfiler profilerIn) {
|
|
||||||
SpriteShifter.reloadUVs();
|
SpriteShifter.reloadUVs();
|
||||||
CreateClient.invalidateRenderers();
|
CreateClient.invalidateRenderers();
|
||||||
IHaveGoggleInformation.numberFormat.update();
|
IHaveGoggleInformation.numberFormat.update();
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.simibubi.create.foundation.utility;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import net.minecraft.profiler.IProfiler;
|
||||||
|
import net.minecraft.resources.IFutureReloadListener;
|
||||||
|
import net.minecraft.resources.IResourceManager;
|
||||||
|
import net.minecraft.util.Unit;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ISimpleReloadListener extends IFutureReloadListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default CompletableFuture<Void> reload(IFutureReloadListener.IStage stage, IResourceManager resourceManager, IProfiler prepareProfiler, IProfiler applyProfiler, Executor prepareExecutor, Executor applyExecutor) {
|
||||||
|
return stage.markCompleteAwaitingOthers(Unit.INSTANCE).thenRunAsync(() -> {
|
||||||
|
onReload(resourceManager, applyProfiler);
|
||||||
|
}, applyExecutor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onReload(IResourceManager resourceManager, IProfiler profiler);
|
||||||
|
|
||||||
|
}
|
|
@ -10,11 +10,9 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.simibubi.create.foundation.utility.ISimpleReloadListener;
|
||||||
|
|
||||||
import net.minecraft.client.resources.ReloadListener;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.profiler.IProfiler;
|
|
||||||
import net.minecraft.resources.IResourceManager;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,19 +56,8 @@ public class RecipeFinder {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final ISimpleReloadListener LISTENER = (resourceManager, profiler) -> {
|
||||||
public static final ReloadListener<Object> LISTENER = new ReloadListener<Object>() {
|
cachedSearches.invalidateAll();
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Object prepare(IResourceManager p_212854_1_, IProfiler p_212854_2_) {
|
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void apply(Object p_212853_1_, IResourceManager p_212853_2_, IProfiler p_212853_3_) {
|
|
||||||
cachedSearches.invalidateAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue