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.

Featured Replies

Posted

Hi, I am a veteran java programmer and also frequently make mods for bukkit. I thought

I would try out forge modding, it sounded interesting. But, I am a noob at forge and need some help with some

code that is probably simple to yall. When I run minecraft the entity Bolt is not rendered when fired from the Blaster Item.

It simply does not show up, but, it acts like it works, meaning when the invisible bolt impacts the world all the code is run and the explosion is created, its just not shown to the player.

Heres the code:

 

Base Code:

package com.fredtech.tutorial.wuppy;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
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.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid = Wuppy.modid, name = "Wuppy", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Wuppy {

@Instance("Wuppy")
public static Wuppy instance;

@SidedProxy(clientSide="com.fredtech.tutorial.wuppy.client.ClientProxy", serverSide="com.fredtech.tutorial.wuppy.CommonProxy")
public static CommonProxy proxy;

public static final String modid = "FredTech_Wuppy";

public static Block testBlock;

public static Item testItem;
public static Item blaster;

@Init
public void load(FMLInitializationEvent event){
	proxy.registerRenderInformation();
	testBlock = new TestBlock(500, Material.rock).setUnlocalizedName("testBlock");
	testItem = new TestItem(5000).setUnlocalizedName("testItem");
	blaster = new Blaster(5001).setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("blaster");
	Register.registerItems();


}

}

 

Register:

package com.fredtech.tutorial.wuppy;

import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

public class Register {

public static void registerItems(){

	ItemStack godSword = new ItemStack(Item.swordDiamond);
	godSword.addEnchantment(Enchantment.unbreaking, 10);
	godSword.addEnchantment(Enchantment.smite, 10);
	godSword.addEnchantment(Enchantment.knockback, 2);
	godSword.addEnchantment(Enchantment.looting, 10);
	godSword.addEnchantment(Enchantment.fireAspect, 10);
	godSword.addEnchantment(Enchantment.sharpness, 10);
	godSword.addEnchantment(Enchantment.baneOfArthropods, 10);

	GameRegistry.registerBlock(Wuppy.testBlock, Wuppy.modid+Wuppy.testBlock.getUnlocalizedName2());
	GameRegistry.addShapelessRecipe(new ItemStack(Wuppy.testBlock), new Object[]{
		new ItemStack(Item.diamond, 1), new ItemStack(Block.stone, 1),new ItemStack(Item.dyePowder, 1, 15)
	});
	GameRegistry.addRecipe(new ItemStack(Wuppy.testBlock), new Object[]{
	"XZX",
	"CXC",
	'X', Item.ingotGold, 'C', Block.stone, 'Z', new ItemStack(Item.dyePowder, 1, 15)
	});
	GameRegistry.addRecipe(godSword, new Object[]{
	"  C",
	" B ",
	"A  ",
	'A', Item.stick, 'B', new ItemStack(Item.diamond, 5), 'C', new ItemStack(Item.emerald, 5)
	});	



	LanguageRegistry.addName(Wuppy.testBlock, "Test Block");
	LanguageRegistry.addName(Wuppy.testItem, "Test Item");
	LanguageRegistry.addName(Wuppy.blaster, "Blaster");


	MinecraftForge.EVENT_BUS.register(new ItemClickHandle());

}

}

 

The Renderer Class

package com.fredtech.tutorial.wuppy;

import net.minecraft.client.renderer.Tessellator;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.util.MathHelper;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.util.MathHelper;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class BoltRenderer extends Render {


    public void renderBolt(Bolt par1EntityArrow, double par2, double par4, double par6, float par8, float par9)
    {
        this.loadTexture("/item/arrows.png");
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
        Tessellator tessellator = Tessellator.instance;
        byte b0 = 0;
        float f2 = 0.0F;
        float f3 = 0.5F;
        float f4 = (float)(0 + b0 * 10) / 32.0F;
        float f5 = (float)(5 + b0 * 10) / 32.0F;
        float f6 = 0.0F;
        float f7 = 0.15625F;
        float f8 = (float)(5 + b0 * 10) / 32.0F;
        float f9 = (float)(10 + b0 * 10) / 32.0F;
        float f10 = 0.05625F;
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        float f11 = 0;

        if (f11 > 0.0F)
        {
            float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
            GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
        }

        GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
        GL11.glScalef(f10, f10, f10);
        GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
        GL11.glNormal3f(f10, 0.0F, 0.0F);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
        tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
        tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
        tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
        tessellator.draw();
        GL11.glNormal3f(-f10, 0.0F, 0.0F);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
        tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
        tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
        tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
        tessellator.draw();

        for (int i = 0; i < 4; ++i)
        {
            GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
            GL11.glNormal3f(0.0F, 0.0F, f10);
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
            tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
            tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
            tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
            tessellator.draw();
        }

        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
    }

    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        this.renderBolt((Bolt)par1Entity, par2, par4, par6, par8, par9);
    }

}

 

The Entity Code:

package com.fredtech.tutorial.wuppy;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class Bolt extends EntityThrowable {

public Bolt(World par1World) {
	super(par1World);
	// TODO Auto-generated constructor stub
	setThrowableHeading(this.motionX, this.motionY, this.motionZ, 2.0F, 1.0F);
}

public Bolt(World par1World, EntityLiving par2EntityLiving) {
	super(par1World, par2EntityLiving);

	setThrowableHeading(this.motionX, this.motionY, this.motionZ, 2.0F, 1.0F);
}

public Bolt(World par1World, double par2, double par4, double par6) {
	super(par1World, par2, par4, par6);
	setThrowableHeading(this.motionX, this.motionY, this.motionZ, 2.0F, 1.0F);
}

@Override
protected void onImpact(MovingObjectPosition movingobjectposition) {

	try
	{
		EntityLiving mob = (EntityLiving) movingobjectposition.entityHit;
		mob.setEntityHealth(mob.getHealth() - 20);
		mob.setFire(60);
	}
	catch(Exception e){

	}
	this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3.0F, true);
	this.setDead();

}

@Override
protected float getGravityVelocity()
{		
	return 0;		
}

}

 

And the client proxy:

package com.fredtech.tutorial.wuppy.client;

import com.fredtech.tutorial.wuppy.Bolt;
import com.fredtech.tutorial.wuppy.BoltRenderer;
import com.fredtech.tutorial.wuppy.CommonProxy;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraftforge.client.MinecraftForgeClient;

public class ClientProxy extends CommonProxy {

@Override
public void registerRenderInformation()
{
	EntityRegistry.registerGlobalEntityID(Bolt.class, "Bolt", EntityRegistry.findGlobalUniqueEntityId());
	RenderingRegistry.instance().registerEntityRenderingHandler(Bolt.class, new BoltRenderer());  
       
}
}

 

That should be all yall need to look at, the rest of the mod is working fine.

Thanks so much.

		EntityRegistry.registerModEntity(EntityTractor.class,"entityTractor",0,this,256,1,true);
and
	RenderingRegistry.registerEntityRenderingHandler(EntityTractor.class,new RenderTractor());

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Generally where you do your other GameRegistry, LanguageRegistry, and EntityRegistry stuff.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.