Added tiers for gears: stone and iron gear

This commit is contained in:
Calclavia 2014-01-30 00:15:54 +08:00
parent daff7a091f
commit 158091519f
7 changed files with 77 additions and 17 deletions

View file

@ -51,11 +51,11 @@ public class RenderRIItem implements IItemRenderer
}
else if (item.getItem() instanceof ItemGear)
{
RenderGear.INSTANCE.renderInventory(null, 0, 0, null);
RenderGear.INSTANCE.renderInventory(null, item.getItemDamage(), 0, null);
}
else if (item.getItem() instanceof ItemGearShaft)
{
RenderGearShaft.INSTANCE.renderInventory(null, 0, 0, null);
RenderGearShaft.INSTANCE.renderInventory(null, item.getItemDamage(), 0, null);
}
else if (item.getItem() instanceof ItemMultimeter)
{

View file

@ -137,7 +137,9 @@ public class Mechanical
public void postInit(FMLPostInitializationEvent evt)
{
// Add recipes
GameRegistry.addRecipe(new ShapedOreRecipe(itemGear, "SWS", "W W", "SWS", 'W', "plankWood", 'S', Item.stick));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 0), "SWS", "W W", "SWS", 'W', "plankWood", 'S', Item.stick));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 1), " W ", "WGW", " W ", 'G', new ItemStack(itemGear, 1, 0), 'W', Block.cobblestone));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemGear, 1, 2), " W ", "WGW", " W ", 'G', new ItemStack(itemGear, 1, 1), 'W', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(itemGearShaft, "S", "S", "S", 'S', Item.stick));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), "III", "GGG", 'I', Item.ingotIron, 'G', itemGear));
GameRegistry.addRecipe(new ShapedOreRecipe(blockManipulator, "SSS", "SRS", "SCS", 'S', Item.ingotIron, 'C', blockConveyorBelt, 'R', Block.blockRedstone));

View file

@ -7,9 +7,9 @@ import calclavia.lib.multiblock.reference.MultiBlockHandler;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
public class MultiPartMultiBlockHandler extends MultiBlockHandler<PartGear>
public class GearMultiBlockHandler extends MultiBlockHandler<PartGear>
{
public MultiPartMultiBlockHandler(PartGear wrapper)
public GearMultiBlockHandler(PartGear wrapper)
{
super(wrapper);
}
@ -24,7 +24,10 @@ public class MultiPartMultiBlockHandler extends MultiBlockHandler<PartGear>
if (part instanceof PartGear)
{
return (PartGear) part;
if (((PartGear) part).tier == self.tier)
{
return (PartGear) part;
}
}
}

View file

@ -1,10 +1,14 @@
package resonantinduction.mechanical.gear;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import resonantinduction.core.Settings;
import resonantinduction.core.prefab.part.ItemMultipartBase;
import resonantinduction.electrical.wire.EnumWireMaterial;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.MultiPartRegistry;
@ -29,4 +33,13 @@ public class ItemGear extends ItemMultipartBase
return part;
}
@Override
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
{
for (int i = 0; i < 3; i++)
{
listToAddTo.add(new ItemStack(itemID, 1, i));
}
}
}

View file

@ -77,9 +77,22 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
if (getMultiBlock().isPrimary())
{
// Decelerate the gear.
torque *= 0.95f;
angularVelocity *= 0.95f;
// Decelerate the gear based on tier.
switch (tier)
{
default:
torque *= 0.9f;
angularVelocity *= 0.95f;
break;
case 1:
torque *= 0.95f;
angularVelocity *= 0.9f;
break;
case 2:
torque *= 0.99f;
angularVelocity *= 0.99f;
break;
}
}
else
{
@ -270,7 +283,7 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
{
if (pass == 0)
{
RenderGear.INSTANCE.renderDynamic(this, pos.x, pos.y, pos.z, frame);
RenderGear.INSTANCE.renderDynamic(this, pos.x, pos.y, pos.z, tier);
}
}
@ -297,7 +310,7 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
/**
* Multiblock
*/
private MultiPartMultiBlockHandler multiBlock;
private GearMultiBlockHandler multiBlock;
@Override
public universalelectricity.api.vector.Vector3[] getMultiBlockVectors()
@ -354,7 +367,7 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
public MultiBlockHandler<PartGear> getMultiBlock()
{
if (multiBlock == null)
multiBlock = new MultiPartMultiBlockHandler(this);
multiBlock = new GearMultiBlockHandler(this);
return multiBlock;
}

View file

@ -23,11 +23,22 @@ public class RenderGear
public void renderInventory(Block block, int metadata, int modelID, RenderBlocks renderer)
{
GL11.glRotatef(90, 1, 0, 0);
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
switch (metadata)
{
default:
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
break;
case 1:
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "cobblestone.png");
break;
case 2:
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "iron_block.png");
break;
}
MODEL.renderOnly("SmallGear");
}
public void renderDynamic(PartGear part, double x, double y, double z, float frame)
public void renderDynamic(PartGear part, double x, double y, double z, int tier)
{
if (part.getMultiBlock().isPrimary())
{
@ -40,7 +51,18 @@ public class RenderGear
GL11.glRotatef((float) Math.toDegrees(part.angle), 0, 1, 0);
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
switch (tier)
{
default:
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "planks_oak.png");
break;
case 1:
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "cobblestone.png");
break;
case 2:
RenderUtility.bind(Reference.BLOCK_TEXTURE_DIRECTORY + "iron_block.png");
break;
}
if (part.getMultiBlock().isConstructed())
{

View file

@ -51,9 +51,12 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
/** The current angle the gear is on. In radians. */
public float angle = 0;
public int tier;
public void preparePlacement(int side, int itemDamage)
{
this.placementSide = ForgeDirection.getOrientation((byte) (side ^ 1));
this.tier = itemDamage;
}
@Override
@ -62,8 +65,10 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
if (!world().isRemote)
{
System.out.println(this + ":" + getNetwork());
/*for (Object obj : connections)
System.out.println(obj);*/
/*
* for (Object obj : connections)
* System.out.println(obj);
*/
}
return false;
@ -195,6 +200,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
{
placementSide = ForgeDirection.getOrientation(nbt.getByte("side"));
angularVelocity = nbt.getFloat("angularVelocity");
tier = nbt.getByte("tier");
}
@Override
@ -202,6 +208,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
{
nbt.setByte("side", (byte) placementSide.ordinal());
nbt.setFloat("angularVelocity", angularVelocity);
nbt.setByte("tier", (byte) tier);
}
protected abstract ItemStack getItem();