Search in sources :

Example 1 with TranslationTextComponent

use of net.minecraft.util.text.TranslationTextComponent in project NetherEx by LogicTechCorp.

the class DullMirrorItem method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (!world.isRemote) {
        if (stack.getDamage() < stack.getMaxDamage() && player.isShiftKeyDown()) {
            DimensionType spawnDimension = world.getDimension().getType();
            BlockPos spawnPoint = player.getPosition();
            CompoundNBT compound = NBTHelper.ensureTagExists(stack);
            if (!compound.contains("SpawnDimension") || !compound.contains("SpawnPoint")) {
                DimensionType bedDimension = player.getSpawnDimension();
                BlockPos bedPos = player.getBedLocation(bedDimension);
                if (bedPos == null) {
                    bedPos = world.getServer().getWorld(bedDimension).getSpawnPoint();
                }
                compound.putString("BedDimension", bedDimension.getRegistryName().toString());
                compound.put("BedPoint", NBTUtil.writeBlockPos(bedPos));
                compound.putString("SpawnDimension", spawnDimension.getRegistryName().toString());
                compound.put("SpawnPoint", NBTUtil.writeBlockPos(spawnPoint));
                player.setSpawnDimenion(spawnDimension);
                player.setSpawnPoint(spawnPoint, true, false, spawnDimension);
                player.sendMessage(new TranslationTextComponent("tooltip.netherex.dull_mirror.spawn_point_set", spawnPoint.getX() + " " + spawnPoint.getY() + " " + spawnPoint.getZ()));
                world.playSound((double) spawnPoint.getX() + 0.5D, (double) spawnPoint.getY() + 0.5D, (double) spawnPoint.getZ() + 0.5D, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, world.rand.nextFloat() * 0.4F + 0.8F, false);
            } else {
                DimensionType bedDimension = DimensionType.byName(new ResourceLocation(compound.getString("BedDimension")));
                if (bedDimension != null) {
                    compound.remove("SpawnDimension");
                    compound.remove("SpawnPoint");
                    player.setSpawnDimenion(bedDimension);
                    player.setSpawnPoint(NBTUtil.readBlockPos(compound.getCompound("BedPoint")), true, false, bedDimension);
                    player.sendMessage(new TranslationTextComponent("tooltip.netherex.dull_mirror.spawn_point_removed", spawnPoint.getX() + " " + spawnPoint.getY() + " " + spawnPoint.getZ()));
                    world.playSound((double) spawnPoint.getX() + 0.5D, (double) spawnPoint.getY() + 0.5D, (double) spawnPoint.getZ() + 0.5D, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 0.5F, world.rand.nextFloat() * 0.4F + 0.8F, false);
                }
            }
            return new ActionResult<>(ActionResultType.SUCCESS, stack);
        }
    }
    return new ActionResult<>(ActionResultType.FAIL, stack);
}
Also used : DimensionType(net.minecraft.world.dimension.DimensionType) CompoundNBT(net.minecraft.nbt.CompoundNBT) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TranslationTextComponent

use of net.minecraft.util.text.TranslationTextComponent in project NetherEx by LogicTechCorp.

the class DullMirrorItem method addInformation.

@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
    CompoundNBT compound = stack.getTag();
    if (compound != null) {
        if (compound.contains("SpawnDimension")) {
            DimensionType type = DimensionType.byName(new ResourceLocation(compound.getString("SpawnDimension")));
            tooltip.add(new TranslationTextComponent("tooltip.netherex.dull_mirror.spawn_dimension", StringUtils.capitalize(type.getRegistryName().getPath().replace("_", " "))));
        }
        if (compound.contains("SpawnPoint")) {
            BlockPos spawnPos = NBTUtil.readBlockPos(compound.getCompound("SpawnPoint"));
            tooltip.add(new TranslationTextComponent("tooltip.netherex.dull_mirror.spawn_point", spawnPos.getX() + " " + spawnPos.getY() + " " + spawnPos.getZ()));
        }
        if (compound.contains("DeathPoint")) {
            BlockPos deathPos = NBTUtil.readBlockPos(compound.getCompound("DeathPoint"));
            tooltip.add(new TranslationTextComponent("tooltip.netherex.dull_mirror.death_point", deathPos.getX() + " " + deathPos.getY() + " " + deathPos.getZ()));
        }
    }
}
Also used : DimensionType(net.minecraft.world.dimension.DimensionType) CompoundNBT(net.minecraft.nbt.CompoundNBT) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with TranslationTextComponent

