tons of javadoc and cleanup
This commit is contained in:
@@ -10,8 +10,14 @@ import java.lang.reflect.Field;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
/** Config base class using annotations
|
||||
* @author octarine-noise
|
||||
*/
|
||||
public class ConfigBase {
|
||||
|
||||
/** Annotates a field linked to a config file property
|
||||
* @author octarine-noise
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public static @interface CfgElement {
|
||||
@@ -20,6 +26,9 @@ public class ConfigBase {
|
||||
String comment() default "";
|
||||
}
|
||||
|
||||
/** Declares a min/max limit on another field
|
||||
* @author octarine-noise
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public static @interface Limit {
|
||||
|
||||
@@ -2,6 +2,9 @@ package mods.betterfoliage.common.util;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/** Immutable 3D vector of double precision.
|
||||
* @author octarine-noise
|
||||
*/
|
||||
public class Double3 {
|
||||
|
||||
public final double x;
|
||||
|
||||
@@ -14,19 +14,24 @@ import mods.betterfoliage.loader.DeobfHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class Utils {
|
||||
|
||||
/** Hide constructor */
|
||||
private Utils() {}
|
||||
|
||||
/**
|
||||
* @return (({@link SimpleReloadableResourceManager}) Minecraft.getMinecraft().getResourceManager()).domainResourceManagers
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, IResourceManager> getDomainResourceManagers() {
|
||||
IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
|
||||
Map<String, IResourceManager> result = getField(manager, "domainResourceManagers", Map.class);
|
||||
if (result == null) result = getField(manager, DeobfHelper.transformElementSearge("domainResourceManagers"), Map.class);
|
||||
Map<String, IResourceManager> result = getField(manager, DeobfHelper.transformElementSearge("domainResourceManagers"), Map.class);
|
||||
if (result == null) result = getField(manager, "domainResourceManagers", Map.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -52,6 +57,10 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/** Retrieve a specific rendering handler from the registry
|
||||
* @param renderType render type of block
|
||||
* @return {@link ISimpleBlockRenderingHandler} if defined, null otherwise
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ISimpleBlockRenderingHandler getRenderingHandler(int renderType) {
|
||||
try {
|
||||
@@ -66,6 +75,10 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/** Check for the existence of a {@link IResource}
|
||||
* @param resourceLocation
|
||||
* @return true if the resource exists
|
||||
*/
|
||||
public static boolean resourceExists(ResourceLocation resourceLocation) {
|
||||
try {
|
||||
IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation);
|
||||
@@ -75,6 +88,10 @@ public class Utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Copy a text file from a resource to the filesystem
|
||||
* @param resourceLocation resource location of text file
|
||||
* @param target target file
|
||||
*/
|
||||
public static void copyFromTextResource(ResourceLocation resourceLocation, File target) {
|
||||
try {
|
||||
IResource defaults = Minecraft.getMinecraft().getResourceManager().getResource(resourceLocation);
|
||||
|
||||
Reference in New Issue
Block a user