Added solar panels

This commit is contained in:
Calclavia 2014-01-11 00:08:58 +08:00
parent 67fc891420
commit ab24bb2746
20 changed files with 104 additions and 186 deletions

View file

@ -9,7 +9,6 @@ import net.minecraft.network.packet.Packet;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.network.ISimplePacketReceiver;
import universalelectricity.api.vector.Vector3;

View file

@ -3,7 +3,6 @@ package resonantinduction.core.resource.item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import resonantinduction.core.Reference;
import resonantinduction.core.resource.BlockOre;
import resonantinduction.core.resource.BlockOre.OreData;
public class ItemBlockOre extends ItemBlock

View file

@ -6,12 +6,14 @@ import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import resonantinduction.electrical.battery.RenderBattery;
import resonantinduction.electrical.battery.TileBattery;
import resonantinduction.electrical.fx.FXElectricBolt;
import resonantinduction.electrical.generator.solar.RenderSolarPanel;
import resonantinduction.electrical.generator.solar.TileSolarPanel;
import resonantinduction.electrical.multimeter.GuiMultimeter;
import resonantinduction.electrical.multimeter.PartMultimeter;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
import resonantinduction.electrical.render.FXElectricBolt;
import resonantinduction.electrical.tesla.RenderTesla;
import resonantinduction.electrical.tesla.TileTesla;
import resonantinduction.old.core.render.BlockRenderingHandler;
import resonantinduction.old.core.render.RenderRIItem;
import resonantinduction.old.transport.levitator.RenderLevitator;
import resonantinduction.old.transport.levitator.TileEMLevitator;
@ -34,12 +36,13 @@ public class ClientProxy extends CommonProxy
@Override
public void preInit()
{
RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE);
RenderingRegistry.registerBlockHandler(ElectricalBlockRenderingHandler.INSTANCE);
MinecraftForgeClient.registerItemRenderer(Electrical.itemMultimeter.itemID, RenderRIItem.INSTANCE);
MinecraftForgeClient.registerItemRenderer(Electrical.itemTransformer.itemID, RenderRIItem.INSTANCE);
ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla());
ClientRegistry.bindTileEntitySpecialRenderer(TileEMLevitator.class, new RenderLevitator());
ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery());
ClientRegistry.bindTileEntitySpecialRenderer(TileSolarPanel.class, new RenderSolarPanel());
}
@Override

View file

