Made gear and shaft placement and bounds more intuitive
This commit is contained in:
parent
158091519f
commit
ad89f41a58
6 changed files with 66 additions and 19 deletions
|
@ -31,14 +31,6 @@ public class ItemMultimeter extends ItemMultipartBase
|
|||
@Override
|
||||
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
|
||||
{
|
||||
/**
|
||||
* If we're clicking on the multipart
|
||||
*/
|
||||
/*if (world.getBlockTileEntity(pos.x, pos.y, pos.z) instanceof TileMultipart && !ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
pos.offset(side ^ 1, -1);
|
||||
}*/
|
||||
|
||||
PartMultimeter part = (PartMultimeter) MultiPartRegistry.createPart("resonant_induction_multimeter", false);
|
||||
|
||||
if (part != null)
|
||||
|
|
|
@ -30,6 +30,7 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
public Vector3 size = new Vector3();
|
||||
|
||||
private long queueGraphValue = 0;
|
||||
private long queueGraphCapacity = 0;
|
||||
private boolean doUpdate = false;
|
||||
|
||||
@Override
|
||||
|
@ -57,6 +58,7 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
{
|
||||
graph.add(queueGraphValue);
|
||||
queueGraphValue = 0;
|
||||
queueGraphCapacity = 0;
|
||||
displayInformation.clear();
|
||||
doUpdate = false;
|
||||
}
|
||||
|
@ -73,9 +75,10 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
|||
return getConnectors().size() > 0;
|
||||
}
|
||||
|
||||
public void updateGraph(long detectedValue)
|
||||
public void updateGraph(long detectedValue, long detectedCapcity)
|
||||
{
|
||||
queueGraphValue += detectedValue;
|
||||
queueGraphCapacity += detectedCapcity;
|
||||
doUpdate = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
|
|||
break;
|
||||
}
|
||||
|
||||
getNetwork().updateGraph(detectedEnergy);
|
||||
getNetwork().updateGraph(detectedEnergy, 0);
|
||||
|
||||
if (outputRedstone != redstoneOn)
|
||||
{
|
||||
|
|
|
@ -93,13 +93,18 @@ public class RenderMultimeter
|
|||
GL11.glTranslated(centerTranslation.x, centerTranslation.y, centerTranslation.z);
|
||||
RenderUtility.rotateFaceBlockToSideOutwards(part.getDirection().getOpposite());
|
||||
GL11.glTranslated(0, 0.07, 0);
|
||||
String display = UnitDisplay.getDisplay(part.getNetwork().graph.get(0), Unit.JOULES);
|
||||
if (dir.offsetX == 0)
|
||||
RenderUtility.renderText(display, (float) (part.getNetwork().size.x * 0.9f), 0.5f);
|
||||
if (dir.offsetZ == 0)
|
||||
RenderUtility.renderText(display, (float) (part.getNetwork().size.z * 0.9f), 0.5f);
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
//TODO: Add other dispaly info support.
|
||||
String display = UnitDisplay.getDisplay(part.getNetwork().graph.get(0), Unit.JOULES);
|
||||
|
||||
if (dir.offsetX == 0)
|
||||
RenderUtility.renderText(display, (float) (part.getNetwork().size.x * 0.9f), 0.5f);
|
||||
if (dir.offsetZ == 0)
|
||||
RenderUtility.renderText(display, (float) (part.getNetwork().size.z * 0.9f), 0.5f);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -5,14 +5,17 @@ import java.util.List;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
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.ControlKeyModifer;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
|
||||
public class ItemGear extends ItemMultipartBase
|
||||
{
|
||||
|
@ -28,6 +31,19 @@ public class ItemGear extends ItemMultipartBase
|
|||
|
||||
if (part != null)
|
||||
{
|
||||
if (ControlKeyModifer.isControlDown(player))
|
||||
pos.offset(side ^ 1, -1);
|
||||
|
||||
TileEntity tile = world.getBlockTileEntity(pos.x, pos.y, pos.z);
|
||||
|
||||
if (tile instanceof TileMultipart)
|
||||
{
|
||||
if (!(((TileMultipart) tile).partMap(side) instanceof PartGear))
|
||||
{
|
||||
side = ForgeDirection.getOrientation(side).getOpposite().ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
part.preparePlacement(side, itemStack.getItemDamage());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package resonantinduction.mechanical.gear;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -24,7 +27,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
*/
|
||||
public class PartGearShaft extends PartMechanical
|
||||
{
|
||||
public static Cuboid6[] sides = new Cuboid6[7];
|
||||
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];
|
||||
|
||||
static
|
||||
{
|
||||
|
@ -146,7 +149,35 @@ public class PartGearShaft extends PartMechanical
|
|||
@Override
|
||||
public Iterable<Cuboid6> getOcclusionBoxes()
|
||||
{
|
||||
return Arrays.asList(sides);
|
||||
return getCollisionBoxes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getCollisionBoxes()
|
||||
{
|
||||
Set<Cuboid6> collisionBoxes = new HashSet<Cuboid6>();
|
||||
collisionBoxes.addAll((Collection<? extends Cuboid6>) getSubParts());
|
||||
|
||||
return collisionBoxes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IndexedCuboid6> getSubParts()
|
||||
{
|
||||
Set<IndexedCuboid6> subParts = new HashSet<IndexedCuboid6>();
|
||||
IndexedCuboid6[] currentSides = sides;
|
||||
|
||||
if (tile() != null)
|
||||
{
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (side == placementSide || side == placementSide.getOpposite())
|
||||
subParts.add(currentSides[side.ordinal()]);
|
||||
}
|
||||
}
|
||||
|
||||
subParts.add(currentSides[6]);
|
||||
return subParts;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue