6f2bbfab4c
- Refactored boostrap code: * Completely reworked item/block/tile registration. * Fixed server side startup. * Fixed server side startup. * More documentation. * More heavy cleanup * More cleanups. * Major refactoring of state mapping and fixes a lot of other issue related to item rendering. * Fixes sky chest item models (no item TESR). * Only use CachingRotatingBakedModel for tile entities automatically. Fix default rotation of quartz pillar for item model. * Used method reference instead of lambda for ItemMeshDefinition for multiparts. * Removed unnecessary IHasSpecialItemModel * Removed unused IconReg class. * Updated resource pack version.
117 lines
3 KiB
Java
117 lines
3 KiB
Java
package appeng.bootstrap;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.function.Supplier;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
import appeng.api.definitions.IItemDefinition;
|
|
import appeng.api.util.AEColor;
|
|
import appeng.api.util.AEColoredItemDefinition;
|
|
import appeng.bootstrap.components.InitComponent;
|
|
import appeng.bootstrap.components.ModelOverrideComponent;
|
|
import appeng.bootstrap.components.PostInitComponent;
|
|
import appeng.bootstrap.components.PreInitComponent;
|
|
import appeng.core.features.AEFeature;
|
|
import appeng.core.features.ActivityState;
|
|
import appeng.core.features.ColoredItemDefinition;
|
|
import appeng.core.features.ItemStackSrc;
|
|
import appeng.util.Platform;
|
|
|
|
|
|
public class FeatureFactory
|
|
{
|
|
|
|
private final AEFeature[] defaultFeatures;
|
|
|
|
private final List<IBootstrapComponent> bootstrapComponents;
|
|
|
|
@SideOnly( Side.CLIENT )
|
|
ModelOverrideComponent modelOverrideComponent;
|
|
|
|
public FeatureFactory()
|
|
{
|
|
this.defaultFeatures = new AEFeature[] { AEFeature.Core };
|
|
this.bootstrapComponents = new ArrayList<>();
|
|
|
|
if( Platform.isClient() )
|
|
{
|
|
modelOverrideComponent = new ModelOverrideComponent();
|
|
this.bootstrapComponents.add( modelOverrideComponent );
|
|
}
|
|
}
|
|
|
|
private FeatureFactory( FeatureFactory parent, AEFeature... defaultFeatures )
|
|
{
|
|
this.defaultFeatures = defaultFeatures.clone();
|
|
this.bootstrapComponents = parent.bootstrapComponents;
|
|
if( Platform.isClient() )
|
|
{
|
|
this.modelOverrideComponent = parent.modelOverrideComponent;
|
|
}
|
|
}
|
|
|
|
public IBlockBuilder block( String id, Supplier<Block> block )
|
|
{
|
|
return new BlockDefinitionBuilder( this, id, block ).features( defaultFeatures );
|
|
}
|
|
|
|
public IItemBuilder item( String id, Supplier<Item> item )
|
|
{
|
|
return new ItemDefinitionBuilder( this, id, item ).features( defaultFeatures );
|
|
}
|
|
|
|
public AEColoredItemDefinition colored( IItemDefinition target, int offset )
|
|
{
|
|
final ColoredItemDefinition definition = new ColoredItemDefinition();
|
|
|
|
for( final Item targetItem : target.maybeItem().asSet() )
|
|
{
|
|
for( final AEColor color : AEColor.VALID_COLORS )
|
|
{
|
|
final ActivityState state = ActivityState.from( target.isEnabled() );
|
|
|
|
definition.add( color, new ItemStackSrc( targetItem, offset + color.ordinal(), state ) );
|
|
}
|
|
}
|
|
|
|
return definition;
|
|
}
|
|
|
|
public FeatureFactory features( AEFeature... features )
|
|
{
|
|
return new FeatureFactory( this, features );
|
|
}
|
|
|
|
void addBootstrapComponent( IBootstrapComponent component )
|
|
{
|
|
this.bootstrapComponents.add( component );
|
|
}
|
|
|
|
void addPreInit( PreInitComponent component )
|
|
{
|
|
this.bootstrapComponents.add( component );
|
|
}
|
|
|
|
void addInit( InitComponent component )
|
|
{
|
|
this.bootstrapComponents.add( component );
|
|
}
|
|
|
|
void addPostInit( PostInitComponent component )
|
|
{
|
|
this.bootstrapComponents.add( component );
|
|
}
|
|
|
|
public List<IBootstrapComponent> getBootstrapComponents()
|
|
{
|
|
return bootstrapComponents;
|
|
}
|
|
|
|
}
|