classic cable

This commit is contained in:
Boblet 2022-03-30 16:10:17 +02:00
parent 957b07cca3
commit d05854f514
6 changed files with 78 additions and 0 deletions

View File

@ -720,6 +720,7 @@ public class ModBlocks {
public static Block red_wire_coated;
public static Block red_cable;
public static Block red_cable_classic;
public static Block red_connector;
public static Block red_pylon;
public static Block red_pylon_large;
@ -1847,6 +1848,7 @@ public class ModBlocks {
red_wire_coated = new WireCoated(Material.iron).setBlockName("red_wire_coated").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_wire_coated");
red_cable = new BlockCable(Material.iron).setBlockName("red_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":cable_neo");
red_cable_classic = new BlockCable(Material.iron).setBlockName("red_cable_classic").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_cable_classic");
rf_cable = new BlockRFCable(Material.iron).setBlockName("rf_cable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":rf_cable_icon");
red_connector = new ConnectorRedWire(Material.iron).setBlockName("red_connector").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_connector");
red_pylon = new PylonRedWire(Material.iron).setBlockName("red_pylon").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":red_pylon");
@ -2963,6 +2965,7 @@ public class ModBlocks {
GameRegistry.registerBlock(pribris_digamma, pribris_digamma.getUnlocalizedName());
GameRegistry.registerBlock(red_cable, red_cable.getUnlocalizedName());
GameRegistry.registerBlock(red_cable_classic, red_cable_classic.getUnlocalizedName());
GameRegistry.registerBlock(red_wire_coated, red_wire_coated.getUnlocalizedName());
GameRegistry.registerBlock(red_connector, ItemBlockBase.class, red_connector.getUnlocalizedName());
GameRegistry.registerBlock(red_pylon, ItemBlockBase.class, red_pylon.getUnlocalizedName());

View File

@ -1,9 +1,11 @@
package com.hbm.blocks.network;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.test.TestConductor;
import com.hbm.lib.Library;
import com.hbm.tileentity.network.TileEntityCableBaseNT;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
@ -21,9 +23,15 @@ public class BlockCable extends BlockContainer {
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityCableBaseNT();
}
public static int renderIDClassic = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType() {
if(this == ModBlocks.red_cable_classic)
return renderIDClassic;
return TestConductor.renderID;
}

View File

@ -679,6 +679,7 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerBlockHandler(new RenderAnvil());
RenderingRegistry.registerBlockHandler(new RenderCrystal());
RenderingRegistry.registerBlockHandler(new RenderTestCable());
RenderingRegistry.registerBlockHandler(new RenderCableClassic());
RenderingRegistry.registerBlockHandler(new RenderTestPipe());
RenderingRegistry.registerBlockHandler(new RenderBlockCT());
RenderingRegistry.registerBlockHandler(new RenderDetCord());

View File

@ -0,0 +1,66 @@
package com.hbm.render.block;
import com.hbm.blocks.network.BlockCable;
import com.hbm.lib.Library;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class RenderCableClassic implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { }
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
IIcon iicon = block.getIcon(0, 0);
tessellator.setColorOpaque_F(1, 1, 1);
if(renderer.hasOverrideBlockTexture()) {
iicon = renderer.overrideBlockTexture;
}
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
tessellator.setColorOpaque_F(1, 1, 1);
boolean pX = Library.canConnect(world, x + 1, y, z, Library.NEG_X);
boolean nX = Library.canConnect(world, x - 1, y, z, Library.POS_X);
boolean pY = Library.canConnect(world, x, y + 1, z, Library.NEG_Y);
boolean nY = Library.canConnect(world, x, y - 1, z, Library.POS_Y);
boolean pZ = Library.canConnect(world, x, y, z + 1, Library.NEG_Z);
boolean nZ = Library.canConnect(world, x, y, z - 1, Library.POS_Z);
double spanU = iicon.getMaxU() - iicon.getMinU();
double spanV = iicon.getMaxV() - iicon.getMinV();
double px = 0.0625D;
double uv_cL = iicon.getMinU();
double uv_cR = iicon.getMinU() + spanU * 5 / px;
double uv_cT = iicon.getMaxV();
double uv_cB = iicon.getMaxV() - spanV * 5 / px;
double pos_min = px * 5.5D;
double pos_max = px * 10.5D;
//TODO: all that manual tessellator crap
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return false;
}
@Override
public int getRenderId() {
return BlockCable.renderIDClassic;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B