Added hover highlight for multimeter and shaft placement

This commit is contained in:
Calclavia 2014-02-18 21:11:59 +08:00
parent 7ba1c1c52e
commit 915a2663ee
6 changed files with 18 additions and 5 deletions

View file

@ -8,16 +8,18 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.prefab.part.IHighlight;
import resonantinduction.electrical.wire.EnumWireMaterial;
import calclavia.lib.utility.LanguageUtility;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.FacePlacementGrid$;
import codechicken.multipart.ControlKeyModifer;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.TMultiPart;
public class ItemMultimeter extends JItemMultiPart
public class ItemMultimeter extends JItemMultiPart implements IHighlight
{
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
@ -29,6 +31,8 @@ public class ItemMultimeter extends JItemMultiPart
@Override
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
{
side = FacePlacementGrid$.MODULE$.getHitSlot(hit, side);
if (side <= 1)
{
return null;

View file

@ -91,7 +91,7 @@ public class PartMultimeter extends JCuboidPart implements IConnector<Multimeter
public void preparePlacement(int side, int itemDamage)
{
this.side = (byte) (side ^ 1);
this.side = (byte) (side);
}
public boolean hasMultimeter(int x, int y, int z)

View file

@ -6,6 +6,7 @@ import net.minecraftforge.event.ForgeSubscribe;
import org.lwjgl.opengl.GL11;
import resonantinduction.core.prefab.part.IHighlight;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.FacePlacementGrid$;
@ -18,7 +19,7 @@ public class MicroblockHighlightHandler
@SideOnly(Side.CLIENT)
public void drawBlockHighlight(DrawBlockHighlightEvent event)
{
if (event.currentItem != null && event.currentItem.getItem() == Mechanical.itemGear && event.target != null && event.target.typeOfHit == EnumMovingObjectType.TILE)
if (event.currentItem != null && (event.currentItem.getItem() instanceof IHighlight) && event.target != null && event.target.typeOfHit == EnumMovingObjectType.TILE)
{
GL11.glPushMatrix();
RenderUtils.translateToWorldCoords(event.player, event.partialTicks);

View file

@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.core.prefab.part.IHighlight;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.FacePlacementGrid$;
@ -16,7 +17,7 @@ import codechicken.multipart.PartMap;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
public class ItemGear extends JItemMultiPart
public class ItemGear extends JItemMultiPart implements IHighlight
{
public ItemGear(int id)
{

View file

@ -3,13 +3,14 @@ package resonantinduction.mechanical.gear;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import resonantinduction.core.prefab.part.IHighlight;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.TMultiPart;
public class ItemGearShaft extends JItemMultiPart
public class ItemGearShaft extends JItemMultiPart implements IHighlight
{
public ItemGearShaft(int id)
{

View file

@ -0,0 +1,6 @@
package resonantinduction.core.prefab.part;
public interface IHighlight
{
}