Jump to content

Recommended Posts

Posted
1 minute ago, Animefan8888 said:

Your ClientProxy. And where do you register your block.

Here is ModBlocks class:

public class ModBlocks {
	
	public static Block nuke;
	
	public static void init(){

		nuke = new Nuke();
		
}
	
	public static void register(){
		registerBlock(nuke);		
	}
	
	private static void registerBlock(Block block) {
		
		GameRegistry.register(nuke);
		ItemBlock item = new ItemBlock(block);
		item.setRegistryName(block.getRegistryName());
		GameRegistry.register(item);
		
	}

	
	public static void registerRenders(){

		
		registerRender(nuke);
	}

	
	public static void registerRender(Block block){
		
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
		
	}

	}

Here is ClientProxy:

@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy{

	
	
	
	
	
	
	@Override
    public void preInit(FMLPreInitializationEvent event) {
        super.preInit(event);
        
        
    }

    @Override
    public void init(FMLInitializationEvent event) {
        super.init(event);
        
       
        
       ModBlocks.registerRenders();
       
       
        
        
        
    }

    @Override
    public void postInit(FMLPostInitializationEvent event) {
        super.postInit(event);
    
       // LootTableList.register(new ResourceLocation(MyMod.MODID, "loot_chest"));
        
        GameRegistry.registerWorldGenerator(new Creeper_Temple(), 2);
        
      
        
	}

    


}

 

  • Replies 78
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted
5 minutes ago, Animefan8888 said:

Call ModBloks.registerRenders in your preInit at least. You could also use the ModelRegistryEvent and RegistryEvent.

That worked thank you!

Posted

Your block registry is broken, it will register the nuke instead of what block you pass into the method...

	private static void registerBlock(Block block) {
		GameRegistry.register(nuke); <-----
		ItemBlock item = new ItemBlock(block);
		item.setRegistryName(block.getRegistryName());
		GameRegistry.register(item);
	}

 

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Posted
2 hours ago, Kokkie said:

Your block registry is broken, it will register the nuke instead of what block you pass into the method...


	private static void registerBlock(Block block) {
		GameRegistry.register(nuke); <-----
		ItemBlock item = new ItemBlock(block);
		item.setRegistryName(block.getRegistryName());
		GameRegistry.register(item);
	}

 

I didnt want to open a new thread so ill just continue it on this one. I am having trouble getting the primed nuke to render correctly. It renders as a regular tnt when I light it. Here is the NukePrimed Class:

package blocks;

import javax.annotation.Nullable;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;

public class NukePrimed extends EntityTNTPrimed
{
	
	 private static final DataParameter<Integer> FUSE = EntityDataManager.<Integer>createKey(EntityTNTPrimed.class, DataSerializers.VARINT);
	    @Nullable
	    private EntityLivingBase tntPlacedBy;
	    /** How long the fuse is */
	    private int fuse;

	    public NukePrimed(World worldIn)
	    {
	        super(worldIn);
	        this.fuse = 80;
	        this.preventEntitySpawning = true;
	        this.setSize(0.98F, 0.98F);
	    }

