mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 04:32:18 +00:00
Fixed SMP solar panel (and changed the algorithm)
Fixed bug in machine upgrades.
This commit is contained in:
1 parent
0be34ac2ef
commit
1989b3faa5
4 files changed
+46
-29
No files matched your search
@@ -43,7 +43,7 @@ import crazypants.enderio.machine.painter.BlockCustomStair;
|
||||
import crazypants.enderio.machine.painter.BlockCustomWall;
|
||||
import crazypants.enderio.machine.painter.BlockPainter;
|
||||
import crazypants.enderio.machine.reservoir.BlockReservoir;
|
||||
import crazypants.enderio.machine.solor.BlockSolarPanel;
|
||||
import crazypants.enderio.machine.solar.BlockSolarPanel;
|
||||
import crazypants.enderio.material.BlockFusedQuartz;
|
||||
import crazypants.enderio.material.ItemAlloy;
|
||||
import crazypants.enderio.material.ItemCapacitor;
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class AbstractMachineEntity extends TileEntity implements IInven
|
||||
capacitorType = Capacitors.BASIC_CAPACITOR;
|
||||
powerHandler = PowerHandlerUtil.createHandler(capacitorType.capacitor, this, powerType);
|
||||
|
||||
inventory = new ItemStack[inventorySize];
|
||||
inventory = new ItemStack[this.inventorySize];
|
||||
|
||||
redstoneControlMode = RedstoneControlMode.IGNORE;
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
package crazypants.enderio.machine.solor;
|
||||
package crazypants.enderio.machine.solar;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class BlockSolarPanel extends Block implements ITileEntityProvider {
|
||||
private void init() {
|
||||
LanguageRegistry.addName(this, ModObject.blockSolarPanel.name);
|
||||
GameRegistry.registerBlock(this, ModObject.blockSolarPanel.unlocalisedName);
|
||||
GameRegistry.registerTileEntity(TileEntitySolorPanel.class, ModObject.blockSolarPanel.unlocalisedName + "TileEntity");
|
||||
GameRegistry.registerTileEntity(TileEntitySolarPanel.class, ModObject.blockSolarPanel.unlocalisedName + "TileEntity");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +62,7 @@ public class BlockSolarPanel extends Block implements ITileEntityProvider {
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
return new TileEntitySolorPanel();
|
||||
return new TileEntitySolarPanel();
|
||||
}
|
||||
|
||||
public Icon getIcon(int side, int meta) {
|
||||
@@ -75,8 +75,8 @@ public class BlockSolarPanel extends Block implements ITileEntityProvider {
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int par5) {
|
||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||
if(te instanceof TileEntitySolorPanel) {
|
||||
((TileEntitySolorPanel)te).onNeighborBlockChange();
|
||||
if(te instanceof TileEntitySolarPanel) {
|
||||
((TileEntitySolarPanel)te).onNeighborBlockChange();
|
||||
}
|
||||
}
|
||||
|
||||
+39
-22
@@ -1,4 +1,4 @@
|
||||
package crazypants.enderio.machine.solor;
|
||||
package crazypants.enderio.machine.solar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -10,6 +10,8 @@ import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
@@ -18,7 +20,7 @@ import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
public class TileEntitySolorPanel extends TileEntity implements IInternalPowerReceptor, IPowerEmitter {
|
||||
public class TileEntitySolarPanel extends TileEntity implements IInternalPowerReceptor, IPowerEmitter {
|
||||
|
||||
protected PowerHandler powerHandler;
|
||||
private BasicCapacitor capacitor;
|
||||
@@ -26,11 +28,10 @@ public class TileEntitySolorPanel extends TileEntity implements IInternalPowerRe
|
||||
private final List<Receptor> receptors = new ArrayList<Receptor>();
|
||||
private ListIterator<Receptor> receptorIterator = receptors.listIterator();
|
||||
private boolean receptorsDirty = true;
|
||||
|
||||
|
||||
private float energyPerTick = 1;
|
||||
|
||||
public TileEntitySolorPanel() {
|
||||
// TODO:
|
||||
public TileEntitySolarPanel() {
|
||||
capacitor = new BasicCapacitor();
|
||||
powerHandler = PowerHandlerUtil.createHandler(capacitor, this, Type.ENGINE);
|
||||
}
|
||||
@@ -77,13 +78,29 @@ public class TileEntitySolorPanel extends TileEntity implements IInternalPowerRe
|
||||
}
|
||||
|
||||
private void collectEnergy() {
|
||||
if(!worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) {
|
||||
if (!worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) {
|
||||
return;
|
||||
}
|
||||
float fromSun = worldObj.getSunBrightness(1);
|
||||
float fromSun = calculateLightRatio();
|
||||
float collected = energyPerTick * fromSun;
|
||||
powerHandler.setEnergy(Math.min(powerHandler.getMaxEnergyStored(), powerHandler.getEnergyStored() + collected));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private float calculateLightRatio() {
|
||||
int lightValue = worldObj.getSavedLightValue(EnumSkyBlock.Sky, xCoord, yCoord, zCoord) - worldObj.skylightSubtracted;
|
||||
float sunAngle = worldObj.getCelestialAngleRadians(1.0F);
|
||||
|
||||
if (sunAngle < (float) Math.PI) {
|
||||
sunAngle += (0.0F - sunAngle) * 0.2F;
|
||||
} else {
|
||||
sunAngle += (((float) Math.PI * 2F) - sunAngle) * 0.2F;
|
||||
}
|
||||
|
||||
lightValue = Math.round((float) lightValue * MathHelper.cos(sunAngle));
|
||||
|
||||
lightValue = MathHelper.clamp_int(lightValue, 0, 15);
|
||||
return lightValue / 15f;
|
||||
}
|
||||
|
||||
private boolean transmitEnergy() {
|
||||
@@ -152,22 +169,23 @@ public class TileEntitySolorPanel extends TileEntity implements IInternalPowerRe
|
||||
if (te instanceof IPowerReceptor) {
|
||||
IPowerReceptor rec = (IPowerReceptor) te;
|
||||
PowerReceiver reciever = rec.getPowerReceiver(dir.getOpposite());
|
||||
if(reciever != null) {
|
||||
if (reciever != null) {
|
||||
receptors.add(new Receptor((IPowerReceptor) te, dir.getOpposite()));
|
||||
}
|
||||
}
|
||||
|
||||
//NB: This is to supports connections from any direction
|
||||
// BlockCoord bc = new BlockCoord(xCoord, yCoord, zCoord);
|
||||
// for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
// BlockCoord checkLoc = bc.getLocation(dir);
|
||||
// TileEntity te = worldObj.getBlockTileEntity(checkLoc.x, checkLoc.y, checkLoc.z);
|
||||
// if (te instanceof IPowerReceptor) {
|
||||
// IPowerReceptor rec = (IPowerReceptor) te;
|
||||
// PowerReceiver reciever = rec.getPowerReceiver(dir.getOpposite());
|
||||
// receptors.add(new Receptor((IPowerReceptor) te, dir.getOpposite()));
|
||||
// }
|
||||
// }
|
||||
|
||||
// NB: This is to supports connections from any direction
|
||||
// BlockCoord bc = new BlockCoord(xCoord, yCoord, zCoord);
|
||||
// for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
// BlockCoord checkLoc = bc.getLocation(dir);
|
||||
// TileEntity te = worldObj.getBlockTileEntity(checkLoc.x, checkLoc.y,
|
||||
// checkLoc.z);
|
||||
// if (te instanceof IPowerReceptor) {
|
||||
// IPowerReceptor rec = (IPowerReceptor) te;
|
||||
// PowerReceiver reciever = rec.getPowerReceiver(dir.getOpposite());
|
||||
// receptors.add(new Receptor((IPowerReceptor) te, dir.getOpposite()));
|
||||
// }
|
||||
// }
|
||||
receptorIterator = receptors.listIterator();
|
||||
receptorsDirty = false;
|
||||
|
||||
@@ -184,5 +202,4 @@ public class TileEntitySolorPanel extends TileEntity implements IInternalPowerRe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user