Added solar panel
This commit is contained in:
parent
ba19a60fcc
commit
ed3d3c78b5
5 changed files with 105 additions and 0 deletions
|
@ -0,0 +1,25 @@
|
||||||
|
package techreborn.blocks.generator;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import reborncore.common.BaseTileBlock;
|
||||||
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
|
import techreborn.tiles.generator.TileSolarPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mark on 25/02/2016.
|
||||||
|
*/
|
||||||
|
public class BlockSolarPanel extends BaseTileBlock {
|
||||||
|
|
||||||
|
public BlockSolarPanel() {
|
||||||
|
super(Material.iron);
|
||||||
|
setUnlocalizedName("techreborn.solarpanel");
|
||||||
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||||
|
return new TileSolarPanel();
|
||||||
|
}
|
||||||
|
}
|
|
@ -79,6 +79,7 @@ public class ModBlocks {
|
||||||
public static Block Compressor;
|
public static Block Compressor;
|
||||||
public static Block Extractor;
|
public static Block Extractor;
|
||||||
public static Block ElectricFurnace;
|
public static Block ElectricFurnace;
|
||||||
|
public static Block solarPanel;
|
||||||
|
|
||||||
public static BlockOre ore;
|
public static BlockOre ore;
|
||||||
public static BlockOre2 ore2;
|
public static BlockOre2 ore2;
|
||||||
|
@ -284,6 +285,9 @@ public class ModBlocks {
|
||||||
GameRegistry.registerBlock(ElectricFurnace, "techreborn.electricfurnace");
|
GameRegistry.registerBlock(ElectricFurnace, "techreborn.electricfurnace");
|
||||||
GameRegistry.registerTileEntity(TileElectricFurnace.class, "TileElectricFurnaceTR");
|
GameRegistry.registerTileEntity(TileElectricFurnace.class, "TileElectricFurnaceTR");
|
||||||
|
|
||||||
|
solarPanel = new BlockSolarPanel();
|
||||||
|
GameRegistry.registerBlock(solarPanel, "techreborn.solarpanel");
|
||||||
|
GameRegistry.registerTileEntity(TileSolarPanel.class, "TileSolarPanel");
|
||||||
|
|
||||||
GameRegistry.registerTileEntity(TileMachineBase.class, "TileMachineBaseTR");
|
GameRegistry.registerTileEntity(TileMachineBase.class, "TileMachineBaseTR");
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class RecipeCompact implements IRecipeCompact {
|
||||||
recipes.put("macerator", new ItemStack(ModBlocks.Grinder));
|
recipes.put("macerator", new ItemStack(ModBlocks.Grinder));
|
||||||
recipes.put("diamondDrill", new ItemStack(ModItems.diamondDrill));
|
recipes.put("diamondDrill", new ItemStack(ModItems.diamondDrill));
|
||||||
recipes.put("miningDrill", new ItemStack(ModItems.ironDrill));
|
recipes.put("miningDrill", new ItemStack(ModItems.ironDrill));
|
||||||
|
recipes.put("solarPanel", new ItemStack(ModBlocks.solarPanel));
|
||||||
inited = false;
|
inited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
74
src/main/java/techreborn/tiles/generator/TileSolarPanel.java
Normal file
74
src/main/java/techreborn/tiles/generator/TileSolarPanel.java
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
package techreborn.tiles.generator;
|
||||||
|
|
||||||
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mark on 25/02/2016.
|
||||||
|
*/
|
||||||
|
public class TileSolarPanel extends TilePowerAcceptor {
|
||||||
|
|
||||||
|
boolean shouldMakePower = false;
|
||||||
|
|
||||||
|
int powerToAdd;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
super.updateEntity();
|
||||||
|
if(worldObj.getTotalWorldTime() % 60 == 0){
|
||||||
|
shouldMakePower = isSunOut();
|
||||||
|
}
|
||||||
|
if(shouldMakePower){
|
||||||
|
powerToAdd = 10;
|
||||||
|
addEnergy(powerToAdd);
|
||||||
|
} else {
|
||||||
|
powerToAdd = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInfo(List<String> info, boolean isRealTile) {
|
||||||
|
super.addInfo(info, isRealTile);
|
||||||
|
if(isRealTile){
|
||||||
|
// FIXME: 25/02/2016
|
||||||
|
//info.add(ChatFormatting.LIGHT_PURPLE + "Power gen/tick " + ChatFormatting.GREEN + PowerSystem.getLocaliszedPower( powerToAdd)) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSunOut() {
|
||||||
|
return worldObj.canBlockSeeSky(pos.up()) && !worldObj.isRaining() && !worldObj.isThundering() && worldObj.isDaytime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileSolarPanel() {
|
||||||
|
super(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxPower() {
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProvideEnergy(EnumFacing direction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxOutput() {
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxInput() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -64,6 +64,7 @@ tile.techreborn.ore2.copper.name=Copper Ore
|
||||||
tile.techreborn.ore2.tin.name=Tin Ore
|
tile.techreborn.ore2.tin.name=Tin Ore
|
||||||
tile.techreborn.storage2.copper.name=Copper Block
|
tile.techreborn.storage2.copper.name=Copper Block
|
||||||
tile.techreborn.storage2.tin.name=Tin Block
|
tile.techreborn.storage2.tin.name=Tin Block
|
||||||
|
tile.techreborn.solarpanel.name=Solar panel
|
||||||
|
|
||||||
#Blocks
|
#Blocks
|
||||||
tile.techreborn.rubberlog.name=Rubber Wood
|
tile.techreborn.rubberlog.name=Rubber Wood
|
||||||
|
|
Loading…
Add table
Reference in a new issue