More 1.12 shenanigans. Still far from done.

This commit is contained in:
Gunther De Wachter
2017-07-09 07:17:24 +02:00
parent 198ea9f16e
commit a57cd3f580
14 changed files with 76 additions and 200 deletions
@@ -32,7 +32,7 @@ public interface IBootstrapComponent
{
}
default void modelLoader( Side side )
default void modelReg( Side side )
{
}
@@ -31,8 +31,6 @@ import net.minecraft.block.BlockDispenser;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -59,6 +57,8 @@ class ItemDefinitionBuilder implements IItemBuilder
private final List<Consumer<Item>> initCallbacks = new ArrayList<>();
private final List<Consumer<Item>> modelRegCallbacks = new ArrayList<>();
private final List<Consumer<Item>> postInitCallbacks = new ArrayList<>();
private Supplier<IBehaviorDispenseItem> dispenserBehaviorSupplier;
@@ -165,6 +165,7 @@ class ItemDefinitionBuilder implements IItemBuilder
// Register all extra handlers
preInitCallbacks.forEach( consumer -> factory.addPreInit( side -> consumer.accept( item ) ) );
initCallbacks.forEach( consumer -> factory.addInit( side -> consumer.accept( item ) ) );
modelRegCallbacks.forEach(consumer -> factory.addModelReg(side -> consumer.accept( item ) ) );
postInitCallbacks.forEach( consumer -> factory.addPostInit( side -> consumer.accept( item ) ) );
// Register custom dispenser behavior if requested
@@ -30,6 +30,8 @@ import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.util.registry.IRegistry;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
@@ -61,7 +63,8 @@ public class ModelOverrideComponent implements PreInitComponent
{
IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
Set<ModelResourceLocation> keys = Sets.newHashSet( modelRegistry.getKeys() );
IBakedModel missingModel = modelRegistry.getObject( MODEL_MISSING );
// IBakedModel missingModel = modelRegistry.getObject( MODEL_MISSING );
IModel missingModel = ModelLoaderRegistry.getMissingModel();
for( ModelResourceLocation location : keys )
{
@@ -31,6 +31,7 @@ import appeng.tile.AEBaseTile;
*
* @param <T>
*/
//public class TesrComponent<T extends AEBaseTile> implements ModelRegComponent
public class TesrComponent<T extends AEBaseTile> implements PreInitComponent
{
@@ -45,6 +46,7 @@ public class TesrComponent<T extends AEBaseTile> implements PreInitComponent
}
@Override
// public void modelReg( Side side )
public void preInitialize( Side side )
{
ClientRegistry.bindTileEntitySpecialRenderer( tileEntityClass, tesr );
@@ -160,6 +160,7 @@ public abstract class AEBaseGui extends GuiContainer
{
super.drawDefaultBackground();
super.drawScreen( mouseX, mouseY, btn );
this.renderHoveredToolTip(mouseX, mouseY);
for( final Object c : this.buttonList )
{
+3
View File
@@ -141,6 +141,7 @@ public final class AppEng
this.configDirectory = new File( event.getModConfigurationDirectory().getPath(), "AppliedEnergistics2" );
this.recipeDirectory = new File( this.configDirectory, "recipes" );
final File configFile = new File( this.configDirectory, "AppliedEnergistics2.cfg" );
final File facadeFile = new File( this.configDirectory, "Facades.cfg" );
final File versionFile = new File( this.configDirectory, "VersionChecker.cfg" );
@@ -154,6 +155,8 @@ public final class AppEng
this.customRecipeConfig = new CustomRecipeForgeConfiguration( recipeConfiguration );
this.exportConfig = new ForgeExportConfig( recipeConfiguration );
this.registration.setRecipeInformation( recipeDirectory, customRecipeConfig );
AELog.info( "Pre Initialization ( started )" );
CreativeTab.init();
+58 -29
View File
@@ -27,12 +27,14 @@ import java.util.Set;
import javax.annotation.Nonnull;
import appeng.util.Platform;
import appeng.items.parts.ItemFacade;
import appeng.recipes.game.DisassembleRecipe;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.DimensionType;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.client.event.ModelRegistryEvent;
@@ -111,6 +113,7 @@ import appeng.tile.AEBaseTile;
import appeng.worldgen.MeteoriteWorldGen;
import appeng.worldgen.QuartzWorldGen;
import net.minecraftforge.registries.IForgeRegistry;
import scala.App;
public final class Registration
{
@@ -122,7 +125,14 @@ public final class Registration
private static List<Block> blocksToRegister = new ArrayList<Block>();
private static List<Item> itemsToRegister = new ArrayList<Item>();
private static List<IRecipe> recipesToRegister = new ArrayList<IRecipe>();
private File recipeDirectory;
private CustomRecipeConfig customRecipeConfig;
public void setRecipeInformation ( File f, CustomRecipeConfig f2)
{
this.recipeDirectory = f;
this.customRecipeConfig = f2;
}
Registration()
{
@@ -138,7 +148,6 @@ public final class Registration
{
if( blocksToRegister == null )
throw new IllegalStateException( "Past the registration phase already!" );
System.out.println("Adding block : " + b +" -> " + b.getRegistryName());
blocksToRegister.add( b );
}
@@ -146,7 +155,6 @@ public final class Registration
{
if( recipesToRegister == null )
throw new IllegalStateException( "Past the registration phase already!" );
System.out.println("Adding " + r);
recipesToRegister.add( r );
}
@@ -154,7 +162,6 @@ public final class Registration
{
if( itemsToRegister == null )
throw new IllegalStateException( "Past the registration phase already!" );
System.out.println("Adding item : " + i + " -> " + i.getRegistryName());
itemsToRegister.add( i );
}
@@ -284,8 +291,8 @@ public final class Registration
// Perform ore camouflage!
ItemMaterial.instance.makeUnique();
final Runnable recipeLoader = new RecipeLoader( recipeDirectory, customRecipeConfig, this.recipeHandler );
recipeLoader.run();
// final Runnable recipeLoader = new RecipeLoader( recipeDirectory, customRecipeConfig, this.recipeHandler );
// recipeLoader.run();
if( Integrations.ic2().isEnabled() )
{
@@ -332,53 +339,38 @@ public final class Registration
registries.matterCannon().registerAmmo( ammoStack, weight );
} );
this.recipeHandler.injectRecipes();
// TODO : 1.12 This is way too late for recipes
// this.recipeHandler.injectRecipes();
final PlayerStatsRegistration registration = new PlayerStatsRegistration( MinecraftForge.EVENT_BUS, AEConfig.instance() );
registration.registerAchievementHandlers();
registration.registerAchievements();
// if( AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ) )
// {
// // TODO : 1.12 Improve
// addRecipeToRegister( new DisassembleRecipe() );
// RecipeSorter.register( "appliedenergistics2:disassemble", DisassembleRecipe.class, Category.SHAPELESS, "after:minecraft:shapeless" );
// }
//
// if( AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_FACADE_CRAFTING ) )
// {
// definitions.items().facade().maybeItem().ifPresent( facadeItem -> {
// // TODO : 1.12 Improve
// addRecipeToRegister( new FacadeRecipe( (ItemFacade) facadeItem ) );
// RecipeSorter.register( "appliedenergistics2:facade", FacadeRecipe.class, Category.SHAPED, "after:minecraft:shaped" );
// } );
// }
}
@SubscribeEvent
public void registerBiomes ( RegistryEvent.Register<Biome> event )
public void registerBiomes( RegistryEvent.Register<Biome> event )
{
IForgeRegistry<Biome> registry = event.getRegistry();
this.registerSpatial( false, registry );
}
@SubscribeEvent
public void modelRegistryEvent ( ModelRegistryEvent event )
public void modelRegistryEvent( ModelRegistryEvent event )
{
final Api api = Api.INSTANCE;
final IPartHelper partHelper = api.partHelper();
final IRegistryContainer registries = api.registries();
ApiDefinitions definitions = api.definitions();
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.modelLoader( FMLCommonHandler.instance().getEffectiveSide() ) );
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.modelReg( FMLCommonHandler.instance().getEffectiveSide() ) );
}
@SubscribeEvent
public void registerBlocks(RegistryEvent.Register<Block> event)
public void registerBlocks( RegistryEvent.Register<Block> event )
{
IForgeRegistry<Block> registry = event.getRegistry();
// TODO : 1.12 Improve
for (Block b : blocksToRegister)
for( Block b : blocksToRegister )
{
registry.register( b );
}
@@ -386,7 +378,8 @@ public final class Registration
}
@SubscribeEvent
public void registerItems(RegistryEvent.Register<Item> event) {
public void registerItems( RegistryEvent.Register<Item> event )
{
IForgeRegistry<Item> registry = event.getRegistry();
// TODO : 1.12 Improve
@@ -401,9 +394,44 @@ public final class Registration
public void registerRecipes(RegistryEvent.Register<IRecipe> event)
{
IForgeRegistry<IRecipe> registry = event.getRegistry();
Api api = Api.INSTANCE;
ApiDefinitions definitions = api.definitions();
final Runnable recipeLoader = new RecipeLoader( recipeDirectory, customRecipeConfig, this.recipeHandler );
recipeLoader.run();
this.recipeHandler.injectRecipes();
if( AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ) )
{
DisassembleRecipe r = new DisassembleRecipe();
// TODO : 1.12 Improve
addRecipeToRegister( r.setRegistryName( AppEng.MOD_ID.toLowerCase(), "disassemble" ) );
// RecipeSorter.register( "appliedenergistics2:disassemble", DisassembleRecipe.class, Category.SHAPELESS, "after:minecraft:shapeless" );
}
if( AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_FACADE_CRAFTING ) )
{
definitions.items().facade().maybeItem().ifPresent( facadeItem -> {
// TODO : 1.12 Improve
FacadeRecipe f = new FacadeRecipe( (ItemFacade) facadeItem );
addRecipeToRegister( f.setRegistryName( AppEng.MOD_ID.toLowerCase(), "facade" ) );
// RecipeSorter.register( "appliedenergistics2:facade", FacadeRecipe.class, Category.SHAPED, "after:minecraft:shaped" );
} );
}
int x = 0;
// TODO : 1.12 Improve
for( IRecipe r : recipesToRegister )
{
// TODO : 1.12 *really* improve.
// Move to json where possible?
if( r.getRegistryName() == null )
{
r.setRegistryName( new ResourceLocation( AppEng.MOD_ID.toLowerCase(), "recipe_" + x ));
x++;
}
registry.register( r );
}
recipesToRegister = null;
@@ -545,6 +573,7 @@ public final class Registration
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFlowerPot.class );
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class );
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityHopper.class );
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityShulkerBox.class );
/*
* Whitelist AE2
@@ -93,7 +93,6 @@ public final class ApiMaterials implements IMaterials
private final IItemDefinition netherQuartzDust;
private final IItemDefinition matterBall;
private final IItemDefinition ironNugget;
private final IItemDefinition certusQuartzCrystal;
private final IItemDefinition certusQuartzCrystalCharged;
@@ -182,7 +181,6 @@ public final class ApiMaterials implements IMaterials
this.netherQuartzDust = new DamagedItemDefinition( "material.dust.quartz.nether", materials.createMaterial( MaterialType.NetherQuartzDust ) );
this.matterBall = new DamagedItemDefinition( "material.ammo.matter_ball", materials.createMaterial( MaterialType.MatterBall ) );
this.ironNugget = new DamagedItemDefinition( "material.ammo.nugget.iron", materials.createMaterial( MaterialType.IronNugget ) );
this.certusQuartzCrystal = new DamagedItemDefinition( "material.crystal.quartz.certus", materials.createMaterial( MaterialType.CertusQuartzCrystal ) );
this.certusQuartzCrystalCharged = new DamagedItemDefinition( "material.crystal.quartz.certus.charged", materials.createMaterial( MaterialType.CertusQuartzCrystalCharged ) );
@@ -448,12 +446,6 @@ public final class ApiMaterials implements IMaterials
return this.matterBall;
}
@Override
public IItemDefinition ironNugget()
{
return this.ironNugget;
}
@Override
public IItemDefinition certusQuartzCrystal()
{
@@ -49,7 +49,6 @@ public enum MaterialType
Flour( 4, "material_flour", EnumSet.of( AEFeature.FLOUR ), "dustWheat" ),
GoldDust( 51, "material_gold_dust", EnumSet.of( AEFeature.DUSTS ), "dustGold" ),
IronDust( 49, "material_iron_dust", EnumSet.of( AEFeature.DUSTS ), "dustIron" ),
IronNugget( 50, "material_iron_nugget", EnumSet.of( AEFeature.NUGGETS ), "nuggetIron" ),
Silicon( 5, "material_silicon", EnumSet.of( AEFeature.SILICON ), "itemSilicon" ),
MatterBall( 6, "material_matter_ball", EnumSet.of( AEFeature.MATTER_BALL ) ),
@@ -47,7 +47,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
public final class DisassembleRecipe implements IRecipe
public final class DisassembleRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
{
private static final ItemStack MISMATCHED_STACK = ItemStack.EMPTY;
@@ -179,42 +179,4 @@ public final class DisassembleRecipe implements IRecipe
{
return ForgeHooks.defaultRecipeGetRemainingItems( inv );
}
/**
* Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item.
* This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.
* Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.
* <p>
* The supplied name will be prefixed with the currently active mod's modId.
* If the supplied name already has a prefix that is different, it will be used and a warning will be logged.
* <p>
* If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown.
* <p>
* Returns 'this' to allow for chaining.
*
* @param name Unique registry name
* @return This instance
*/
@Override
public IRecipe setRegistryName(ResourceLocation name) {
return null;
}
/**
* A unique identifier for this entry, if this entry is registered already it will return it's official registry name.
* Otherwise it will return the name set in setRegistryName().
* If neither are valid null is returned.
*
* @return Unique identifier or null.
*/
@Nullable
@Override
public ResourceLocation getRegistryName() {
return null;
}
@Override
public Class<IRecipe> getRegistryType() {
return null;
}
}
@@ -36,7 +36,7 @@ import appeng.api.definitions.IDefinitions;
import appeng.items.parts.ItemFacade;
public final class FacadeRecipe implements IRecipe
public final class FacadeRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
{
private final IComparableDefinition anchor;
private final ItemFacade facade;
@@ -96,42 +96,4 @@ public final class FacadeRecipe implements IRecipe
{
return ForgeHooks.defaultRecipeGetRemainingItems( inv );
}
/**
* Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item.
* This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.
* Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.
* <p>
* The supplied name will be prefixed with the currently active mod's modId.
* If the supplied name already has a prefix that is different, it will be used and a warning will be logged.
* <p>
* If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown.
* <p>
* Returns 'this' to allow for chaining.
*
* @param name Unique registry name
* @return This instance
*/
@Override
public IRecipe setRegistryName(ResourceLocation name) {
return null;
}
/**
* A unique identifier for this entry, if this entry is registered already it will return it's official registry name.
* Otherwise it will return the name set in setRegistryName().
* If neither are valid null is returned.
*
* @return Unique identifier or null.
*/
@Nullable
@Override
public ResourceLocation getRegistryName() {
return null;
}
@Override
public Class<IRecipe> getRegistryType() {
return null;
}
}
@@ -38,7 +38,7 @@ import appeng.api.recipes.IIngredient;
import javax.annotation.Nullable;
public class ShapedRecipe implements IRecipe, IRecipeBakeable
public class ShapedRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe, IRecipeBakeable
{
// Added in for future ease of change, but hard coded for now.
private static final int MAX_CRAFT_GRID_WIDTH = 3;
@@ -333,42 +333,4 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
{
return ForgeHooks.defaultRecipeGetRemainingItems( inv );
}
/**
* Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item.
* This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.
* Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.
* <p>
* The supplied name will be prefixed with the currently active mod's modId.
* If the supplied name already has a prefix that is different, it will be used and a warning will be logged.
* <p>
* If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown.
* <p>
* Returns 'this' to allow for chaining.
*
* @param name Unique registry name
* @return This instance
*/
@Override
public IRecipe setRegistryName(ResourceLocation name) {
return null;
}
/**
* A unique identifier for this entry, if this entry is registered already it will return it's official registry name.
* Otherwise it will return the name set in setRegistryName().
* If neither are valid null is returned.
*
* @return Unique identifier or null.
*/
@Nullable
@Override
public ResourceLocation getRegistryName() {
return null;
}
@Override
public Class<IRecipe> getRegistryType() {
return null;
}
}
@@ -37,7 +37,7 @@ import appeng.api.recipes.IIngredient;
import javax.annotation.Nullable;
public class ShapelessRecipe implements IRecipe, IRecipeBakeable
public class ShapelessRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe, IRecipeBakeable
{
private final ArrayList<Object> input = new ArrayList<Object>();
@@ -189,42 +189,4 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
{
return ForgeHooks.defaultRecipeGetRemainingItems( inv );
}
/**
* Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item.
* This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.
* Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.
* <p>
* The supplied name will be prefixed with the currently active mod's modId.
* If the supplied name already has a prefix that is different, it will be used and a warning will be logged.
* <p>
* If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown.
* <p>
* Returns 'this' to allow for chaining.
*
* @param name Unique registry name
* @return This instance
*/
@Override
public IRecipe setRegistryName(ResourceLocation name) {
return null;
}
/**
* A unique identifier for this entry, if this entry is registered already it will return it's official registry name.
* Otherwise it will return the name set in setRegistryName().
* If neither are valid null is returned.
*
* @return Unique identifier or null.
*/
@Nullable
@Override
public ResourceLocation getRegistryName() {
return null;
}
@Override
public Class<IRecipe> getRegistryType() {
return null;
}
}