Gave the Solar Generator a new model

This commit is contained in:
Aidan Brady 2013-11-02 12:00:29 -04:00
parent 289a2ee227
commit 2a73dc3332
16 changed files with 238 additions and 257 deletions

View file

@ -25,10 +25,6 @@ public class ModelLogisticalSorter extends ModelBase
ModelRenderer PoleTL;
ModelRenderer PoleTR;
ModelRenderer PoleBL;
ModelRenderer InjectorTL;
ModelRenderer InjectorBR;
ModelRenderer InjectorTR;
ModelRenderer InjectorBL;
ModelRenderer Base;
ModelRenderer PipeBase;
ModelRenderer DecorPlate;
@ -146,30 +142,6 @@ public class ModelLogisticalSorter extends ModelBase
PoleBL.setTextureSize(128, 64);
PoleBL.mirror = true;
setRotation(PoleBL, 0F, 0F, 0F);
InjectorTL = new ModelRenderer(this, 0, 46);
InjectorTL.addBox(0F, 0F, 0F, 4, 1, 1);
InjectorTL.setRotationPoint(-7F, 12F, -3F);
InjectorTL.setTextureSize(128, 64);
InjectorTL.mirror = true;
setRotation(InjectorTL, 0F, 0F, -0.7853982F);
InjectorBR = new ModelRenderer(this, 0, 46);
InjectorBR.addBox(0F, 0F, 0F, 4, 1, 1);
InjectorBR.setRotationPoint(-6.3F, 19.3F, 2F);
InjectorBR.setTextureSize(128, 64);
InjectorBR.mirror = true;
setRotation(InjectorBR, 0F, 0F, 0.7853982F);
InjectorTR = new ModelRenderer(this, 0, 46);
InjectorTR.addBox(0F, 0F, 0F, 4, 1, 1);
InjectorTR.setRotationPoint(-7F, 12F, 2F);
InjectorTR.setTextureSize(128, 64);
InjectorTR.mirror = true;
setRotation(InjectorTR, 0F, 0F, -0.7853982F);
InjectorBL = new ModelRenderer(this, 0, 46);
InjectorBL.addBox(0F, 0F, 0F, 4, 1, 1);
InjectorBL.setRotationPoint(-6.5F, 19F, -3F);
InjectorBL.setTextureSize(128, 64);
InjectorBL.mirror = true;
setRotation(InjectorBL, 0F, 0F, 0.7853982F);
Base = new ModelRenderer(this, 0, 0);
Base.addBox(0F, 0F, 0F, 2, 14, 14);
Base.setRotationPoint(6F, 9F, -7F);
@ -222,10 +194,6 @@ public class ModelLogisticalSorter extends ModelBase
PoleTL.render(size);
PoleTR.render(size);
PoleBL.render(size);
InjectorTL.render(size);
InjectorBR.render(size);
InjectorTR.render(size);
InjectorBL.render(size);
Base.render(size);
PipeBase.render(size);
DecorPlate.render(size);

View file

@ -5,7 +5,7 @@ import java.util.Iterator;
public class HashList<T> implements Iterable<T>
{
private ArrayList<T> list = new ArrayList<T>();
private ArrayList<T> list = new ArrayList<T>(256);
public boolean contains(T obj)
{

View file

@ -67,21 +67,26 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
}
}
public ForgeDirection getOutputtingSide()
{
return null;
}
protected EnumSet<ForgeDirection> getConsumingSides()
{
return EnumSet.allOf(ForgeDirection.class);
}
protected EnumSet<ForgeDirection> getOutputtingSides()
public double getMaxOutput()
{
return EnumSet.noneOf(ForgeDirection.class);
return 0;
}
@Override
public boolean canConnect(ForgeDirection direction)
{
return getConsumingSides().contains(direction) || getOutputtingSides().contains(direction);
return getConsumingSides().contains(direction) || getOutputtingSide() == direction;
}
@Override
@ -191,7 +196,19 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Override
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
{
return null;
if(getOutputtingSide() == from)
{
double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), request.getWatts()*Mekanism.FROM_UE));
if(doProvide)
{
setEnergy(getEnergy() - toSend);
}
return ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), getVoltage());
}
return new ElectricityPack();
}
@Override
@ -206,9 +223,9 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
public float getProvide(ForgeDirection direction)
public float getProvide(ForgeDirection direction)
{
return 0;
return getOutputtingSide() == direction ? Math.min(getEnergyStored(), (float)(getMaxOutput()*Mekanism.TO_UE)) : 0;
}
@Override