@ -1,8 +1,9 @@
package resonantinduction.electrical;
import ic2.api.item.Items;
import java.util.Map;
import ic2.api.item.Items;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -15,10 +16,11 @@ import resonantinduction.core.ResonantInduction;
import resonantinduction.core.ResonantInductionTabs;
import resonantinduction.core.Settings;
import resonantinduction.core.part.BlockMachinePart;
import resonantinduction.core.resource.fluid.TileFluidMixture;
import resonantinduction.electrical.battery.BlockBattery;
import resonantinduction.electrical.battery.ItemBlockBattery;
import resonantinduction.electrical.battery.TileBattery;
import resonantinduction.electrical.generator.solar.BlockSolarPanel;
import resonantinduction.electrical.generator.solar.TileSolarPanel;
import resonantinduction.electrical.multimeter.ItemMultimeter;
import resonantinduction.electrical.tesla.BlockTesla;
import resonantinduction.electrical.tesla.TileTesla;
@ -38,10 +40,10 @@ import calclavia.lib.network.PacketHandler;
import calclavia.lib.recipe.UniversalRecipe;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
@ -56,7 +58,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
* @author Calclavia
*
*/
@Mod(modid = Electrical.ID, name = Electrical.NAME, version = Reference.VERSION, dependencies = "required-after:" + ResonantInduction.ID)
@Mod(modid = Electrical.ID, name = Electrical.NAME, version = Reference.VERSION, dependencies = "before:ThermalExpansion;required-after:" + ResonantInduction.ID)
@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class Electrical
{
@ -80,12 +82,15 @@ public class Electrical
public static Block blockTesla;
public static Block blockBattery;
// Transport
public static Block blockEMContractor;
// Generators
public static Block blockSolarPanel;
// Machines
public static Block blockAdvancedFurnace, blockMachinePart, blockGrinderWheel, blockPurifier;
// Transport
public static Block blockEMContractor;
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
@ -108,6 +113,9 @@ public class Electrical
blockGrinderWheel = new BlockGrinderWheel(Settings.getNextBlockID());
blockPurifier = new BlockPurifier(Settings.getNextBlockID());
// Generator
blockSolarPanel = new BlockSolarPanel();
if (Settings.REPLACE_FURNACE)
{
blockAdvancedFurnace = BlockAdvancedFurnace.createNew(false);
@ -120,6 +128,7 @@ public class Electrical
GameRegistry.registerItem(itemMultimeter, itemMultimeter.getUnlocalizedName());
GameRegistry.registerItem(itemTransformer, itemTransformer.getUnlocalizedName());
GameRegistry.registerBlock(blockSolarPanel, blockSolarPanel.getUnlocalizedName());
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
GameRegistry.registerBlock(blockBattery, ItemBlockBattery.class, blockBattery.getUnlocalizedName());
GameRegistry.registerBlock(blockGrinderWheel, blockGrinderWheel.getUnlocalizedName());
@ -130,8 +139,7 @@ public class Electrical
// Tiles
GameRegistry.registerTileEntity(TileTesla.class, blockTesla.getUnlocalizedName());
GameRegistry.registerTileEntity(TileBattery.class, blockBattery.getUnlocalizedName());
// Tiles
GameRegistry.registerTileEntity(TileSolarPanel.class, blockSolarPanel.getUnlocalizedName());
GameRegistry.registerTileEntity(TilePurifier.class, blockPurifier.getUnlocalizedName());
GameRegistry.registerTileEntity(TileGrinderWheel.class, blockGrinderWheel.getUnlocalizedName());
GameRegistry.registerTileEntity(TileEMLevitator.class, blockEMContractor.getUnlocalizedName());

View file

@ -12,7 +12,7 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockIOBase;
import resonantinduction.old.core.render.BlockRenderingHandler;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
import universalelectricity.api.CompatibilityModule;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -70,7 +70,7 @@ public class BlockBattery extends BlockIOBase implements ITileEntityProvider
@SideOnly(Side.CLIENT)
public int getRenderType()
{
return BlockRenderingHandler.INSTANCE.getRenderId();
return ElectricalBlockRenderingHandler.INSTANCE.getRenderId();
}
@Override

View file

@ -1,41 +1,25 @@
package resonantinduction.electrical.generator.solar;
import java.util.List;
import java.util.Set;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.oredict.OreDictionary;
import resonantinduction.core.prefab.block.BlockMachine;
import resonantinduction.old.client.render.BlockRenderingHandler;
import resonantinduction.old.client.render.RenderBlockSolarPanel;
import com.builtbroken.common.Pair;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.lib.IExtraInfo.IExtraBlockInfo;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.core.prefab.block.BlockMachine;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
import resonantinduction.old.client.render.BlockRenderingHandler;
public class BlockSolarPanel extends BlockMachine implements IExtraBlockInfo
public class BlockSolarPanel extends BlockMachine
{
public static int tickRate = 10;
public static long wattDay = 120;
public static long wattNight = 1;
public static long wattStorm = 5;
public BlockSolarPanel()
{
super("BlockSolarPanel");
this.setBlockBounds(0, 0, 0, 1f, .6f, 1f);
super("solarPanel");
this.setBlockBounds(0, 0, 0, 1, 0.5f, 1);
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileEntitySolarPanel();
return new TileSolarPanel();
}
@Override
@ -50,45 +34,10 @@ public class BlockSolarPanel extends BlockMachine implements IExtraBlockInfo
return false;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.BLOCK_RENDER_ID;
return ElectricalBlockRenderingHandler.ID;
}
@Override
public void getTileEntities(int blockID, Set<Pair<String, Class<? extends TileEntity>>> list)
{
list.add(new Pair<String, Class<? extends TileEntity>>("DMSolarCell", TileEntitySolarPanel.class));
}
@Override
@SideOnly(Side.CLIENT)
public void getClientTileEntityRenderers(List<Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer>> list)
{
list.add(new Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer>(TileEntitySolarPanel.class, new RenderBlockSolarPanel()));
}
@Override
public void loadExtraConfigs(Configuration config)
{
tickRate = config.get("settings", "PanelUpdateRate", tickRate).getInt();
wattDay = config.get("settings", "WattDayLight", 120).getInt();
wattNight = config.get("settings", "WattMoonLight", 1).getInt();
wattStorm = config.get("settings", "WattStorm", 6).getInt();
}
@Override
public void loadOreNames()
{
OreDictionary.registerOre("SolarPanel", new ItemStack(this, 1, 0));
}
@Override
public boolean hasExtraConfigs()
{
// TODO Auto-generated method stub
return false;
}
}

View file

@ -1,10 +1,4 @@
// Date: 9/20/2013 12:38:02 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package resonantinduction.old.client.model;
package resonantinduction.electrical.generator.solar;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;

View file

@ -1,4 +1,4 @@
package resonantinduction.old.client.render;
package resonantinduction.electrical.generator.solar;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
@ -7,16 +7,14 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import resonantinduction.core.Reference;
import resonantinduction.old.client.model.ModelSolarPanel;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderBlockSolarPanel extends TileEntitySpecialRenderer
public class RenderSolarPanel extends TileEntitySpecialRenderer
{
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_DIRECTORY + "SolarPanel.png");
public static final ModelSolarPanel model = new ModelSolarPanel();
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)
@ -26,7 +24,7 @@ public class RenderBlockSolarPanel extends TileEntitySpecialRenderer
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);
MODEL.render(0.0625F);
GL11.glPopMatrix();
}
}

