-
Posts
124 -
Joined
-
Last visited
Everything posted by Kakarotvg
-
[solved] changing leaf texture based on graphics level
Kakarotvg replied to Kakarotvg's topic in Modder Support
the issue with being see through is gone, but I still can't get it to switch the texture whenever minecraft is on fancy or fast graphics -
[solved] changing leaf texture based on graphics level
Kakarotvg replied to Kakarotvg's topic in Modder Support
Here is the new code with the @Override annotations images of whats happening -
you can also use techne. I made tutorials on this for the techne modelling for the custom block modeling
-
[solved] changing leaf texture based on graphics level
Kakarotvg replied to Kakarotvg's topic in Modder Support
please help -
[solved] changing leaf texture based on graphics level
Kakarotvg replied to Kakarotvg's topic in Modder Support
thanks, the normal minecraft code is wierd, it returns false in the super constructor, yet when I do that with my block, it renders all weird. -
I was wondering how you would get a custom leaf block to change between an opaque texture, when using fast graphics and the normal semitransparent texture when using fancy. I know minecraft does it, but I can't figure out how. here is the leaf block class package kakarotvg.omega.blocks; import java.util.ArrayList; import java.util.List; import java.util.Random; import kakarotvg.omega.Reference; import kakarotvg.omega.handlers.blocks.BlockHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockLeavesBase; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class TealLeaf extends BlockLeavesBase implements IShearable { public static final String[] VGLEAF_TYPES = new String[] { "tealleaf" }; public static final String[][] field_94396_b = new String[][] { { Reference.MOD_ID + ":" + "tealleaf" }, { Reference.MOD_ID + ":" + "tealleafopaque" } }; @SideOnly(Side.CLIENT) /** 1 for fast graphic. 0 for fancy graphics. used in iconArray. */ private int iconType; private Icon[][] iconArray = new Icon[2][]; int[] adjacentTreeBlocks; public TealLeaf(int par1, Material material) { super(par1, material, true); this.setTickRandomly(true); this.setCreativeTab(CreativeTabs.tabDecorations); } /** * Called on server worlds only when the block has been replaced by a different block ID, or the same block with a different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old metadata */ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { byte b0 = 1; int j1 = b0 + 1; if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1)) { for (int k1 = -b0; k1 <= b0; ++k1) { for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2); if (Block.blocksList[j2] != null) { Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2); } } } } } } /** * 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 l = par1World.getBlockMetadata(par2, par3, par4); if ((l & != 0 && (l & 4) == 0) { byte b0 = 4; int i1 = b0 + 1; byte b1 = 32; int j1 = b1 * b1; int k1 = b1 / 2; if (this.adjacentTreeBlocks == null) { this.adjacentTreeBlocks = new int[b1 * b1 * b1]; } int l1; if (par1World.checkChunksExist(par2 - i1, par3 - i1, par4 - i1, par2 + i1, par3 + i1, par4 + i1)) { int i2; int j2; int k2; for (l1 = -b0; l1 <= b0; ++l1) { for (i2 = -b0; i2 <= b0; ++i2) { for (j2 = -b0; j2 <= b0; ++j2) { k2 = par1World.getBlockId(par2 + l1, par3 + i2, par4 + j2); Block block = Block.blocksList[k2]; if (block != null && block.canSustainLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0; } else if (block != null && block.isLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2; } else { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1; } } } } for (l1 = 1; l1 <= 4; ++l1) { for (i2 = -b0; i2 <= b0; ++i2) { for (j2 = -b0; j2 <= b0; ++j2) { for (k2 = -b0; k2 <= b0; ++k2) { if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) { if (this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1; } } } } } } } l1 = this.adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1]; if (l1 >= 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, l & -9, 4); } 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 d0 = (double) ((float) par2 + par5Random.nextFloat()); double d1 = (double) par3 - 0.05D; double d2 = (double) ((float) par4 + par5Random.nextFloat()); par1World.spawnParticle("dripWater", d0, d1, d2, 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.setBlockToAir(par2, par3, par4); } /** * 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 BlockHandler.tealsapling.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) { int j1 = 20; if ((par5 & 3) == 3) { j1 = 40; } if (par7 > 0) { j1 -= 2 << par7; if (j1 < 10) { j1 = 10; } } if (par1World.rand.nextInt(j1) == 0) { int k1 = this.idDropped(par5, par1World.rand, par7); this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(k1, 1, this.damageDropped(par5))); } j1 = 200; if (par7 > 0) { j1 -= 10 << par7; if (j1 < 40) { j1 = 40; } } if ((par5 & 3) == 0 && par1World.rand.nextInt(j1) == 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); } public 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 Icon getIcon(int par1, int par2) { return this.iconArray[this.iconType][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.iconType = par1 ? 0 : 1; } @SideOnly(Side.CLIENT) /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); } /** * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. */ protected ItemStack createStackedBlock(int par1) { return new ItemStack(this.blockID, 1, par1 & 3); } @SideOnly(Side.CLIENT) /** * When this method is called, your block should register all the icons it needs with the given IconRegister. This * is the only chance you get to register icons. */ public void registerIcons(IconRegister register) { for (int i = 0; i < field_94396_b.length; ++i) { this.iconArray[i] = new Icon[field_94396_b[i].length]; for (int j = 0; j < field_94396_b[i].length; ++j) { this.iconArray[i][j] = register.registerIcon(field_94396_b[i][j]); } } } @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.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4); } @Override public boolean isLeaves(World world, int x, int y, int z) { return true; } }
-
I got it working as it turns out this line in the super constructor needed to be true not false. super(par1, material, true);
-
Hi I am having a problem with getting the texture for my leaf to load, for some reason it keeps giving me the missing texture, texture. Edit: so i have the texture working now but something weird happened please help images as you can see the leaves aren't rendering properly please help leaf class
-
try changing protected ModelPowerBeam powerbeamModel; to private ModelPowerBeam powerbeamModel; and try using the latest version of forge instead of the recommended version from here http://www.files.minecraftforge.net in the latest versions func_110577_a was replaced with bindTexture so try using that, as well as what I said above about the private, if it still doesn't work let me know.
-
may I see your code please
-
we cant help you unless you post the error log
-
i just so happened to make a video tutorial for this
-
also try turning this MinecraftForgeClient.registerItemRenderer(dubGun.itemID, (IItemRenderer)new ItemRendererWubGun()); into this because you dont need (IItemRenderer) it extends it therefore it doesn't need to be cast to it. MinecraftForgeClient.registerItemRenderer(dubGun.itemID, new ItemRendererWubGun()); also try putting it in your clientproxy class
-
you may also want to try having the resource location as a private static final method, then register it like this //this gets the textures private static final ResourceLocation resourceloc = new (ResourceLocation"mac_dubstepgun", "textures/models/dg3d.png"); // this calls the texture FMLClientHandler.instance().getClient().renderEngine.bindTexture(resourceloc); what this means is that your texture path must look like this "/assets/mac_dubstepgun/textures/models/dg3d.png"
-
[SOLVED]Inventory render custom model block
Kakarotvg replied to xGamer_Allx's topic in Modder Support
your right after updating the bindtexture method was there -
[SOLVED]Inventory render custom model block
Kakarotvg replied to xGamer_Allx's topic in Modder Support
will check that out right now -
[SOLVED]Inventory render custom model block
Kakarotvg replied to xGamer_Allx's topic in Modder Support
I just tried the FMLClientHandler.instance().getClient().renderEngine.bindtexture(TEXTURE); in my mod and it could not find bindtexture but this worked FMLClientHandler.instance().getClient().renderEngine.func_110577_a(resourceloc); -
[SOLVED]Inventory render custom model block
Kakarotvg replied to xGamer_Allx's topic in Modder Support
so actually it can have a comma or a : it doesn't matter it works both ways, but bindtexture does not exist anymore -
[SOLVED]Inventory render custom model block
Kakarotvg replied to xGamer_Allx's topic in Modder Support
this is 1.6.2 bind texture does not exist and registering textures requires this format for custom mobs and custom blocks ("modid:texture/(pathtoimage).png -
[SOLVED]Inventory render custom model block
Kakarotvg replied to xGamer_Allx's topic in Modder Support
this is what I get when my block is in game so im not sure what your talking about -
[SOLVED]Inventory render custom model block
Kakarotvg replied to xGamer_Allx's topic in Modder Support
That took me while to figure out but now that I know it its easy first you need an Item render class for it such as this Disclaimer: this works for blocks, may or may not work for items itemcomputerrenderer package kakarotvg.omega.render.itemrender; import kakarotvg.omega.entity.tileentity.TileEntityComputerEntity; import kakarotvg.omega.model.ModelComputer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; public class ItemComputerRenderer implements IItemRenderer { private ModelComputer computermodel; public ItemComputerRenderer() { computermodel = new ModelComputer(); } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { // TODO Auto-generated method stub return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { // TODO Auto-generated method stub return true; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { TileEntityRenderer.instance.renderTileEntityAt(new TileEntityComputerEntity(), 0.0D, 0.0D, 0.0D, 0.0f); } } then you need to register the item renderer in your client proxy package kakarotvg.omega.proxys; import kakarotvg.omega.entity.mobs.EntityAnnihilator; import kakarotvg.omega.entity.mobs.EntityEliminator; import kakarotvg.omega.entity.mobs.EntityJungleAssasin; import kakarotvg.omega.entity.mobs.EntityOmegaHound; import kakarotvg.omega.entity.mobs.EntityOmegakiller; import kakarotvg.omega.entity.mobs.EntitySlayer; import kakarotvg.omega.entity.tileentity.TileEntityComputerEntity; import kakarotvg.omega.entity.tileentity.TileEntityDarknessSolidEntity; import kakarotvg.omega.handlers.tileentity.TileEntityHandler; import kakarotvg.omega.model.ModelAnnihilator; import kakarotvg.omega.model.ModelEliminator; import kakarotvg.omega.model.ModelJungleAsasin; import kakarotvg.omega.model.ModelOmegaHound; import kakarotvg.omega.model.ModelOmegakiller; import kakarotvg.omega.model.ModelSlayer; import kakarotvg.omega.render.itemrender.ItemComputerRenderer; import kakarotvg.omega.render.itemrender.UnderworldChestItemRender; import kakarotvg.omega.render.mobs.RenderAnnihilator; import kakarotvg.omega.render.mobs.RenderEliminator; import kakarotvg.omega.render.mobs.RenderJungleAssasin; import kakarotvg.omega.render.mobs.RenderOmegaHound; import kakarotvg.omega.render.mobs.RenderOmegaKiller; import kakarotvg.omega.render.mobs.RenderSlayer; import kakarotvg.omega.render.tileentity.TileEntityComputerRenderer; import kakarotvg.omega.render.tileentity.TileEntityDarknessSolidRenderer; import kakarotvg.omega.render.tileentity.TileEntityUnderworldchestrenderer; import kakarotvg.omega.tileentity.TileEntityUnderworldChest; import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy { public void registerRenderInformation() { // Renders the Mobs RenderingRegistry.registerEntityRenderingHandler(EntityOmegaHound.class, new RenderOmegaHound(new ModelOmegaHound(), 0.05F)); RenderingRegistry.registerEntityRenderingHandler(EntityOmegakiller.class, new RenderOmegaKiller(new ModelOmegakiller(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityEliminator.class, new RenderEliminator(new ModelEliminator(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntitySlayer.class, new RenderSlayer(new ModelSlayer(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityAnnihilator.class, new RenderAnnihilator(new ModelAnnihilator(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityJungleAssasin.class, new RenderJungleAssasin(new ModelJungleAsasin(), 0.5F)); } public void registerRenderThings() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDarknessSolidEntity.class, new TileEntityDarknessSolidRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityComputerEntity.class, new TileEntityComputerRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityUnderworldChest.class, new TileEntityUnderworldchestrenderer()); // the item renderers MinecraftForgeClient.registerItemRenderer(TileEntityHandler.underworldchest.blockID, new UnderworldChestItemRender()); MinecraftForgeClient.registerItemRenderer(TileEntityHandler.computer.blockID, new ItemComputerRenderer()); } @Override public void registerRenders() { } @Override public int addArmor(String armor) { return RenderingRegistry.addNewArmourRendererPrefix(armor); } } then you need to make sure that if your block rotates based on your direction when placing it. then you have to have an if else statement for the world package kakarotvg.omega.render.tileentity; import kakarotvg.omega.Reference; import kakarotvg.omega.model.ModelComputer; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; public class TileEntityComputerRenderer extends TileEntitySpecialRenderer { //The model of your block public final ModelComputer model; private static final ResourceLocation resourceloc = new ResourceLocation(Reference.MOD_ID + ":" + "textures/tileentity/computer.png"); public TileEntityComputerRenderer() { this.model = new ModelComputer(); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { //The PushMatrix tells the renderer to "start" doing something. GL11.glPushMatrix(); //This is setting the initial location. GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); //This is the texture of your block. It's pathed to be the same place as your other blocks here. //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! Minecraft.getMinecraft().renderEngine.func_110577_a(resourceloc); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); adjustLightFixture(te.worldObj, te.xCoord, te.yCoord, te.zCoord, te.blockType); //A reference to your Model file. Again, very important. //Tell it to stop rendering for both the PushMatrix's GL11.glPopMatrix(); GL11.glPopMatrix(); } //Set the lighting stuff, so it changes it's brightness properly. private void adjustLightFixture(World world, int i, int j, int k, Block block) { // the if statement checking for if the world is null or not if not renders the block if null renders the item model // != means not equal if (world != null) { int dir = world.getBlockMetadata(i, j, k); GL11.glPushMatrix(); //This line actually rotates the renderer. GL11.glRotatef(dir * (90F), 0F, 1F, 0F); this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); /* * Place your rendering code here. */ GL11.glPopMatrix(); } else { GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); } } } -
ok so first of all your registering your texture wrong it should this Minecraft.getMinecraft().renderEngine.func_110577_a(new ResourceLocation("mac_dubstepgun:textures/models/dg3d.png")); or this Minecraft.getMinecraft().renderEngine.func_110577_a(new ResourceLocation("mac_dubstepgun"+ ":"+"textures/models/dg3d.png")); and as for the render function try replacing data[1] with null and see if that works.
-
For those who were wondering these are images of the custom gui working properly
-
Thanks to diesieben07 my custom chest is now working here is my guihandler code