Search in sources :

Example 11 with TranslationTextComponent

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

the class BlockBPMicroblock method getDrops.

@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
    TileEntity tileentity = builder.getParameter(LootParameters.BLOCK_ENTITY);
    List<ItemStack> itemStacks = new ArrayList<>();
    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());
        ItemStack stack = new ItemStack(this);
        stack.setTag(nbt);
        stack.setHoverName(new TranslationTextComponent(((TileBPMicroblock) tileentity).getBlock().getDescriptionId()).append(new StringTextComponent(" ")).append(new TranslationTextComponent(this.getDescriptionId())));
        itemStacks.add(stack);
    }
    return itemStacks;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileBPMicroblock(com.bluepowermod.tile.TileBPMicroblock) CompoundNBT(net.minecraft.nbt.CompoundNBT) ArrayList(java.util.ArrayList) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) TileBPMultipart(com.bluepowermod.tile.TileBPMultipart) ItemStack(net.minecraft.item.ItemStack)

Example 12 with TranslationTextComponent

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

the class GuiPlugin method onSeedAnalyzerRightClick.

public void onSeedAnalyzerRightClick(PlayerInteractEvent.RightClickBlock event) {
    BlockPos pos = event.getPos();
    BlockState state = event.getWorld().getBlockState(pos);
    if (event.getPlayer().isSneaking()) {
        return;
    }
    if (state.getBlock() != AgriCraft.instance.getModBlockRegistry().seed_analyzer.getBlock()) {
        return;
    }
    event.setCancellationResult(ActionResultType.SUCCESS);
    event.setCanceled(true);
    if (event.getPlayer().world.isRemote) {
        return;
    }
    INamedContainerProvider containerProvider = new INamedContainerProvider() {

        @Nonnull
        @Override
        public ITextComponent getDisplayName() {
            return new TranslationTextComponent("screen.agricraft.seed_analyzer");
        }

        @Override
        public Container createMenu(int id, @Nonnull PlayerInventory playerInventory, @Nonnull PlayerEntity player) {
            return new SeedAnalyzerContainer(id, event.getWorld(), playerInventory, pos);
        }
    };
    NetworkHooks.openGui((ServerPlayerEntity) event.getPlayer(), containerProvider, pos);
}
Also used : BlockState(net.minecraft.block.BlockState) Nonnull(javax.annotation.Nonnull) SeedAnalyzerContainer(com.infinityraider.agricraft.plugins.agrigui.analyzer.SeedAnalyzerContainer) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos) INamedContainerProvider(net.minecraft.inventory.container.INamedContainerProvider) PlayerInventory(net.minecraft.entity.player.PlayerInventory) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 13 with TranslationTextComponent

use of net.minecraft.util.text.TranslationTextComponent in project Geolosys by oitsjustjose.

the class ProPickItem method prospectChunk.

private boolean prospectChunk(World world, ItemStack stack, BlockPos pos, PlayerEntity player) {
    HashSet<BlockState> foundBlocks = new HashSet<BlockState>();
    HashSet<BlockState> depositBlocks = Prospecting.getDepositBlocks();
    ChunkPos tempPos = new ChunkPos(pos);
    for (int x = tempPos.getXStart(); x <= tempPos.getXEnd(); x++) {
        for (int z = tempPos.getZStart(); z <= tempPos.getZEnd(); z++) {
            for (int y = 0; y < world.getHeight(); y++) {
                BlockState state = world.getBlockState(new BlockPos(x, y, z));
                if (depositBlocks.contains(state)) {
                    foundBlocks.add(state);
                }
            }
        }
    }
    if (!foundBlocks.isEmpty()) {
        Geolosys.proxy.sendProspectingMessage(player, foundBlocks, null);
        return true;
    }
    player.sendStatusMessage(new TranslationTextComponent("geolosys.pro_pick.tooltip.nonefound_surface"), true);
    return false;
}
Also used : BlockState(net.minecraft.block.BlockState) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) HashSet(java.util.HashSet)

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