View file

@ -69,55 +69,18 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
ChargeUtils.charge(0, this);
ChargeUtils.discharge(1, this);
if(!worldObj.isRemote && MekanismUtils.canFunction(this))
if(MekanismUtils.canFunction(this))
{
TileEntity tileEntity = Object3D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj);
if(getEnergy() > 0)
{
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
setEnergy(getEnergy() - (Math.min(getEnergy(), tier.OUTPUT) - CableUtils.emitEnergyToNetwork(Math.min(getEnergy(), tier.OUTPUT), this, ForgeDirection.getOrientation(facing))));
return;
}
else if(tileEntity instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
{
PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(ForgeDirection.getOrientation(facing).getOpposite());
if(receiver != null)
{
double electricityNeeded = Math.min(receiver.powerRequest(), receiver.getMaxEnergyStored() - receiver.getEnergyStored())*Mekanism.FROM_BC;
double transferEnergy = Math.min(getEnergy(), Math.min(electricityNeeded, tier.OUTPUT));
receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), ForgeDirection.getOrientation(facing).getOpposite());
setEnergy(getEnergy() - transferEnergy);
}
}
}
if(tileEntity instanceof IConductor)
{
ForgeDirection outputDirection = ForgeDirection.getOrientation(facing);
float provide = getProvide(outputDirection);
if(provide > 0)
{
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(tileEntity, outputDirection);
if(outputNetwork != null)
{
ElectricityPack request = outputNetwork.getRequest(this);
if(request.getWatts() > 0)
{
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(getEnergyStored(), getVoltage()), ElectricityPack.getFromWatts(provide, getVoltage()));
float rejectedPower = outputNetwork.produce(sendPack, this);
setEnergyStored(getEnergyStored() - (sendPack.getWatts() - rejectedPower));
}
}
}
}
CableUtils.emit(this);
}
}
@Override
public double getMaxOutput()
{
return tier.OUTPUT;
}
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
{
@ -150,9 +113,9 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
}
@Override
protected EnumSet<ForgeDirection> getOutputtingSides()
public ForgeDirection getOutputtingSide()
{
return EnumSet.of(ForgeDirection.getOrientation(facing));
return ForgeDirection.getOrientation(facing);
}
@Override
@ -160,30 +123,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
{
return direction != ForgeDirection.getOrientation(facing);
}
@Override
public float getProvide(ForgeDirection direction)
{
return getOutputtingSides().contains(direction) ? Math.min(getEnergyStored(), (float)(tier.OUTPUT*Mekanism.TO_UE)) : 0;
}
@Override
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
{
if(getOutputtingSides().contains(from))
{
double toSend = Math.min(getEnergy(), Math.min(tier.OUTPUT, request.getWatts()*Mekanism.FROM_UE));
if(doProvide)
{
setEnergy(getEnergy() - toSend);
}
return ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), getVoltage());
}
return new ElectricityPack();
}
@Override
public int getStored()

View file