use of net.minecraft.util.text.TranslationTextComponent in project AgriCraft by AgriCraft.

the class JournalDataDrawerPlant method drawTooltipLeft.

@Override
public void drawTooltipLeft(PlantPage page, IPageRenderContext context, MatrixStack transforms, int mouseX, int mouseY) {
    // seed item
    if (4 <= mouseX && mouseX <= 20 && 5 <= mouseY && mouseY <= 21) {
        context.drawTooltip(transforms, Collections.singletonList(page.getPlant().getTooltip()), mouseX, mouseY);
        return;
    }
    // Growth requirements
    // draw offscreen to get offset
    float offset = context.drawText(transforms, page.getPlant().getInformation(), -1000, -1000, 0.70F);
    float dy = Math.max(offset, 60);
    // draw offscreen to get offset
    dy += context.drawText(transforms, GROWTH_REQUIREMENTS, -1000, -1000, 0.80F) + 1;
    // Light level
    for (int i = 0; i < page.brightnessMask().length; i++) {
        if (6 + 4 * i <= mouseX && mouseX <= 6 + 4 * i + 4 && dy + 1 <= mouseY && mouseY <= dy + 9) {
            context.drawTooltip(transforms, Collections.singletonList(new TranslationTextComponent("agricraft.tooltip.light").appendString(" " + i)), mouseX, mouseY);
            return;
        }
    }
    dy += 9;
    // Seasons
    if (AgriApi.getSeasonLogic().isActive()) {
        for (int i = 0; i < page.seasonMask().length; i++) {
            int w = 10;
            int h = 12;
            int x = (i % 2) * (w + 2) + 5 + 70;
            int y = (i / 2) * (h + 2) + 6 + (int) dy;
            if (x <= mouseX && mouseX <= x + w && y <= mouseY && mouseY <= y + h) {
                context.drawTooltip(transforms, Collections.singletonList(AgriSeason.values()[i].getDisplayName()), mouseX, mouseY);
                return;
            }
        }
    }
    // Humidity
    for (int i = 0; i < page.humidityMask().length; i++) {
        int dx = JournalDataDrawerBase.Textures.HUMIDITY_OFFSETS[i] + 10;
        int w = JournalDataDrawerBase.Textures.HUMIDITY_OFFSETS[i + 1] - JournalDataDrawerBase.Textures.HUMIDITY_OFFSETS[i];
        if (dx <= mouseX && mouseX <= dx + w && dy <= mouseY && mouseY <= dy + 12) {
            context.drawTooltip(transforms, Collections.singletonList(IAgriSoil.Humidity.values()[i].getDescription()), mouseX, mouseY);
            return;
        }
    }
    dy += 13;
    // Acidity
    for (int i = 0; i < page.acidityMask().length; i++) {
        int dx = JournalDataDrawerBase.Textures.ACIDITY_OFFSETS[i] + 10;
        int w = JournalDataDrawerBase.Textures.ACIDITY_OFFSETS[i + 1] - JournalDataDrawerBase.Textures.ACIDITY_OFFSETS[i];
        if (dx <= mouseX && mouseX <= dx + w && dy <= mouseY && mouseY <= dy + 12) {
            context.drawTooltip(transforms, Collections.singletonList(IAgriSoil.Acidity.values()[i].getDescription()), mouseX, mouseY);
            return;
        }
    }
    dy += 13;
    // Nutrients
    for (int i = 0; i < page.nutrientsMask().length; i++) {
        int dx = JournalDataDrawerBase.Textures.NUTRIENTS_OFFSETS[i] + 10;
        int w = JournalDataDrawerBase.Textures.NUTRIENTS_OFFSETS[i + 1] - JournalDataDrawerBase.Textures.NUTRIENTS_OFFSETS[i];
        if (dx <= mouseX && mouseX <= dx + w && dy <= mouseY && mouseY <= dy + 12) {
            context.drawTooltip(transforms, Collections.singletonList(IAgriSoil.Nutrients.values()[i].getDescription()), mouseX, mouseY);
            return;
        }
    }
}
Also used : TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent)

Example 4 with TranslationTextComponent

use of net.minecraft.util.text.TranslationTextComponent in project BluePower by Qmunity.

the class BlockBPMicroblock method getCloneItemStack.

