use of am2.blocks.tileentities.TileEntityCrystalMarker in project ArsMagica2 by Mithion.
the class ItemCrystalWrench method handleCMPair.
private void handleCMPair(ItemStack stack, World world, EntityPlayer player, TileEntity te, double hitX, double hitY, double hitZ) {
AMVector3 habLocation = AMVector3.readFromNBT(stack.stackTagCompound.getCompoundTag(HAB_PAIRLOC));
if (world.isRemote) {
spawnLinkParticles(world, hitX, hitY, hitZ);
} else {
TileEntityCrystalMarker tecm = (TileEntityCrystalMarker) te;
tecm.linkToHabitat(habLocation, player);
if (!stack.stackTagCompound.hasKey(KEEP_BINDING))
stack.stackTagCompound.removeTag(HAB_PAIRLOC);
}
}
use of am2.blocks.tileentities.TileEntityCrystalMarker in project ArsMagica2 by Mithion.
the class ItemCrystalWrench method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
TileEntity te = world.getTileEntity(x, y, z);
if (!stack.hasTagCompound())
stack.setTagCompound(new NBTTagCompound());
int cMode = getMode(stack);
if (te != null && !(te instanceof IPowerNode || te instanceof TileEntityParticleEmitter) && cMode == MODE_DISCONNECT) {
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.wrongWrenchMode")));
return false;
}
if (te != null && te instanceof IPowerNode) {
if (cMode == MODE_DISCONNECT) {
doDisconnect((IPowerNode) te, world, x + hitX, y + hitY, z + hitZ, player);
return false;
}
if (stack.stackTagCompound.hasKey(KEY_PAIRLOC)) {
doPairNodes(world, x, y, z, stack, player, hitX, hitY, hitZ, te);
} else {
storePairLocation(world, te, stack, player, x + hitX, y + hitY, z + hitZ);
}
} else if (te != null && te instanceof TileEntityCrystalMarker && stack.stackTagCompound != null && stack.stackTagCompound.hasKey(HAB_PAIRLOC)) {
handleCMPair(stack, world, player, te, x + hitX, y + hitY, z + hitZ);
} else if (player.isSneaking()) {
handleModeChanges(stack);
}
return false;
}
Aggregations