View file

@ -1,23 +0,0 @@
package resonantinduction.electrical.generator.solar;
import resonantinduction.core.prefab.tile.TileGenerator;
/** TileEntity that acts as the connection node for the solar panel */
public class TileEntitySolarBox extends TileGenerator
{
@Override
public boolean hasFuel()
{
// TODO Auto-generated method stub
return false;
}
@Override
public void consumeFuel()
{
// TODO Auto-generated method stub
}
}

View file

@ -1,56 +0,0 @@
package resonantinduction.electrical.generator.solar;
import java.util.EnumSet;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.prefab.tile.TileGenerator;
public class TileEntitySolarPanel extends TileGenerator
{
public TileEntitySolarPanel()
{
super();
}
@Override
public EnumSet<ForgeDirection> getOutputDirections()
{
return EnumSet.of(ForgeDirection.DOWN);
}
@Override
public boolean hasFuel()
{
return this.JOULES_PER_TICK > 0;
}
@Override
public void consumeFuel()
{
if (!this.worldObj.isRemote && this.ticks % BlockSolarPanel.tickRate == 0)
{
this.setJoulesPerSecound(0);
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky)
{
if (this.worldObj.isDaytime())
{
this.setJoulesPerTick(BlockSolarPanel.wattDay);
if (this.worldObj.isThundering() || this.worldObj.isRaining())
{
this.setJoulesPerSecound(BlockSolarPanel.wattStorm);
}
}
else
{
if (!this.worldObj.isThundering() && !this.worldObj.isRaining())
{
this.setJoulesPerTick(BlockSolarPanel.wattNight);
}
}
//TODO add GC support
//this.setJoulesPerSecound(this.JOULES_PER_TICK + this.JOULES_PER_TICK * (this.worldObj.provider instanceof ISolarLevel ? (int) ((ISolarLevel) this.worldObj.provider).getSolarEnergyMultiplier() : 0));
}
}
}
}

View file

@ -0,0 +1,35 @@
package resonantinduction.electrical.generator.solar;
import universalelectricity.api.energy.EnergyStorageHandler;
import calclavia.lib.prefab.tile.TileElectrical;
public class TileSolarPanel extends TileElectrical
{
public TileSolarPanel()
{
this.energy = new EnergyStorageHandler(200);
this.ioMap = 728;
}
@Override
public void updateEntity()
{
super.updateEntity();
if (!this.worldObj.isRemote)
{
if (this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && !this.worldObj.provider.hasNoSky)
{
if (this.worldObj.isDaytime())
{
if (!(this.worldObj.isThundering() || this.worldObj.isRaining()))
{
this.energy.receiveEnergy(1, true);
this.produce();
}
}
}
}
}
}

View file

@ -1,7 +1,7 @@
/**
*
*/
package resonantinduction.old.core.render;
package resonantinduction.electrical.render;
import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
@ -12,8 +12,13 @@ import static org.lwjgl.opengl.GL11.glTranslatef;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import resonantinduction.electrical.battery.BlockBattery;
import resonantinduction.electrical.battery.RenderBattery;
import resonantinduction.electrical.generator.solar.BlockSolarPanel;
import resonantinduction.electrical.generator.solar.RenderSolarPanel;
import resonantinduction.electrical.tesla.BlockTesla;
import resonantinduction.electrical.tesla.RenderTesla;
import resonantinduction.old.transport.levitator.BlockLevitator;
@ -29,10 +34,10 @@ import cpw.mods.fml.relauncher.SideOnly;
*
*/
@SideOnly(Side.CLIENT)
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
public class ElectricalBlockRenderingHandler implements ISimpleBlockRenderingHandler
{
public static final BlockRenderingHandler INSTANCE = new BlockRenderingHandler();
private static final int ID = RenderingRegistry.getNextAvailableRenderId();
public static final ElectricalBlockRenderingHandler INSTANCE = new ElectricalBlockRenderingHandler();
public static final int ID = RenderingRegistry.getNextAvailableRenderId();
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
@ -65,6 +70,13 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
RenderBattery.MODEL.renderAll();
glPopMatrix();
}
else if (block instanceof BlockSolarPanel)
{
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderSolarPanel.TEXTURE);
GL11.glTranslatef(0.0F, 1.1F, 0.0F);
GL11.glRotatef(180f, 0f, 0f, 1f);
RenderSolarPanel.MODEL.render(0.0625F);
}
}
@Override

