Search in sources :

Example 76 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project Geolosys by oitsjustjose.

the class ItemFieldManual method translatePageText.

@SideOnly(Side.CLIENT)
public String translatePageText(int pageNumber) {
    String langFile = Minecraft.getMinecraft().gameSettings.language;
    langFile = langFile.substring(0, langFile.indexOf("_")) + langFile.substring(langFile.indexOf("_")).toUpperCase();
    InputStream in = Geolosys.class.getResourceAsStream("/assets/geolosys/book/" + langFile + ".lang");
    if (in == null) {
        langFile = "en_US";
        in = Geolosys.class.getResourceAsStream("/assets/geolosys/book/" + langFile + ".lang");
    }
    try {
        for (String s : IOUtils.readLines(in, "utf-8")) {
            if (s.indexOf("=") == -1) {
                continue;
            }
            if (s.substring(0, s.indexOf("=")).equals("page_" + pageNumber + "_text")) {
                return s.substring(s.indexOf("=") + 1);
            }
        }
    } catch (IOException e) {
    }
    return "ERROR READING PAGE " + pageNumber;
}
Also used : Geolosys(com.oitsjustjose.geolosys.Geolosys) InputStream(java.io.InputStream) NBTTagString(net.minecraft.nbt.NBTTagString) IOException(java.io.IOException) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 77 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project Geolosys by oitsjustjose.

the class ItemFieldManual method getNumEntries.

@SideOnly(Side.CLIENT)
public int getNumEntries() {
    String langFile = Minecraft.getMinecraft().gameSettings.language;
    langFile = langFile.substring(0, langFile.indexOf("_")) + langFile.substring(langFile.indexOf("_")).toUpperCase();
    InputStream in = Geolosys.class.getResourceAsStream("/assets/geolosys/book/" + langFile + ".lang");
    int numLines = 0;
    if (in == null) {
        langFile = "en_US";
        in = Geolosys.class.getResourceAsStream("/assets/geolosys/lang/" + langFile + ".lang");
    }
    try {
        for (String s : IOUtils.readLines(in, "utf-8")) {
            if (s.indexOf("=") == -1) {
                continue;
            }
            if (s.contains("_title")) {
                numLines++;
            }
        }
    } catch (IOException e) {
    }
    return numLines;
}
Also used : Geolosys(com.oitsjustjose.geolosys.Geolosys) InputStream(java.io.InputStream) NBTTagString(net.minecraft.nbt.NBTTagString) IOException(java.io.IOException) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 78 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project RFToolsDimensions by McJty.

the class FeatureAbsorberBlock method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, World player, List<String> list, ITooltipFlag whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    NBTTagCompound tagCompound = itemStack.getTagCompound();
    if (tagCompound != null && tagCompound.hasKey("feature")) {
        int absorbing = tagCompound.getInteger("absorbing");
        int pct = ((DimletConstructionConfiguration.maxFeatureAbsorbtion - absorbing) * 100) / DimletConstructionConfiguration.maxFeatureAbsorbtion;
        if (pct == 100) {
            list.add(TextFormatting.GREEN + tagCompound.getString("feature"));
            list.add(TextFormatting.GREEN + "Absorbed: " + pct + "%");
        } else {
            list.add(TextFormatting.GREEN + "Unknown Feature");
            list.add(TextFormatting.GREEN + "Absorbed: " + pct + "%");
        }
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        list.add(TextFormatting.WHITE + "Place this block in an area and it will");
        list.add(TextFormatting.WHITE + "gradually absorb the essence of a random feature of");
        list.add(TextFormatting.WHITE + "this dimension.");
        list.add(TextFormatting.WHITE + "You can use the end result in the Dimlet Workbench.");
    } else {
        list.add(TextFormatting.WHITE + RFToolsDim.SHIFT_MESSAGE);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 79 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project RFToolsDimensions by McJty.

the class LiquidAbsorberBlock method getWailaBody.

@SideOnly(Side.CLIENT)
@Override
@Optional.Method(modid = "waila")
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    super.getWailaBody(itemStack, currenttip, accessor, config);
    LiquidAbsorberTileEntity tileEntity = (LiquidAbsorberTileEntity) accessor.getTileEntity();
    if (tileEntity != null && tileEntity.getBlock() != null) {
        Block block = tileEntity.getBlock();
        Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
        if (fluid != null) {
            int absorbing = tileEntity.getAbsorbing();
            int pct = ((DimletConstructionConfiguration.maxLiquidAbsorbtion - absorbing) * 100) / DimletConstructionConfiguration.maxLiquidAbsorbtion;
            currenttip.add(TextFormatting.GREEN + "Liquid: " + new FluidStack(fluid, 1).getLocalizedName() + " (" + pct + "%)");
        }
    }
    return currenttip;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) Block(net.minecraft.block.Block) GenericRFToolsBlock(mcjty.rftoolsdim.blocks.GenericRFToolsBlock) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 80 with SideOnly

use of net.minecraftforge.fml.relauncher.SideOnly in project RFToolsDimensions by McJty.

the class LiquidAbsorberBlock method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack itemStack, World player, List<String> list, ITooltipFlag whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    NBTTagCompound tagCompound = itemStack.getTagCompound();
    if (tagCompound != null && tagCompound.hasKey("liquid")) {
        Block block = Block.REGISTRY.getObject(new ResourceLocation(tagCompound.getString("liquid")));
        if (block != null) {
            Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
            if (fluid != null) {
                list.add(TextFormatting.GREEN + "Liquid: " + new FluidStack(fluid, 1).getLocalizedName());
                int absorbing = tagCompound.getInteger("absorbing");
                int pct = ((DimletConstructionConfiguration.maxLiquidAbsorbtion - absorbing) * 100) / DimletConstructionConfiguration.maxLiquidAbsorbtion;
                list.add(TextFormatting.GREEN + "Absorbed: " + pct + "%");
            }
        }
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        list.add(TextFormatting.WHITE + "Place this block on top of a liquid and it will");
        list.add(TextFormatting.WHITE + "gradually absorb all this liquid in the area.");
        list.add(TextFormatting.WHITE + "You can use the end result in the Dimlet Workbench.");
    } else {
        list.add(TextFormatting.WHITE + RFToolsDim.SHIFT_MESSAGE);
    }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) ResourceLocation(net.minecraft.util.ResourceLocation) Fluid(net.minecraftforge.fluids.Fluid) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block) GenericRFToolsBlock(mcjty.rftoolsdim.blocks.GenericRFToolsBlock) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1328 ItemStack (net.minecraft.item.ItemStack)238 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)149 IBlockState (net.minecraft.block.state.IBlockState)140 ResourceLocation (net.minecraft.util.ResourceLocation)139 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)127 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)126 BlockPos (net.minecraft.util.math.BlockPos)85 Block (net.minecraft.block.Block)82 TileEntity (net.minecraft.tileentity.TileEntity)80 EntityPlayer (net.minecraft.entity.player.EntityPlayer)72 Vec3d (net.minecraft.util.math.Vec3d)71 World (net.minecraft.world.World)69 EnumFacing (net.minecraft.util.EnumFacing)64 Minecraft (net.minecraft.client.Minecraft)62 ArrayList (java.util.ArrayList)50 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)42 Nonnull (javax.annotation.Nonnull)41 Entity (net.minecraft.entity.Entity)39 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)39