Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

KaptainWiz

Members
  • Joined

  • Last visited

  1. I want to add instant structures to my mod but the code just won't work: package com.kaptainwiz.mykindmod.blocks; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class BlockInstantStructure extends Block { Blocks block; public BlockInstantStructure(Material material) { super(material); } public void onBlockPlacedBy(World world, Random random, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack) { super.onBlockPlacedBy(world, x, y, z, entity, itemstack);//Super world.setBlockToAir(x, y, z);//Sets the block to air on the x, y, and z coords from where you placed the block world.setBlock(x, y, z, block.cobblestone);//Sets the block on the x, y, and z coords starting from where you placed the block world.setBlock(x, y+1, z, block.planks, 2, 2); //Sets the block(with set metadata) on the x, y, and z coords from where you placed the block world.setBlock(x+1, y, z+1, block.planks, 2, 2); world.setBlock(x+2, y, z+2, block.planks, 2, 2); world.setBlock(x+3, y, z+3, block.planks, 2, 2); world.setBlock(x+4, y, z+4, block.planks, 2, 2);//This is for birch planks, if you want other planks, search 'Minecraft Block Metadata'in google or find it on the MinecraftWiki } } Here's the registry: public static Block blockInstantStructure; blockInstantStructure = new BlockInstantStructure(Material.anvil).setCreativeTab(SampleTab).setBlockName("Instant").setBlockTextureName("sample:SampleInstant"); GameRegistry.registerBlock(blockInstantStructure, "instant"); This doesn't seem to work when I place the block down.. What now
  2. Thanks it works Now this.mc.renderEngine.bindTexture(new ResourceLocation("/mods/your_mod_name/textures/gui/your_image.png"));
  3. Ok so i wanted to create a Gui Overlay so I went to this website: http://www.minecraftforge.net/wiki/Gui_Overlay I did everything that it said... and then I got an error with this part: .bindTexture("") in this line: this.mc.renderEngine.bindTexture("/mods/your_mod_name/textures/gui/your_image.png"); Here is my code for the Gui Class (this gui overlay is for potion effects) Oh! And can u guys help me with the textures for the overlay... the different potion textures(256x256 pixels) The Code: package com.kaptainwiz.mykindmod.handlers; import java.util.Collection; import java.util.Iterator; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import org.lwjgl.opengl.GL11; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; // // GuiBuffBar implements a simple status bar at the top of the screen which // shows the current buffs/debuffs applied to the character. // public class GuiBuffBar extends Gui { private Minecraft mc; public GuiBuffBar(Minecraft mc) { super(); // We need this to invoke the render engine. this.mc = mc; } private static final int BUFF_ICON_SIZE = 20; private static final int BUFF_ICON_SPACING = BUFF_ICON_SIZE + 10; // 2 pixels between buff icons private static final int BUFF_ICON_BASE_U_OFFSET = 0; private static final int BUFF_ICON_BASE_V_OFFSET = 198; private static final int BUFF_ICONS_PER_ROW = 8; // // This event is called by GuiIngameForge during each frame by // GuiIngameForge.pre() and GuiIngameForce.post(). // @SubscribeEvent(priority = EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent event) { // // We draw after the ExperienceBar has drawn. The event raised by GuiIngameForge.pre() // will return true from isCancelable. If you call event.setCanceled(true) in // that case, the portion of rendering which this event represents will be canceled. // We want to draw *after* the experience bar is drawn, so we make sure isCancelable() returns // false and that the eventType represents the ExperienceBar event. if(event.isCancelable() || event.type != ElementType.EXPERIENCE) { return; } // Starting position for the buff bar - 2 pixels from the top left corner. int xPos = 10; int yPos = 10; Collection collection = this.mc.thePlayer.getActivePotionEffects(); if (!collection.isEmpty()) { GL11.glColor4f(1.0F, 1.0F, 0.0F, 0.0F); GL11.glDisable(GL11.GL_LIGHTING); this.mc.renderEngine.bindTexture("/mods/your_mod_name/textures/gui/your_image.png"); for (Iterator iterator = this.mc.thePlayer.getActivePotionEffects() .iterator(); iterator.hasNext(); xPos += BUFF_ICON_SPACING) { PotionEffect potioneffect = (PotionEffect) iterator.next(); Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; if (potion.hasStatusIcon()) { int iconIndex = potion.getStatusIconIndex(); this.drawTexturedModalRect( xPos, yPos, BUFF_ICON_BASE_U_OFFSET + iconIndex % BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE, BUFF_ICON_BASE_V_OFFSET + iconIndex / BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE, BUFF_ICON_SIZE, BUFF_ICON_SIZE); } } } } }

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.