diff --git a/archaic/src/main/scala/resonantinduction/archaic/fluid/gutter/TileGutter.java b/archaic/src/main/scala/resonantinduction/archaic/fluid/gutter/TileGutter.java index 22cdd955a..5a7e28ab7 100644 --- a/archaic/src/main/scala/resonantinduction/archaic/fluid/gutter/TileGutter.java +++ b/archaic/src/main/scala/resonantinduction/archaic/fluid/gutter/TileGutter.java @@ -134,7 +134,7 @@ public class TileGutter extends TilePressureNode { FluidUtility.fillAllTanks(tanks, drain, true); FluidUtility.drainBlock(worldObj, drainPos, true); - + synchronized (node.getGrid().getNodes()) { for (Object check : node.getGrid().getNodes()) diff --git a/electrical/src/main/scala/resonantinduction/electrical/ClientProxy.java b/electrical/src/main/scala/resonantinduction/electrical/ClientProxy.java index 9c372e151..0813c8f4a 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/ClientProxy.java +++ b/electrical/src/main/scala/resonantinduction/electrical/ClientProxy.java @@ -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 diff --git a/electrical/src/main/scala/resonantinduction/electrical/Electrical.java b/electrical/src/main/scala/resonantinduction/electrical/Electrical.java index 4879cf4e4..7f926527e 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/Electrical.java +++ b/electrical/src/main/scala/resonantinduction/electrical/Electrical.java @@ -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); diff --git a/electrical/src/main/scala/resonantinduction/electrical/battery/TileEnergyDistribution.java b/electrical/src/main/scala/resonantinduction/electrical/battery/TileEnergyDistribution.java index 72ee65f0d..ebc4adab0 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/battery/TileEnergyDistribution.java +++ b/electrical/src/main/scala/resonantinduction/electrical/battery/TileEnergyDistribution.java @@ -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 +public class TileEnergyDistribution extends TileElectrical + implements IConnector { - 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() { diff --git a/electrical/src/main/scala/resonantinduction/electrical/generator/solar/BlockSolarPanel.java b/electrical/src/main/scala/resonantinduction/electrical/generator/solar/BlockSolarPanel.java deleted file mode 100644 index bb60c3bd2..000000000 --- a/electrical/src/main/scala/resonantinduction/electrical/generator/solar/BlockSolarPanel.java +++ /dev/null @@ -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; - } -} diff --git a/electrical/src/main/scala/resonantinduction/electrical/generator/solar/RenderSolarPanel.java b/electrical/src/main/scala/resonantinduction/electrical/generator/solar/RenderSolarPanel.java deleted file mode 100644 index 122d45b5f..000000000 --- a/electrical/src/main/scala/resonantinduction/electrical/generator/solar/RenderSolarPanel.java +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/electrical/src/main/scala/resonantinduction/electrical/generator/solar/TileSolarPanel.java b/electrical/src/main/scala/resonantinduction/electrical/generator/solar/TileSolarPanel.java index 20f8d3052..80d01df76 100644 --- a/electrical/src/main/scala/resonantinduction/electrical/generator/solar/TileSolarPanel.java +++ b/electrical/src/main/scala/resonantinduction/electrical/generator/solar/TileSolarPanel.java @@ -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"); + } }