Search in sources :

Example 71 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Armourers-Workshop by RiskyKen.

the class ItemLinkingTool 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) {
    if (world.isRemote) {
        return false;
    }
    if (!world.isRemote) {
        if (!hasLinkLocation(stack)) {
            Block block = world.getBlock(x, y, z);
            if (!(block instanceof BlockSkinnable)) {
                setLinkLocation(stack, new BlockLocation(x, y, z));
                player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.start", (Object) null));
                return true;
            } else {
                player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.linkedToSkinnable", (Object) null));
                return true;
            }
        } else {
            BlockLocation loc = getLinkLocation(stack);
            Block block = world.getBlock(x, y, z);
            if (block instanceof BlockSkinnable) {
                TileEntity te = world.getTileEntity(x, y, z);
                if (te != null && te instanceof TileEntitySkinnable) {
                    ((TileEntitySkinnable) te).getParent().setLinkedBlock(loc);
                    player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.finish", (Object) null));
                    removeLinkLocation(stack);
                    return true;
                }
            }
        }
        removeLinkLocation(stack);
        player.addChatMessage(new ChatComponentTranslation("chat.armourersworkshop:linkingTool.fail", (Object) null));
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockSkinnable(riskyken.armourersWorkshop.common.blocks.BlockSkinnable) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) Block(net.minecraft.block.Block) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) TileEntitySkinnable(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinnable)

Example 72 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Armourers-Workshop by RiskyKen.

the class ItemSkinUnlock method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    if (world.isRemote) {
        return itemStack;
    }
    ISkinType skinType = getSkinTypeFormStack(itemStack);
    ExPropsPlayerSkinData equipmentData = ExPropsPlayerSkinData.get(player);
    int count = equipmentData.getEquipmentWardrobeData().getUnlockedSlotsForSkinType(skinType);
    count++;
    String localizedSkinName = SkinTypeRegistry.INSTANCE.getLocalizedSkinTypeName(skinType);
    if (count <= ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE) {
        equipmentData.setSkinColumnCount(skinType, count);
        player.addChatComponentMessage(new ChatComponentTranslation("chat.armourersworkshop:slotUnlocked", localizedSkinName.toLowerCase(), Integer.toString(count)));
        itemStack.stackSize--;
    } else {
        player.addChatComponentMessage(new ChatComponentTranslation("chat.armourersworkshop:slotUnlockedFailed", localizedSkinName));
    }
    return itemStack;
}
Also used : ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ExPropsPlayerSkinData(riskyken.armourersWorkshop.common.skin.ExPropsPlayerSkinData)

Example 73 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.

the class ItemAmadronTablet method onItemUse.

@Override
public boolean onItemUse(ItemStack tablet, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof IFluidHandler) {
        if (!world.isRemote) {
            setLiquidProvidingLocation(tablet, x, y, z, world.provider.dimensionId);
            player.addChatComponentMessage(new ChatComponentTranslation("message.amadronTable.setLiquidProvidingLocation", x, y, z, world.provider.dimensionId, world.provider.getDimensionName()));
        }
    } else if (te instanceof IInventory) {
        if (!world.isRemote) {
            setItemProvidingLocation(tablet, x, y, z, world.provider.dimensionId);
            player.addChatComponentMessage(new ChatComponentTranslation("message.amadronTable.setItemProvidingLocation", x, y, z, world.provider.dimensionId, world.provider.getDimensionName()));
        }
    } else {
        return false;
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 74 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.

the class ItemSeismicSensor method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) {
    if (!world.isRemote) {
        int testingY = y;
        while (testingY > 0) {
            testingY--;
            if (world.getBlock(x, testingY, z) == FluidRegistry.getFluid(Fluids.oil.getName()).getBlock()) {
                Set<ChunkPosition> oilPositions = new HashSet<ChunkPosition>();
                Stack<ChunkPosition> pendingPositions = new Stack<ChunkPosition>();
                pendingPositions.add(new ChunkPosition(x, testingY, z));
                while (!pendingPositions.empty()) {
                    ChunkPosition checkingPos = pendingPositions.pop();
                    for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                        ChunkPosition newPos = new ChunkPosition(checkingPos.chunkPosX + d.offsetX, checkingPos.chunkPosY + d.offsetY, checkingPos.chunkPosZ + d.offsetZ);
                        if (world.getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == Fluids.oil.getBlock() && world.getBlockMetadata(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ) == 0 && oilPositions.add(newPos)) {
                            pendingPositions.add(newPos);
                        }
                    }
                }
                player.addChatComponentMessage(new ChatComponentTranslation("message.seismicSensor.foundOilDetails", EnumChatFormatting.GREEN.toString() + (y - testingY), EnumChatFormatting.GREEN.toString() + oilPositions.size() / 10 * 10));
                return true;
            }
        }
        player.addChatComponentMessage(new ChatComponentTranslation("message.seismicSensor.noOilFound"));
    }
    // we don't want to use the item.
    return true;
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ChunkPosition(net.minecraft.world.ChunkPosition) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) Stack(java.util.Stack)

Example 75 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.

the class ItemRemote method onItemUseFirst.

/**
 * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
 * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
 */
@Override
public boolean onItemUseFirst(ItemStack remote, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote && !player.isSneaking() && isAllowedToEdit(player, remote)) {
        TileEntity te = world.getTileEntity(x, y, z);
        if (te instanceof TileEntitySecurityStation) {
            if (((TileEntitySecurityStation) te).doesAllowPlayer(player)) {
                NBTTagCompound tag = remote.getTagCompound();
                if (tag == null) {
                    tag = new NBTTagCompound();
                    remote.setTagCompound(tag);
                }
                tag.setInteger("securityX", x);
                tag.setInteger("securityY", y);
                tag.setInteger("securityZ", z);
                tag.setInteger("securityDimension", world.provider.dimensionId);
                player.addChatComponentMessage(new ChatComponentTranslation("gui.remote.boundSecurityStation", x, y, z));
                return true;
            } else {
                player.addChatComponentMessage(new ChatComponentTranslation("gui.remote.cantBindSecurityStation"));
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySecurityStation(pneumaticCraft.common.tileentity.TileEntitySecurityStation) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)89 ItemStack (net.minecraft.item.ItemStack)21 TileEntity (net.minecraft.tileentity.TileEntity)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)11 ChatComponentText (net.minecraft.util.ChatComponentText)6 ArrayList (java.util.ArrayList)5 Block (net.minecraft.block.Block)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 World (net.minecraft.world.World)4 Item1N4148 (club.nsdn.nyasamarailway.item.tool.Item1N4148)3 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)3 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)3 TileEntityActuator (club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator)3 BufferedImage (java.awt.image.BufferedImage)3 IChatComponent (net.minecraft.util.IChatComponent)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 Int3 (WayofTime.alchemicalWizardry.api.Int3)2 TEReagentConduit (WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit)2 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)2