	    public NukePrimed(World worldIn, double x, double y, double z, EntityLivingBase igniter)
	    {
	        this(worldIn);
	        this.setPosition(x, y, z);
	        float f = (float)(Math.random() * (Math.PI * 2D));
	        this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F);
	        this.motionY = 0.20000000298023224D;
	        this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F);
	        this.setFuse(80);
	        this.prevPosX = x;
	        this.prevPosY = y;
	        this.prevPosZ = z;
	        this.tntPlacedBy = igniter;
	    }

	    protected void entityInit()
	    {
	        this.dataManager.register(FUSE, Integer.valueOf(80));
	    }

	    /**
	     * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
	     * prevent them from trampling crops
	     */
	    protected boolean canTriggerWalking()
	    {
	        return false;
	    }

	    /**
	     * Returns true if other Entities should be prevented from moving through this Entity.
	     */
	    public boolean canBeCollidedWith()
	    {
	        return !this.isDead;
	    }

	    /**
	     * Called to update the entity's position/logic.
	     */
	    public void onUpdate()
	    {
	        this.prevPosX = this.posX;
	        this.prevPosY = this.posY;
	        this.prevPosZ = this.posZ;

	        if (!this.hasNoGravity())
	        {
	            this.motionY -= 0.03999999910593033D;
	        }

	        this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
	        this.motionX *= 0.9800000190734863D;
	        this.motionY *= 0.9800000190734863D;
	        this.motionZ *= 0.9800000190734863D;

	        if (this.onGround)
	        {
	            this.motionX *= 0.699999988079071D;
	            this.motionZ *= 0.699999988079071D;
	            this.motionY *= -0.5D;
	        }

	        --this.fuse;

	        if (this.fuse <= 0)
	        {
	            this.setDead();

	            if (!this.world.isRemote)
	            {
	                this.explode();
	            }
	        }
	        else
	        {
	            this.handleWaterMovement();
	            this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
	        }
	    }
	    
	    public Explosion newExplosion(@Nullable Entity entity, double x, double y, double z, float strength, boolean isFlaming, boolean isSmoking)
	    {
	        CustomExplosion explosion = new CustomExplosion(world, entity, x, y, z, strength, isFlaming, isSmoking);
	        if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(world, explosion)) return explosion;
	        explosion.doExplosionA();
	        explosion.doExplosionB(true);
	        return explosion;
	    }

	    private void explode()
	    {
	    	float f = 100.0F;
	        this.newExplosion(this, this.posX, this.posY, this.posZ, f, false, true);
	    }

	    /**
	     * (abstract) Protected helper method to write subclass entity data to NBT.
	     */ 
	    protected void writeEntityToNBT(NBTTagCompound compound)
	    {
	        compound.setShort("Fuse", (short)this.getFuse());
	    }

	    /**
	     * (abstract) Protected helper method to read subclass entity data from NBT.
	     */
	    protected void readEntityFromNBT(NBTTagCompound compound)
	    {
	        this.setFuse(compound.getShort("Fuse"));
	    }

	    /**
	     * returns null or the entityliving it was placed or ignited by
	     */
	    @Nullable
	    public EntityLivingBase getTntPlacedBy()
	    {
	        return this.tntPlacedBy;
	    }

	    public float getEyeHeight()
	    {
	        return 0.0F;
	    }

	    public void setFuse(int fuseIn)
	    {
	        this.dataManager.set(FUSE, Integer.valueOf(fuseIn));
	        this.fuse = fuseIn;
	    }

	    public void notifyDataManagerChange(DataParameter<?> key)
	    {
	        if (FUSE.equals(key))
	        {
	            this.fuse = this.getFuseDataManager();
	        }
	    }

	    /**
	     * Gets the fuse from the data manager
	     */
	    public int getFuseDataManager()
	    {
	        return ((Integer)this.dataManager.get(FUSE)).intValue();
	    }

	    public int getFuse()
	    {
	        return this.fuse;
	    }
	

}

Here is my NukeRenderClass:

package blocks;

import init.ModBlocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderTNTPrimed;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import noahsmod.main.MyMod;

@SideOnly(Side.CLIENT)
public class RenderNukePrimed extends RenderTNTPrimed
{
    public RenderNukePrimed(RenderManager renderManagerIn)
    {
        super(renderManagerIn);
        this.shadowSize = 0.5F;
    }

   
    public void doRender(NukePrimed entity, double x, double y, double z, float entityYaw, float partialTicks)
    {
        BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
        GlStateManager.pushMatrix();
        GlStateManager.translate((float)x, (float)y + 0.5F, (float)z);

        if ((float)entity.getFuse() - partialTicks + 1.0F < 10.0F)
        {
            float f = 1.0F - ((float)entity.getFuse() - partialTicks + 1.0F) / 10.0F;
            f = MathHelper.clamp(f, 0.0F, 1.0F);
            f = f * f;
            f = f * f;
            float f1 = 1.0F + f * 0.3F;
            GlStateManager.scale(f1, f1, f1);
        }

        float f2 = (1.0F - ((float)entity.getFuse() - partialTicks + 1.0F) / 100.0F) * 0.8F;
        this.bindEntityTexture(entity);
        GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.5F, -0.5F, 0.5F);
        blockrendererdispatcher.renderBlockBrightness(ModBlocks.nuke.getDefaultState(), entity.getBrightness(partialTicks));
        GlStateManager.translate(0.0F, 0.0F, 1.0F);

