From 17ce3eadc4149c057913333db90a1b92e4946f6d Mon Sep 17 00:00:00 2001 From: thatsIch Date: Thu, 27 Nov 2014 18:18:15 +0100 Subject: [PATCH] Enhancement: better generics --- src/main/java/appeng/core/Registration.java | 31 +++++++++---------- .../java/appeng/items/parts/PartType.java | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index 3f98fb1b..db6d43e2 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -21,10 +21,6 @@ package appeng.core; import java.lang.reflect.Field; -import com.google.common.base.Optional; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; - import net.minecraft.item.crafting.CraftingManager; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.biome.BiomeGenBase; @@ -41,6 +37,10 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; +import com.google.common.base.Optional; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; + import appeng.api.AEApi; import appeng.api.config.Upgrades; import appeng.api.definitions.Blocks; @@ -210,16 +210,16 @@ import appeng.util.Platform; public class Registration { - final public static Registration instance = new Registration(); - public final RecipeHandler recipeHandler; - final private Multimap featuresToEntities = ArrayListMultimap.create(); + private final RecipeHandler recipeHandler; + private final Multimap> featuresToEntities; public BiomeGenBase storageBiome; private Registration() { recipeHandler = new RecipeHandler(); + featuresToEntities = ArrayListMultimap.create(); } public void PreInit( FMLPreInitializationEvent event ) @@ -251,14 +251,14 @@ public class Registration MinecraftForge.EVENT_BUS.register( OreDictionaryHandler.instance ); - Items items = appeng.core.Api.instance.items(); - Materials materials = appeng.core.Api.instance.materials(); - Parts parts = appeng.core.Api.instance.parts(); - Blocks blocks = appeng.core.Api.instance.blocks(); + Items items = Api.instance.items(); + Materials materials = Api.instance.materials(); + Parts parts = Api.instance.parts(); + Blocks blocks = Api.instance.blocks(); AEItemDefinition materialItem = addFeature( ItemMultiMaterial.class ); - Class materialClass = materials.getClass(); + Class materialClass = materials.getClass(); for ( MaterialType mat : MaterialType.values() ) { try @@ -284,7 +284,7 @@ public class Registration AEItemDefinition partItem = addFeature( ItemMultiPart.class ); - Class partClass = parts.getClass(); + Class partClass = parts.getClass(); for ( PartType type : PartType.values() ) { try @@ -294,7 +294,7 @@ public class Registration else { Field f = partClass.getField( "part" + type.name() ); - Enum variants[] = type.getVariants(); + Enum[] variants = type.getVariants(); if ( variants == null ) { ItemStackSrc is = ( ( ItemMultiPart ) partItem.item() ).createPart( type, null ); @@ -309,7 +309,7 @@ public class Registration { ColoredItemDefinition def = new ColoredItemDefinition(); - for ( Enum v : variants ) + for ( Enum v : variants ) { ItemStackSrc is = ( ( ItemMultiPart ) partItem.item() ).createPart( type, v ); if ( is != null ) @@ -757,5 +757,4 @@ public class Registration */ OreDictionaryHandler.instance.bakeRecipes(); } - } diff --git a/src/main/java/appeng/items/parts/PartType.java b/src/main/java/appeng/items/parts/PartType.java index 5258c188..598b05f2 100644 --- a/src/main/java/appeng/items/parts/PartType.java +++ b/src/main/java/appeng/items/parts/PartType.java @@ -144,7 +144,7 @@ public enum PartType baseDamage = baseMetaValue; } - public Enum[] getVariants() + public Enum[] getVariants() { if ( this == CableSmart || this == CableCovered || this == CableGlass || this == CableDense ) return AEColor.values();