Search in sources :

Example 11 with TileEntityCrystalMarker

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);
    }
}
Also used : AMVector3(am2.api.math.AMVector3) TileEntityCrystalMarker(am2.blocks.tileentities.TileEntityCrystalMarker)

Example 12 with TileEntityCrystalMarker

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCrystalMarker(am2.blocks.tileentities.TileEntityCrystalMarker) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityParticleEmitter(am2.blocks.tileentities.TileEntityParticleEmitter) ChatComponentText(net.minecraft.util.ChatComponentText) IPowerNode(am2.api.power.IPowerNode)

Aggregations

TileEntityCrystalMarker (am2.blocks.tileentities.TileEntityCrystalMarker)8 TileEntity (net.minecraft.tileentity.TileEntity)8 AMVector3 (am2.api.math.AMVector3)5 ItemStack (net.minecraft.item.ItemStack)5 Block (net.minecraft.block.Block)3 IKeystoneLockable (am2.api.blocks.IKeystoneLockable)2 TileEntityFlickerHabitat (am2.blocks.tileentities.TileEntityFlickerHabitat)2 ArrayList (java.util.ArrayList)2 IInventory (net.minecraft.inventory.IInventory)2 TileEntityChest (net.minecraft.tileentity.TileEntityChest)2 IPowerNode (am2.api.power.IPowerNode)1 TileEntityParticleEmitter (am2.blocks.tileentities.TileEntityParticleEmitter)1 GetFirstStackStartingFromSlotResult (am2.utility.GetFirstStackStartingFromSlotResult)1 HashMap (java.util.HashMap)1 EntityItem (net.minecraft.entity.item.EntityItem)1 ItemBlock (net.minecraft.item.ItemBlock)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagString (net.minecraft.nbt.NBTTagString)1 ChatComponentText (net.minecraft.util.ChatComponentText)1