@ -16,10 +16,17 @@ import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.EnergyNetwork;
import mekanism.common.Mekanism;
import mekanism.common.tileentity.TileEntityElectricBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.electricity.ElectricityHelper;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.grid.IElectricityNetwork;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
public final class CableUtils
{
@ -253,4 +260,62 @@ public final class CableUtils
return amount;
}
public static void emit(TileEntityElectricBlock emitter)
{
if(!emitter.worldObj.isRemote && MekanismUtils.canFunction(emitter))
{
TileEntity tileEntity = Object3D.get(emitter).getFromSide(emitter.getOutputtingSide()).getTileEntity(emitter.worldObj);
if(emitter.getEnergy() > 0)
{
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
emitter.setEnergy(emitter.getEnergy() - (Math.min(emitter.getEnergy(), emitter.getMaxOutput()) - CableUtils.emitEnergyToNetwork(Math.min(emitter.getEnergy(), emitter.getMaxOutput()), emitter, ForgeDirection.getOrientation(emitter.facing))));
return;
}
else if(tileEntity instanceof IStrictEnergyAcceptor)
{
IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor)tileEntity;
double toSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput());
emitter.setEnergy(emitter.getEnergy() - (toSend - acceptor.transferEnergyToAcceptor(toSend)));
}
else if(tileEntity instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
{
PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(ForgeDirection.getOrientation(emitter.facing).getOpposite());
if(receiver != null)
{
double electricityNeeded = Math.min(receiver.powerRequest(), receiver.getMaxEnergyStored() - receiver.getEnergyStored())*Mekanism.FROM_BC;
double transferEnergy = Math.min(emitter.getEnergy(), Math.min(electricityNeeded, emitter.getMaxOutput()));
receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), ForgeDirection.getOrientation(emitter.facing).getOpposite());
emitter.setEnergy(emitter.getEnergy() - transferEnergy);
}
}
}
if(tileEntity instanceof IConductor)
{
ForgeDirection outputDirection = ForgeDirection.getOrientation(emitter.facing);
float provide = emitter.getProvide(outputDirection);
if(provide > 0)
{
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(tileEntity, outputDirection);
if(outputNetwork != null)
{
ElectricityPack request = outputNetwork.getRequest(emitter);
if(request.getWatts() > 0)
{
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(emitter.getEnergyStored(), emitter.getVoltage()), ElectricityPack.getFromWatts(provide, emitter.getVoltage()));
float rejectedPower = outputNetwork.produce(sendPack, emitter);
emitter.setEnergyStored(emitter.getEnergyStored() - (sendPack.getWatts() - rejectedPower));
}
}
}
}
}
}
}

View file

