Search in sources :

Example 56 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project DefiledLands by Lykrast.

the class ItemBookWyrmAnalyzer method itemInteractionForEntity.

/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand) {
    if (entity.world.isRemote) {
        return false;
    }
    if (entity instanceof EntityBookWyrm) {
        EntityBookWyrm target = (EntityBookWyrm) entity;
        String base = "ui.defiledlands.book_wyrm_analyze.";
        player.sendMessage(new TextComponentTranslation(base + "health", (int) target.getHealth(), (int) target.getMaxHealth()));
        player.sendMessage(new TextComponentTranslation(base + "digest_time", target.getDigestTime()));
        player.sendMessage(new TextComponentTranslation(base + "max_level", target.getMaxLevel()));
        player.sendMessage(new TextComponentTranslation(base + "digested", target.digested));
        if (target.digesting > 0)
            player.sendMessage(new TextComponentTranslation(base + "digesting", target.digesting));
        if (target.isChild()) {
            int minutes = (int) Math.ceil((-target.getGrowingAge()) / 1200.0D);
            player.sendMessage(new TextComponentTranslation(base + "maturing", minutes));
        } else if (target.getGrowingAge() > 0) {
            int minutes = (int) Math.ceil(target.getGrowingAge() / 1200.0D);
            player.sendMessage(new TextComponentTranslation(base + "reproduce", minutes));
        } else
            player.sendMessage(new TextComponentTranslation(base + "ready"));
        if (target.isGolden())
            player.sendMessage(new TextComponentTranslation(base + "golden"));
        return true;
    }
    return false;
}
Also used : EntityBookWyrm(lykrast.defiledlands.common.entity.passive.EntityBookWyrm) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 57 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project Wizardry by TeamWizardry.

the class ItemFairyBell method itemInteractionForEntity.

@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand) {
    if (playerIn.world.isRemote || playerIn.isSneaking())
        return super.itemInteractionForEntity(stack, playerIn, target, hand);
    if (target instanceof EntityFairy) {
        EntityFairy targetFairy = (EntityFairy) target;
        FairyData targetData = targetFairy.getDataFairy();
        if (targetData == null)
            return super.itemInteractionForEntity(stack, playerIn, target, hand);
        if (targetData.isDepressed) {
            IMiscCapability cap = MiscCapabilityProvider.getCap(playerIn);
            if (cap != null) {
                UUID selected = cap.getSelectedFairyUUID();
                if (selected != null && selected.equals(targetFairy.getUniqueID())) {
                    cap.setSelectedFairy(null);
                    playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 0.25f);
                    playerIn.sendStatusMessage(new TextComponentTranslation("item.wizardry:fairy_bell.status.deselected"), true);
                } else if (selected != null && !selected.equals(targetFairy.getUniqueID())) {
                    List<Entity> list = playerIn.world.loadedEntityList;
                    for (Entity entity : list) {
                        if (entity instanceof EntityFairy && entity.getUniqueID().equals(selected)) {
                            if (entity.isDead)
                                continue;
                            ((EntityFairy) entity).setChainedFairy(targetFairy.getUniqueID());
                            targetFairy.setChainedFairy(selected);
                            playerIn.sendStatusMessage(new TextComponentTranslation("item.wizardry:fairy_bell.status.linked_to_fairy"), true);
                            break;
                        }
                    }
                } else {
                    cap.setSelectedFairy(targetFairy.getUniqueID());
                    boolean movingMode = NBTHelper.getBoolean(stack, "moving_mode", true);
                    if (!movingMode) {
                        playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 0.75f);
                    } else {
                        playerIn.world.playSound(null, playerIn.getPosition(), ModSounds.TINY_BELL, SoundCategory.NEUTRAL, 1, 1.25f);
                    }
                    playerIn.sendStatusMessage(new TextComponentTranslation(movingMode ? "item.wizardry:fairy_bell.status.fairy_moving" : "item.wizardry:fairy_bell.status.fairy_aiming"), true);
                }
                cap.dataChanged(playerIn);
            }
        }
    }
    return super.itemInteractionForEntity(stack, playerIn, target, hand);
}
Also used : Entity(net.minecraft.entity.Entity) IMiscCapability(com.teamwizardry.wizardry.api.capability.player.miscdata.IMiscCapability) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) EntityFairy(com.teamwizardry.wizardry.common.entity.EntityFairy) FairyData(com.teamwizardry.wizardry.api.entity.fairy.FairyData) List(java.util.List) UUID(java.util.UUID)

Example 58 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.

the class AbstractEntityAIStructure method structureStep.

