more broken CT garbage

This commit is contained in:
Boblet 2021-09-28 16:54:20 +02:00
parent d59e27e73f
commit 96fb78aa28
4 changed files with 137 additions and 9 deletions

View File

@ -57,6 +57,7 @@ public class ModBlocks {
public static Block test_core;
public static Block test_charge;
public static Block test_conductor;
public static Block test_ct;
public static Block ore_uranium;
public static Block ore_uranium_scorched;
@ -1202,6 +1203,7 @@ public class ModBlocks {
test_core = new TestCore(Material.iron).setBlockName("test_core").setCreativeTab(null).setHardness(2.5F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":test_core");
test_charge = new TestCharge(Material.iron).setBlockName("test_charge").setCreativeTab(null).setHardness(2.5F).setResistance(10.0F);
test_conductor = new TestConductor(Material.iron).setBlockName("test_conductor").setCreativeTab(null).setHardness(2.5F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cable_neo");
test_ct = new TestCT(Material.iron).setBlockName("test_ct").setCreativeTab(null).setHardness(2.5F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":test_ct");
ore_uranium = new BlockOutgas(Material.rock, true, 5, false).setBlockName("ore_uranium").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":ore_uranium");
ore_uranium_scorched = new BlockOutgas(Material.rock, true, 5, false).setBlockName("ore_uranium_scorched").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":ore_uranium_scorched");
@ -2155,6 +2157,7 @@ public class ModBlocks {
GameRegistry.registerBlock(test_core, test_core.getUnlocalizedName());
GameRegistry.registerBlock(test_charge, test_charge.getUnlocalizedName());
GameRegistry.registerBlock(test_conductor, test_conductor.getUnlocalizedName());
GameRegistry.registerBlock(test_ct, test_ct.getUnlocalizedName());
//Ores
GameRegistry.registerBlock(ore_uranium, ore_uranium.getUnlocalizedName());

View File

@ -0,0 +1,49 @@
package com.hbm.blocks.test;
import com.hbm.render.block.ct.IconCT;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
public class TestCT extends Block {
public TestCT(Material p_i45394_1_) {
super(p_i45394_1_);
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType() {
return renderID;
}
public IIcon[] frags = new IIcon[20];
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
this.blockIcon = reg.registerIcon(this.getTextureName());
IIcon ct = new SevenUp(this.getTextureName() + "_ct");
reg.registerIcon(this.getTextureName() + "_ct");
for(int i = 0; i < frags.length; i++) {
frags[i] = new IconCT(i < 4 ? this.blockIcon : ct, i);
}
}
@SideOnly(Side.CLIENT)
public static class SevenUp extends TextureAtlasSprite {
protected SevenUp(String tex) {
super(tex);
}
}
}

View File

@ -4,7 +4,6 @@ import net.minecraft.util.IIcon;
public class IconCT implements IIcon {
public static final int l = 0; //left
public static final int r = 1; //right
public static final int t = 0; //top
@ -43,12 +42,38 @@ public class IconCT implements IIcon {
private float minV;
private float maxV;
/// none of this is going to work because that's just not how icon UV works! ///
public IconCT(IIcon parent, int type) {
this.parent = parent;
this.type = type;
int sub = ((type & f) != 0) ? 2 : 4;
float len = 1F / sub;
float du = 0F;
float dv = 0F;
//set pos to full block (coarse positioning)
if((type & v) > 0 || (type & j) > 0) {
du += len * 2;
}
if((type & h) > 0 || (type & j) > 0) {
dv += len * 2;
}
//set pos to sub-block (fine positioning)
if((type & r) > 0) {
du += len;
}
if((type & b) > 0) {
dv += len;
}
minU = du;
maxU = du + len;
minV = dv;
maxV = dv + len;
//what moron wrote this
}
@Override
@ -63,12 +88,12 @@ public class IconCT implements IIcon {
@Override
public float getMinU() {
return 0;
return this.minU;
}
@Override
public float getMaxU() {
return 0;
return this.maxU;
}
@Override
@ -83,12 +108,12 @@ public class IconCT implements IIcon {
@Override
public float getInterpolatedU(double interp) {
return 0;
return (float) (this.minU + (this.maxU - this.minU) * interp / 16D); //why 16 is involved here i do not know, but for some reason the interp range is [0;16]
}
@Override
public float getInterpolatedV(double interp) {
return 0;
return (float) (this.minV + (this.maxV - this.minV) * interp / 16D);
}
@Override

View File

@ -1,7 +1,9 @@
package com.hbm.render.block.ct;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
public class RenderBlocksCT extends RenderBlocks {
@ -39,11 +41,60 @@ public class RenderBlocksCT extends RenderBlocks {
this.cc = VertInfo.avg(tl, tr, bl, br);
}
@Override
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceXPos(block, x, y, z, icon);
}
@Override
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceXNeg(block, x, y, z, icon);
}
@Override
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceYPos(block, x, y, z, icon);
}
@Override
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceYNeg(block, x, y, z, icon);
}
@Override
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceZPos(block, x, y, z, icon);
}
@Override
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
super.renderFaceZNeg(block, x, y, z, icon);
}
private void drawFace(double[] ftl, double[] ftr, double[] fbl, double[] fbr) {
private void drawFace(double[] ftl, double[] ftr, double[] fbl, double[] fbr, IIcon itl, IIcon itr, IIcon ibl, IIcon ibr) {
double[] ftc = avgCoords(ftl, ftr);
///TODO///
double[] fbc = avgCoords(fbl, fbr);
double[] fcl = avgCoords(ftl, fbl);
double[] fcr = avgCoords(ftr, fbr);
double[] fcc = avgCoords(ftc, fbc);
drawSubFace(ftl, this.tl, ftc, this.tc, fcl, this.cl, fcc, this.cc, itl);
drawSubFace(ftc, this.tc, ftr, this.tr, fcc, this.cc, fcr, this.cr, itr);
drawSubFace(fcl, this.cl, fcc, this.cc, fbl, this.bl, fbc, this.bc, ibl);
drawSubFace(fcc, this.cc, fcr, this.cr, fbc, this.bc, fbr, this.br, ibr);
}
private void drawSubFace(double[] ftl, VertInfo ntl, double[] ftr, VertInfo ntr, double[] fbl, VertInfo nbl, double[] fbr, VertInfo nbr, IIcon icon) {
drawVert(ftl, icon.getMinU(), icon.getMinV(), ntl);
drawVert(ftr, icon.getMinU(), icon.getMaxV(), ntr);
drawVert(fbr, icon.getMaxU(), icon.getMaxV(), nbr);
drawVert(fbl, icon.getMaxU(), icon.getMinV(), nbl);
}
private void drawVert(double[] coord, double u, double v, VertInfo info) {
drawVert(coord[0], coord[1], coord[2], u, v, info);
}
private void drawVert(double x, double y, double z, double u, double v, VertInfo info) {