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:
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.client;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
|
||||
public class BakingPipeline<F, T> implements BakingPipelineElement<F, T>
|
||||
{
|
||||
|
||||
private final ImmutableList<BakingPipelineElement<?, ?>> pipeline;
|
||||
|
||||
public BakingPipeline( BakingPipelineElement<?, ?>... pipeline )
|
||||
{
|
||||
this.pipeline = ImmutableList.copyOf( pipeline );
|
||||
}
|
||||
|
||||
public List pipe( List things, IBakedModel parent, IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
for( BakingPipelineElement pipe : pipeline )
|
||||
{
|
||||
things = pipe.pipe( things, parent, state, side, rand );
|
||||
}
|
||||
return things;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.client;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
|
||||
public interface BakingPipelineElement<F, T>
|
||||
{
|
||||
|
||||
public List<T> pipe( List<F> elements, IBakedModel parent, IBlockState state, EnumFacing side, long rand );
|
||||
|
||||
}
|
||||
@@ -86,4 +86,5 @@ public interface IPartCable extends IPart, IGridHost
|
||||
* @return true if this side is currently connects to an external block.
|
||||
*/
|
||||
boolean isConnected( EnumFacing side );
|
||||
|
||||
}
|
||||
|
||||
@@ -24,11 +24,19 @@
|
||||
package appeng.api.parts;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
|
||||
|
||||
@@ -72,4 +80,7 @@ public interface IFacadePart
|
||||
void setThinFacades( boolean useThinFacades );
|
||||
|
||||
boolean isTransparent();
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public List<BakedQuad> getOrBakeQuads( IPartHost host, BakingPipeline<BakedQuad, BakedQuad> rotatingPipeline, IBlockState state, EnumFacing side, long rand );
|
||||
}
|
||||
@@ -30,17 +30,23 @@ import java.util.Random;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
|
||||
@@ -216,9 +222,10 @@ public interface IPart extends IBoxProvider
|
||||
void getDrops( List<ItemStack> drops, boolean wrenched );
|
||||
|
||||
/**
|
||||
* @return 0 - 8, reasonable default 3-4, this controls the cable connection to the node.
|
||||
* @return 0 - 8, reasonable default 3-4, this controls the cable connection to the node. -1 to render connection
|
||||
* yourself.
|
||||
*/
|
||||
int cableConnectionRenderTo();
|
||||
int getCableConnectionLength();
|
||||
|
||||
/**
|
||||
* same as Block.randomDisplayTick, for but parts.
|
||||
@@ -246,4 +253,8 @@ public interface IPart extends IBoxProvider
|
||||
* @return true if the part can be placed on this support.
|
||||
*/
|
||||
boolean canBePlacedOn( BusSupport what );
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public List<BakedQuad> getOrBakeQuads( BakingPipeline<BakedQuad, BakedQuad> rotatingPipeline, IBlockState state, EnumFacing side, long rand );
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ package appeng.api.parts;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -72,7 +73,7 @@ public interface IPartHelper
|
||||
*
|
||||
* @return true if placing was successful
|
||||
*/
|
||||
boolean placeBus( ItemStack is, BlockPos pos, EnumFacing side, EntityPlayer player, EnumHand hand, World world );
|
||||
EnumActionResult placeBus( ItemStack is, BlockPos pos, EnumFacing side, EntityPlayer player, EnumHand hand, World world );
|
||||
|
||||
/**
|
||||
* @return the render mode
|
||||
|
||||
@@ -36,26 +36,20 @@ import net.minecraft.item.ItemStack;
|
||||
*
|
||||
* you must register your bus with the Bus renderer, using AEApi.INSTANCE().partHelper().setItemBusRenderer( this );
|
||||
*
|
||||
* then simply add these two methods, which tell MC to use the Block Textures, and call AE's Bus Placement Code.
|
||||
* then simply add this, and call AE's Bus Placement Code.
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* {@literal @}Override
|
||||
* {@literal @}SideOnly(Side.CLIENT)
|
||||
* public int getSpriteNumber()
|
||||
* {
|
||||
* return 0;
|
||||
* }
|
||||
*
|
||||
* {@literal @}Override
|
||||
* public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
* {
|
||||
* return AEApi.INSTANCE().partHelper().placeBus( is, x, y, z, side, player, world );
|
||||
* }
|
||||
* public default EnumActionResult onItemUse(ItemStack is, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
* {
|
||||
* return AEApi.instance().partHelper().placeBus( is, pos, side, player, hand, world );
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
public interface IPartItem
|
||||
public interface IPartItem<P extends IPart>
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -66,5 +60,6 @@ public interface IPartItem
|
||||
* @return part from item
|
||||
*/
|
||||
@Nullable
|
||||
IPart createPartFromItemStack( ItemStack is );
|
||||
P createPartFromItemStack( ItemStack is );
|
||||
|
||||
}
|
||||
@@ -24,31 +24,71 @@
|
||||
package appeng.api.util;
|
||||
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
public enum AECableType
|
||||
{
|
||||
/**
|
||||
* No Cable present.
|
||||
*/
|
||||
NONE,
|
||||
NONE( null, 0 ),
|
||||
|
||||
/**
|
||||
* Connections to this block should render as glass.
|
||||
*/
|
||||
GLASS,
|
||||
GLASS( "glass", 0 ),
|
||||
|
||||
/**
|
||||
* Connections to this block should render as covered.
|
||||
*/
|
||||
COVERED,
|
||||
COVERED( "covered", 0 ),
|
||||
|
||||
/**
|
||||
* Connections to this block should render as smart.
|
||||
*/
|
||||
SMART,
|
||||
SMART( "smart", 8 ),
|
||||
|
||||
/**
|
||||
* Dense Cable, represents a tier 2 block that can carry 32 channels.
|
||||
*/
|
||||
DENSE,
|
||||
DENSE( "dense", 32 );
|
||||
|
||||
public static final AECableType[] VALIDCABLES = { GLASS, COVERED, SMART, DENSE };
|
||||
|
||||
private final String type;
|
||||
private final int displayedChannels;
|
||||
private final ResourceLocation model;
|
||||
private final ResourceLocation connectionModel;
|
||||
private final ResourceLocation straightModel;
|
||||
|
||||
private AECableType( String type, int displayedChannels )
|
||||
{
|
||||
this.type = type;
|
||||
this.displayedChannels = displayedChannels;
|
||||
this.model = new ResourceLocation( "appliedenergistics2", "part/cable/" + type + "/center" );
|
||||
this.connectionModel = new ResourceLocation( "appliedenergistics2", "part/cable/" + type + "/connection" );
|
||||
this.straightModel = new ResourceLocation( "appliedenergistics2", "part/cable/" + type + "/straight" );
|
||||
}
|
||||
|
||||
public int displayedChannels()
|
||||
{
|
||||
return displayedChannels;
|
||||
}
|
||||
|
||||
public ResourceLocation getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public ResourceLocation getConnectionModel()
|
||||
{
|
||||
return connectionModel;
|
||||
}
|
||||
|
||||
public ResourceLocation getStraightModel()
|
||||
{
|
||||
return straightModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user