Added connected textures to solar panel
This commit is contained in:
parent
cee4358aae
commit
0358d65ee1
7 changed files with 64 additions and 91 deletions
|
@ -86,7 +86,7 @@ public class Electrical
|
|||
public static Block blockEncoder;
|
||||
|
||||
// Generators
|
||||
public static Block blockSolarPanel;
|
||||
public static BlockSolarPanel blockSolarPanel;
|
||||
public static Block blockGenerator;
|
||||
public static Block blockThermopile;
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class Electrical
|
|||
itemDisk = contentRegistry.createItem(ItemDisk.class);
|
||||
|
||||
// Generator
|
||||
blockSolarPanel = contentRegistry.createTile(BlockSolarPanel.class, TileSolarPanel.class);
|
||||
blockSolarPanel = (BlockSolarPanel) contentRegistry.createTile(BlockSolarPanel.class, TileSolarPanel.class);
|
||||
blockGenerator = contentRegistry.createTile(BlockGenerator.class, TileGenerator.class);
|
||||
blockThermopile = contentRegistry.createTile(BlockThermopile.class, TileThermopile.class);
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package resonantinduction.electrical.generator.solar;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.render.RIBlockRenderingHandler;
|
||||
|
@ -11,11 +13,39 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
|
||||
public class BlockSolarPanel extends BlockTile
|
||||
{
|
||||
public Icon sideIcon;
|
||||
public Icon bottomIcon;
|
||||
|
||||
public BlockSolarPanel(int id)
|
||||
{
|
||||
super(id, UniversalElectricity.machine);
|
||||
setTextureName(Reference.PREFIX + "material_metal_side");
|
||||
setBlockBounds(0, 0, 0, 1, 0.5f, 1);
|
||||
setTextureName(Reference.PREFIX + "solarPanel_top");
|
||||
setBlockBounds(0, 0, 0, 1, 0.3f, 1);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IconRegister iconReg)
|
||||
{
|
||||
sideIcon = iconReg.registerIcon(Reference.PREFIX + "solarPanel_side");
|
||||
bottomIcon = iconReg.registerIcon(Reference.PREFIX + "solarPanel_bottom");
|
||||
super.registerIcons(iconReg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(int side, int meta)
|
||||
{
|
||||
if (side == 0)
|
||||
{
|
||||
return bottomIcon;
|
||||
}
|
||||
else if (side == 1)
|
||||
{
|
||||
return blockIcon;
|
||||
}
|
||||
|
||||
return sideIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
package resonantinduction.electrical.generator.solar;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelSolarPanel extends ModelBase
|
||||
{
|
||||
// fields
|
||||
ModelRenderer base;
|
||||
ModelRenderer neck;
|
||||
ModelRenderer panel;
|
||||
ModelRenderer brace;
|
||||
ModelRenderer braceLeft;
|
||||
ModelRenderer braceRight;
|
||||
|
||||
public ModelSolarPanel()
|
||||
{
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
base = new ModelRenderer(this, 0, 0);
|
||||
base.addBox(-3.5F, 0F, -3.5F, 7, 1, 7);
|
||||
base.setRotationPoint(0F, 23F, 0F);
|
||||
base.setTextureSize(128, 128);
|
||||
base.mirror = true;
|
||||
setRotation(base, 0F, 0F, 0F);
|
||||
neck = new ModelRenderer(this, 57, 17);
|
||||
neck.addBox(-3F, 0F, -2.5F, 6, 2, 5);
|
||||
neck.setRotationPoint(0F, 21F, 0F);
|
||||
neck.setTextureSize(128, 128);
|
||||
neck.mirror = true;
|
||||
setRotation(neck, 0F, 0F, 0F);
|
||||
panel = new ModelRenderer(this, 0, 31);
|
||||
panel.addBox(-7F, 0F, -7F, 14, 3, 14);
|
||||
panel.setRotationPoint(0F, 15F, 0F);
|
||||
panel.setTextureSize(128, 128);
|
||||
panel.mirror = true;
|
||||
setRotation(panel, 0F, 0F, 0F);
|
||||
brace = new ModelRenderer(this, 9, 16);
|
||||
brace.addBox(-8F, 0F, -3F, 16, 2, 6);
|
||||
brace.setRotationPoint(0F, 19F, 0F);
|
||||
brace.setTextureSize(128, 128);
|
||||
brace.mirror = true;
|
||||
setRotation(brace, 0F, 0F, 0F);
|
||||
braceLeft = new ModelRenderer(this, 57, 0);
|
||||
braceLeft.addBox(7F, 0F, -3F, 1, 3, 6);
|
||||
braceLeft.setRotationPoint(0F, 16F, 0F);
|
||||
braceLeft.setTextureSize(128, 128);
|
||||
braceLeft.mirror = true;
|
||||
setRotation(braceLeft, 0F, 0F, 0F);
|
||||
braceRight = new ModelRenderer(this, 39, 0);
|
||||
braceRight.addBox(-8F, 0F, -3F, 1, 3, 6);
|
||||
braceRight.setRotationPoint(0F, 16F, 0F);
|
||||
braceRight.setTextureSize(128, 128);
|
||||
braceRight.mirror = true;
|
||||
setRotation(braceRight, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float f5)
|
||||
{
|
||||
base.render(f5);
|
||||
neck.render(f5);
|
||||
panel.render(f5);
|
||||
brace.render(f5);
|
||||
braceLeft.render(f5);
|
||||
braceRight.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +1,49 @@
|
|||
package resonantinduction.electrical.generator.solar;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
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 resonantinduction.core.Reference;
|
||||
import resonantinduction.electrical.Electrical;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import calclavia.lib.utility.WorldUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderSolarPanel extends TileEntitySpecialRenderer
|
||||
{
|
||||
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "solarPanel.png");
|
||||
public static final ModelSolarPanel MODEL = new ModelSolarPanel();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f)
|
||||
{
|
||||
// Texture file
|
||||
this.bindTexture(TEXTURE);
|
||||
float width = 0.25f;
|
||||
float thickness = 0.07f;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
MODEL.render(0.0625F);
|
||||
GL11.glTranslated(x + 0.5, y + 0.05f, z + 0.5);
|
||||
RenderUtility.bind(TextureMap.locationBlocksTexture);
|
||||
|
||||
// Render the main panel
|
||||
RenderUtility.renderCube(-0.5, -0.05, -0.5, 0.5, width, 0.5, Electrical.blockSolarPanel);
|
||||
ForgeDirection dir = ForgeDirection.DOWN;
|
||||
|
||||
// Render edges
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection check = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (tile.worldObj == null || !(tile.worldObj.getBlockTileEntity(tile.xCoord + check.offsetX, tile.yCoord + check.offsetY, tile.zCoord + check.offsetZ) instanceof TileSolarPanel))
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(WorldUtility.getAngleFromForgeDirection(check), 0, 1, 0);
|
||||
RenderUtility.renderCube(0.5 - thickness, -0.0501, -0.501, 0.501, width + 0.001, 0.501, Electrical.blockSolarPanel, Electrical.blockSolarPanel.sideIcon);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Loading…
Reference in a new issue