reformatted all src files (#141)
This commit is contained in:
@@ -19,13 +19,8 @@
|
||||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
@@ -36,61 +31,55 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
|
||||
public class ModelOverrideComponent implements IPreInitComponent
|
||||
{
|
||||
public class ModelOverrideComponent implements IPreInitComponent {
|
||||
|
||||
private static final ModelResourceLocation MODEL_MISSING = new ModelResourceLocation( "builtin/missing", "missing" );
|
||||
private static final ModelResourceLocation MODEL_MISSING = new ModelResourceLocation("builtin/missing", "missing");
|
||||
|
||||
// Maps from resource path to customizer
|
||||
private final Map<String, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel>> customizer = new HashMap<>();
|
||||
// Maps from resource path to customizer
|
||||
private final Map<String, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel>> customizer = new HashMap<>();
|
||||
|
||||
public void addOverride( String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer )
|
||||
{
|
||||
this.customizer.put( resourcePath, customizer );
|
||||
}
|
||||
public void addOverride(String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer) {
|
||||
this.customizer.put(resourcePath, customizer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInitialize( Side side )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
}
|
||||
@Override
|
||||
public void preInitialize(Side side) {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onModelBakeEvent( final ModelBakeEvent event )
|
||||
{
|
||||
IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
Set<ModelResourceLocation> keys = Sets.newHashSet( modelRegistry.getKeys() );
|
||||
// IBakedModel missingModel = modelRegistry.getObject( MODEL_MISSING );
|
||||
IModel missingModel = ModelLoaderRegistry.getMissingModel();
|
||||
@SubscribeEvent
|
||||
public void onModelBakeEvent(final ModelBakeEvent event) {
|
||||
IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
Set<ModelResourceLocation> keys = Sets.newHashSet(modelRegistry.getKeys());
|
||||
// IBakedModel missingModel = modelRegistry.getObject( MODEL_MISSING );
|
||||
IModel missingModel = ModelLoaderRegistry.getMissingModel();
|
||||
|
||||
for( ModelResourceLocation location : keys )
|
||||
{
|
||||
if( !location.getResourceDomain().equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (ModelResourceLocation location : keys) {
|
||||
if (!location.getResourceDomain().equals(AppEng.MOD_ID)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IBakedModel orgModel = modelRegistry.getObject( location );
|
||||
IBakedModel orgModel = modelRegistry.getObject(location);
|
||||
|
||||
// Don't customize the missing model. This causes Forge to swallow exceptions
|
||||
if( orgModel == missingModel )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Don't customize the missing model. This causes Forge to swallow exceptions
|
||||
if (orgModel == missingModel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer = this.customizer.get( location.getResourcePath() );
|
||||
if( customizer != null )
|
||||
{
|
||||
IBakedModel newModel = customizer.apply( location, orgModel );
|
||||
BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer = this.customizer.get(location.getResourcePath());
|
||||
if (customizer != null) {
|
||||
IBakedModel newModel = customizer.apply(location, orgModel);
|
||||
|
||||
if( newModel != orgModel )
|
||||
{
|
||||
modelRegistry.putObject( location, newModel );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newModel != orgModel) {
|
||||
modelRegistry.putObject(location, newModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user