@ -8,9 +8,10 @@ import mekanism.generators.client.model.ModelBioGenerator;
import mekanism.generators.client.model.ModelElectrolyticSeparator;
import mekanism.generators.client.model.ModelHeatGenerator;
import mekanism.generators.client.model.ModelHydrogenGenerator;
import mekanism.generators.client.model.ModelSolarGenerator;
import mekanism.generators.client.model.ModelWindTurbine;
import mekanism.generators.common.block.BlockGenerator.GeneratorType;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.block.BlockGenerator.GeneratorType;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
@ -26,6 +27,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
{
public ModelAdvancedSolarGenerator advancedSolarGenerator = new ModelAdvancedSolarGenerator();
public ModelSolarGenerator solarGenerator = new ModelSolarGenerator();
public ModelBioGenerator bioGenerator = new ModelBioGenerator();
public ModelHeatGenerator heatGenerator = new ModelHeatGenerator();
public ModelHydrogenGenerator hydrogenGenerator = new ModelHydrogenGenerator();
@ -56,6 +58,14 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png"));
advancedSolarGenerator.render(0.0F, 0.022F);
}
else if(metadata == GeneratorType.SOLAR_GENERATOR.meta)
{
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F);
GL11.glTranslated(0.0F, -1.0F, 0.0F);
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png"));
solarGenerator.render(0.0625F);
}
else if(metadata == GeneratorType.HEAT_GENERATOR.meta)
{
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

View file

@ -11,6 +11,7 @@ import mekanism.generators.client.render.RenderBioGenerator;
import mekanism.generators.client.render.RenderElectrolyticSeparator;
import mekanism.generators.client.render.RenderHeatGenerator;
import mekanism.generators.client.render.RenderHydrogenGenerator;
import mekanism.generators.client.render.RenderSolarGenerator;
import mekanism.generators.client.render.RenderWindTurbine;
import mekanism.generators.common.GeneratorsCommonProxy;
import mekanism.generators.common.tileentity.TileEntityAdvancedSolarGenerator;
@ -38,6 +39,7 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy
public void registerSpecialTileEntities()
{
ClientRegistry.registerTileEntity(TileEntityAdvancedSolarGenerator.class, "AdvancedSolarGenerator", new RenderAdvancedSolarGenerator());
ClientRegistry.registerTileEntity(TileEntitySolarGenerator.class, "SolarGenerator", new RenderSolarGenerator());
ClientRegistry.registerTileEntity(TileEntityBioGenerator.class, "BioGenerator", new RenderBioGenerator());
ClientRegistry.registerTileEntity(TileEntityHeatGenerator.class, "HeatGenerator", new RenderHeatGenerator());
ClientRegistry.registerTileEntity(TileEntityHydrogenGenerator.class, "HydrogenGenerator", new RenderHydrogenGenerator());

View file

@ -0,0 +1,59 @@
package mekanism.generators.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelSolarGenerator extends ModelBase
{
ModelRenderer Base;
ModelRenderer Base2;
ModelRenderer Stand;
ModelRenderer PhotovoltaicCells;
public ModelSolarGenerator()
{
textureWidth = 64;
textureHeight = 32;
Base = new ModelRenderer(this, 0, 16);
Base.addBox(0F, 0F, 0F, 6, 1, 6);
Base.setRotationPoint(-3F, 23F, -3F);
Base.setTextureSize(64, 32);
Base.mirror = true;
setRotation(Base, 0F, 0F, 0F);
Base2 = new ModelRenderer(this, 0, 24);
Base2.addBox(0F, 0F, 0F, 3, 1, 3);
Base2.setRotationPoint(-1.5F, 22F, -1.5F);
Base2.setTextureSize(64, 32);
Base2.mirror = true;
setRotation(Base2, 0F, 0F, 0F);
Stand = new ModelRenderer(this, 25, 16);
Stand.addBox(0F, 0F, 0F, 1, 7, 1);
Stand.setRotationPoint(-0.5F, 15F, -0.5F);
Stand.setTextureSize(64, 32);
Stand.mirror = true;
setRotation(Stand, 0F, 0F, 0F);
PhotovoltaicCells = new ModelRenderer(this, 0, 0);
PhotovoltaicCells.addBox(-7F, -1F, -7F, 14, 1, 14);
PhotovoltaicCells.setRotationPoint(0F, 15F, 0F);
PhotovoltaicCells.setTextureSize(64, 32);
PhotovoltaicCells.mirror = true;
setRotation(PhotovoltaicCells, 0F, 0F, 0F);
}
public void render(float size)
{
Base.render(size);
Base2.render(size);
Stand.render(size);
PhotovoltaicCells.render(size);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -0,0 +1,33 @@
package mekanism.generators.client.render;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.generators.client.model.ModelSolarGenerator;
import mekanism.generators.common.tileentity.TileEntitySolarGenerator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
public class RenderSolarGenerator extends TileEntitySpecialRenderer
{
private ModelSolarGenerator model = new ModelSolarGenerator();
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{
renderAModelAt((TileEntitySolarGenerator)tileEntity, x, y, z, partialTick);
}
private void renderAModelAt(TileEntitySolarGenerator tileEntity, double x, double y, double z, float partialTick)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png"));
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
model.render(0.0625F);
GL11.glPopMatrix();
}
}

View file

@ -33,6 +33,7 @@ public class GeneratorsCommonProxy
public void registerSpecialTileEntities()
{
GameRegistry.registerTileEntity(TileEntityAdvancedSolarGenerator.class, "AdvancedSolarGenerator");
GameRegistry.registerTileEntity(TileEntitySolarGenerator.class, "SolarGenerator");
GameRegistry.registerTileEntity(TileEntityBioGenerator.class, "BioGenerator");
GameRegistry.registerTileEntity(TileEntityHeatGenerator.class, "HeatGenerator");
GameRegistry.registerTileEntity(TileEntityHydrogenGenerator.class, "HydrogenGenerator");

View file

@ -93,7 +93,6 @@ public class MekanismGenerators implements IModule
addBlocks();
addItems();
addRecipes();
addEntities();
//Packet registrations
PacketHandler.registerPacket(PacketElectrolyticSeparatorParticle.class);
@ -153,11 +152,6 @@ public class MekanismGenerators implements IModule
InfuseRegistry.registerInfuseObject(new ItemStack(BioFuel), new InfuseObject(InfuseRegistry.get("BIO"), 5));
}
public void addEntities()
{
GameRegistry.registerTileEntity(TileEntitySolarGenerator.class, "SolarGenerator");
}
public void addBlocks()
{
//Declarations

View file

@ -56,7 +56,6 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
public class BlockGenerator extends BlockContainer implements ISpecialBounds
{
public Icon[] solarSprites = new Icon[256];
public Random machineRand = new Random();
public BlockGenerator(int id)
@ -68,13 +67,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
}
@Override
public void registerIcons(IconRegister register)
{
solarSprites[0] = register.registerIcon("mekanism:SteelBlock");
solarSprites[1] = register.registerIcon("mekanism:SolarGeneratorTop");
solarSprites[2] = register.registerIcon("mekanism:SolarGeneratorSide");
solarSprites[3] = register.registerIcon("mekanism:SolarGeneratorFront");
}
public void registerIcons(IconRegister register) {}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack)
@ -158,60 +151,6 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
return 0;
}
@Override
public Icon getIcon(int side, int meta)
{
if(meta == 1)
{
if(side == 3)
{
return solarSprites[3];
}
else if(side == 1)
{
return solarSprites[1];
}
else if(side == 0)
{
return solarSprites[0];
}
else {
return solarSprites[2];
}
}
return null;
}
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
{
int metadata = world.getBlockMetadata(x, y, z);
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z);
if(metadata == 1)
{
if(side == tileEntity.facing)
{
return solarSprites[3];
}
else if(side == 1)
{
return solarSprites[1];
}
else if(side == 0)
{
return solarSprites[0];
}
else {
return solarSprites[2];
}
}
return null;
}
@Override
public int damageDropped(int i)
{
@ -475,7 +414,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
if(metadata == GeneratorType.SOLAR_GENERATOR.meta)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.4F, 1.0F);
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.65F, 1.0F);
}
else {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
@ -552,7 +491,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
public static enum GeneratorType
{
HEAT_GENERATOR(0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true),
SOLAR_GENERATOR(1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, false),
SOLAR_GENERATOR(1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, true),
ELECTROLYTIC_SEPARATOR(2, "ElectrolyticSeparator", 2, 20000, TileEntityElectrolyticSeparator.class, true),
HYDROGEN_GENERATOR(3, "HydrogenGenerator", 3, 40000, TileEntityHydrogenGenerator.class, true),
BIO_GENERATOR(4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true),
@ -604,7 +543,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
{
if(metadata == GeneratorType.SOLAR_GENERATOR.meta)
{
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.4F, 1.0F);
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.65F, 1.0F);
}
else {
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

View file

@ -1,5 +1,6 @@
package mekanism.generators.common.tileentity;
import net.minecraftforge.common.ForgeDirection;
import mekanism.api.Object3D;
import mekanism.common.IBoundingBlock;
import mekanism.common.util.MekanismUtils;
@ -11,6 +12,12 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i
{
super("Advanced Solar Generator", 200000, 360, MekanismGenerators.advancedSolarGeneration);
}
@Override
public ForgeDirection getOutputtingSide()
{
return ForgeDirection.getOrientation(facing);
}
@Override
public void onPlace()

View file

@ -106,57 +106,19 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
}
}
TileEntity tileEntity = Object3D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj);
if(getEnergy() > 0)
if(MekanismUtils.canFunction(this))
{
if(!worldObj.isRemote)
{
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))
{
setEnergy(getEnergy() - (Math.min(getEnergy(), output) - CableUtils.emitEnergyToNetwork(Math.min(getEnergy(), output), this, ForgeDirection.getOrientation(facing))));
return;
}
else if(tileEntity instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
{
PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(ForgeDirection.getOrientation(facing).getOpposite());
if(receiver != null)
{
double electricityNeeded = Math.min(receiver.powerRequest(), receiver.getMaxEnergyStored() - receiver.getEnergyStored())*Mekanism.FROM_BC;
double transferEnergy = Math.min(getEnergy(), Math.min(electricityNeeded, output));
receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), ForgeDirection.getOrientation(facing).getOpposite());
setEnergy(getEnergy() - transferEnergy);
}
}
}
}
if(tileEntity instanceof IConductor)
{
ForgeDirection outputDirection = ForgeDirection.getOrientation(facing);
float provide = getProvide(outputDirection);
if(provide > 0)
{
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(tileEntity, outputDirection);
if(outputNetwork != null)
{
ElectricityPack request = outputNetwork.getRequest(this);
if(request.getWatts() > 0)
{
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(getEnergyStored(), getVoltage()), ElectricityPack.getFromWatts(provide, getVoltage()));
float rejectedPower = outputNetwork.produce(sendPack, this);
setEnergyStored(getEnergyStored() - (sendPack.getWatts() - rejectedPower));
}
}
}
CableUtils.emit(this);
}
}
}
@Override
public double getMaxOutput()
{
return output;
}
@Override
protected EnumSet<ForgeDirection> getConsumingSides()
{
@ -164,9 +126,9 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
}
@Override
protected EnumSet<ForgeDirection> getOutputtingSides()
public ForgeDirection getOutputtingSide()
{
return EnumSet.of(ForgeDirection.getOrientation(facing));
return ForgeDirection.getOrientation(facing);
}
@Override
@ -175,30 +137,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
return 0;
}
@Override
public float getProvide(ForgeDirection direction)
{
return getOutputtingSides().contains(direction) ? Math.min(getEnergyStored(), (float)(output*Mekanism.TO_UE)) : 0;
}
@Override
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
{
if(getOutputtingSides().contains(from))
{
double toSend = Math.min(getEnergy(), Math.min(output, request.getWatts()*Mekanism.FROM_UE));
if(doProvide)
{
setEnergy(getEnergy() - toSend);
}
return ElectricityPack.getFromWatts((float)(toSend*Mekanism.TO_UE), getVoltage());
}
return new ElectricityPack();
}
@Override
public void invalidate()
{
@ -269,7 +207,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
@Override
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction)
{
return direction == ForgeDirection.getOrientation(facing);
return getOutputtingSide() == direction;
}
@Override
@ -293,7 +231,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
@Override
public boolean isTeleporterCompatible(ForgeDirection side)
{
return side == ForgeDirection.getOrientation(facing);
return getOutputtingSide() == side;
}
@Override
@ -374,7 +312,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
@Override
public boolean canOutputTo(ForgeDirection side)
{
return side == ForgeDirection.getOrientation(facing);
return getOutputtingSide() == side;
}
@Override

View file

@ -1,6 +1,7 @@
package mekanism.generators.common.tileentity;
import java.util.ArrayList;
import java.util.EnumSet;
import mekanism.api.Object3D;
import mekanism.common.util.ChargeUtils;
@ -10,6 +11,8 @@ import mekanism.generators.common.block.BlockGenerator.GeneratorType;
import micdoodle8.mods.galacticraft.api.world.ISolarLevel;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import com.google.common.io.ByteArrayDataInput;
@ -174,6 +177,12 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
return data;
}
@Override
public ForgeDirection getOutputtingSide()
{
return ForgeDirection.getOrientation(0);
}
@Override
public boolean renderUpdate()
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB