Jump to content

[SOLVED] Rendering custom projectile


MinecraftWero

Recommended Posts

If you want something to behave similar to vanilla, look at the vanilla implementation and either re-use or extend it as appropriate.

 

In this case, use or extend RenderSnowball to render an entity as an item model.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

On 5/29/2017 at 0:31 AM, Choonster said:

If you want something to behave similar to vanilla, look at the vanilla implementation and either re-use or extend it as appropriate.

 

In this case, use or extend RenderSnowball to render an entity as an item model.

 

I tried using this 

	RenderingRegistry.registerEntityRenderingHandler(EntityBacon.class, new RenderSnowball(ModItems.rawbacon ));

 

 

But it asks me to add arguments and i tried everything but can't figure it out.

Link to comment
Share on other sites

5 hours ago, Jay Avery said:

What arguments does it ask for? Are they objects which you have access to?

 

heres the error 

 

EDIT: Here's my code:

 

	package com.minecraftwero.baconmod.renders;
	 
	import org.lwjgl.opengl.GL11;
	 
	import com.minecraftwero.baconmod.Bacon;
	import com.minecraftwero.baconmod.Reference;
	import com.minecraftwero.baconmod.entities.EntityBacon;
	 
	import net.minecraft.client.renderer.GlStateManager;
	import net.minecraft.client.renderer.Tessellator;
	import net.minecraft.client.renderer.VertexBuffer;
	import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
	import net.minecraft.client.renderer.entity.Render;
	import net.minecraft.client.renderer.entity.RenderEntity;
	import net.minecraft.client.renderer.entity.RenderManager;
	import net.minecraft.client.renderer.entity.RenderSnowball;
	import net.minecraft.client.renderer.texture.TextureMap;
	import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
	import net.minecraft.entity.Entity;
	import net.minecraft.item.ItemStack;
	import net.minecraft.util.ResourceLocation;
	 
	public class RenderBacon extends RenderEntity {
	 
	 
	public RenderBacon(RenderManager renderManagerIn) {
	super(renderManagerIn);
	}
	 
	@Override
	protected ResourceLocation getEntityTexture(Entity entity) {
	return new ResourceLocation(":textures/entity/rawbacon");
	}
	}
	

 

	 
	package com.minecraftwero.baconmod.init;
	import com.minecraftwero.baconmod.Bacon;
import com.minecraftwero.baconmod.Reference;
import com.minecraftwero.baconmod.entities.EntityBacon;
import com.minecraftwero.baconmod.handlers.EntityHandler;
import com.minecraftwero.baconmod.items.BaconLauncher;
import com.minecraftwero.baconmod.items.CookedBacon;
import com.minecraftwero.baconmod.items.RawBacon;
import com.minecraftwero.baconmod.renders.RenderBacon;
import com.minecraftwero.baconmod.util.Utils;
	import net.minecraft.client.Minecraft;
import net.minecraft.client.main.Main;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.common.registry.GameRegistry;
	public class ModItems {
	    private static final String Harvester = null;
    public static Item rawbacon;
    public static Item cookedbacon;
    public static Item baconlauncher;
    
    
    public static void init(){
        rawbacon = new RawBacon("rawbacon", "rawbacon");
        cookedbacon = new CookedBacon("cookedbacon", "cookedbacon");
        baconlauncher = new BaconLauncher("baconlauncher", "baconlauncher");
        
        //Entity Registration
        ResourceLocation baconbullet = new ResourceLocation(Reference.MODID + ":" + "baconbullet" , "inventory");
    //    EntityHandler.registerModEntity(entitybaconres, EntityBacon.class, "entitybaconres", Bacon.instance, 16, 20, true);
        EntityRegistry.registerModEntity(baconbullet, EntityBacon.class, "baconbullet", 1, Reference.MODID, 128, 1, true);
        RenderingRegistry.registerEntityRenderingHandler(EntityBacon.class, new RenderSnowball(ModItems.rawbacon ));
        }
    
    public static void register(){
        registerItem(rawbacon);
        registerItem(cookedbacon);
        registerItem(baconlauncher);
    }
    
    public static void registerRenders(){
        registerRender(rawbacon);
        registerRender(cookedbacon);
        registerRender(baconlauncher);
    }
    
    public static void registerItem(Item item){
        item.setCreativeTab(Bacon.items);
        GameRegistry.register(item);
        Utils.getLogger().info("Registered Item: " + item.getUnlocalizedName().substring(5));
    }
    
    public static void registerRender(Item item){
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, item.getUnlocalizedName().substring(5)), "inventory"));
        Utils.getLogger().info("Registered render for " + item.getUnlocalizedName().substring(5));
    }
    
}
 
	

Edited by MinecraftWero
Link to comment
Share on other sites

Well, your IDE told you what arguments you need to provide. RenderItem can be obtained at Minecraft::getRenderItem(). To obtain a RenderManager you need to properly register your renderer using RenderingRegistry::registerEntityRenderingHandler(Class, IRenderFactory). IRenderFactory::createRenderFor has RenderManager as an argument.

  • Like 1
Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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