Temp using BC wire render

I plan to make a redpower like wire render later but first we need to
make it work. The render is just for visual aid rather than anything
else.
This commit is contained in:
DarkGuardsman 2013-08-26 14:36:25 -04:00
parent d733dd6029
commit 842b0f69d5
3 changed files with 290 additions and 1 deletions

View file

@ -0,0 +1,130 @@
package dark.client.models;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelCopperWire extends ModelBase
{
// fields
ModelRenderer Middle;
ModelRenderer Right;
ModelRenderer Left;
ModelRenderer Back;
ModelRenderer Front;
ModelRenderer Top;
ModelRenderer Bottom;
public ModelCopperWire()
{
textureWidth = 64;
textureHeight = 32;
Middle = new ModelRenderer(this, 0, 0);
Middle.addBox(-1F, -1F, -1F, 4, 4, 4);
Middle.setRotationPoint(-1F, 15F, -1F);
Middle.setTextureSize(64, 32);
Middle.mirror = true;
setRotation(Middle, 0F, 0F, 0F);
Right = new ModelRenderer(this, 21, 0);
Right.addBox(0F, 0F, 0F, 6, 4, 4);
Right.setRotationPoint(2F, 14F, -2F);
Right.setTextureSize(64, 32);
Right.mirror = true;
setRotation(Right, 0F, 0F, 0F);
Left = new ModelRenderer(this, 21, 0);
Left.addBox(0F, 0F, 0F, 6, 4, 4);
Left.setRotationPoint(-8F, 14F, -2F);
Left.setTextureSize(64, 32);
Left.mirror = true;
setRotation(Left, 0F, 0F, 0F);
Back = new ModelRenderer(this, 0, 11);
Back.addBox(0F, 0F, 0F, 4, 4, 6);
Back.setRotationPoint(-2F, 14F, 2F);
Back.setTextureSize(64, 32);
Back.mirror = true;
setRotation(Back, 0F, 0F, 0F);
Front = new ModelRenderer(this, 0, 11);
Front.addBox(0F, 0F, 0F, 4, 4, 6);
Front.setRotationPoint(-2F, 14F, -8F);
Front.setTextureSize(64, 32);
Front.mirror = true;
setRotation(Front, 0F, 0F, 0F);
Top = new ModelRenderer(this, 21, 11);
Top.addBox(0F, 0F, 0F, 4, 6, 4);
Top.setRotationPoint(-2F, 8F, -2F);
Top.setTextureSize(64, 32);
Top.mirror = true;
setRotation(Top, 0F, 0F, 0F);
Bottom = new ModelRenderer(this, 21, 11);
Bottom.addBox(0F, 0F, 0F, 4, 6, 4);
Bottom.setRotationPoint(-2F, 18F, -2F);
Bottom.setTextureSize(64, 32);
Bottom.mirror = true;
setRotation(Bottom, 0F, 0F, 0F);
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.renderMiddle();
this.renderBottom();
this.renderTop();
this.renderLeft();
this.renderRight();
this.renderBack();
this.renderFront();
}
public void renderMiddle()
{
Middle.render(0.0625F);
}
public void renderBottom()
{
Bottom.render(0.0625F);
}
public void renderTop()
{
Top.render(0.0625F);
}
public void renderLeft()
{
Left.render(0.0625F);
}
public void renderRight()
{
Right.render(0.0625F);
}
public void renderBack()
{
Back.render(0.0625F);
}
public void renderFront()
{
Front.render(0.0625F);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
@Override
public void setRotationAngles(float x, float y, float z, float f3, float f4, float f5, Entity entity)
{
super.setRotationAngles(x, y, z, f3, f4, f5, entity);
}
}

View file

@ -0,0 +1,128 @@
package dark.client.renders;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergyTile;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
import universalelectricity.compatibility.Compatibility;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import buildcraft.api.power.IPowerReceptor;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.client.models.ModelCopperWire;
import dark.common.transmit.TileEntityWire;
import dark.core.DarkMain;
@SideOnly(Side.CLIENT)
public class RenderCopperWire extends TileEntitySpecialRenderer
{
private static final ResourceLocation copperWireTexture = new ResourceLocation(DarkMain.TEXTURE_DIRECTORY, "textures/models/copperWire.png");
public static final ModelCopperWire model = new ModelCopperWire();
public void renderModelAt(TileEntityWire tileEntity, double d, double d1, double d2, float f)
{
// Texture file
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(copperWireTexture);
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
List<TileEntity> adjecentConnections = new ArrayList<TileEntity>();
for (byte i = 0; i < 6; i++)
{
ForgeDirection side = ForgeDirection.getOrientation(i);
TileEntity adjacentTile = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity), side);
if (adjacentTile instanceof IConnector)
{
if (((IConnector) adjacentTile).canConnect(side.getOpposite()))
{
adjecentConnections.add(adjacentTile);
}
else
{
adjecentConnections.add(null);
}
}
else if (Compatibility.isIndustrialCraft2Loaded() && adjacentTile instanceof IEnergyTile)
{
if (adjacentTile instanceof IEnergyAcceptor)
{
if (((IEnergyAcceptor) adjacentTile).acceptsEnergyFrom(tileEntity, side.getOpposite()))
{
adjecentConnections.add(adjacentTile);
}
else
{
adjecentConnections.add(null);
}
}
else
{
adjecentConnections.add(adjacentTile);
}
}
else if (Compatibility.isBuildcraftLoaded() && adjacentTile instanceof IPowerReceptor)
{
adjecentConnections.add(adjacentTile);
}
else
{
adjecentConnections.add(null);
}
}
if (adjecentConnections.toArray()[0] != null)
{
model.renderBottom();
}
if (adjecentConnections.toArray()[1] != null)
{
model.renderTop();
}
if (adjecentConnections.toArray()[2] != null)
{
model.renderBack();
}
if (adjecentConnections.toArray()[3] != null)
{
model.renderFront();
}
if (adjecentConnections.toArray()[4] != null)
{
model.renderLeft();
}
if (adjecentConnections.toArray()[5] != null)
{
model.renderRight();
}
model.renderMiddle();
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
{
this.renderModelAt((TileEntityWire) tileEntity, var2, var4, var6, var8);
}
}

View file

@ -1,10 +1,13 @@
package dark.common.transmit;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.Configuration;
import dark.core.DarkMain;
import dark.core.blocks.BlockMachine;
public class BlockWire extends BlockMachine
@ -13,8 +16,36 @@ public class BlockWire extends BlockMachine
public BlockWire(Configuration config, int blockID)
{
super("DMWire", config, blockID, Material.cloth);
this.setStepSound(soundClothFootstep);
this.setResistance(0.2F);
this.setHardness(0.1f);
this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f);
this.setCreativeTab(CreativeTabs.tabRedstone);
this.setBlockBounds(0, 0, 0, 1, .3f, 1);
Block.setBurnProperties(this.blockID, 30, 60);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(DarkMain.getInstance().PREFIX +"CopperWire");
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override