Added solar panel
This commit is contained in:
parent
ba19a60fcc
commit
ed3d3c78b5
5 changed files with 105 additions and 0 deletions
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue