Fixed #423 - Multimeter unintuitive placement on pipes

This commit is contained in:
Calclavia 2014-03-12 17:55:08 +08:00
parent f0191022d7
commit ab9de9b555

View file

@ -7,11 +7,13 @@ import org.lwjgl.input.Keyboard;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import resonantinduction.core.prefab.part.IHighlight;
import resonantinduction.electrical.wire.EnumWireMaterial;
import resonantinduction.mechanical.energy.gear.PartGearShaft;
import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import calclavia.lib.render.EnumColor;
@ -21,7 +23,9 @@ import codechicken.lib.vec.Vector3;
import codechicken.microblock.FacePlacementGrid$;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.PartMap;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
public class ItemMultimeter extends JItemMultiPart implements IHighlight
{
@ -37,6 +41,18 @@ public class ItemMultimeter extends JItemMultiPart implements IHighlight
{
side = FacePlacementGrid$.MODULE$.getHitSlot(hit, side);
TileEntity tile = world.getBlockTileEntity(pos.x, pos.y, pos.z);
if (tile instanceof TileMultipart)
{
TMultiPart centerPart = ((TileMultipart) tile).partMap(PartMap.CENTER.ordinal());
if (centerPart != null && !player.isSneaking())
{
pos.offset(side ^ 1);
}
}
PartMultimeter part = (PartMultimeter) MultiPartRegistry.createPart("resonant_induction_multimeter", false);
if (part != null)