        if (this.renderOutlines)
        {
            GlStateManager.enableColorMaterial();
            GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            blockrendererdispatcher.renderBlockBrightness(ModBlocks.nuke.getDefaultState(), 1.0F);
            GlStateManager.disableOutlineMode();
            GlStateManager.disableColorMaterial();
        }
        else if (entity.getFuse() / 5 % 2 == 0)
        {
            GlStateManager.disableTexture2D();
            GlStateManager.disableLighting();
            GlStateManager.enableBlend();
            GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.DST_ALPHA);
            GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
            GlStateManager.doPolygonOffset(-3.0F, -3.0F);
            GlStateManager.enablePolygonOffset();
            blockrendererdispatcher.renderBlockBrightness(ModBlocks.nuke.getDefaultState(), 1.0F);
            GlStateManager.doPolygonOffset(0.0F, 0.0F);
            GlStateManager.disablePolygonOffset();
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            GlStateManager.disableBlend();
            GlStateManager.enableLighting();
            GlStateManager.enableTexture2D();
        }

        GlStateManager.popMatrix();
        this.doRender(entity, x, y, z, entityYaw, partialTicks);
    }

    
    protected ResourceLocation getEntityTexture(NukePrimed entity)
  {
        return TextureMap.LOCATION_BLOCKS_TEXTURE;
    }
    
    
    
}

Any help is appreciated, Thanks!

Posted
5 minutes ago, V0idWa1k3r said:

Please show where you are registering your entity renderer. Additionally make sure that your nuke block actually spawns your nuke entity when ignited.

Oh, I don't think I registered it, must've slipped my mind how would I go about doing this?

Posted

You must use RenderingRegistry::registerEntityRenderingHandler (the one overload that takes a class and a IRenderFactory). IRenderFactory is an interface that you can either implement directly or use lambdas. You must call RenderingRegistry::registerEntityRenderingHandler during pre-init from either your client proxy or another client-only class.

Posted
4 minutes ago, V0idWa1k3r said:

You must use RenderingRegistry::registerEntityRenderingHandler (the one overload that takes a class and a IRenderFactory). IRenderFactory is an interface that you can either implement directly or use lambdas. You must call RenderingRegistry::registerEntityRenderingHandler during pre-init from either your client proxy or another client-only class.

should I extend any classes

Posted
5 minutes ago, V0idWa1k3r said:

You must use RenderingRegistry::registerEntityRenderingHandler (the one overload that takes a class and a IRenderFactory). IRenderFactory is an interface that you can either implement directly or use lambdas. You must call RenderingRegistry::registerEntityRenderingHandler during pre-init from either your client proxy or another client-only class.

Also what should I put for the renderer parameter in: RenderingRegistry.registerEntityRenderingHandler(RenderNukePrimed.class, renderer);

Posted

Your renderer must extend any subclass of Render<T> where T is a type of your entity class. Currently you are extending RenderTNTPrimed.

 

1 minute ago, funsize888 said:

Also what should I put for the renderer parameter in: RenderingRegistry.registerEntityRenderingHandler(RenderNukePrimed.class, renderer);

That is a wrong method. Use the other method that takes IRenderingFactory as it's second parameter.

Posted
3 minutes ago, V0idWa1k3r said:

Your renderer must extend any subclass of Render<T> where T is a type of your entity class. Currently you are extending RenderTNTPrimed.

 