private Boolean structureStep(final Structure.StructureBlock structureBlock) {
    if (!BlockUtils.shouldNeverBeMessedWith(structureBlock.worldBlock)) {
        worker.setLatestStatus(new TextComponentTranslation("com.minecolonies.coremod.status.building"));
        // also ensure we are at that position.
        if (!walkToConstructionSite()) {
            return false;
        }
        if (structureBlock.block == null || (!structureBlock.metadata.getMaterial().isSolid() && structureBlock.block != Blocks.AIR)) {
            // findNextBlock count was reached and we can ignore this block
            return true;
        }
        if (structureBlock.doesStructureBlockEqualWorldBlock()) {
            connectBlockToBuildingIfNecessary(structureBlock.metadata, structureBlock.blockPosition);
            // findNextBlock count was reached and we can ignore this block
            return true;
        }
        @Nullable Block block = structureBlock.block;
        @Nullable IBlockState blockState = structureBlock.metadata;
        if (block == ModBlocks.blockSolidSubstitution && shallReplaceSolidSubstitutionBlock(structureBlock.worldBlock, structureBlock.worldMetadata)) {
            blockState = getSolidSubstitution(structureBlock.blockPosition);
            block = blockState.getBlock();
        }
        worker.faceBlock(structureBlock.blockPosition);
        // should never happen
        if (block == null) {
            @NotNull final BlockPos local = structureBlock.blockPosition;
            Log.getLogger().error(String.format("StructureProxy has null block at %s - local(%s)", currentStructure.getCurrentBlockPosition(), local));
            return true;
        }
        return placeBlockAt(blockState, structureBlock.blockPosition);
    }
    return true;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Example 59 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.

the class AbstractEntityAIStructure method spawnEntity.

/**
 * Iterates through all entities and spawns them
 * Suppressing Sonar Rule Squid:S3047
 * The rule thinks we can merge the two forge loops iterating over resources
 * But in this case the rule does not apply because that would destroy the logic.
 */
@SuppressWarnings(MULTIPLE_LOOPS_OVER_THE_SAME_SET_SHOULD_BE_COMBINED)
private Boolean spawnEntity(@NotNull final Structure.StructureBlock currentBlock) {
    final Template.EntityInfo entityInfo = currentBlock.entity;
    if (entityInfo == null) {
        return true;
    }
    worker.setLatestStatus(new TextComponentTranslation("com.minecolonies.coremod.status.spawning"));
    final Entity entity = ItemStackUtils.getEntityFromEntityInfoOrNull(entityInfo, world);
    if (entity != null && !isEntityAtPosition(entity, world)) {
        final List<ItemStack> request = new ArrayList<>();
        if (entity instanceof EntityItemFrame) {
            final ItemStack stack = ((EntityItemFrame) entity).getDisplayedItem();
            if (!ItemStackUtils.isEmpty(stack)) {
                ItemStackUtils.changeSize(stack, 1);
                request.add(stack);
            }
            request.add(new ItemStack(Items.ITEM_FRAME, 1));
        } else if (entity instanceof EntityArmorStand) {
            request.add(entity.getPickedResult(new RayTraceResult(worker)));
            entity.getArmorInventoryList().forEach(request::add);
            entity.getHeldEquipment().forEach(request::add);
        } else {
            request.add(entity.getPickedResult(new RayTraceResult(worker)));
        }
        if (!Configurations.gameplay.builderInfiniteResources) {
            if (PlacementHandlers.checkForListInInvAndRequest(this, new ArrayList<>(request))) {
                return false;
            }
            // Surpress
            for (final ItemStack stack : request) {
                if (ItemStackUtils.isEmpty(stack)) {
                    continue;
                }
                final int slot = worker.findFirstSlotInInventoryWith(stack.getItem(), stack.getItemDamage());
                if (slot != -1) {
                    new InvWrapper(getInventory()).extractItem(slot, 1, false);
                    reduceNeededResources(stack);
                }
            }
        }
        entity.setUniqueId(UUID.randomUUID());
        entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
        if (!world.spawnEntity(entity)) {
            Log.getLogger().info("Failed to spawn entity");
        }
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) ArrayList(java.util.ArrayList) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) Template(net.minecraft.world.gen.structure.template.Template) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) ItemStack(net.minecraft.item.ItemStack)

Example 60 with TextComponentTranslation

use of net.minecraft.util.text.TextComponentTranslation in project minecolonies by Minecolonies.

the class AbstractEntityAIUsesFurnace method checkForAdditionalJobs.

/**
 * Check for additional jobs to execute after the traditional furnace user jobs have been handled.
 * @return the next AIState to go to.
 */
protected AIState checkForAdditionalJobs() {
    worker.setLatestStatus(new TextComponentTranslation(COM_MINECOLONIES_COREMOD_STATUS_IDLING));
    setDelay(WAIT_AFTER_REQUEST);
    walkToBuilding();
    return START_WORKING;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Aggregations

TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)502 ItemStack (net.minecraft.item.ItemStack)134 ITextComponent (net.minecraft.util.text.ITextComponent)82 EntityPlayer (net.minecraft.entity.player.EntityPlayer)72 BlockPos (net.minecraft.util.math.BlockPos)70 TextComponentString (net.minecraft.util.text.TextComponentString)66 Style (net.minecraft.util.text.Style)60 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)58 TileEntity (net.minecraft.tileentity.TileEntity)45 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)36 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)33 ArrayList (java.util.ArrayList)32 World (net.minecraft.world.World)30 IBlockState (net.minecraft.block.state.IBlockState)28 EnumFacing (net.minecraft.util.EnumFacing)26 CommandException (net.minecraft.command.CommandException)25 Block (net.minecraft.block.Block)20 Nonnull (javax.annotation.Nonnull)19 WrongUsageException (net.minecraft.command.WrongUsageException)19 EnumActionResult (net.minecraft.util.EnumActionResult)19