Third update pass (3/?)

Last (?) update pass. AE2 can be launched and used (?) in game.

Rendering system changed again and again - rendering is NOT working, to
be rewritten and CAN be done a lot simpler.
This commit is contained in:
elix-x
2016-06-21 16:36:15 +02:00
parent 05aa6972c4
commit 8acee98b8f
20 changed files with 146 additions and 100 deletions
+55 -1
View File
@@ -30,24 +30,28 @@ import java.util.Random;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.MouseEvent;
@@ -76,8 +80,10 @@ import appeng.client.texture.ExtraBlockTextures;
import appeng.client.texture.ExtraItemTextures;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.CommonHelper;
import appeng.core.features.IAEFeature;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketValueConfig;
@@ -90,6 +96,7 @@ import appeng.helpers.IMouseWheelItem;
import appeng.hooks.TickHandler;
import appeng.hooks.TickHandler.PlayerColor;
import appeng.items.AEBaseItem;
import appeng.items.misc.ItemPaintBall;
import appeng.server.ServerHelper;
import appeng.transformer.MissingCoreMod;
import appeng.util.Platform;
@@ -137,6 +144,15 @@ public class ClientHelper extends ServerHelper
// AELog.info( "Registering with %s with unlocalized %s", item, item.getUnlocalizedName() );
// mesher.register( item, DEFAULT_ITEM_SUBTYPE, fluixStairModel );
// }
for( IAEFeature feature : Api.INSTANCE.definitions().getFeatureRegistry().getRegisteredFeatures() )
{
if( feature instanceof AEBaseBlock )
{
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler( new AEBaseBlockColor(), ( Block ) feature );
}
}
Minecraft.getMinecraft().getItemColors().registerItemColorHandler( new ItemPaintBallColor(), Api.INSTANCE.definitions().items().paintBall().maybeItem().get() );
}
@Override
@@ -627,4 +643,42 @@ public class ClientHelper extends ServerHelper
this.loc = res;
}
}
public static class AEBaseBlockColor implements IBlockColor
{
@Override
public int colorMultiplier( IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex )
{
return tintIndex;
}
}
public class ItemPaintBallColor implements IItemColor
{
@Override
public int getColorFromItemstack( ItemStack stack, int tintIndex )
{
final AEColor col = ( ( ItemPaintBall ) stack.getItem() ).getColor( stack );
final int colorValue = stack.getItemDamage() >= 20 ? col.mediumVariant : col.mediumVariant;
final int r = ( colorValue >> 16 ) & 0xff;
final int g = ( colorValue >> 8 ) & 0xff;
final int b = ( colorValue ) & 0xff;
if( stack.getItemDamage() >= 20 )
{
final float fail = 0.7f;
final int full = (int) ( 255 * 0.3 );
return (int) ( full + r * fail ) << 16 | (int) ( full + g * fail ) << 8 | (int) ( full + b * fail ) | 0xff << 24;
}
else
{
return r << 16 | g << 8 | b | 0xff << 24;
}
}
}
}
+1 -1
View File
@@ -95,7 +95,7 @@ public class SmartModel implements IBakedModel
{
final ModelGenerator helper = new BakingModelGenerator();
final Block blk = Block.getBlockFromItem( stack.getItem() );
helper.setRenderBoundsFromBlock( blk.getDefaultState(), null );
helper.setRenderBoundsFromBlock( blk != null ? blk.getDefaultState() : null, null );
aeRenderer.getRendererInstance().renderInventory( blk instanceof AEBaseBlock ? (AEBaseBlock) blk : null, stack, helper, ItemRenderType.INVENTORY, null );
helper.finalizeModel( true );
return helper.getOutput();
@@ -928,12 +928,6 @@ public abstract class AEBaseGui extends GuiContainer
final ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/" + file );
this.mc.getTextureManager().bindTexture( loc );
}
public void func_146977_a( final Slot s )
{
this.drawSlot( s );
}
protected GuiScrollbar getScrollBar()
{
return this.myScrollBar;
@@ -7,11 +7,13 @@ import java.util.List;
import javax.annotation.Nullable;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BlockFaceUV;
import net.minecraft.client.renderer.block.model.BlockPartFace;
@@ -23,7 +25,6 @@ import net.minecraft.client.renderer.block.model.ModelRotation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
@@ -45,10 +46,12 @@ public class BakingModelGenerator implements ModelGenerator
{
private static final class CachedModel implements IBakedModel
{
private final List<BakedQuad> general;
private final List<BakedQuad>[] faces = new List[6];
public CachedModel()
{
this.general = new ArrayList<BakedQuad>();
for( final EnumFacing f : EnumFacing.VALUES )
{
this.faces[f.ordinal()] = new ArrayList<BakedQuad>();
@@ -88,7 +91,7 @@ public class BakingModelGenerator implements ModelGenerator
@Override
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
{
return this.faces[side.ordinal()];
return side == null ? general : this.faces[side.ordinal()];
}
@Override
@@ -132,9 +135,10 @@ public class BakingModelGenerator implements ModelGenerator
private boolean flipTexture = false;
private final List<SMFace> faces = new ArrayList();
private int point = 0;
// private int point = 0;
private int brightness = -1;
private final float[][] points = new float[4][];
private VertexBuffer vertexBuffer;
//private final float[][] points = new float[4][];
private EnumFacing currentFace = EnumFacing.UP;
private int color = -1;
@@ -154,6 +158,7 @@ public class BakingModelGenerator implements ModelGenerator
{
boundingBox = Block.FULL_BLOCK_AABB;
}
this.setRenderMinX( boundingBox.minX );
this.setRenderMinY( boundingBox.minY );
this.setRenderMinZ( boundingBox.minZ );
@@ -303,19 +308,25 @@ public class BakingModelGenerator implements ModelGenerator
return this.getIcon( state );
}
//TODO 1.9.4 aftermath - Check that this shit still works.
//TODO 1.9.4 aftermath - Check that this shit still works. VertexBuffer
public void addVertexWithUV( final EnumFacing face, final double x, final double y, final double z, final double u, final double v )
{
this.points[this.point++] = new float[] { (float) x + this.tx, (float) y + this.ty, (float) z + this.tz, (float) u, (float) v };
if( this.point == 4 )
//this.points[this.point++] = new float[] { (float) x + this.tx, (float) y + this.ty, (float) z + this.tz, (float) u, (float) v };
if( vertexBuffer == null )
{
this.brightness = -1;
vertexBuffer = new VertexBuffer( 4 );
vertexBuffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
}
vertexBuffer.pos( x, y, z ).tex( u, v ).endVertex();
// if( this.point == 4 )
if( vertexBuffer.getVertexCount() == 4)
{
/*this.brightness = -1;
final int[] vertData = {
Float.floatToRawIntBits( this.points[0][0] ),
Float.floatToRawIntBits( this.points[0][1] ),
Float.floatToRawIntBits( this.points[0][2] ),
// this.brightness,
this.brightness,
Float.floatToRawIntBits( this.points[0][3] ),
Float.floatToRawIntBits( this.points[0][4] ),
// 0,
@@ -323,7 +334,7 @@ public class BakingModelGenerator implements ModelGenerator
Float.floatToRawIntBits( this.points[1][0] ),
Float.floatToRawIntBits( this.points[1][1] ),
Float.floatToRawIntBits( this.points[1][2] ),
// this.brightness,
this.brightness,
Float.floatToRawIntBits( this.points[1][3] ),
Float.floatToRawIntBits( this.points[1][4] ),
// 0,
@@ -331,7 +342,7 @@ public class BakingModelGenerator implements ModelGenerator
Float.floatToRawIntBits( this.points[2][0] ),
Float.floatToRawIntBits( this.points[2][1] ),
Float.floatToRawIntBits( this.points[2][2] ),
// this.brightness,
this.brightness,
Float.floatToRawIntBits( this.points[2][3] ),
Float.floatToRawIntBits( this.points[2][4] ),
// 0,
@@ -339,18 +350,28 @@ public class BakingModelGenerator implements ModelGenerator
Float.floatToRawIntBits( this.points[3][0] ),
Float.floatToRawIntBits( this.points[3][1] ),
Float.floatToRawIntBits( this.points[3][2] ),
// this.brightness,
this.brightness,
Float.floatToRawIntBits( this.points[3][3] ),
Float.floatToRawIntBits( this.points[3][4] ),
// 0,
};
this.generatedModel.general.add( new BakedQuad( vertData, this.color, face, Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry( TextureMap.LOCATION_BLOCKS_TEXTURE.toString() ), true, DefaultVertexFormats.POSITION_TEX ) );
for( List<BakedQuad> list : this.generatedModel.faces )
{
list.add( new BakedQuad( vertData, this.color, face, Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry( TextureMap.LOCATION_BLOCKS_TEXTURE.toString() ), true, DefaultVertexFormats.POSITION_TEX ) );
}
this.point = 0;
this.point = 0;*/
vertexBuffer.finishDrawing();
final VertexBuffer.State state = vertexBuffer.getVertexState();
this.generatedModel.general.add( new BakedQuad( state.getRawBuffer(), this.color, face, Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry( TextureMap.LOCATION_BLOCKS_TEXTURE.toString() ), true, state.getVertexFormat() ) );
for( List<BakedQuad> list : this.generatedModel.faces )
{
list.add( new BakedQuad( state.getRawBuffer(), this.color, face, Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry( TextureMap.LOCATION_BLOCKS_TEXTURE.toString() ), true, state.getVertexFormat() ) );
}
vertexBuffer = null;
}
}
@@ -582,6 +603,7 @@ public class BakingModelGenerator implements ModelGenerator
}
else
{
this.generatedModel.general.add( bf );
for( List<BakedQuad> list : this.generatedModel.faces )
{
list.add( bf );
@@ -49,8 +49,8 @@ public class RenderBlockController extends BaseBlockRender<BlockController, Tile
final boolean zz = this.getTileEntity( world, pos.offset( EnumFacing.SOUTH ) ) instanceof TileController && this.getTileEntity( world, pos.offset( EnumFacing.NORTH ) ) instanceof TileController;
final BlockController.ControllerBlockState meta = (ControllerBlockState) world.getBlockState( pos ).getValue( BlockController.CONTROLLER_STATE );
final boolean hasPower = meta != BlockController.ControllerBlockState.OFFLINE;
final boolean isConflict = meta == BlockController.ControllerBlockState.CONFLICTED;
final boolean hasPower = meta != BlockController.ControllerBlockState.offline;
final boolean isConflict = meta == BlockController.ControllerBlockState.conflicted;
ExtraBlockTextures lights = null;