That is a wrong method. Use the other method that takes IRenderingFactory as it's second parameter.

Sorry I'm new to rendering entity, I'm kinda lost. I have:

public class ModEntity implements IRenderFactory{

	
	public static void register(){

  createRenderFor(null)
		
	}

	public Render createRenderFor(IRenderFactory renderFactory) {
		RenderingRegistry.registerEntityRenderingHandler(NukePrimed.class, renderFactory);
		return null;
		
	}

	}

lots of errors but I don't know what goes where

Posted
1 minute ago, funsize888 said:

RenderingRegistry.registerEntityRenderingHandler

Call this in your register method.

 

If you are implementing an interface you must implement it's methods which are not default. In your case you must implement 

 

public Render<? super T> createRenderFor(RenderManager manager)

Your IDE most likely will tell you that you need to do so anyway. This method must return a new instance of your Render class(new RenderNukePrimed(manager))

 

4 minutes ago, funsize888 said:

createRenderFor(null)

Blindly passing null into methods is probably a bad idea. Especially if you do not know what those methods do.

 

Here is an example of how to register a renderer for your entity. 

Posted
4 minutes ago, V0idWa1k3r said:

Call this in your register method.

 

If you are implementing an interface you must implement it's methods which are not default. In your case you must implement 

 


public Render<? super T> createRenderFor(RenderManager manager)

Your IDE most likely will tell you that you need to do so anyway. This method must return a new instance of your Render class(new RenderNukePrimed(manager))

 

Blindly passing null into methods is probably a bad idea. Especially if you do not know what those methods do.

 

Here is an example of how to register a renderer for your entity. 

Ok, ty will test when back home

Posted

Ok, I got this, getting errors, still don't quite fully understand

public class ModEntity<T> implements IRenderFactory{

	
	public static void register(){
		
		RenderingRegistry.registerEntityRenderingHandler(RenderNukePrimed.class, factory);
		
	}
		
	
	@Override
	 public Render<? super T> createRenderFor(RenderManager manager){
		
		return (new RenderNukePrimed(manager));
	}

	}

	

 

Posted

I already have this code in my RenderNukePrimed, shouldn't this do the trick?:

 public void doRender(NukePrimed entity, double x, double y, double z, float entityYaw, float partialTicks)

also it shouldn't be rendering as regular tnt it should be rendering as a missing texture, why is it rendering as regular tnt?

Posted
5 hours ago, funsize888 said:

RenderingRegistry.registerEntityRenderingHandler(RenderNukePrimed.class, factory);

What is factory in this context? You do not have a local and/or a field with this name. You must provide an instance of IRenderFactory. This is a basic java concept.

 

5 hours ago, funsize888 said:

also it shouldn't be rendering as regular tnt it should be rendering as a missing texture, why is it rendering as regular tnt?

You can have all the things in the world in your renderer, if it is not registered the game is not aware of it's existance. If no renderer is found for an entity minecraft will use the one for one of the parent classes of the entity.

Posted
3 hours ago, V0idWa1k3r said:

What is factory in this context? You do not have a local and/or a field with this name. You must provide an instance of IRenderFactory. This is a basic java concept.

 

You can have all the things in the world in your renderer, if it is not registered the game is not aware of it's existance. If no renderer is found for an entity minecraft will use the one for one of the parent classes of the entity.

Ok, now I have

public class ModEntities<T> implements IRenderFactory{

	
	public static void register(IRenderFactory factory){
		
		RenderingRegistry.registerEntityRenderingHandler(RenderNukePrimed.class, factory);
		
	}
		
	
	@SuppressWarnings("unchecked")
	@Override
	 public Render<? super T> createRenderFor(RenderManager manager){
		
		return (Render<? super T>) (new RenderNukePrimed(manager));
	}

	}

