Tile entity work

This commit is contained in:
Dimmerworld 2017-10-05 23:55:56 +11:00 committed by drcrazy
parent c4711848ae
commit fed439307e
2 changed files with 61 additions and 14 deletions

View file

@ -4,27 +4,38 @@ import net.minecraft.util.IStringSerializable;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
public enum EnumPanelType implements IStringSerializable { public enum EnumPanelType implements IStringSerializable {
Basic("basic", 128, EnumPowerTier.LOW, 0), Basic("basic", 128, 1000, 50000, EnumPowerTier.LOW, 0),
Hybrid("hybrid", 32, EnumPowerTier.MEDIUM, 1), Hybrid("hybrid", 32, 2000, 100000, EnumPowerTier.MEDIUM, 1),
Advanced("advanced", 512, EnumPowerTier.MEDIUM, 2), Advanced("advanced", 512, 3000, 200000, EnumPowerTier.MEDIUM, 2),
Ultimate("ultimate", 2048, EnumPowerTier.HIGH, 3), Ultimate("ultimate", 2048, 4000, 300000, EnumPowerTier.HIGH, 3),
Quantum("quantum", 2048, EnumPowerTier.EXTREME, 4); Quantum("quantum", 2048, 5000, 400000, EnumPowerTier.EXTREME, 4);
private int ID; private int ID;
public int generationRate = 128;
private String friendlyName; private String friendlyName;
EnumPanelType(String friendlyName, int generationRate, EnumPowerTier tier, int ID) { public int generationRateD = 128;
// Generation of FE during Day
public int generationRateN = 64;
// Generation of FE during Night
public int internalCapacity = 0;
// Internal FE storage of solar panel
EnumPanelType(String friendlyName, int generationRateD, int generationRateN, int internalCapacity, EnumPowerTier tier, int ID) {
this.friendlyName = friendlyName; this.friendlyName = friendlyName;
this.generationRate = generationRate;
this.ID = ID; this.ID = ID;
this.generationRateD = generationRateD;
this.generationRateN = generationRateN;
this.internalCapacity = internalCapacity;
} }
@Override @Override
public String getName() { public String getName() {
return friendlyName.toLowerCase(); return friendlyName;
} }

View file

@ -28,6 +28,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.RebornRegistry;
@ -44,7 +45,7 @@ import java.util.List;
*/ */
@RebornRegistry(modID = ModInfo.MOD_ID) @RebornRegistry(modID = ModInfo.MOD_ID)
public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop, IEnergyStorage {
// @ConfigRegistry(config = "machines", category = "solar_panel", key = "SolarPanelMaxOutput", comment = "Solar Panel Max Output (Value in EU)") // @ConfigRegistry(config = "machines", category = "solar_panel", key = "SolarPanelMaxOutput", comment = "Solar Panel Max Output (Value in EU)")
// public static int maxOutput = 32; // public static int maxOutput = 32;
@ -56,11 +57,15 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
boolean shouldMakePower = false; boolean shouldMakePower = false;
boolean lastTickSate = false; boolean lastTickSate = false;
int powerToAdd; int powerToAdd;
private int generationRateD;
private int generationRateN;
private int internalCapacity;
public TileSolarPanel() { public TileSolarPanel() {
super(); super();
IBlockState panelType = world.getBlockState(pos); generationRateD = getPanelType().generationRateD;
System.out.println(panelType + " Dimmer"); generationRateN = getPanelType().generationRateN;
internalCapacity = getPanelType().internalCapacity;
} }
@Override @Override
@ -89,7 +94,7 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
@Override @Override
public double getBaseMaxPower() { public double getBaseMaxPower() {
return 5; return (double)generationRateD;
} }
@Override @Override
@ -102,14 +107,45 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
return true; return true;
} }
@Override
public boolean canReceive() {
return false;
}
@Override
public int getEnergyStored() {
return 100;
}
@Override
public int getMaxEnergyStored() {
return internalCapacity;
}
@Override
public boolean canExtract() {
return true;
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
return 0;
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
return 0;
}
@Override @Override
public double getBaseMaxOutput() { public double getBaseMaxOutput() {
return 200; return generationRateD;
} }
private EnumPanelType getPanelType() { private EnumPanelType getPanelType() {
return world.getBlockState(pos).getValue(BlockSolarPanel.TYPE); return world.getBlockState(pos).getValue(BlockSolarPanel.TYPE);
} }
@Override @Override
public double getBaseMaxInput() { public double getBaseMaxInput() {
return 0; return 0;