Added custom sized wind turbines
This commit is contained in:
parent
6beb785e42
commit
7e1778098c
4 changed files with 64 additions and 10 deletions
|
@ -42,7 +42,7 @@ public class ItemGear extends JItemMultiPart
|
||||||
{
|
{
|
||||||
TMultiPart occupyingPart = ((TileMultipart) tile).partMap(side);
|
TMultiPart occupyingPart = ((TileMultipart) tile).partMap(side);
|
||||||
TMultiPart centerPart = ((TileMultipart) tile).partMap(PartMap.CENTER.ordinal());
|
TMultiPart centerPart = ((TileMultipart) tile).partMap(PartMap.CENTER.ordinal());
|
||||||
boolean clickedCenter = hit.mag() < 1;
|
boolean clickedCenter = hit.mag() < 0.4;
|
||||||
|
|
||||||
if ((clickedCenter && centerPart instanceof PartGearShaft))
|
if ((clickedCenter && centerPart instanceof PartGearShaft))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package resonantinduction.mechanical.turbine;
|
package resonantinduction.mechanical.turbine;
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.render.RIBlockRenderingHandler;
|
import resonantinduction.core.render.RIBlockRenderingHandler;
|
||||||
import calclavia.lib.prefab.turbine.BlockTurbine;
|
import calclavia.lib.prefab.turbine.BlockTurbine;
|
||||||
|
import calclavia.lib.prefab.turbine.TileTurbine;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -18,6 +20,45 @@ public class BlockWindTurbine extends BlockTurbine
|
||||||
rotationMask = Byte.parseByte("111111", 2);
|
rotationMask = Byte.parseByte("111111", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (entityPlayer.getCurrentEquippedItem() == null)
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (tileEntity instanceof TileTurbine)
|
||||||
|
{
|
||||||
|
if (!world.isRemote && !((TileTurbine) tileEntity).getMultiBlock().isConstructed())
|
||||||
|
{
|
||||||
|
((TileTurbine) tileEntity).multiBlockRadius = Math.max(((TileTurbine) tileEntity).multiBlockRadius + 1, 1);
|
||||||
|
entityPlayer.addChatMessage("Turbine radius: " + ((TileTurbine) tileEntity).multiBlockRadius);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (tileEntity instanceof TileTurbine)
|
||||||
|
{
|
||||||
|
if (!world.isRemote && !((TileTurbine) tileEntity).getMultiBlock().isConstructed())
|
||||||
|
{
|
||||||
|
((TileTurbine) tileEntity).multiBlockRadius = Math.max(((TileTurbine) tileEntity).multiBlockRadius - 1, 1);
|
||||||
|
entityPlayer.addChatMessage("Turbine radius: " + ((TileTurbine) tileEntity).multiBlockRadius);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public int getRenderType()
|
public int getRenderType()
|
||||||
|
|
|
@ -43,6 +43,8 @@ public class RenderWindTurbine extends TileEntitySpecialRenderer
|
||||||
*/
|
*/
|
||||||
if (tile.getMultiBlock().isConstructed())
|
if (tile.getMultiBlock().isConstructed())
|
||||||
{
|
{
|
||||||
|
GL11.glScalef(0.3f, 1, 0.3f);
|
||||||
|
GL11.glScalef(tile.multiBlockRadius * 2 + 1, 1, tile.multiBlockRadius * 2 + 1);
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
|
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
|
||||||
MODEL.renderOnly("LargeBladeArm");
|
MODEL.renderOnly("LargeBladeArm");
|
||||||
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "wool_colored_white.png");
|
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "wool_colored_white.png");
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
|
||||||
*/
|
*/
|
||||||
if (getDirection().offsetY == 0)
|
if (getDirection().offsetY == 0)
|
||||||
{
|
{
|
||||||
maxPower = 200;
|
maxPower = 120;
|
||||||
getMultiBlock().get().power += getWindPower();
|
getMultiBlock().get().power += getWindPower();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -44,10 +44,10 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
|
||||||
maxPower = 1000;
|
maxPower = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getMultiBlock().isConstructed())
|
if (getMultiBlock().isConstructed())
|
||||||
torque = defaultTorque / 9;
|
torque = (long) (defaultTorque / (9f / multiBlockRadius));
|
||||||
else
|
else
|
||||||
torque = defaultTorque / 3;
|
torque = defaultTorque / 12;
|
||||||
|
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
|
||||||
if (!worldObj.canBlockSeeTheSky(xCoord, yCoord + 4, zCoord))
|
if (!worldObj.canBlockSeeTheSky(xCoord, yCoord + 4, zCoord))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (long) (((((float) yCoord + 4) / 256) * maxPower) * (hasBonus ? 3 : 1)) * (worldObj.isRaining() ? 2 : 1);
|
return (long) (((((float) yCoord + 4) / 256) * maxPower) * (hasBonus ? 2 : 1)) * (worldObj.isRaining() ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -166,8 +166,19 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection from, Object sourcen)
|
public boolean canConnect(ForgeDirection from, Object source)
|
||||||
{
|
{
|
||||||
return from == getDirection().getOpposite();
|
/**
|
||||||
|
* Face to face stick connection.
|
||||||
|
*/
|
||||||
|
TileEntity sourceTile = getPosition().translate(from).getTileEntity(getWorld());
|
||||||
|
|
||||||
|
if (sourceTile instanceof IMechanical)
|
||||||
|
{
|
||||||
|
IMechanical sourceInstance = ((IMechanical) sourceTile).getInstance(from.getOpposite());
|
||||||
|
return sourceInstance == source && from == getDirection().getOpposite();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue