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
|
@ -134,7 +134,7 @@ public class TileGutter extends TilePressureNode
|
||||||
{
|
{
|
||||||
FluidUtility.fillAllTanks(tanks, drain, true);
|
FluidUtility.fillAllTanks(tanks, drain, true);
|
||||||
FluidUtility.drainBlock(worldObj, drainPos, true);
|
FluidUtility.drainBlock(worldObj, drainPos, true);
|
||||||
|
|
||||||
synchronized (node.getGrid().getNodes())
|
synchronized (node.getGrid().getNodes())
|
||||||
{
|
{
|
||||||
for (Object check : node.getGrid().getNodes())
|
for (Object check : node.getGrid().getNodes())
|
||||||
|
|
|
@ -8,7 +8,6 @@ import resonantinduction.electrical.battery.TileBattery;
|
||||||
import resonantinduction.electrical.charger.RenderCharger;
|
import resonantinduction.electrical.charger.RenderCharger;
|
||||||
import resonantinduction.electrical.encoder.TileEncoder;
|
import resonantinduction.electrical.encoder.TileEncoder;
|
||||||
import resonantinduction.electrical.encoder.gui.GuiEncoderInventory;
|
import resonantinduction.electrical.encoder.gui.GuiEncoderInventory;
|
||||||
import resonantinduction.electrical.generator.solar.RenderSolarPanel;
|
|
||||||
import resonantinduction.electrical.generator.solar.TileSolarPanel;
|
import resonantinduction.electrical.generator.solar.TileSolarPanel;
|
||||||
import resonantinduction.electrical.levitator.RenderLevitator;
|
import resonantinduction.electrical.levitator.RenderLevitator;
|
||||||
import resonantinduction.electrical.multimeter.GuiMultimeter;
|
import resonantinduction.electrical.multimeter.GuiMultimeter;
|
||||||
|
@ -43,7 +42,6 @@ public class ClientProxy extends CommonProxy
|
||||||
GlobalItemRenderer.register(Electrical.itemQuantumGlyph.itemID, RenderQuantumGlyph.INSTANCE);
|
GlobalItemRenderer.register(Electrical.itemQuantumGlyph.itemID, RenderQuantumGlyph.INSTANCE);
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileSolarPanel.class, new RenderSolarPanel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,6 @@ import resonantinduction.electrical.battery.TileBattery;
|
||||||
import resonantinduction.electrical.charger.ItemCharger;
|
import resonantinduction.electrical.charger.ItemCharger;
|
||||||
import resonantinduction.electrical.generator.BlockMotor;
|
import resonantinduction.electrical.generator.BlockMotor;
|
||||||
import resonantinduction.electrical.generator.TileMotor;
|
import resonantinduction.electrical.generator.TileMotor;
|
||||||
import resonantinduction.electrical.generator.solar.BlockSolarPanel;
|
|
||||||
import resonantinduction.electrical.generator.solar.TileSolarPanel;
|
import resonantinduction.electrical.generator.solar.TileSolarPanel;
|
||||||
import resonantinduction.electrical.generator.thermopile.BlockThermopile;
|
import resonantinduction.electrical.generator.thermopile.BlockThermopile;
|
||||||
import resonantinduction.electrical.generator.thermopile.TileThermopile;
|
import resonantinduction.electrical.generator.thermopile.TileThermopile;
|
||||||
|
@ -81,7 +80,7 @@ public class Electrical
|
||||||
public static Block blockEncoder;
|
public static Block blockEncoder;
|
||||||
|
|
||||||
// Generators
|
// Generators
|
||||||
public static BlockSolarPanel blockSolarPanel;
|
public static Block blockSolarPanel;
|
||||||
public static Block blockMotor;
|
public static Block blockMotor;
|
||||||
public static Block blockThermopile;
|
public static Block blockThermopile;
|
||||||
|
|
||||||
|
@ -118,7 +117,7 @@ public class Electrical
|
||||||
itemInsulation = contentRegistry.createItem("insulation", ItemResourcePart.class);
|
itemInsulation = contentRegistry.createItem("insulation", ItemResourcePart.class);
|
||||||
|
|
||||||
// Generator
|
// Generator
|
||||||
blockSolarPanel = (BlockSolarPanel) contentRegistry.createTile(BlockSolarPanel.class, TileSolarPanel.class);
|
blockSolarPanel = contentRegistry.newBlock(TileSolarPanel.class);
|
||||||
blockMotor = contentRegistry.createTile(BlockMotor.class, TileMotor.class);
|
blockMotor = contentRegistry.createTile(BlockMotor.class, TileMotor.class);
|
||||||
blockThermopile = contentRegistry.createTile(BlockThermopile.class, TileThermopile.class);
|
blockThermopile = contentRegistry.createTile(BlockThermopile.class, TileThermopile.class);
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,29 @@
|
||||||
package resonantinduction.electrical.battery;
|
package resonantinduction.electrical.battery;
|
||||||
|
|
||||||
|
import calclavia.lib.prefab.tile.TileElectrical;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.api.net.IConnector;
|
import universalelectricity.api.net.IConnector;
|
||||||
import universalelectricity.api.vector.Vector3;
|
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 markClientUpdate = false;
|
||||||
public boolean markDistributionUpdate = false;
|
public boolean markDistributionUpdate = false;
|
||||||
|
|
||||||
public long renderEnergyAmount = 0;
|
public long renderEnergyAmount = 0;
|
||||||
|
private EnergyDistributionNetwork network;
|
||||||
|
|
||||||
|
public TileEnergyDistribution()
|
||||||
|
{
|
||||||
|
super(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileEnergyDistribution(Material material)
|
||||||
|
{
|
||||||
|
super(material);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initiate()
|
public void initiate()
|
||||||
|
@ -22,6 +32,24 @@ public class TileEnergyDistribution extends TileElectrical implements IConnector
|
||||||
this.updateStructure();
|
this.updateStructure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAdded()
|
||||||
|
{
|
||||||
|
if (!world().isRemote)
|
||||||
|
{
|
||||||
|
updateStructure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNeighborChanged()
|
||||||
|
{
|
||||||
|
if (!world().isRemote)
|
||||||
|
{
|
||||||
|
updateStructure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
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;
|
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 resonantinduction.electrical.battery.TileEnergyDistribution;
|
||||||
import universalelectricity.api.energy.EnergyStorageHandler;
|
import universalelectricity.api.energy.EnergyStorageHandler;
|
||||||
|
|
||||||
public class TileSolarPanel extends TileEnergyDistribution
|
public class TileSolarPanel extends TileEnergyDistribution
|
||||||
{
|
{
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public static Icon sideIcon, bottomIcon;
|
||||||
|
|
||||||
public TileSolarPanel()
|
public TileSolarPanel()
|
||||||
{
|
{
|
||||||
this.energy = new EnergyStorageHandler(800);
|
super(Material.iron);
|
||||||
this.ioMap = 728;
|
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
|
@Override
|
||||||
|
@ -32,4 +74,10 @@ public class TileSolarPanel extends TileEnergyDistribution
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
protected TileRender newRenderer()
|
||||||
|
{
|
||||||
|
return new ConnectedTextureRenderer(this, Reference.PREFIX + "tankEdge");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue