Jump to content

Recommended Posts

Posted

In a 1.7.10 mod I made a bomb that could be thrown and explodes on impact, and it worked.

However, I'm having trouble updating it to 1.8.

 

When I throw the item after trying to update the code it crashes.

(With this if it matters)

 

I can't find anything about rendering simple thrown projectiles in 1.8 or about updating it to 1.8, and there are still pretty much no YouTube tutorials at all for 1.8 except for simple blocks and items. So I'm kind of at a loss here.

 

Main class:

 

@Mod(modid = Main.MODID, name = Main.NAME, version = Main.VERSION)

public class Main

{

@SidedProxy(clientSide = "apocalypse.publicraft.network.ClientProxy", serverSide = "apocalypse.publicraft.network.CommonProxy")

public static CommonProxy proxy;

 

    public static final String MODID = "publicraft";

    public static final String NAME = "PubliCraft";

    public static final String VERSION = "0.1";

 

    public static final Tabs tabPubliCraft = new Tabs("tabPubliCraft");

   

    public static Generation generation = new Generation();

   

   

   

    @EventHandler

    public void preInit(FMLPreInitializationEvent event)

    {

    PubliConfig.init(event);

    ItemReg.register();

    BlockReg.register();

    }

    @EventHandler

    public void init(FMLInitializationEvent event)

    {

    proxy.registerRenders();

    proxy.renderProjectiles();

 

    EntityRegistry.registerModEntity(EntityBomb.class, "Bomb", PubliConfig.bombID(), this, 64, 10, true);

   

    }

    @EventHandler

    public void postInit(FMLPostInitializationEvent event)

    {

   

    }

}

 

 

 

Bomb item:

 

public class Bomb extends Item

{

 

public Bomb()

{

super();

setMaxStackSize(1);

 

}

public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)

{

if (!player.capabilities.isCreativeMode)

{

--stack.stackSize;

}

 

world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

 

if (!world.isRemote)

{

world.spawnEntityInWorld(new EntityBomb(world, player));

}

 

return stack;

}

 

}

 

 

 

 

ClientProxy:

 

public class ClientProxy extends CommonProxy

{

@Override

public void registerRenders()

{

ItemReg.render();

BlockReg.render();

}

 

@SideOnly(Side.CLIENT)

@Override

public void renderProjectiles()

{

    RenderingRegistry.registerEntityRenderingHandler(EntityBomb.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), ItemReg.bomb, null));

 

}

}

 

 

 

Item registry:

 

 

public class ItemReg

{

public static Item bomb;

public static void register()

{

bomb = new Bomb().setUnlocalizedName("bomb").setCreativeTab(Main.tabPubliCraft);

GameRegistry.registerItem(bomb, bomb.getUnlocalizedName().substring(5));

}

public static void render()

{

registerRender(bomb);

}

public static void registerRender(Item item)

{

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Main.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

}

}

 

 

 

Could someone please shed some light on why this isn't working?

 

Posted

Caused by: java.lang.NullPointerException

        at net.minecraft.client.renderer.entity.RenderSnowball.doRender(RenderSnowball.java:41) ~[RenderSnowball.class:?]

 

RenderSnowball code please, and please mark line 41 if you could.

Posted

 

package net.minecraft.client.renderer.entity;

 

import net.minecraft.client.renderer.GlStateManager;

import net.minecraft.client.renderer.texture.TextureMap;

import net.minecraft.entity.Entity;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

 

@SideOnly(Side.CLIENT)

public class RenderSnowball extends Render

{

    protected final Item field_177084_a;

    private final RenderItem field_177083_e;

    private static final String __OBFID = "CL_00001008";

 

    public RenderSnowball(RenderManager p_i46137_1_, Item p_i46137_2_, RenderItem p_i46137_3_)

    {

        super(p_i46137_1_);

        this.field_177084_a = p_i46137_2_;

        this.field_177083_e = p_i46137_3_;

    }

 

    /**

    * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then

    * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic

    * (Render<T extends Entity>) and this method has signature public void func_76986_a(T entity, double d, double d1,

    * double d2, float f, float f1). But JAD is pre 1.5 so doe

    */

    public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks)

    {

        GlStateManager.pushMatrix();

        GlStateManager.translate((float)x, (float)y, (float)z);

        GlStateManager.enableRescaleNormal();

        GlStateManager.scale(0.5F, 0.5F, 0.5F);

        GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);

        GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);

        this.bindTexture(TextureMap.locationBlocksTexture);

        this.field_177083_e.renderItemModel(this.func_177082_d(entity));                                    //      <------------------ Line 41

        GlStateManager.disableRescaleNormal();

        GlStateManager.popMatrix();

        super.doRender(entity, x, y, z, p_76986_8_, partialTicks);

    }

 

    public ItemStack func_177082_d(Entity p_177082_1_)

    {

        return new ItemStack(this.field_177084_a, 1, 0);

    }

 

    /**

    * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.

    */

    protected ResourceLocation getEntityTexture(Entity entity)

    {

        return TextureMap.locationBlocksTexture;

    }

}

 

Posted

Firstly remove __OBFID, that's vanilla classes only (From what I've heard)

Secondly I suggest naming your variables to something other than srg names, rather than private final RenderItem field_177083_e; you can call it renderItem or something more understandable. Same with the methods.

 

Lastly either field_177083_e, field_177084_a, or entity is null on line 41. My best guess is that it is entity, add these 3 lines above line 41 to find out which one it is

 

System.out.println("RenderItem " + (field_177083_e == null));
System.out.println("Item " + (field_177084_a == null));
System.out.println("entity " + (entity == null));

Posted

Oh derp, So basically you're trying to get your entity to render as a snowball? I wouldn't know what the issue is if it is a vanilla class, unless this happens with vanilla snowballs as well.

Posted

No wonder if you are putting NULL to RenderItem:

Code:

public RenderSnowball(RenderManager p_i46137_1_, Item p_i46137_2_, RenderItem p_i46137_3_)

 

You:

new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), ItemReg.bomb, null)

 

You need to Minecraft.getMinecraft().getRenderItem()

 

 

1.7.10 is no longer supported by forge, you are on your own.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Ignore shrimple, it doesn't work with Oculus. Also, enableShaders was alr true when it said that towards the end of the log. If you could also figure out why my tags are messed up that'd be cool too, but that's a later issue. https://drive.google.com/drive/folders/1ovEKDZECUCl7zZxGfpyQcS4s5PZPQyfa?usp=drive_link
    • accidental duplicate mesage cuz lag
    • https://gnomebot.dev/paste/231527759279685634/1372324909073563730/1372324908629102716 https://gnomebot.dev/paste/231527759279685634/1372320454861262908/1372320454299090996 seems like theres a registry sync error, not sure what that means though, however in an old pack i played on, i actually had a registry sync error happen whenever the world tried too save and it would suddenly stop loading chunks, is there a mod fix for this or some way too bypass registry syncing? is this a server problem? i have no issues with the pack on pc, only on my server.
    • i think the problem is the player animator library but i need it for one of my main mods is there any way i can fix this? The game crashed: rendering overlay Error: java.lang.IllegalArgumentException: Failed to create player model for default heres the crash report: https://pastebin.com/U5Wp8ysb
    • I have been an enthusiastic investor in crypt0currencies for several years, and my digital assets have been integral to my financial strategy. A few months ago, I encountered a distressing predicament when I lost access to my primary cryptocurrency walleet after clicking on an airdrop link that inadvertently connected to my walleet. The dread of potentially losing all my hard-earned funds was overwhelming, leaving me uncertain about where to seek assistance. In my pursuit of solutions, I stumbled upon ChainDigger Retrievers. From our initial consultation to the triumphant recovery of my assets, the team exhibited exceptional expertise. They provided comprehensive explanations of the recovery process, ensuring I was informed at every stage and offering reassurance during this tumultuous time. Their approach was not only meticulous but also compassionate, which significantly alleviated my anxiety. ChainDigger Retrievers unwavering commitment to resolving my issue was evident throughout the process. Leveraging their profound understanding of crypt0currency technology and digital forensics, they initiated an exhaustive investigation to trace the transactions linked to my compromised wallet. Their meticulous analysis and relentless determination were apparent as they left no stone unturned in their quest to recover my funds. After several days of diligent investigation, the team successfully recovered everything I had lost. They uncovered that the link I had clicked contained malware, which scammeers had used to infiltrate my walleet. This revelation was both alarming and enlightening, underscoring the inherent risks associated with crypt0currency transactions when proper precautions are not taken.Thanks to ChainDigger Retrievers, I not only regained everything but also acquired invaluable knowledge about safeguarding my investments. Their expertise and steadfast support transformed a daunting situation into a manageable one, and I am profoundly grateful for their assistance. I can now continue my investment journey with renewed confidence, knowing that I have a trustworthy ally in ChainDigger Retrievers. Their client satisfaction is truly commendable, and I wholeheartedly recommend their services to anyone facing similar challenges in the crypt0currency realm. With their help, I was able to turn a distressing time into a positive outcome, and I will forever be grateful for their support.  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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