Added custom sized wind turbines

This commit is contained in:
Calclavia 2014-02-16 16:08:23 +08:00
parent 6beb785e42
commit 7e1778098c
4 changed files with 64 additions and 10 deletions

View file

@ -37,13 +37,13 @@ public class ItemGear extends JItemMultiPart
side = FacePlacementGrid$.MODULE$.getHitSlot(hit, side);
TileEntity tile = world.getBlockTileEntity(pos.x, pos.y, pos.z);
if (tile instanceof TileMultipart)
{
TMultiPart occupyingPart = ((TileMultipart) tile).partMap(side);
TMultiPart centerPart = ((TileMultipart) tile).partMap(PartMap.CENTER.ordinal());
boolean clickedCenter = hit.mag() < 1;
boolean clickedCenter = hit.mag() < 0.4;
if ((clickedCenter && centerPart instanceof PartGearShaft))
{
side ^= 1;

View file

@ -1,11 +1,13 @@
package resonantinduction.mechanical.turbine;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.core.Reference;
import resonantinduction.core.render.RIBlockRenderingHandler;
import calclavia.lib.prefab.turbine.BlockTurbine;
import calclavia.lib.prefab.turbine.TileTurbine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -18,6 +20,45 @@ public class BlockWindTurbine extends BlockTurbine
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)
@Override
public int getRenderType()

View file

@ -43,6 +43,8 @@ public class RenderWindTurbine extends TileEntitySpecialRenderer
*/
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");
MODEL.renderOnly("LargeBladeArm");
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "wool_colored_white.png");

View file

@ -36,7 +36,7 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
*/
if (getDirection().offsetY == 0)
{
maxPower = 200;
maxPower = 120;
getMultiBlock().get().power += getWindPower();
}
else
@ -44,10 +44,10 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
maxPower = 1000;
}
if (!getMultiBlock().isConstructed())
torque = defaultTorque / 9;
if (getMultiBlock().isConstructed())
torque = (long) (defaultTorque / (9f / multiBlockRadius));
else
torque = defaultTorque / 3;
torque = defaultTorque / 12;
super.updateEntity();
}
@ -66,7 +66,7 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
if (!worldObj.canBlockSeeTheSky(xCoord, yCoord + 4, zCoord))
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
@ -166,8 +166,19 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
}
@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;
}
}