GhostSnyperRecon Posted September 9, 2012 Posted September 9, 2012 hi, im creating some trees for a new dimension, and ive come to a texture issue, i cant work out how to make the graphics work with fancy and fast variations, any help? Quote
Toldea Posted September 10, 2012 Posted September 10, 2012 If you look at the BlockLeaves object it has a function called setGraphicsLevel which apart from the graphics level also changes the texture index. Likewise it has a function isOpaqueCube that returns true or false depending on the graphics level and determines if a block should be transparant or not. Quote
GhostSnyperRecon Posted September 10, 2012 Author Posted September 10, 2012 i have tried using that but i cant seem to get it to work, heres the code package mod.warp; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; import java.util.ArrayList; import java.util.List; import java.util.Random; import net.minecraft.src.Block; import net.minecraft.src.BlockLeavesBase; import net.minecraft.src.ColorizerFoliage; import net.minecraft.src.CreativeTabs; import net.minecraft.src.EntityPlayer; import net.minecraft.src.IBlockAccess; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.Material; import net.minecraft.src.World; import net.minecraftforge.common.IShearable; public class BlockWarpLeaves extends BlockLeavesBase implements IShearable { /** * The base index in terrain.png corresponding to the fancy version of the leaf texture. This is stored so we can * switch the displayed version between fancy and fast graphics (fast is this index + 1). */ private int baseIndexInPNG; int[] adjacentTreeBlocks; protected BlockWarpLeaves(int par1, int par2) { super(par1, par2, Material.leaves, false); this.baseIndexInPNG = par2; this.setTickRandomly(true); blockIndexInTexture = 9; setBlockName("Infused Leaves"); this.setCreativeTab(CreativeTabs.tabDeco); } /** * ejects contained items into the world, and notifies neighbours of an update, as appropriate */ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { byte var7 = 1; int var8 = var7 + 1; if (par1World.checkChunksExist(par2 - var8, par3 - var8, par4 - var8, par2 + var8, par3 + var8, par4 + var8)) { for (int var9 = -var7; var9 <= var7; ++var9) { for (int var10 = -var7; var10 <= var7; ++var10) { for (int var11 = -var7; var11 <= var7; ++var11) { int var12 = par1World.getBlockId(par2 + var9, par3 + var10, par4 + var11); if (Block.blocksList[var12] != null) { Block.blocksList[var12].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11); } } } } } } /** * Ticks the block if it's been scheduled */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote) { int var6 = par1World.getBlockMetadata(par2, par3, par4); if ((var6 & != 0 && (var6 & 4) == 0) { byte var7 = 4; int var8 = var7 + 1; byte var9 = 32; int var10 = var9 * var9; int var11 = var9 / 2; if (this.adjacentTreeBlocks == null) { this.adjacentTreeBlocks = new int[var9 * var9 * var9]; } int var12; if (par1World.checkChunksExist(par2 - var8, par3 - var8, par4 - var8, par2 + var8, par3 + var8, par4 + var8)) { int var13; int var14; int var15; for (var12 = -var7; var12 <= var7; ++var12) { for (var13 = -var7; var13 <= var7; ++var13) { for (var14 = -var7; var14 <= var7; ++var14) { var15 = par1World.getBlockId(par2 + var12, par3 + var13, par4 + var14); Block block = Block.blocksList[var15]; if (block != null && block.canSustainLeaves(par1World, par2 + var12, par3 + var13, par4 + var14)) { this.adjacentTreeBlocks[(var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] = 0; } else if (block != null && block.isLeaves(par1World, par2 + var12, par3 + var13, par4 + var14)) { this.adjacentTreeBlocks[(var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] = -2; } else { this.adjacentTreeBlocks[(var12 + var11) * var10 + (var13 + var11) * var9 + var14 + var11] = -1; } } } } for (var12 = 1; var12 <= 4; ++var12) { for (var13 = -var7; var13 <= var7; ++var13) { for (var14 = -var7; var14 <= var7; ++var14) { for (var15 = -var7; var15 <= var7; ++var15) { if (this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11) * var9 + var15 + var11] == var12 - 1) { if (this.adjacentTreeBlocks[(var13 + var11 - 1) * var10 + (var14 + var11) * var9 + var15 + var11] == -2) { this.adjacentTreeBlocks[(var13 + var11 - 1) * var10 + (var14 + var11) * var9 + var15 + var11] = var12; } if (this.adjacentTreeBlocks[(var13 + var11 + 1) * var10 + (var14 + var11) * var9 + var15 + var11] == -2) { this.adjacentTreeBlocks[(var13 + var11 + 1) * var10 + (var14 + var11) * var9 + var15 + var11] = var12; } if (this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11 - 1) * var9 + var15 + var11] == -2) { this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11 - 1) * var9 + var15 + var11] = var12; } if (this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11 + 1) * var9 + var15 + var11] == -2) { this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11 + 1) * var9 + var15 + var11] = var12; } if (this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11) * var9 + (var15 + var11 - 1)] == -2) { this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11) * var9 + (var15 + var11 - 1)] = var12; } if (this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11) * var9 + var15 + var11 + 1] == -2) { this.adjacentTreeBlocks[(var13 + var11) * var10 + (var14 + var11) * var9 + var15 + var11 + 1] = var12; } } } } } } } var12 = this.adjacentTreeBlocks[var11 * var10 + var11 * var9 + var11]; if (var12 >= 0) { par1World.setBlockMetadata(par2, par3, par4, var6 & -9); } else { this.removeLeaves(par1World, par2, par3, par4); } } } } @SideOnly(Side.CLIENT) /** * A randomly called display update to be able to add particles or other items for display */ public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (par1World.canLightningStrikeAt(par2, par3 + 1, par4) && !par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && par5Random.nextInt(15) == 1) { double var6 = (double)((float)par2 + par5Random.nextFloat()); double var8 = (double)par3 - 0.05D; double var10 = (double)((float)par4 + par5Random.nextFloat()); par1World.spawnParticle("dripWater", var6, var8, var10, 0.0D, 0.0D, 0.0D); } } private void removeLeaves(World par1World, int par2, int par3, int par4) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockWithNotify(par2, par3, par4, 0); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1Random) { return par1Random.nextInt(20) == 0 ? 1 : 0; } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par1, Random par2Random, int par3) { return Block.sapling.blockID; } /** * Drops the block items with a specified chance of dropping the specified items */ public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) { if (!par1World.isRemote) { byte var8 = 20; if ((par5 & 3) == 3) { var8 = 40; } if (par1World.rand.nextInt(var8) == 0) { int var9 = this.idDropped(par5, par1World.rand, par7); this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(var9, 1, this.damageDropped(par5))); } if ((par5 & 3) == 0 && par1World.rand.nextInt(200) == 0) { this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Item.appleRed, 1, 0)); } } } /** * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the * block and l is the block's subtype/damage. */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); } /** * Determines the damage on the item the block drops. Used in cloth and wood. */ protected int damageDropped(int par1) { return par1 & 3; } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return !this.graphicsLevel; } public int getRenderBlockPass() { return 0; } @SideOnly(Side.CLIENT) /** * Pass true to draw this block using fancy graphics, or false for fast graphics. */ public void setGraphicsLevel(boolean par1) { this.graphicsLevel = par1; this.blockIndexInTexture = this.baseIndexInPNG + 1; } @Override public boolean isShearable(ItemStack item, World world, int x, int y, int z) { return true; } @Override public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3)); return ret; } @Override public void beginLeavesDecay(World world, int x, int y, int z) { world.setBlockMetadata(x, y, z, world.getBlockMetadata(x, y, z) | ; } @Override public boolean isLeaves(World world, int x, int y, int z) { return true; } @Override public String getTextureFile() { return "/warpcraft/blocks/Blocks.png"; } } Quote
Toldea Posted September 10, 2012 Posted September 10, 2012 Can you define what exactly doesn't work? Assuming you are trying to achieve the same effect as vanilla Minecraft (fancy = transparent block and transparent texture, fast = opaque block/texture), this seems wrong: public void setGraphicsLevel(boolean par1) { this.graphicsLevel = par1; this.blockIndexInTexture = this.baseIndexInPNG + 1; <--- } This will always sets the same texture, so you are either always using an opaque or a transparant texture. Quote
GhostSnyperRecon Posted September 10, 2012 Author Posted September 10, 2012 even when its liek this public void setGraphicsLevel(boolean par1) { this.graphicsLevel = par1; this.blockIndexInTexture = this.baseIndexInPNG + (par1 ? 0 : 1); } it only give me one texture Quote
GeoffNukem Posted September 10, 2012 Posted September 10, 2012 On the wiki (here), there is an example of how to set up the Tick Handler. If you haven't already, go through this. In there is an OnRenderTick method. Inside that I do this for my leaves: private void onRenderTick() { if(isWorldLoaded()) { MCGLoader.block_leaves.setGraphicsLevel(fancyGraphics); fancyGraphics = this.mc.gameSettings.fancyGraphics; } } The isWorldLoaded() is just a method checking if the world is loaded (!= null). I then call the leaves' setGraphicsLevel() method which then sets the fancy graphics on/off. I don't use the 'this.blockIndexInTexture' line. Obviously, make sure you change it so that it calls for your leaves block and not mine lol. The code may need cleaning up a bit, but this is how I do it and it works for me. I hope it'll work with you Quote [1.3.2] Minecraft Generations v0.1.0
GhostSnyperRecon Posted September 10, 2012 Author Posted September 10, 2012 i added it and i still dont get any texture changes, anybody willing to post a custom leaves code with working fancy / fast textures that i could have a look at? Quote
Toldea Posted September 10, 2012 Posted September 10, 2012 Have you logged to make sure that function gets called properly? Are you sure baseIndexInPNG + 0 or 1 is the correct texture index? I just tried and for me this works perfectly: public class CustomLeaves extends BlockLeaves { public CustomLeaves(int par1, int par2) { super(par1, par2); } public void setGraphicsLevel(boolean par1) { this.graphicsLevel = par1; this.blockIndexInTexture = (par1 ? 0 : 16); } public String getTextureFile() { return "somecustomtexturefile.png"; } } Fancy ingots or fast swords tree woosh: Quote
Toldea Posted September 10, 2012 Posted September 10, 2012 Btw one quick side note, isOpaqueCube doesn't mean your texture gets rendered with transparancy or not, it determines if it should try to render edges that would be 'invisable' when a block is opaque. If you look at the swords they only render on specific sides (those visable would the block actually be fully opaque) while the ingots version renders them on all sides. Quote
GhostSnyperRecon Posted September 10, 2012 Author Posted September 10, 2012 do i need to add something to my mainmodfile.java? if i do then im an idiot package mod.warp; import java.util.Map; import java.util.logging.Level; import net.minecraft.src.BiomeDecorator; import net.minecraft.src.BiomeGenBase; import net.minecraft.src.BiomeGenPlains; import net.minecraft.src.Block; import net.minecraft.src.BlockFire; import net.minecraft.src.DimensionAPI; import net.minecraft.src.EnumCreatureType; import net.minecraft.src.EnumToolMaterial; import net.minecraft.src.Item; import net.minecraft.src.ItemBlock; import net.minecraft.src.ItemStack; import net.minecraft.src.Material; import net.minecraft.src.WorldProvider; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.DimensionManager; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import java.awt.Color; @Mod(modid = "WarpCraft", name = "WarpCraft", version = "In-Dev 1.0") @NetworkMod( channels = { "WarpCraft" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class ) public class WarpCraft { @Instance public static WarpCraft instance; @SidedProxy(clientSide = "mod.warp.ClientProxy", serverSide = "mod.warp.CommonProxy") public static CommonProxy proxy; //Dimension public static BiomeGenWarp warp; //Blocks public static BlockWarpOre warpOreBlock; public static BlockWarpBlock warpBlockBlock; public static BlockWarpLight warpLight; public static BlockWarpLightON warpLightON; public static BlockWarpCorupt warpCoruptBlock; public static BlockPortalWarp warpPortal; public static BlockWarpFrame warpFrame; public static BlockWarpFire warpFire; public static BlockWarpStone warpStoneBlock; public static BlockWarpBush warpBushBlock; public static BlockWarpCoalOre warpCOBlock; public static BlockWarpLog warpLogBlock; public static BlockWarpLeaves warpLeavesBlock; //Items public static ItemWarpDust warpDustItem; public static ItemWarpIngot warpIngotItem; public static ItemWarpPaxel warpPaxelItem; public static ItemWarpCDust warpCDustItem; public static ItemWarpFS warpFSItem; public static ItemWarpBerry warpBerryItem; public static ItemWarpCoal warpCoalItem; //Config Values // Blocks private int bWarpOreID; private int bWarpBlockID; private int bWarpLightID; private int bWarpLightONID; private int bWarpCoruptBlockID; private int bWarpPortalID; private int bWarpFrameID; private int bWarpFireID; private int bWarpStoneID; private int bWarpBushID; private int bWarpCOID; private int bWarpLogID; private int bWarpLeavesID; // Items private int iWarpDustID; private int iWarpIngotID; private int iWarpPaxelID; private int iWarpCDustID; private int iWarpFSID; private int iWarpBerryID; private int iWarpCoalID; @PreInit public void preInit(FMLPreInitializationEvent event) { // Loading in Configuration Data Configuration cfg = new Configuration(event.getSuggestedConfigurationFile()); try { cfg.load(); // Load Block IDs bWarpOreID = cfg.getOrCreateBlockIdProperty("Warp Ore", 140).getInt(140); bWarpBlockID = cfg.getOrCreateBlockIdProperty("Warp Block", 141).getInt(141); bWarpLightID = cfg.getOrCreateBlockIdProperty("Warp Lamp", 142).getInt(142); bWarpLightONID = cfg.getOrCreateBlockIdProperty("Warp LampON", 143).getInt(143); bWarpCoruptBlockID = cfg.getOrCreateBlockIdProperty("Corupt Warp Ore", 144).getInt(144); bWarpPortalID = cfg.getOrCreateBlockIdProperty("Warp Portal", 145).getInt(145); bWarpFrameID = cfg.getOrCreateBlockIdProperty("Warp Portal Frame", 146).getInt(146); bWarpFireID = cfg.getOrCreateBlockIdProperty("Warp Fire", 147).getInt(147); bWarpStoneID = cfg.getOrCreateBlockIdProperty("Warp Stone", 148).getInt(148); bWarpBushID = cfg.getOrCreateBlockIdProperty("Warp Bush", 149).getInt(149); bWarpCOID = cfg.getOrCreateBlockIdProperty("Warp Coal Ore", 150).getInt(150); bWarpLogID = cfg.getOrCreateBlockIdProperty("Infused Log", 151).getInt(151); bWarpLeavesID = cfg.getOrCreateBlockIdProperty("Infused Leaves", 152).getInt(152); // Load Item IDs iWarpDustID = cfg.getOrCreateIntProperty("Warp Dust", Configuration.CATEGORY_ITEM, 400).getInt(400); iWarpIngotID = cfg.getOrCreateIntProperty("Warp Ingot", Configuration.CATEGORY_ITEM, 401).getInt(401); iWarpPaxelID = cfg.getOrCreateIntProperty("Warp Paxel", Configuration.CATEGORY_ITEM, 402).getInt(402); iWarpCDustID = cfg.getOrCreateIntProperty("Corupt Warp Dust", Configuration.CATEGORY_ITEM, 403).getInt(403); iWarpFSID = cfg.getOrCreateIntProperty("Warp Lighter", Configuration.CATEGORY_ITEM, 404).getInt(404); iWarpBerryID = cfg.getOrCreateIntProperty("Warp Berry", Configuration.CATEGORY_ITEM, 405).getInt(405); iWarpCoalID = cfg.getOrCreateIntProperty("Warp Coal", Configuration.CATEGORY_ITEM, 406).getInt(406); } catch (Exception e) { FMLLog.log(Level.SEVERE, e, "WarpCraft's configuration failed to load."); } finally { cfg.save(); } } @Init public void init(FMLInitializationEvent evt) { // Entity int redColor = (35 << 16)+ (35 << ; int orangeColor = (107 << 16)+ (68 << ; LanguageRegistry.instance().addStringLocalization("entity.Rat.name", "en_US", "Rat"); EntityRegistry.registerGlobalEntityID(EntityRat.class, "Rat", EntityRegistry.findGlobalUniqueEntityId(), redColor, orangeColor); // Initialize Blocks warpOreBlock = new BlockWarpOre(bWarpOreID); warpBlockBlock = new BlockWarpBlock(bWarpBlockID); warpLight = new BlockWarpLight(bWarpLightID); warpLightON = new BlockWarpLightON(bWarpLightONID); warpCoruptBlock = new BlockWarpCorupt(bWarpCoruptBlockID); warpPortal = new BlockPortalWarp(bWarpPortalID); warpFrame = new BlockWarpFrame(bWarpFrameID); warpFire = new BlockWarpFire(bWarpFireID, bWarpBlockID); warpStoneBlock = new BlockWarpStone(bWarpStoneID); warpBushBlock = new BlockWarpBush(bWarpBushID); warpCOBlock = new BlockWarpCoalOre(bWarpCOID); warpLogBlock = new BlockWarpLog(bWarpLogID); warpLeavesBlock = new BlockWarpLeaves(bWarpLeavesID, 0); // Initialize Items warpDustItem = (ItemWarpDust) new ItemWarpDust(iWarpDustID).setIconIndex(0).setItemName("Warp Dust"); warpIngotItem = (ItemWarpIngot) new ItemWarpIngot(iWarpIngotID).setIconIndex(1).setItemName("Warp Ingot"); warpPaxelItem = (ItemWarpPaxel) new ItemWarpPaxel(iWarpPaxelID, EnumToolMaterial.EMERALD).setIconIndex(2).setItemName("Warp Paxel"); warpCDustItem = (ItemWarpCDust) new ItemWarpCDust(iWarpCDustID).setIconIndex(3).setItemName("Corupt Warp Dust"); warpFSItem = (ItemWarpFS) new ItemWarpFS(iWarpFSID).setIconIndex(4).setItemName("Warp Lighter"); warpBerryItem = (ItemWarpBerry) new ItemWarpBerry(iWarpBerryID, 1, true).setIconIndex(5).setItemName("Warp Berry"); warpCoalItem = (ItemWarpCoal) new ItemWarpCoal(iWarpCoalID).setIconIndex(6).setItemName("Warp Coal"); // Entity // Register Blocks GameRegistry.registerBlock(warpOreBlock); GameRegistry.registerBlock(warpBlockBlock); GameRegistry.registerBlock(warpLight); GameRegistry.registerBlock(warpLightON); GameRegistry.registerBlock(warpCoruptBlock); GameRegistry.registerBlock(warpPortal); GameRegistry.registerBlock(warpFrame); GameRegistry.registerBlock(warpFire); GameRegistry.registerBlock(warpStoneBlock); GameRegistry.registerBlock(warpBushBlock); GameRegistry.registerBlock(warpCOBlock); GameRegistry.registerBlock(warpLogBlock); GameRegistry.registerBlock(warpLeavesBlock); // Add Localization Data // Blocks LanguageRegistry.instance().addStringLocalization(warpOreBlock.getBlockName() + ".name", "en_US", "Warp Ore"); LanguageRegistry.instance().addStringLocalization(warpBlockBlock.getBlockName() + ".name", "en_US", "Warp Block"); LanguageRegistry.instance().addStringLocalization(warpLight.getBlockName() + ".name", "en_US", "Warp Lamp"); LanguageRegistry.instance().addStringLocalization(warpLightON.getBlockName() + ".name", "en_US", "Warp Lamp"); LanguageRegistry.instance().addStringLocalization(warpCoruptBlock.getBlockName() + ".name", "en_US", "Corupt Warp Ore"); LanguageRegistry.instance().addStringLocalization(warpPortal.getBlockName() + ".name", "en_US", "Warp Portal"); LanguageRegistry.instance().addStringLocalization(warpFrame.getBlockName() + ".name", "en_US", "Warp Portal Frame"); LanguageRegistry.instance().addStringLocalization(warpFire.getBlockName() + ".name", "en_US", "Warp Fire"); LanguageRegistry.instance().addStringLocalization(warpStoneBlock.getBlockName() + ".name", "en_US", "Warp Stone"); LanguageRegistry.instance().addStringLocalization(warpBushBlock.getBlockName() + ".name", "en_US", "Warp Bush"); LanguageRegistry.instance().addStringLocalization(warpCOBlock.getBlockName() + ".name", "en_US", "Warp Coal Ore"); LanguageRegistry.instance().addStringLocalization(warpLogBlock.getBlockName() + ".name", "en_US", "Infused Log"); LanguageRegistry.instance().addStringLocalization(warpLeavesBlock.getBlockName() + ".name", "en_US", "Infused Leaves"); // Items LanguageRegistry.instance().addStringLocalization(warpDustItem.getItemName() + ".name", "en_US", "Warp Dust"); LanguageRegistry.instance().addStringLocalization(warpIngotItem.getItemName() + ".name", "en_US", "Warp Ingot"); LanguageRegistry.instance().addStringLocalization(warpPaxelItem.getItemName() + ".name", "en_US", "Warp Paxel"); LanguageRegistry.instance().addStringLocalization(warpCDustItem.getItemName() + ".name", "en_US", "Corupt Warp Dust"); LanguageRegistry.instance().addStringLocalization(warpFSItem.getItemName() + ".name", "en_US", "Warp Lighter"); LanguageRegistry.instance().addStringLocalization(warpBerryItem.getItemName() + ".name", "en_US", "Warp Berry"); LanguageRegistry.instance().addStringLocalization(warpCoalItem.getItemName() + ".name", "en_US", "Warp Coal"); // Entity // Register Recipes // Block Recipes GameRegistry.addRecipe(new ItemStack(warpBlockBlock, 1), "xx", "xx", 'x', warpDustItem ); GameRegistry.addRecipe(new ItemStack(warpLight, 1), " x ", "xyx", " x ", 'x', Block.fenceIron, 'y', warpDustItem ); GameRegistry.addRecipe(new ItemStack(warpFrame, 4), " x ", "xyx", " x ", 'x', Block.obsidian, 'y', warpDustItem ); // Item Recipes GameRegistry.addRecipe(new ItemStack(warpPaxelItem, 1), "xxx", "xyx", "xyx", 'x', warpIngotItem, 'y', Item.stick ); GameRegistry.addRecipe(new ItemStack(warpDustItem, 4), "x", 'x', warpBlockBlock ); GameRegistry.addRecipe(new ItemStack(warpFSItem, 1), "xyx", "xzx", "xxx", 'x', Item.ingotIron, 'y', Item.flint, 'z', warpIngotItem ); // Fuel GameRegistry.registerFuelHandler(new WarpFuel()); // Register Smelting GameRegistry.addSmelting(warpDustItem.shiftedIndex, new ItemStack(warpIngotItem), 0.1F); // Ore Generation GameRegistry.registerWorldGenerator(new WorldGeneratorWarpCraft()); GameRegistry.addBiome(warp = new BiomeGenWarp(65)); // Register Rendering Information proxy.registerRenderInformation(); // Register Dimension DimensionAPI.registerDimension(new WorldProviderWarp()); // Entities } @PostInit public void postInit(FMLPostInitializationEvent evt) { // TODO: Add Post-Initialization code such as mod hooks } } Quote
Toldea Posted September 10, 2012 Posted September 10, 2012 Does the setGraphicsLevel function get called or not? Are you certain your code for actually generating the tree properly uses your custom leave block? I don't see you registering a TickHandler anywhere in your main mod file like GeoffNukem suggested, so your function probably just never gets called. Quote
GhostSnyperRecon Posted September 10, 2012 Author Posted September 10, 2012 how would one go about registering a tick handler? im new to crreating stuff like this so i have no idea what im doing. Quote
GeoffNukem Posted September 10, 2012 Posted September 10, 2012 Like I said, read the wiki page I gave the link for. Make a new class file and implement the ITickHandler Interface then register it in your client proxy using something l like this: TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT); Quote [1.3.2] Minecraft Generations v0.1.0
GhostSnyperRecon Posted September 10, 2012 Author Posted September 10, 2012 could you post the main file and the custom leaves file so i can actually see what ive done wrong? Quote
GeoffNukem Posted September 10, 2012 Posted September 10, 2012 This is pretty much what I do, maybe not named as they are here, but the important stuff should be there. The @Mod class. @Mod(modid = "MyMod", name = "My Mod", version = "1.0.0") @NetworkMod ( clientSideRequired = true, serverSideRequired = false) public final class MyMod { @SidedProxy(clientSide = "[MyPackage.ClientProxy", serverSide = "MyPackage.CommonProxy") public static CommonProxy proxy; @Instance public static MyMod instance; @PreInit public void preInit(FMLPreInitializationEvent event) { } @Init public void Load(FMLInitializationEvent event) { proxy.registerRenderInformation(); } ClientProxy class. public class ClientProxy extends CommonProxy { @Override public void registerRenderInformation() { TickRegistry.registerTickHandler(new MyTickHandler(), Side.CLIENT); } } MyTickHandler class. public final class MyTickHandler implements ITickHandler { public MyTickHandler() { } @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { if (type.equals(EnumSet.of(TickType.RENDER))) { onRenderTick(); } else if (type.equals(EnumSet.of(TickType.CLIENT))) { GuiScreen guiscreen = Minecraft.getMinecraft().currentScreen; if (guiscreen != null) { onTickInGUI(guiscreen); } else { onTickInGame(); } } } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.RENDER, TickType.CLIENT); } @Override public String getLabel() { return "MyMod"; } private void onRenderTick() { if(Minecraft.getMinecraft().theWorld != null) { [myLeaves].setGraphicsLevel(Minecraft.getMinecraft().gameSettings.fancyGraphics); } } private void onTickInGame() { } private void onTickInGUI(GuiScreen guiscreen) { } Your leaves class should be okay. Also remember to change the names of the classes and things to the ones you're using. Hope this helps. Quote [1.3.2] Minecraft Generations v0.1.0
GhostSnyperRecon Posted September 10, 2012 Author Posted September 10, 2012 thanks, ive got it working now Quote
Thor597 Posted November 20, 2012 Posted November 20, 2012 My problem is that every time I change the fast/fancy graphic settings my block needs a block update or another one of its type to be placed down in order for it to change texture(but it changes in my hand immediately) and I can see through it and into the block underneath when its fancy Quote http://i.imgur.com/Hppni.png[/img]
SanAndreaP Posted November 20, 2012 Posted November 20, 2012 My problem is that every time I change the fast/fancy graphic settings my block needs a block update or another one of its type to be placed down in order for it to change texture(but it changes in my hand immediately) and I can see through it and into the block underneath when its fancy Which method in your block class do you use to get the texture index? Quote Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
Thor597 Posted November 20, 2012 Posted November 20, 2012 My problem is that every time I change the fast/fancy graphic settings my block needs a block update or another one of its type to be placed down in order for it to change texture(but it changes in my hand immediately) and I can see through it and into the block underneath when its fancy Which method in your block class do you use to get the texture index? Im not entirely sure what you mean by that but here is the block class: package thedecopack.medieval.blocks; import net.minecraft.src.*; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; import java.util.List; import java.util.Random; import thedecopack.medieval.DecoMedieval; public class BlockMedievalCedarLog extends Block { protected BlockMedievalCedarLog(int par1) { super(par1, Material.wood); this.setCreativeTab(DecoMedieval.medievalTab); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1Random) { return 1; } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par1, Random par2Random, int par3) { return this.blockID; } /** * ejects contained items into the world, and notifies neighbours of an update, as appropriate */ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { byte var7 = 4; int var8 = var7 + 1; if (par1World.checkChunksExist(par2 - var8, par3 - var8, par4 - var8, par2 + var8, par3 + var8, par4 + var8)) { for (int var9 = -var7; var9 <= var7; ++var9) { for (int var10 = -var7; var10 <= var7; ++var10) { for (int var11 = -var7; var11 <= var7; ++var11) { int var12 = par1World.getBlockId(par2 + var9, par3 + var10, par4 + var11); if (Block.blocksList[var12] != null) { Block.blocksList[var12].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11); } } } } } } /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public int getBlockTextureFromSide(int i) { if(i == 1 || i == 0) { return 17; } else { return 16; } } @Override public boolean canSustainLeaves(World world, int x, int y, int z) { return true; } @Override public boolean isWood(World world, int x, int y, int z) { return true; } public String getTextureFile() { return DecoMedieval.instance.blockTextureFile(); } } Quote http://i.imgur.com/Hppni.png[/img]
SanAndreaP Posted November 20, 2012 Posted November 20, 2012 My problem is that every time I change the fast/fancy graphic settings my block needs a block update or another one of its type to be placed down in order for it to change texture(but it changes in my hand immediately) and I can see through it and into the block underneath when its fancy Which method in your block class do you use to get the texture index? Im not entirely sure what you mean by that but here is the block class: package thedecopack.medieval.blocks; import net.minecraft.src.*; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; import java.util.List; import java.util.Random; import thedecopack.medieval.DecoMedieval; public class BlockMedievalCedarLog extends Block { protected BlockMedievalCedarLog(int par1) { super(par1, Material.wood); this.setCreativeTab(DecoMedieval.medievalTab); } /** * Returns the quantity of items to drop on block destruction. */ public int quantityDropped(Random par1Random) { return 1; } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par1, Random par2Random, int par3) { return this.blockID; } /** * ejects contained items into the world, and notifies neighbours of an update, as appropriate */ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { byte var7 = 4; int var8 = var7 + 1; if (par1World.checkChunksExist(par2 - var8, par3 - var8, par4 - var8, par2 + var8, par3 + var8, par4 + var8)) { for (int var9 = -var7; var9 <= var7; ++var9) { for (int var10 = -var7; var10 <= var7; ++var10) { for (int var11 = -var7; var11 <= var7; ++var11) { int var12 = par1World.getBlockId(par2 + var9, par3 + var10, par4 + var11); if (Block.blocksList[var12] != null) { Block.blocksList[var12].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11); } } } } } } /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public int getBlockTextureFromSide(int i) { if(i == 1 || i == 0) { return 17; } else { return 16; } } @Override public boolean canSustainLeaves(World world, int x, int y, int z) { return true; } @Override public boolean isWood(World world, int x, int y, int z) { return true; } public String getTextureFile() { return DecoMedieval.instance.blockTextureFile(); } } I meant your leaves. Quote Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
Thor597 Posted November 20, 2012 Posted November 20, 2012 Whoops, I sent the wrong thing. When I wake up in the morning ill post the leaves Quote http://i.imgur.com/Hppni.png[/img]
gravitythief Posted November 20, 2012 Posted November 20, 2012 Since it seems that other people have this problem, what i could do is send a pr to forge that adds a loadrenderers event and passes an instance of a renderer class. It will called each time the world is re-rendered. You can then use the graphics setting. Quote I like collars. XP
SanAndreaP Posted November 20, 2012 Posted November 20, 2012 Since it seems that other people have this problem, what i could do is send a pr to forge that adds a loadrenderers event and passes an instance of a renderer class. It will called each time the world is re-rendered. You can then use the graphics setting. That is not needed. All you need is the graphicsLevel boolean variable from an instance of the BlockLeaves class. It will be set to true automatically when the graphic level is fancy, false if it's fast. I would suggest to extend BlockLeaves. You can also get an instance of a leave block and then get the boolean variable from there, like this: boolean fancy = ((BlockLeaves)Block.blocksList[18]).graphicsLevel Then you can use that boolean in your getTextureFromSideAndMetadata method of your block to determine the fast/fancy texture. Also in isOpaqueCube and in shouldSideBeRendered for correct rendering. Just look at the vanilla leaves code for this. Quote Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
Thor597 Posted November 20, 2012 Posted November 20, 2012 Seems legit Quote http://i.imgur.com/Hppni.png[/img]
gravitythief Posted November 20, 2012 Posted November 20, 2012 What i meant is, in RenderGlobal.class under loadRenderers() There is a specific call to the setGraphicsLevel right before the world is re-rendered. all i have to do is post an event right before or after the call. then in your event listener, you can update the static info in your leaves class. Quote I like collars. XP
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.