View file

@ -1,4 +1,4 @@
package resonantinduction.electrical.fx;
package resonantinduction.electrical.render;
import static org.lwjgl.opengl.GL11.GL_BLEND;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;

View file

@ -11,7 +11,7 @@ import net.minecraft.world.World;
import resonantinduction.core.Reference;
import resonantinduction.core.Utility;
import resonantinduction.core.prefab.block.BlockIOBase;
import resonantinduction.old.core.render.BlockRenderingHandler;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
import calclavia.lib.utility.LanguageUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -107,7 +107,7 @@ public class BlockTesla extends BlockIOBase implements ITileEntityProvider
@Override
public int getRenderType()
{
return BlockRenderingHandler.INSTANCE.getRenderId();
return ElectricalBlockRenderingHandler.INSTANCE.getRenderId();
}
@Override

View file

@ -28,7 +28,6 @@ import resonantinduction.old.client.render.RenderTurkey;
import resonantinduction.old.core.misc.EntityFarmEgg;
import resonantinduction.old.core.misc.EntityTurkey;
import resonantinduction.old.core.recipe.RecipeLoader;
import resonantinduction.old.mechanics.CommonProxy;
import resonantinduction.old.mechanics.processor.TileEntityProcessor;
import resonantinduction.old.transport.encoder.TileEntityEncoder;
import resonantinduction.old.transport.fluid.TileEntityReleaseValve;

View file

@ -21,7 +21,6 @@ import resonantinduction.archaic.blocks.BlockColorSand;
import resonantinduction.archaic.blocks.BlockTurntable;
import resonantinduction.archaic.blocks.ItemBlockColored;
import resonantinduction.core.ResonantInductionTabs;
import resonantinduction.core.Settings;
import resonantinduction.core.debug.BlockDebug;
import resonantinduction.core.network.PacketIDTile;
import resonantinduction.core.resource.BlockGasOre;
@ -82,9 +81,6 @@ import resonantinduction.old.transport.fluid.pump.BlockPumpMachine;
import resonantinduction.old.transport.hopper.BlockAdvancedHopper;
import resonantinduction.old.transport.imprinter.BlockImprinter;
import resonantinduction.old.transport.imprinter.ItemImprinter;
import resonantinduction.old.transport.levitator.BlockLevitator;
import resonantinduction.old.transport.levitator.ItemBlockContractor;
import resonantinduction.old.transport.levitator.TileEMLevitator;
import resonantinduction.old.transport.logistic.BlockDetector;
import resonantinduction.old.transport.logistic.BlockManipulator;
import resonantinduction.old.transport.logistic.BlockRejector;

View file

@ -15,7 +15,6 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockMachine;
import resonantinduction.old.mechanics.CommonProxy;
import resonantinduction.old.transport.ResonantInductionTransport;
import com.builtbroken.common.Pair;

View file

@ -8,7 +8,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockMachine;
import resonantinduction.old.core.render.BlockRenderingHandler;
import resonantinduction.electrical.render.ElectricalBlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -24,7 +24,7 @@ public class BlockLevitator extends BlockMachine
@Override
public int getRenderType()
{
return BlockRenderingHandler.INSTANCE.getRenderId();
return ElectricalBlockRenderingHandler.INSTANCE.getRenderId();
}
@Override

View file

@ -9,6 +9,7 @@ meta.resonantinduction.credits=Visit website for credits.
fluid.mixture=Mixture
### Electrical Module
## Blocks
tile.resonantinduction\:tesla.name=Tesla Coil
tile.resonantinduction\:levitator.name=Electromagnetic Levitator
@ -17,6 +18,7 @@ tile.resonantinduction\:machinePart.name=Machine Part
tile.resonantinduction\:grindingWheel.name=Grinder Wheel
tile.resonantinduction\:purifier.name=Purifier Rotor
tile.resonantinduction\:filter.name=Filter
tile.resonantinduction\:solarPanel.name=Solar Panel
## Items
item.resonantinduction\:quantumEntangler.name=Quantum Entangler
@ -72,7 +74,11 @@ message.tesla.mode=Tesla receive mode is now %v
## Misc. Stuff
misc.resonantinduction.ingot=Ingot
# Assembly Line Language Properties
# OLD!!! Assembly Line Language Properties
# @author alGuardsman
itemGroup.Automation = Automation
itemGroup.Industrial = Industrial