but I get an error on: registerEntityRenderingHandler. It says: The method registerEntityRenderingHandler(Class<? extends Entity>, Render<? extends Entity>) in the type RenderingRegistry is not applicable for the arguments (Class<RenderNukePrimed>, IRenderFactory)

Posted (edited)
16 minutes ago, funsize888 said:

public static void register(IRenderFactory factory)

Do not use raw types. 

 

16 minutes ago, funsize888 said:

return (Render<? super T>) (new RenderNukePrimed(manager))

Do you know what generics are and how they work? Your type is EntityNukePrimed.

Edited by V0idWa1k3r
Posted
5 minutes ago, V0idWa1k3r said:

Do not use raw types. 

 

Do you know what generics are and how they work? Your type is EntityNukePrimed.

Why would it be EntityNukePrimed, I don't even have a class called that

Posted
2 minutes ago, V0idWa1k3r said:

My mistake, your class is called NukePrimed, without the Entity prefix.

@Override
	 public Render<? super T> createRenderFor(RenderManager manager){
		
		return (Render<? super T>) (new NukePrimed(manager));

this throws a bunch of errors

Posted

Your type, not your render class instance. This is java basics. You do not need to use unknown and raw types as you know for a fact that this IRenderFactory you are implementing is used for registering an entity of type NukePrimed. Thus your type is NukePrimed.

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

    • Hi, i'm really having problems trying to set the texture to my custom item. I thought i'm doing everything correctly, but all i see is the missing texture block for my item. I am trying this for over a week now and getting really frustrated. The only time i could make the texture work, was when i used an older Forge version (52.0.1) for Minecraft (1.21.4). Was there a fundamental change for textures and models somewhere between versions that i'm missing? I started with Forge 54.1.0 and had this problem, so in my frustration i tried many things: Upgrading to Forge 54.1.1, created multiple new projects, workspaces, redownloaded everything and setting things up multiple times, as it was suggested in an older thread. Therea are no errors in the console logs, but maybe i'm blind, so i pasted the console logs to pastebin anyway: https://pastebin.com/zAM8RiUN The only time i see an error is when i change the models JSON file to an incorrect JSON which makes sense and that suggests to me it is actually reading the JSON file.   I set the github repository to public, i would be so thankful if anyone could take a look and tell me what i did wrong: https://github.com/xLorkin/teleport_pug_forge   As a note: i'm pretty new to modding, this is my first mod ever. But i'm used to programming. I had some up and downs, but through reading the documentation, using google and experimenting, i could solve all other problems. I only started modding for Minecraft because my son is such a big fan and wanted this mod.
    • Please read the FAQ (link in orange bar at top of page), and post logs as described there.
    • Hello fellow Minecrafters! I recently returned to Minecraft and realized I needed a wiki that displays basic information easily and had great user navigation. That’s why I decided to build: MinecraftSearch — a site by a Minecraft fan, for Minecraft fans. Key Features So Far Straight-to-the-Point Info: No extra fluff; just the essentials on items, mobs, recipes, loot and more. Clean & Intuitive Layout: Easy navigation so you spend less time scrolling and more time playing. Optimized Search: Search for anything—items, mobs, blocks—and get results instantly. What I’m Thinking of Adding More data/information: Catch chances for fishing rod, traveling villager trades, biomes info and a lot more. The website is still under development and need a lot more data added. Community Contributions: Potential for user-uploaded tips for items/mobs/blocks in the future. Feature Requests Welcome: Your ideas could shape how the wiki evolves! You can see my roadmap at the About page https://minecraftsearch.com/about I’d love for you to check out MinecraftSearch and see if it helps you find the info you need faster. Feedback is crucial—I want to develop this further based on what the community needs most, so please let me know what you think. Thanks, and happy crafting!
    • Instructions on how to install newer Java can be found in the FAQ
    • That's just plain wrong... newer versions are much better optimised and start a lot faster than 1.8.9, both Forge and Minecraft itself. Comparing Fabric 1.21 with Forge 1.8 is like comparing apples and oranges... one's brand new and the other's over a decade old.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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