mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
Expose ICondition$IContext to modded reload listeners. (#8596)
This commit is contained in:
1 parent
2fb8b2eb18
commit
168a3bc6fc
2 files changed
+32
-2
No files matched your search
@@ -18,8 +18,8 @@
|
||||
this.f_206849_ = new TagManager(p_206857_);
|
||||
this.f_206847_ = new Commands(p_206858_);
|
||||
this.f_206854_ = new ServerFunctionLibrary(p_206859_, this.f_206847_.m_82094_());
|
||||
+ // Forge: pass condition context too
|
||||
+ var context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.f_206849_);
|
||||
+ // Forge: Create context object and pass it to the recipe manager.
|
||||
+ this.context = new net.minecraftforge.common.crafting.conditions.ConditionContext(this.f_206849_);
|
||||
+ this.f_206848_ = new RecipeManager(context);
|
||||
+ this.f_206853_ = new ServerAdvancementManager(this.f_206850_, context);
|
||||
}
|
||||
@@ -44,3 +44,20 @@
|
||||
}
|
||||
|
||||
private static <T> void m_206870_(RegistryAccess p_206871_, TagManager.LoadResult<T> p_206872_) {
|
||||
@@ -96,5 +_,16 @@
|
||||
return p_206874_.getValue().m_6497_();
|
||||
}));
|
||||
p_206871_.m_175515_(resourcekey).m_203652_(map);
|
||||
+ }
|
||||
+
|
||||
+ private final net.minecraftforge.common.crafting.conditions.ICondition.IContext context;
|
||||
+
|
||||
+ /**
|
||||
+ * Exposes the current condition context for usage in other reload listeners.<br>
|
||||
+ * This is not useful outside the reloading stage.
|
||||
+ * @return The condition context for the currently active reload.
|
||||
+ */
|
||||
+ public net.minecraftforge.common.crafting.conditions.ICondition.IContext getConditionContext() {
|
||||
+ return this.context;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
|
||||
@@ -48,11 +49,23 @@ public class AddReloadListenerEvent extends Event
|
||||
return ImmutableList.copyOf(listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The ReloableServerResources being reloaded.
|
||||
*/
|
||||
public ReloadableServerResources getServerResources()
|
||||
{
|
||||
return serverResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* This context object holds data relevant to the current reload, such as staged tags.
|
||||
* @return The condition context for the currently active reload.
|
||||
*/
|
||||
public ICondition.IContext getConditionContext()
|
||||
{
|
||||
return serverResources.getConditionContext();
|
||||
}
|
||||
|
||||
private static class WrappedStateAwareListener implements PreparableReloadListener {
|
||||
private final PreparableReloadListener wrapped;
|
||||
|
||||
|
||||
Reference in new issue
Block a user