Cables & parts and Baking pipeline
- Added cables & parts rendering. - Facades got a completely new way of rendering. Anvil facades are totally a thing. - Added baking pipeline for simplified, highly configurable quad baking. NOTE: Yes, there are a lot of improvements to do, bugs to fix, stuff to add. I'm just pushing it prior to code structure change, so it does not get lost in stashes. But it actually works!
This commit is contained in:
@@ -58,7 +58,7 @@ public class FacadeConfig extends Configuration
|
||||
{
|
||||
if( f.get( Block.class ) == id )
|
||||
{
|
||||
return this.get( "minecraft", f.getName() + ( metadata == 0 ? "" : "." + metadata ), automatic ).getBoolean( automatic );
|
||||
return this.get( "minecraft", f.getName() + ( metadata == 0 ? "" : "/" + metadata ), automatic ).getBoolean( automatic );
|
||||
}
|
||||
}
|
||||
catch( final Throwable e )
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.objectweb.asm.tree.MethodNode;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -326,7 +327,7 @@ public class ApiPart implements IPartHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBus( final ItemStack is, final BlockPos pos, final EnumFacing side, final EntityPlayer player, final EnumHand hand, final World w )
|
||||
public EnumActionResult placeBus( final ItemStack is, final BlockPos pos, final EnumFacing side, final EntityPlayer player, final EnumHand hand, final World w )
|
||||
{
|
||||
return PartPlacement.place( is, pos, side, player, hand, w, PartPlacement.PlaceType.PLACE_ITEM, 0 );
|
||||
}
|
||||
|
||||
@@ -20,25 +20,43 @@ package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.client.render.model.pipeline.BakingPipelineBakedModel;
|
||||
import appeng.client.render.model.pipeline.FacingQuadRotator;
|
||||
import appeng.client.render.model.pipeline.Merge;
|
||||
import appeng.client.render.model.pipeline.TintIndexModifier;
|
||||
import appeng.client.render.model.pipeline.TypeTransformer;
|
||||
import appeng.client.render.model.pipeline.cable.CableAndConnections;
|
||||
import appeng.client.render.model.pipeline.cable.Facades;
|
||||
import appeng.client.render.model.pipeline.cable.Parts;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -106,6 +124,7 @@ public final class AECableBusFeatureHandler implements IFeatureHandler
|
||||
@Override
|
||||
public void registerModel()
|
||||
{
|
||||
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler( new CableBusColor(), this.featured );
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this.definition.maybeItem().get(), 0, new ModelResourceLocation( registryName, "normal" ) );
|
||||
}
|
||||
|
||||
@@ -118,6 +137,40 @@ public final class AECableBusFeatureHandler implements IFeatureHandler
|
||||
@Override
|
||||
public void registerCustomModelOverride( IRegistry<ModelResourceLocation, IBakedModel> modelRegistry )
|
||||
{
|
||||
final BakingPipeline rotatingPipeline = new BakingPipeline( TypeTransformer.quads2vecs, new FacingQuadRotator(), TypeTransformer.vecs2quads );
|
||||
final TintIndexModifier tintIndexModifier = new TintIndexModifier( tint -> tint );
|
||||
final BakingPipeline tintIndexFixPipeline = new BakingPipeline( TypeTransformer.quads2vecs, tintIndexModifier, TypeTransformer.vecs2quads );
|
||||
Set<ModelResourceLocation> keys = Sets.newHashSet( modelRegistry.getKeys() );
|
||||
for( ModelResourceLocation model : keys )
|
||||
{
|
||||
if( model.getResourceDomain().equals( registryName.getResourceDomain() ) && model.getResourcePath().equals( registryName.getResourcePath() ) )
|
||||
{
|
||||
modelRegistry.putObject( model, new BakingPipelineBakedModel( modelRegistry.getObject( model ), new Merge( new CableAndConnections( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ), new Facades( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ), new Parts( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CableBusColor implements IBlockColor
|
||||
{
|
||||
|
||||
@Override
|
||||
public int colorMultiplier( IBlockState state, IBlockAccess worldIn, BlockPos pos, int color )
|
||||
{
|
||||
AEPartLocation side = AEPartLocation.fromOrdinal( ( color >> 2 ) & 7 );
|
||||
CableBusContainer bus = ( (IExtendedBlockState) state ).getValue( BlockCableBus.cableBus );
|
||||
switch( color & 3 )
|
||||
{
|
||||
case 0:
|
||||
return bus.getGridNode( side ) != null && bus.getGridNode( side ).isActive() ? 0xffffff : 0;
|
||||
case 1:
|
||||
return bus.getColor().blackVariant;
|
||||
case 2:
|
||||
return bus.getColor().mediumVariant;
|
||||
case 3:
|
||||
return bus.getColor().whiteVariant;
|
||||
default:
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user