@Override
public ItemStack getCloneItemStack(IBlockReader world, BlockPos pos, BlockState state) {
    TileEntity tileentity = world.getBlockEntity(pos);
    ItemStack stack = ItemStack.EMPTY;
    if (tileentity instanceof TileBPMultipart) {
        tileentity = ((TileBPMultipart) tileentity).getTileForState(state);
    }
    if (tileentity instanceof TileBPMicroblock) {
        CompoundNBT nbt = new CompoundNBT();
        nbt.putString("block", ((TileBPMicroblock) tileentity).getBlock().getRegistryName().toString());
        stack = new ItemStack(this);
        stack.setTag(nbt);
        stack.setHoverName(new TranslationTextComponent(((TileBPMicroblock) tileentity).getBlock().getDescriptionId()).append(new StringTextComponent(" ")).append(new TranslationTextComponent(this.getDescriptionId())));
    }
    return stack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileBPMicroblock(com.bluepowermod.tile.TileBPMicroblock) CompoundNBT(net.minecraft.nbt.CompoundNBT) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) TileBPMultipart(com.bluepowermod.tile.TileBPMultipart) ItemStack(net.minecraft.item.ItemStack)

Example 5 with TranslationTextComponent

use of net.minecraft.util.text.TranslationTextComponent in project BluePower by Qmunity.

the class MicroblockRecipe method assemble.

@Override
public ItemStack assemble(CraftingInventory inv) {
    for (int i = 0; i < inv.getContainerSize(); ++i) {
        ItemStack stack = inv.getItem(i);
        if (!stack.isEmpty() && stack.getItem() instanceof BlockItem) {
            if (Block.byItem(stack.getItem()).defaultBlockState().getShape(null, null) == VoxelShapes.block()) {
                CompoundNBT nbt = new CompoundNBT();
                nbt.putString("block", stack.getItem().getRegistryName().toString());
                ItemStack outStack = new ItemStack(BPBlocks.half_block, 2);
                outStack.setTag(nbt);
                outStack.setHoverName(new TranslationTextComponent(stack.getItem().getDescriptionId()).append(" ").append(new TranslationTextComponent(BPBlocks.half_block.getDescriptionId())));
                return outStack;
            } else if (Block.byItem(stack.getItem()) == BPBlocks.half_block) {
                CompoundNBT nbt = new CompoundNBT();
                nbt.putString("block", stack.getTag().getString("block"));
                ItemStack outStack = new ItemStack(BPBlocks.panel, 2);
                outStack.setTag(nbt);
                Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(nbt.getString("block")));
                outStack.setHoverName(new TranslationTextComponent(block.getDescriptionId()).append(" ").append(new TranslationTextComponent(BPBlocks.panel.getDescriptionId())));
                return outStack;
            } else if (Block.byItem(stack.getItem()) == BPBlocks.panel) {
                CompoundNBT nbt = new CompoundNBT();
                nbt.putString("block", stack.getTag().getString("block"));
                ItemStack outStack = new ItemStack(BPBlocks.cover, 2);
                outStack.setTag(nbt);
                Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(nbt.getString("block")));
                outStack.setHoverName(new TranslationTextComponent(block.getDescriptionId()).append(" ").append(new TranslationTextComponent(BPBlocks.cover.getDescriptionId())));
                return outStack;
            }
        }
    }
    return ItemStack.EMPTY;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) ResourceLocation(net.minecraft.util.ResourceLocation) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem)

Aggregations

TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)13 ItemStack (net.minecraft.item.ItemStack)6 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 BlockPos (net.minecraft.util.math.BlockPos)4 StringTextComponent (net.minecraft.util.text.StringTextComponent)4 ResourceLocation (net.minecraft.util.ResourceLocation)3 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)3 TileBPMicroblock (com.bluepowermod.tile.TileBPMicroblock)2 TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)2 BlockState (net.minecraft.block.BlockState)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 DimensionType (net.minecraft.world.dimension.DimensionType)2 BluePower (com.bluepowermod.BluePower)1 IAlloyFurnaceRecipe (com.bluepowermod.api.recipe.IAlloyFurnaceRecipe)1 GuiAlloyFurnace (com.bluepowermod.client.gui.GuiAlloyFurnace)1 GuiBlulectricAlloyFurnace (com.bluepowermod.client.gui.GuiBlulectricAlloyFurnace)1 GuiBlulectricFurnace (com.bluepowermod.client.gui.GuiBlulectricFurnace)1 ContainerAlloyFurnace (com.bluepowermod.container.ContainerAlloyFurnace)1 ContainerBlulectricAlloyFurnace (com.bluepowermod.container.ContainerBlulectricAlloyFurnace)1 ContainerBlulectricFurnace (com.bluepowermod.container.ContainerBlulectricFurnace)1