Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Helper method to ASMDataTable #267

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add helper and doc
Ecdcaeb authored Dec 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8c13f8a70dabaf3065d995190f845afb913d6657
Original file line number Diff line number Diff line change
@@ -452,9 +452,9 @@ public void modConstruction(FMLConstructionEvent evt)
}

List<String> all = Lists.newArrayList();
for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashReportDetail.class.getName().replace('.', '/')))
for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashReportDetail.class))
all.add(asm.getClassName());
for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashCallable.class.getName().replace('.', '/')))
for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashCallable.class))
all.add(asm.getClassName());
// Add table classes for mod list tabulation
all.add("net/minecraftforge/common/util/TextTable");
4 changes: 2 additions & 2 deletions src/main/java/net/minecraftforge/common/MinecraftForge.java
Original file line number Diff line number Diff line change
@@ -103,9 +103,9 @@ public static void preloadCrashClasses(ASMDataTable table, String modID, Set<Str
{
//Find all ICrashReportDetail's handlers and preload them.
List<String> all = Lists.newArrayList();
for (ASMData asm : table.getAll(ICrashReportDetail.class.getName().replace('.', '/')))
for (ASMData asm : table.getAll(ICrashReportDetail.class))
all.add(asm.getClassName());
for (ASMData asm : table.getAll(ICrashCallable.class.getName().replace('.', '/')))
for (ASMData asm : table.getAll(ICrashCallable.class))
all.add(asm.getClassName());

all.retainAll(classes);
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ public <T> void register(Class<T> type, Capability.IStorage<T> storage, Callable
private IdentityHashMap<String, List<Function<Capability<?>, Object>>> callbacks = Maps.newIdentityHashMap();
public void injectCapabilities(ASMDataTable data)
{
for (ASMDataTable.ASMData entry : data.getAll(CapabilityInject.class.getName()))
for (ASMDataTable.ASMData entry : data.getAll(CapabilityInject.class))
{
final String targetClass = entry.getClassName();
final String targetName = entry.getObjectName();
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ private static void register(Class<?> cls, ITypeAdapter adpt)
public static void loadData(ASMDataTable data)
{
FMLLog.log.debug("Loading @Config anotation data");
for (ASMData target : data.getAll(Config.class.getName()))
for (ASMData target : data.getAll(Config.class))
{
String modid = (String)target.getAnnotationInfo().get("modid");
Multimap<Config.Type, ASMData> map = asm_data.computeIfAbsent(modid, k -> ArrayListMultimap.create());
Original file line number Diff line number Diff line change
@@ -44,8 +44,8 @@ public static void inject(ModContainer mod, ASMDataTable data, Side side)
{
FMLLog.log.debug("Attempting to inject @EventBusSubscriber classes into the eventbus for {}", mod.getModId());
SetMultimap<String, ASMData> modData = data.getAnnotationsFor(mod);
Set<ASMDataTable.ASMData> mods = modData.get(Mod.class.getName());
Set<ASMDataTable.ASMData> targets = modData.get(Mod.EventBusSubscriber.class.getName());
Set<ASMDataTable.ASMData> mods = modData.get(Mod.class);
Set<ASMDataTable.ASMData> targets = modData.get(Mod.EventBusSubscriber.class);
ClassLoader mcl = Loader.instance().getModClassLoader();

for (ASMDataTable.ASMData targ : targets)
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ public void distributeStateMessage(LoaderState state, Object... eventData)

MixinBooterPlugin.LOGGER.info("Instantiating all ILateMixinLoader implemented classes...");

for (ASMDataTable.ASMData asmData : asmDataTable.getAll(ILateMixinLoader.class.getName().replace('.', '/'))) {
for (ASMDataTable.ASMData asmData : asmDataTable.getAll(ILateMixinLoader.class)) {
if (!log) {
MixinBooterPlugin.LOGGER.info("Instantiating all ILateMixinLoader implemented classes...");
log = true;
Original file line number Diff line number Diff line change
@@ -42,8 +42,8 @@ public static void inject(ModContainer mod, ASMDataTable data, Side side, ILangu
{
FMLLog.log.debug("Attempting to inject @SidedProxy classes into {}", mod.getModId());
SetMultimap<String, ASMData> modData = data.getAnnotationsFor(mod);
Set<ASMData> mods = modData.get(Mod.class.getName());
Set<ASMData> targets = modData.get(SidedProxy.class.getName());
Set<ASMData> mods = modData.get(Mod.class);
Set<ASMData> targets = modData.get(SidedProxy.class);
ClassLoader mcl = Loader.instance().getModClassLoader();

for (ASMData targ : targets)
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ public void inject() {

public void findHolders(ASMDataTable table) {
FMLLog.log.info("Identifying ItemStackHolder annotations");
Set<ASMData> allItemStackHolders = table.getAll(GameRegistry.ItemStackHolder.class.getName());
Set<ASMData> allItemStackHolders = table.getAll(GameRegistry.ItemStackHolder.class);
Map<String, Class<?>> classCache = Maps.newHashMap();
for (ASMData data : allItemStackHolders)
{
Original file line number Diff line number Diff line change
@@ -49,10 +49,10 @@ public enum ObjectHolderRegistry
public void findObjectHolders(ASMDataTable table)
{
FMLLog.log.info("Processing ObjectHolder annotations");
Set<ASMData> allObjectHolders = table.getAll(GameRegistry.ObjectHolder.class.getName());
Set<ASMData> allObjectHolders = table.getAll(GameRegistry.ObjectHolder.class);
Map<String, String> classModIds = Maps.newHashMap();
Map<String, Class<?>> classCache = Maps.newHashMap();
for (ASMData data : table.getAll(Mod.class.getName()))
for (ASMData data : table.getAll(Mod.class))
{
String modid = (String)data.getAnnotationInfo().get("modid");
classModIds.put(data.getClassName(), modid);