Created
February 28, 2016 00:38
-
-
Save anonymous/81e2a90998f318f1c47d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Minecraft mc = Minecraft.getMinecraft(); | |
MovingObjectPosition objectMouseOver = mc.objectMouseOver; | |
System.out.println(objectMouseOver.entityHit); | |
// makes a variable for where you look | |
if (objectMouseOver != null && objectMouseOver.entityHit != null) { | |
// checks if you hit an Entity | |
Entity target = objectMouseOver.entityHit; | |
// make a variable: Target(just so I can use it easier) AND | |
// makes it "select the Entity" | |
if (target instanceof EntityFlat) /* | |
* or whatever you want recognised | |
*/{ | |
double bX = target.getPosition().getX(); | |
double bY = target.getPosition().getY();// blockpos.getY() + | |
// 1; | |
double bZ = target.getPosition().getZ(); | |
ECEntityRune rune; | |
try { | |
double xm = 0.125; | |
double zm = 0.125; | |
double hitX = objectMouseOver.hitVec.xCoord - bX; | |
double hitZ = objectMouseOver.hitVec.zCoord - bZ; | |
if (hitX < 0.3333) { | |
xm = 0.125 + 0.025; | |
} else if (hitX > 0.333 * 2) { | |
xm = 1 - (0.125 + 0.025); | |
} else { | |
xm = 0.333 + 0.25 / 2 + 0.05; | |
} | |
if (hitZ < 0.3333) { | |
zm = 0.125 + 0.025; | |
} else if (hitZ > 0.333 * 2) { | |
zm = 1 - (0.125 + 0.025); | |
} else { | |
zm = 0.333 + 0.25 / 2 + 0.05; | |
} | |
if (isEmptyOf(worldIn, bX + xm, bY, bZ + zm)) { | |
rune = (ECEntityRune) RuneRegistry.runeClasses.get(id).getConstructor(new Class[] { World.class }).newInstance(new Object[] { worldIn }); | |
rune.setPosition(bX + xm, bY, bZ + zm); | |
if (!worldIn.isRemote) | |
worldIn.spawnEntityInWorld(rune); | |
if (!playerIn.capabilities.isCreativeMode && playerIn instanceof EntityPlayerMP) { | |
itemStackIn.stackSize--; | |
} | |
} | |
int currentItem = playerIn.inventory.currentItem; | |
playerIn.inventory.setInventorySlotContents(currentItem, itemStackIn); | |
} catch (InstantiationException e) { | |
e.printStackTrace(); | |
} catch (IllegalAccessException e) { | |
e.printStackTrace(); | |
} catch (IllegalArgumentException e) { | |
e.printStackTrace(); | |
} catch (InvocationTargetException e) { | |
e.printStackTrace(); | |
} catch (NoSuchMethodException e) { | |
e.printStackTrace(); | |
} catch (SecurityException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment