Added water turbine
This commit is contained in:
parent
58c0017d13
commit
9dc8824e4d
7 changed files with 323 additions and 8 deletions
|
@ -55,10 +55,6 @@ public class BlockFluidMixture extends BlockFluidFinite
|
|||
public int colorMultiplier(IBlockAccess access, int x, int y, int z)
|
||||
{
|
||||
return ResourceGenerator.getColor(getFluid().getName().replace("mixture", ""));
|
||||
/*
|
||||
* TileFluidMixture tileFluid = (TileFluidMixture) access.getBlockTileEntity(x, y, z);
|
||||
* return tileFluid.getColor();
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean mix(World world, int x, int y, int z, ItemStack stack)
|
||||
|
|
|
@ -7,7 +7,7 @@ public class TileSolarPanel extends TileElectrical
|
|||
{
|
||||
public TileSolarPanel()
|
||||
{
|
||||
this.energy = new EnergyStorageHandler(400);
|
||||
this.energy = new EnergyStorageHandler(500);
|
||||
this.ioMap = 728;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ import resonantinduction.mechanical.process.BlockFilter;
|
|||
import resonantinduction.mechanical.process.BlockGrinderWheel;
|
||||
import resonantinduction.mechanical.process.TileGrinderWheel;
|
||||
import resonantinduction.mechanical.process.TileMixer;
|
||||
import resonantinduction.mechanical.turbine.BlockWaterTurbine;
|
||||
import resonantinduction.mechanical.turbine.BlockWindTurbine;
|
||||
import resonantinduction.mechanical.turbine.TileWaterTurbine;
|
||||
import resonantinduction.mechanical.turbine.TileWindTurbine;
|
||||
import calclavia.lib.content.ContentRegistry;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
|
@ -76,7 +78,8 @@ public class Mechanical
|
|||
// Energy
|
||||
public static Item itemGear;
|
||||
public static Item itemGearShaft;
|
||||
public static Block mechanicalTurbine;
|
||||
public static Block windTurbine;
|
||||
public static Block waterTurbine;
|
||||
|
||||
// Transport
|
||||
public static Block blockConveyorBelt;
|
||||
|
@ -106,7 +109,8 @@ public class Mechanical
|
|||
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
||||
itemGear = contentRegistry.createItem(ItemGear.class);
|
||||
itemGearShaft = contentRegistry.createItem(ItemGearShaft.class);
|
||||
mechanicalTurbine = contentRegistry.createTile(BlockWindTurbine.class, TileWindTurbine.class);
|
||||
windTurbine = contentRegistry.createTile(BlockWindTurbine.class, TileWindTurbine.class);
|
||||
waterTurbine = contentRegistry.createTile(BlockWaterTurbine.class, TileWaterTurbine.class);
|
||||
|
||||
blockConveyorBelt = contentRegistry.createTile(BlockConveyorBelt.class, TileConveyorBelt.class);
|
||||
blockManipulator = contentRegistry.createTile(BlockManipulator.class, TileManipulator.class);
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package resonantinduction.mechanical.turbine;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import resonantinduction.core.Reference;
|
||||
import resonantinduction.core.Settings;
|
||||
import resonantinduction.core.TabRI;
|
||||
import resonantinduction.core.render.RIBlockRenderingHandler;
|
||||
import calclavia.lib.prefab.turbine.BlockTurbine;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockWaterTurbine extends BlockTurbine
|
||||
{
|
||||
public BlockWaterTurbine()
|
||||
{
|
||||
this(Settings.getNextBlockID(), "waterTurbine", Material.iron);
|
||||
setTextureName(Reference.PREFIX + "material_wood_surface");
|
||||
rotationMask = Byte.parseByte("111111", 2);
|
||||
}
|
||||
|
||||
public BlockWaterTurbine(int id, String name, Material material)
|
||||
{
|
||||
super(Settings.CONFIGURATION.getBlock(name, id).getInt(id), material);
|
||||
this.setUnlocalizedName(Reference.PREFIX + name);
|
||||
this.setCreativeTab(TabRI.CORE);
|
||||
this.setTextureName(Reference.PREFIX + name);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return RIBlockRenderingHandler.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
return new TileWaterTurbine();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package resonantinduction.mechanical.turbine;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonantinduction.core.Reference;
|
||||
import calclavia.lib.prefab.turbine.TileTurbine;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderWaterTurbine extends TileEntitySpecialRenderer
|
||||
{
|
||||
// TODO: Fix model.
|
||||
public final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "gears.obj");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
||||
{
|
||||
TileTurbine tile = (TileTurbine) t;
|
||||
|
||||
if (tile.getMultiBlock().isPrimary())
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5f, (float) y + 0.5f, (float) z + 0.5f);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (tile.worldObj != null)
|
||||
{
|
||||
RenderUtility.rotateBlockBasedOnDirectionUp(tile.getDirection());
|
||||
}
|
||||
|
||||
GL11.glRotatef((float) Math.toDegrees(tile.rotation), 0, 1, 0);
|
||||
|
||||
/**
|
||||
* TODO: Bind based on tier.
|
||||
*/
|
||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "cobblestone.png");
|
||||
|
||||
if (tile.getMultiBlock().isConstructed())
|
||||
{
|
||||
MODEL.renderOnly("LargeGear");
|
||||
}
|
||||
else
|
||||
{
|
||||
MODEL.renderOnly("SmallGear");
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
package resonantinduction.mechanical.turbine;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.BiomeGenOcean;
|
||||
import net.minecraft.world.biome.BiomeGenPlains;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.core.ResonantInduction;
|
||||
import resonantinduction.mechanical.gear.PartGearShaft;
|
||||
import resonantinduction.mechanical.network.IMechanical;
|
||||
import resonantinduction.mechanical.network.IMechanicalNetwork;
|
||||
import resonantinduction.mechanical.network.MechanicalNetwork;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.turbine.TileTurbine;
|
||||
|
||||
/**
|
||||
* The vertical wind turbine collects airflow.
|
||||
* The horizontal wind turbine collects steam from steam power plants.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileWaterTurbine extends TileTurbine implements IMechanical
|
||||
{
|
||||
public TileWaterTurbine()
|
||||
{
|
||||
maxPower = 800;
|
||||
torque = 500;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
getNetwork().split(this);
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
|
||||
/**
|
||||
* If this is a horizontal turbine.
|
||||
*/
|
||||
if (getDirection().offsetY != 0)
|
||||
{
|
||||
int blockIDAbove = worldObj.getBlockId(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
if (blockIDAbove == Block.waterStill.blockID || worldObj.isAirBlock(xCoord, yCoord - 1, zCoord))
|
||||
{
|
||||
getMultiBlock().get().power += getWaterPower();
|
||||
worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord);
|
||||
worldObj.setBlock(xCoord, yCoord - 1, zCoord, Block.waterStill.blockID);
|
||||
}
|
||||
}
|
||||
else if (this.getMultiBlock().isPrimary())
|
||||
{
|
||||
if (worldObj.getBlockId(xCoord, yCoord - (this.getMultiBlock().isConstructed() ? 2 : 1), zCoord) == Block.waterMoving.blockID)
|
||||
{
|
||||
getMultiBlock().get().power += getWaterPower();
|
||||
}
|
||||
}
|
||||
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gravitation Potential Energy:
|
||||
* PE = mgh
|
||||
*/
|
||||
private long getWaterPower()
|
||||
{
|
||||
return 1 * 10 * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProduce()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound()
|
||||
{
|
||||
if (this.ticks % 18 == 0)
|
||||
{
|
||||
// this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord,
|
||||
// "atomicscience:turbine", 0.6f, (float) (0.7f + (0.2 * ((double) this.power / (double)
|
||||
// this.getMaxPower()))));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return ResonantInduction.PACKET_TILE.getPacket(this, (byte) 1, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPowerUpdate()
|
||||
{
|
||||
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, (byte) 2, angularVelocity), this.worldObj, new Vector3(this), 25);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mechanical Methods
|
||||
*
|
||||
* @return The connections.
|
||||
*/
|
||||
@Override
|
||||
public Object[] getConnections()
|
||||
{
|
||||
Object[] connections = new Object[6];
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = new Vector3(this).translate(dir).getTileEntity(worldObj);
|
||||
|
||||
if (tile instanceof IMechanical)
|
||||
{
|
||||
IMechanical mech = ((IMechanical) tile).getInstance(dir.getOpposite());
|
||||
|
||||
// Don't connect with shafts
|
||||
if (mech != null && !(mech instanceof PartGearShaft) && canConnect(dir, this) && mech.canConnect(dir.getOpposite(), this))
|
||||
{
|
||||
connections[dir.ordinal()] = mech;
|
||||
getNetwork().merge(mech.getNetwork());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return connections;
|
||||
}
|
||||
|
||||
private IMechanicalNetwork network;
|
||||
|
||||
@Override
|
||||
public IMechanicalNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null)
|
||||
{
|
||||
this.network = new MechanicalNetwork();
|
||||
this.network.addConnector(this);
|
||||
}
|
||||
return this.network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(IMechanicalNetwork network)
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAngularVelocity()
|
||||
{
|
||||
return angularVelocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAngularVelocity(float velocity)
|
||||
{
|
||||
this.angularVelocity = velocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTorque()
|
||||
{
|
||||
return torque;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTorque(long torque)
|
||||
{
|
||||
this.torque = torque;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRatio(ForgeDirection dir)
|
||||
{
|
||||
return getMultiBlock().isConstructed() ? 1.5f : 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inverseRotation(ForgeDirection dir, IMechanical with)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMechanical getInstance(ForgeDirection dir)
|
||||
{
|
||||
return (IMechanical) getMultiBlock().get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection from, Object sourcen)
|
||||
{
|
||||
return from == getDirection().getOpposite();
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
|
|||
{
|
||||
public TileWindTurbine()
|
||||
{
|
||||
maxPower = 300;
|
||||
maxPower = 500;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue