diff --git a/models/SolarPanelSingle.tcn b/models/SolarPanelSingle.tcn new file mode 100644 index 000000000..7283f59f4 Binary files /dev/null and b/models/SolarPanelSingle.tcn differ diff --git a/resources/assets/dark/languages/en_US.properties b/resources/assets/dark/languages/en_US.properties index 6b262900e..2c9ec6c5c 100644 --- a/resources/assets/dark/languages/en_US.properties +++ b/resources/assets/dark/languages/en_US.properties @@ -1,5 +1,9 @@ # FluidMechanics Language Properties # @author DarkGuardsman +itemGroup.Automation = Automation +itemGroup.Industrial = Industrial +itemGroup.Hydraulic = Hydraulics + item.dark\:WoodDust.name = Wood Dust item.dark\:WoodPlate.name = Plank @@ -7,7 +11,7 @@ item.dark\:WoodGears.name = Wooden Gears item.dark\:WoodTube.name = Wooden Tube item.dark\:WoodScraps.name = Wood Fragments -item.dark\:StoneRubble.name = Stone Cobble +item.dark\:StoneRubble.name = Rocks item.dark\:StoneDust.name = Stone Dust item.dark\:StonePlate.name = Stone Sheet item.dark\:StoneGears.name = Stone Gears @@ -171,6 +175,15 @@ tile.basaltchiseled.name = Chiseled Basalt Bricks tile.basaltmossy.name = Mossy Basalt Bricks tile.basaltcracked.name = Cracked Basalt Bricks +tile.BlockSolarPanel.0.name = Solar Panel + +tile.BasicMachine.0.name = Coal Generator +tile.BasicMachine.4.name = Fuel Generator +tile.BasicMachine.8.name = Battery Box +tile.BasicMachine.12.name = Electric Furnace + +tile.DMWire.0.name = Copper Wire + # Items item.BronzeTube.name=Bronze Tube item.IronTube.name=Iron Tube diff --git a/resources/assets/dark/textures/models/SolarPanel.png b/resources/assets/dark/textures/models/SolarPanel.png new file mode 100644 index 000000000..e50ecca1a Binary files /dev/null and b/resources/assets/dark/textures/models/SolarPanel.png differ diff --git a/src/dark/core/client/ClientProxy.java b/src/dark/core/client/ClientProxy.java index d90dde3a1..52f34b01d 100644 --- a/src/dark/core/client/ClientProxy.java +++ b/src/dark/core/client/ClientProxy.java @@ -8,15 +8,20 @@ import net.minecraft.world.World; import universalelectricity.core.vector.Vector3; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import dark.core.client.renders.BlockRenderingHandler; import dark.core.client.renders.RenderBlockWire; +import dark.core.client.renders.RenderBlockSolarPanel; import dark.core.common.CommonProxy; import dark.core.common.CoreRecipeLoader; +import dark.core.common.DarkMain; import dark.core.common.machines.TileEntityBatteryBox; import dark.core.common.machines.TileEntityCoalGenerator; import dark.core.common.machines.TileEntityElectricFurnace; +import dark.core.common.machines.TileEntitySolarPanel; import dark.core.common.transmit.TileEntityWire; import dark.core.prefab.ModPrefab; @@ -25,7 +30,7 @@ public class ClientProxy extends CommonProxy { /** Renders a laser beam from one power to another by a set color for a set time - * + * * @param world - world this laser is to be rendered in * @param position - start vector3 * @param target - end vector3 @@ -40,6 +45,13 @@ public class ClientProxy extends CommonProxy } } + @Override + public void preInit() + { + RenderingRegistry.registerBlockHandler(new BlockRenderingHandler()); + //MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE); + } + @Override public void init() { @@ -47,6 +59,10 @@ public class ClientProxy extends CommonProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWire.class, new RenderBlockWire()); } + if (DarkMain.blockSolar != null) + { + ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySolarPanel.class, new RenderBlockSolarPanel()); + } } @Override diff --git a/src/dark/core/client/models/ModelSolarPanel.java b/src/dark/core/client/models/ModelSolarPanel.java new file mode 100644 index 000000000..bbca9fbee --- /dev/null +++ b/src/dark/core/client/models/ModelSolarPanel.java @@ -0,0 +1,82 @@ +// 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 dark.core.client.models; + +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; + } + +} diff --git a/src/dark/core/client/renders/BlockRenderingHandler.java b/src/dark/core/client/renders/BlockRenderingHandler.java new file mode 100644 index 000000000..eb0fbfe5d --- /dev/null +++ b/src/dark/core/client/renders/BlockRenderingHandler.java @@ -0,0 +1,57 @@ +package dark.core.client.renders; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import dark.core.client.models.ModelSolarPanel; +import dark.core.common.DarkMain; +import dark.core.prefab.ModPrefab; + +@SideOnly(Side.CLIENT) +public class BlockRenderingHandler implements ISimpleBlockRenderingHandler +{ + public static BlockRenderingHandler instance = new BlockRenderingHandler(); + public static final int BLOCK_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); + private static ModelSolarPanel solarPanelModel = new ModelSolarPanel(); + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) + { + GL11.glPushMatrix(); + if (DarkMain.blockSolar != null && block.blockID == DarkMain.blockSolar.blockID) + { + FMLClientHandler.instance().getClient().renderEngine.func_110577_a(new ResourceLocation(DarkMain.getInstance().DOMAIN, ModPrefab.MODEL_DIRECTORY + "solarPanel.png")); + GL11.glTranslatef(0.0F, 1.5F, 0.0F); + GL11.glRotatef(180f, 0f, 0f, 1f); + solarPanelModel.render(0.0625F); + } + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) + { + return false; + } + + @Override + public boolean shouldRender3DInInventory() + { + return true; + } + + @Override + public int getRenderId() + { + return BLOCK_RENDER_ID; + } +} diff --git a/src/dark/core/client/renders/RenderBlockSolarPanel.java b/src/dark/core/client/renders/RenderBlockSolarPanel.java new file mode 100644 index 000000000..09605a780 --- /dev/null +++ b/src/dark/core/client/renders/RenderBlockSolarPanel.java @@ -0,0 +1,37 @@ +package dark.core.client.renders; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import dark.core.client.models.ModelSolarPanel; +import dark.core.common.DarkMain; + +@SideOnly(Side.CLIENT) +public class RenderBlockSolarPanel extends RenderTileMachine +{ + private static final ResourceLocation solarPanelTexture = new ResourceLocation(DarkMain.getInstance().DOMAIN, DarkMain.MODEL_DIRECTORY + "SolarPanel.png"); + + public static final ModelSolarPanel model = new ModelSolarPanel(); + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) + { + // Texture file + this.bindTextureByName(this.getTexture(tileEntity.getBlockType().blockID, tileEntity.getBlockMetadata())); + 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.glPopMatrix(); + } + + @Override + public ResourceLocation getTexture(int block, int meta) + { + return solarPanelTexture; + } +} \ No newline at end of file diff --git a/src/dark/core/common/DarkMain.java b/src/dark/core/common/DarkMain.java index 2e6e0583e..7d0a4e730 100644 --- a/src/dark/core/common/DarkMain.java +++ b/src/dark/core/common/DarkMain.java @@ -48,6 +48,7 @@ import dark.core.common.items.ItemParts.Parts; import dark.core.common.items.ItemTools; import dark.core.common.items.ItemWrench; import dark.core.common.machines.BlockBasicMachine; +import dark.core.common.machines.BlockSolarPanel; import dark.core.common.transmit.BlockWire; import dark.core.network.PacketHandler; import dark.core.prefab.ModPrefab; @@ -87,7 +88,7 @@ public class DarkMain extends ModPrefab public static boolean overPressureDamage; public static BlockMulti blockMulti; - public static Block basicMachine; + public static Block basicMachine, blockSolar; @Instance(MOD_ID) private static DarkMain instance; @@ -196,6 +197,8 @@ public class DarkMain extends ModPrefab CoreRecipeLoader.blockColorSand = ModObjectRegistry.createNewBlock("DMBlockColorSand", DarkMain.MOD_ID, BlockColorSand.class, ItemBlockColored.class); CoreRecipeLoader.blockBasalt = ModObjectRegistry.createNewBlock("DMBlockBasalt", DarkMain.MOD_ID, BlockBasalt.class, ItemBlockColored.class); CoreRecipeLoader.blockGlowGlass = ModObjectRegistry.createNewBlock("DMBlockGlowGlass", DarkMain.MOD_ID, BlockColorGlowGlass.class, ItemBlockColored.class); + blockSolar = ModObjectRegistry.createNewBlock("DMBlockSolar", DarkMain.MOD_ID, BlockSolarPanel.class, ItemBlockHolder.class); + /* ITEMS */ CoreRecipeLoader.itemTool = new ItemTools(ITEM_ID_PREFIX++, DarkMain.CONFIGURATION); diff --git a/src/dark/core/common/machines/BlockSolarPanel.java b/src/dark/core/common/machines/BlockSolarPanel.java new file mode 100644 index 000000000..6dea0d15a --- /dev/null +++ b/src/dark/core/common/machines/BlockSolarPanel.java @@ -0,0 +1,56 @@ +package dark.core.common.machines; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.Configuration; +import universalelectricity.core.UniversalElectricity; +import dark.core.client.renders.BlockRenderingHandler; +import dark.core.common.DMCreativeTab; +import dark.core.prefab.machine.BlockMachine; +import dark.core.registration.BlockConfigFile; +import dark.core.registration.ModObjectRegistry.BlockBuildData; +import dark.core.registration.BlockTileEntityInfo; + +@BlockTileEntityInfo(tileEntities = { TileEntitySolarPanel.class }, tileEntitiesNames = { "DMSolarCell" }) +public class BlockSolarPanel extends BlockMachine +{ + public static float tickRate = 10; + public static float wattPerLightValue = .012f; + + public BlockSolarPanel() + { + super(new BlockBuildData(BlockSolarPanel.class, "BlockSolarPanel", UniversalElectricity.machine)); + this.setBlockBounds(0, 0, 0, 1f, .3f, 1f); + this.setCreativeTab(DMCreativeTab.tabIndustrial); + } + + @BlockConfigFile + public void loadBlockConfig(Configuration config) + { + tickRate = config.get("settings", "PanelUpdateRate", tickRate).getInt(); + wattPerLightValue = (config.get("settings", "WattPerLightvalue", (int) wattPerLightValue * 1000, "Value * 15 equals full output").getInt() / 1000); + } + + public TileEntity createNewTileEntity(World world) + { + return new TileEntitySolarPanel(); + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + public int getRenderType() + { + return BlockRenderingHandler.BLOCK_RENDER_ID; + } +} diff --git a/src/dark/core/common/machines/TileEntitySolarPanel.java b/src/dark/core/common/machines/TileEntitySolarPanel.java new file mode 100644 index 000000000..978caf5b4 --- /dev/null +++ b/src/dark/core/common/machines/TileEntitySolarPanel.java @@ -0,0 +1,50 @@ +package dark.core.common.machines; + +import java.util.EnumSet; + +import universalelectricity.core.electricity.ElectricityPack; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.ForgeDirection; +import dark.core.prefab.machine.TileEntityEnergyMachine; + +public class TileEntitySolarPanel extends TileEntityEnergyMachine +{ + public TileEntitySolarPanel() + { + this.MAX_WATTS = 1; + } + + public void updateEntity() + { + super.updateEntity(); + if (this.ticks % BlockSolarPanel.tickRate == 0) + { + this.produceAllSides(); + } + + } + + public EnumSet getOutputDirections() + { + return EnumSet.of(ForgeDirection.DOWN); + } + + @Override + public void discharge(ItemStack itemStack) + { + + } + + @Override + public float getRequest(ForgeDirection direction) + { + return 0; + } + + @Override + public float receiveElectricity(ElectricityPack receive, boolean doReceive) + { + return 0; + } +} diff --git a/src/dark/core/registration/TileEntityUser.java b/src/dark/core/registration/BlockTileEntityInfo.java similarity index 94% rename from src/dark/core/registration/TileEntityUser.java rename to src/dark/core/registration/BlockTileEntityInfo.java index cc9b8ca31..ff4ff17c0 100644 --- a/src/dark/core/registration/TileEntityUser.java +++ b/src/dark/core/registration/BlockTileEntityInfo.java @@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntity; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) -public @interface TileEntityUser +public @interface BlockTileEntityInfo { /** Array of tile entities this tile uses. Is a parallel array in combo with tileEntitiesName */ Class[] tileEntities() default {}; diff --git a/src/dark/core/registration/ModObjectRegistry.java b/src/dark/core/registration/ModObjectRegistry.java index b63144b31..4e00252b8 100644 --- a/src/dark/core/registration/ModObjectRegistry.java +++ b/src/dark/core/registration/ModObjectRegistry.java @@ -26,7 +26,7 @@ import dark.core.prefab.helpers.Pair; import dark.core.prefab.machine.BlockMachine; /** Handler to make registering all parts of a mod's objects that are loaded into the game by forge - * + * * @author DarkGuardsman */ public class ModObjectRegistry { @@ -126,20 +126,18 @@ public class ModObjectRegistry { if (block != null) { - // Read block class annotions - for (Annotation annotian : block.getClass().getDeclaredAnnotations()) + BlockTileEntityInfo blockTileEntityInfo = block.getClass().getAnnotation(BlockTileEntityInfo.class); + if (blockTileEntityInfo != null) { - if (annotian instanceof TileEntityUser) - { - Class[] tileEntities = ((TileEntityUser) annotian).tileEntities(); - String[] tileEntitiesNames = ((TileEntityUser) annotian).tileEntitiesNames(); + System.out.println("\n\n\n\n[ModObjectRegistry] Reading tile entities for " + block.getUnlocalizedName()); + Class[] tileEntities = blockTileEntityInfo.tileEntities(); + String[] tileEntitiesNames = blockTileEntityInfo.tileEntitiesNames(); - if (tileEntities != null && tileEntities.length > 0 && tileEntitiesNames != null && tileEntitiesNames.length > 0) + if (tileEntities != null && tileEntities.length > 0 && tileEntitiesNames != null && tileEntitiesNames.length > 0) + { + for (int i = 0; i < tileEntities.length && i < tileEntitiesNames.length; i++) { - for (int i = 0; i < tileEntities.length && i < tileEntitiesNames.length; i++) - { - GameRegistry.registerTileEntityWithAlternatives(tileEntities[i], tileEntitiesNames[i], "DM" + tileEntitiesNames[i]); - } + GameRegistry.registerTileEntityWithAlternatives(tileEntities[i], tileEntitiesNames[i], "DM" + tileEntitiesNames[i]); } } } @@ -147,10 +145,14 @@ public class ModObjectRegistry // Read threw the block class looking for annotions on fields for (Method method : block.getClass().getMethods()) { + System.out.println("[ModObjectRegistry] Reading class methods " + method.toGenericString()); for (Annotation annotian : method.getDeclaredAnnotations()) { + System.out.println("[ModObjectRegistry] Reading annotion " + annotian.toString()); if (annotian instanceof BlockConfigFile) { + + System.out.println("[ModObjectRegistry] Loading config file for " + block.getUnlocalizedName()); Type[] types = method.getParameterTypes(); if (types.length == 1 && types[0] instanceof Configuration) { @@ -159,7 +161,7 @@ public class ModObjectRegistry try { method.setAccessible(true); - method.invoke(null, extraBlockConfig); + method.invoke(extraBlockConfig); } catch (IllegalAccessException e) { @@ -176,6 +178,7 @@ public class ModObjectRegistry extraBlockConfig.save(); } + break; } } } @@ -245,10 +248,6 @@ public class ModObjectRegistry { if (block != null && name != null) { - - System.out.println("Block: " + (block == null ? "null" : block.toString())); - System.out.println("Item: " + (itemClass == null ? "null" : itemClass.toString())); - System.out.println("name: " + name.toString()); GameRegistry.registerBlock(block, itemClass == null ? ItemBlock.class : itemClass, name, modID); } } @@ -304,7 +303,7 @@ public class ModObjectRegistry } /** Adds a tileEntity to be registered when this block is registered - * + * * @param name - mod name for the tileEntity, should be unique * @param class1 - new instance of the TileEntity to register */ public BlockBuildData addTileEntity(String name, Class class1)