Added missing custom preInit/init/postInit functionality to the IItemBuilder.
This commit is contained in:
parent
e276aa682f
commit
d831d1302f
|
@ -1,11 +1,13 @@
|
||||||
package appeng.bootstrap;
|
package appeng.bootstrap;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.features.ItemDefinition;
|
import appeng.core.features.ItemDefinition;
|
||||||
import appeng.util.Platform;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +17,12 @@ import appeng.util.Platform;
|
||||||
public interface IItemBuilder
|
public interface IItemBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
|
IItemBuilder preInit( Consumer<Item> callback );
|
||||||
|
|
||||||
|
IItemBuilder init( Consumer<Item> callback );
|
||||||
|
|
||||||
|
IItemBuilder postInit( Consumer<Item> callback );
|
||||||
|
|
||||||
IItemBuilder features( AEFeature... features );
|
IItemBuilder features( AEFeature... features );
|
||||||
|
|
||||||
IItemBuilder addFeatures( AEFeature... features );
|
IItemBuilder addFeatures( AEFeature... features );
|
||||||
|
@ -24,5 +32,4 @@ public interface IItemBuilder
|
||||||
IItemBuilder rendering( ItemRenderingCustomizer callback );
|
IItemBuilder rendering( ItemRenderingCustomizer callback );
|
||||||
|
|
||||||
ItemDefinition build();
|
ItemDefinition build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package appeng.bootstrap;
|
package appeng.bootstrap;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
@ -30,6 +33,12 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||||
|
|
||||||
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
|
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
|
||||||
|
|
||||||
|
private final List<Consumer<Item>> preInitCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
|
private final List<Consumer<Item>> initCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
|
private final List<Consumer<Item>> postInitCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
@SideOnly( Side.CLIENT )
|
@SideOnly( Side.CLIENT )
|
||||||
private ItemRendering itemRendering;
|
private ItemRendering itemRendering;
|
||||||
|
|
||||||
|
@ -46,6 +55,27 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemDefinitionBuilder preInit( Consumer<Item> callback )
|
||||||
|
{
|
||||||
|
preInitCallbacks.add( callback );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemDefinitionBuilder init( Consumer<Item> callback )
|
||||||
|
{
|
||||||
|
initCallbacks.add( callback );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemDefinitionBuilder postInit( Consumer<Item> callback )
|
||||||
|
{
|
||||||
|
postInitCallbacks.add( callback );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemBuilder features( AEFeature... features )
|
public IItemBuilder features( AEFeature... features )
|
||||||
{
|
{
|
||||||
|
@ -100,6 +130,11 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||||
item.setUnlocalizedName( "appliedenergistics2." + registryName );
|
item.setUnlocalizedName( "appliedenergistics2." + registryName );
|
||||||
item.setCreativeTab( creativeTab );
|
item.setCreativeTab( creativeTab );
|
||||||
|
|
||||||
|
// Register all extra handlers
|
||||||
|
preInitCallbacks.forEach( consumer -> factory.addPreInit( side -> consumer.accept( item ) ) );
|
||||||
|
initCallbacks.forEach( consumer -> factory.addInit( side -> consumer.accept( item ) ) );
|
||||||
|
postInitCallbacks.forEach( consumer -> factory.addPostInit( side -> consumer.accept( item ) ) );
|
||||||
|
|
||||||
factory.addPreInit( side -> GameRegistry.register( item ) );
|
factory.addPreInit( side -> GameRegistry.register( item ) );
|
||||||
|
|
||||||
if( Platform.isClient() )
|
if( Platform.isClient() )
|
||||||
|
|
Loading…
Reference in a new issue