Fixed #477 - Solar panel now efficiently use ISBRH connected texture renderer
This commit is contained in:
parent
fc5af14ff0
commit
1bbfb89a30
7 changed files with 86 additions and 161 deletions
|
@ -8,7 +8,6 @@ import resonantinduction.electrical.battery.TileBattery;
|
|||
import resonantinduction.electrical.charger.RenderCharger;
|
||||
import resonantinduction.electrical.encoder.TileEncoder;
|
||||
import resonantinduction.electrical.encoder.gui.GuiEncoderInventory;
|
||||
import resonantinduction.electrical.generator.solar.RenderSolarPanel;
|
||||
import resonantinduction.electrical.generator.solar.TileSolarPanel;
|
||||
import resonantinduction.electrical.levitator.RenderLevitator;
|
||||
import resonantinduction.electrical.multimeter.GuiMultimeter;
|
||||
|
@ -43,7 +42,6 @@ public class ClientProxy extends CommonProxy
|
|||
GlobalItemRenderer.register(Electrical.itemQuantumGlyph.itemID, RenderQuantumGlyph.INSTANCE);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileSolarPanel.class, new RenderSolarPanel());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@ import resonantinduction.electrical.battery.TileBattery;
|
|||
import resonantinduction.electrical.charger.ItemCharger;
|
||||
import resonantinduction.electrical.generator.BlockMotor;
|
||||
import resonantinduction.electrical.generator.TileMotor;
|
||||
import resonantinduction.electrical.generator.solar.BlockSolarPanel;
|
||||
import resonantinduction.electrical.generator.solar.TileSolarPanel;
|
||||
import resonantinduction.electrical.generator.thermopile.BlockThermopile;
|
||||
import resonantinduction.electrical.generator.thermopile.TileThermopile;
|
||||
|
@ -81,7 +80,7 @@ public class Electrical
|
|||
public static Block blockEncoder;
|
||||
|
||||
// Generators
|
||||
public static BlockSolarPanel blockSolarPanel;
|
||||
public static Block blockSolarPanel;
|
||||
public static Block blockMotor;
|
||||
public static Block blockThermopile;
|
||||
|
||||
|
@ -118,7 +117,7 @@ public class Electrical
|
|||
itemInsulation = contentRegistry.createItem("insulation", ItemResourcePart.class);
|
||||
|
||||
// Generator
|
||||
blockSolarPanel = (BlockSolarPanel) contentRegistry.createTile(BlockSolarPanel.class, TileSolarPanel.class);
|
||||
blockSolarPanel = contentRegistry.newBlock(TileSolarPanel.class);
|
||||
blockMotor = contentRegistry.createTile(BlockMotor.class, TileMotor.class);
|
||||
blockThermopile = contentRegistry.createTile(BlockThermopile.class, TileThermopile.class);
|
||||
|
||||
|
|
|
@ -1,19 +1,29 @@
|
|||
package resonantinduction.electrical.battery;
|
||||
|
||||
import calclavia.lib.prefab.tile.TileElectrical;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.api.net.IConnector;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.prefab.tile.TileElectrical;
|
||||
|
||||
public class TileEnergyDistribution extends TileElectrical implements IConnector<EnergyDistributionNetwork>
|
||||
public class TileEnergyDistribution extends TileElectrical
|
||||
implements IConnector<EnergyDistributionNetwork>
|
||||
{
|
||||
private EnergyDistributionNetwork network;
|
||||
|
||||
public boolean markClientUpdate = false;
|
||||
public boolean markDistributionUpdate = false;
|
||||
|
||||
public long renderEnergyAmount = 0;
|
||||
private EnergyDistributionNetwork network;
|
||||
|
||||
public TileEnergyDistribution()
|
||||
{
|
||||
super(null);
|
||||
}
|
||||
|
||||
public TileEnergyDistribution(Material material)
|
||||
{
|
||||
super(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate()
|
||||
|
@ -22,6 +32,24 @@ public class TileEnergyDistribution extends TileElectrical implements IConnector
|
|||
this.updateStructure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
updateStructure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
if (!world().isRemote)
|
||||
{
|
||||
updateStructure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
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.electrical.battery.TileEnergyDistribution;
|
||||
import universalelectricity.api.UniversalElectricity;
|
||||
import calclavia.lib.prefab.block.BlockTile;
|
||||
import calclavia.lib.render.block.BlockRenderingHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
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 + "solarPanel_top");
|
||||
setBlockBounds(0, 0, 0, 1, 0.3f, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
if (!world.isRemote && tileEntity instanceof TileEnergyDistribution)
|
||||
{
|
||||
TileEnergyDistribution distribution = (TileEnergyDistribution) tileEntity;
|
||||
distribution.updateStructure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (!world.isRemote && tileEntity instanceof TileEnergyDistribution)
|
||||
{
|
||||
TileEnergyDistribution distribution = (TileEnergyDistribution) tileEntity;
|
||||
distribution.updateStructure();
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileSolarPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return BlockRenderingHandler.ID;
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
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.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f)
|
||||
{
|
||||
float width = 0.25f;
|
||||
float thickness = 0.07f;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -1,14 +1,56 @@
|
|||
package resonantinduction.electrical.generator.solar;
|
||||
|
||||
import calclavia.lib.content.module.TileRender;
|
||||
import calclavia.lib.prefab.vector.Cuboid;
|
||||
import calclavia.lib.render.ConnectedTextureRenderer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.electrical.battery.TileEnergyDistribution;
|
||||
import universalelectricity.api.energy.EnergyStorageHandler;
|
||||
|
||||
public class TileSolarPanel extends TileEnergyDistribution
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Icon sideIcon, bottomIcon;
|
||||
|
||||
public TileSolarPanel()
|
||||
{
|
||||
this.energy = new EnergyStorageHandler(800);
|
||||
this.ioMap = 728;
|
||||
super(Material.iron);
|
||||
energy = new EnergyStorageHandler(800);
|
||||
ioMap = 728;
|
||||
textureName = "solarPanel_top";
|
||||
bounds = new Cuboid(0, 0, 0, 1, 0.3f, 1);
|
||||
isOpaqueCube = false;
|
||||
normalRender = false;
|
||||
}
|
||||
|
||||
@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 getIcon();
|
||||
}
|
||||
|
||||
return sideIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,4 +74,10 @@ public class TileSolarPanel extends TileEnergyDistribution
|
|||
super.updateEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected TileRender newRenderer()
|
||||
{
|
||||
return new ConnectedTextureRenderer(this, Reference.PREFIX + "tankEdge");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue