From 24c405665105a789a0708a7e30c8bcb96899da6b Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 6 Jun 2013 10:02:48 -0400 Subject: [PATCH] Add in an optional modid identifier for @SidedProxy. It's main use is when both scala and java @Mods reside in the same package, and you want the @SidedProxy behaviour for a specific @Mod language type. In general it should not be needed otherwise. --- common/cpw/mods/fml/common/ProxyInjector.java | 10 +++++++++- common/cpw/mods/fml/common/SidedProxy.java | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/common/cpw/mods/fml/common/ProxyInjector.java b/common/cpw/mods/fml/common/ProxyInjector.java index a0e47d15b7..fe1716523f 100644 --- a/common/cpw/mods/fml/common/ProxyInjector.java +++ b/common/cpw/mods/fml/common/ProxyInjector.java @@ -17,6 +17,8 @@ import java.lang.reflect.Modifier; import java.util.Set; import java.util.logging.Level; +import com.google.common.base.Strings; + import cpw.mods.fml.common.discovery.ASMDataTable; import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; import cpw.mods.fml.relauncher.Side; @@ -46,7 +48,13 @@ public class ProxyInjector throw new LoaderException(); } - String targetType = side.isClient() ? target.getAnnotation(SidedProxy.class).clientSide() : target.getAnnotation(SidedProxy.class).serverSide(); + SidedProxy annotation = target.getAnnotation(SidedProxy.class); + if (!Strings.isNullOrEmpty(annotation.modId()) && !annotation.modId().equals(mod.getModId())) + { + FMLLog.fine("Skipping proxy injection for %s.%s since it is not for mod %s", targ.getClassName(), targ.getObjectName(), mod.getModId()); + continue; + } + String targetType = side.isClient() ? annotation.clientSide() : annotation.serverSide(); Object proxy=Class.forName(targetType, true, mcl).newInstance(); if (languageAdapter.supportsStatics() && (target.getModifiers() & Modifier.STATIC) == 0 ) diff --git a/common/cpw/mods/fml/common/SidedProxy.java b/common/cpw/mods/fml/common/SidedProxy.java index 54ad385455..10f85783e3 100644 --- a/common/cpw/mods/fml/common/SidedProxy.java +++ b/common/cpw/mods/fml/common/SidedProxy.java @@ -5,7 +5,7 @@ * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * + * * Contributors: * cpw - implementation */ @@ -35,8 +35,17 @@ public @interface SidedProxy */ String serverSide() default ""; + @Deprecated /** + * Not implemented * The name of a special bukkit plugin class to load and populate */ String bukkitSide() default ""; + + /** + * The (optional) name of a mod to load this proxy for. This will help ensure correct behaviour when loading a combined + * scala/java mod package. It is almost never going to be required, unless you ship both Scala and Java {@link Mod} content + * in a single jar. + */ + String modId() default ""; }