metadata aware connected textures

This commit is contained in:
Bob 2022-10-19 21:06:05 +02:00
parent 6fa857fed0
commit 8134907dd9
9 changed files with 31 additions and 15 deletions

View File

@ -9,6 +9,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class BlockDecoCT extends BlockOre implements IBlockCT{
@ -31,7 +32,7 @@ public class BlockDecoCT extends BlockOre implements IBlockCT{
}
@Override
public IIcon[] getFragments() {
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) {
return rec.fragCache;
}
}

View File

@ -9,6 +9,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class BlockNTMGlassCT extends BlockNTMGlass implements IBlockCT {
@ -35,7 +36,7 @@ public class BlockNTMGlassCT extends BlockNTMGlass implements IBlockCT {
}
@Override
public IIcon[] getFragments() {
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) {
return rec.fragCache;
}
}

View File

@ -42,7 +42,7 @@ public class BlockHadronCoil extends Block implements IBlockCT, ITooltipProvider
}
@Override
public IIcon[] getFragments() {
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) {
return rec.fragCache;
}

View File

@ -12,6 +12,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class WireCoated extends BlockContainer implements IBlockCT {
@ -40,7 +41,7 @@ public class WireCoated extends BlockContainer implements IBlockCT {
}
@Override
public IIcon[] getFragments() {
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) {
return rec.fragCache;
}
}

View File

@ -4,13 +4,13 @@ import com.hbm.render.block.ct.CT;
import com.hbm.render.block.ct.CTStitchReceiver;
import com.hbm.render.block.ct.IBlockCT;
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.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class TestCT extends Block implements IBlockCT {
@ -33,17 +33,22 @@ public class TestCT extends Block implements IBlockCT {
return true;
}
@SideOnly(Side.CLIENT)
public CTStitchReceiver rec;
@SideOnly(Side.CLIENT) public CTStitchReceiver rec;
@SideOnly(Side.CLIENT) protected IIcon secondIcon;
@SideOnly(Side.CLIENT) public CTStitchReceiver secondrec;
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
this.blockIcon = reg.registerIcon(this.getTextureName());
this.secondIcon = reg.registerIcon(this.getTextureName() + ".1");
this.rec = IBlockCT.primeReceiver(reg, this.getTextureName(), this.blockIcon);
this.secondrec = IBlockCT.primeReceiver(reg, this.getTextureName() + ".1", this.secondIcon);
}
@Override
public IIcon[] getFragments() {
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) {
if(world.getBlockMetadata(x, y, z) != 0)
return secondrec.fragCache;
return rec.fragCache;
}
}

View File

@ -96,7 +96,7 @@ public class CTContext {
int ibl = b | l | cornerType(cons[3], cons[5], cons[6]);
int ibr = b | r | cornerType(cons[4], cons[7], cons[6]);
faces[i] = new CTFace((IBlockCT)block, itl, itr, ibl, ibr);
faces[i] = new CTFace(world, x, y, z, (IBlockCT)block, itl, itr, ibl, ibr);
}
}
@ -148,6 +148,10 @@ public class CTContext {
*/
public static class CTFace {
IBlockAccess world;
int x;
int y;
int z;
IBlockCT ct;
int index_tl;
int index_tr;
@ -156,7 +160,11 @@ public class CTContext {
public CTFace() { }
public CTFace(IBlockCT block, int i, int j, int k, int l) {
public CTFace(IBlockAccess world, int x, int y, int z, IBlockCT block, int i, int j, int k, int l) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.ct = block;
this.index_tl = i;
this.index_tr = j;
@ -164,9 +172,9 @@ public class CTContext {
this.index_br = l;
}
public IIcon getTopLeft() { return ct.getFragments()[index_tl]; }
public IIcon getTopRight() { return ct.getFragments()[index_tr]; }
public IIcon getBottomLeft() { return ct.getFragments()[index_bl]; }
public IIcon getBottomRight() { return ct.getFragments()[index_br]; }
public IIcon getTopLeft() { return ct.getFragments(world, x, y, z)[index_tl]; }
public IIcon getTopRight() { return ct.getFragments(world, x, y, z)[index_tr]; }
public IIcon getBottomLeft() { return ct.getFragments(world, x, y, z)[index_bl]; }
public IIcon getBottomRight() { return ct.getFragments(world, x, y, z)[index_br]; }
}
}

View File

@ -6,7 +6,7 @@ import net.minecraft.world.IBlockAccess;
public interface IBlockCT {
public IIcon[] getFragments();
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z);
public default boolean canConnect(IBlockAccess world, int x, int y, int z, IBlockCT block) {
return this == block;

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B