Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16] Entity not rendering


Recommended Posts

Hey, 

I'm trying to make blocks that are moving smoothly. For that, I want to create an entity that renders the block. 

I'm registering the renderer but for some reason, it isn't being rendered. 
This is my code of the renderer and the registry

package me.cirex.fluidships.entity.renderer;

import com.mojang.blaze3d.matrix.MatrixStack;

import me.cirex.fluidships.entity.EntityBlock;
import me.cirex.fluidships.entity.model.EntityBlockModel;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.registry.IRenderFactory;

public class EntityBlockRenderer extends EntityRenderer<EntityBlock> {

	protected EntityBlockRenderer(EntityRendererManager renderManager) {
		super(renderManager);
	}

	@Override
	public void render(EntityBlock entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn,
			IRenderTypeBuffer bufferIn, int packedLightIn) {
		System.out.println("test");
		EntityBlockModel model = new EntityBlockModel(entityIn);
		for (net.minecraft.client.renderer.RenderType type : net.minecraft.client.renderer.RenderType
				.getBlockRenderTypes()) {
			model.render(matrixStackIn, bufferIn.getBuffer(type), packedLightIn, 0, 1, 1, 1, 1);
		}
		super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
	}

	@Override
	public ResourceLocation getEntityTexture(EntityBlock entity) {
		return null;
	}


	public static class RenderFactory implements IRenderFactory<EntityBlock> {

		@Override
		public EntityRenderer<? super EntityBlock> createRenderFor(EntityRendererManager manager) {
			return new EntityBlockRenderer(manager);
		}

	}
}
package me.cirex.fluidships.registry;

import me.cirex.fluidships.FluidShips;
import me.cirex.fluidships.block.InvisibleBlock;
import me.cirex.fluidships.entity.EntityBlock;
import me.cirex.fluidships.entity.renderer.EntityBlockRenderer;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ShipRegistry {

	@SuppressWarnings("unchecked")
	public static EntityType<EntityBlock> BLOCK_ENTITY = (EntityType<EntityBlock>) EntityType.Builder
			.create(EntityBlock::new, EntityClassification.MISC).size(1F, 1F)
			.build(FluidShips.MODID + ":block_entity")
			.setRegistryName(new ResourceLocation(FluidShips.MODID, "block_entity"));

	public static Block INVISIBLE_BLOCK = new InvisibleBlock();

	@SubscribeEvent
	public void onBlockRegistry(final RegistryEvent.Register<Block> event) {
		event.getRegistry().register(INVISIBLE_BLOCK);
	}

	@SubscribeEvent
	public void onEntityTypeRegistry(final RegistryEvent.Register<EntityType<? extends Entity>> event) {
		event.getRegistry().register(BLOCK_ENTITY);
	}

	public void registerRenderer() {
		RenderingRegistry.registerEntityRenderingHandler(BLOCK_ENTITY, new EntityBlockRenderer.RenderFactory());
	}

	public void onClientSetup(final FMLClientSetupEvent event) {
		registerRenderer();
	}

}

 

Link to post
Share on other sites
25 minutes ago, diesieben07 said:

An entity is the wrong tool for this.

Show your attempt with a TE.

So far, I'm having problems with what arguments I put in for 
Builder.create

and for new EntityBlockRenderer

package me.cirex.fluidships.registry;

import me.cirex.fluidships.FluidShips;
import me.cirex.fluidships.block.InvisibleBlock;
import me.cirex.fluidships.entity.EntityBlock;
import me.cirex.fluidships.entity.renderer.EntityBlockRenderer;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ShipRegistry {

    public static TileEntityType<?> BLOCK_TILE_ENTITY;

    @SubscribeEvent
    public void onBlockRegistry(final RegistryEvent.Register<Block> event) {

    }

    @SubscribeEvent
    public void onEntityTypeRegistry(final RegistryEvent.Register<TileEntityType<?>> event) {
        BLOCK_TILE_ENTITY = TileEntityType.Builder.create(null, null).build(null);
        event.getRegistry().register(BLOCK_TILE_ENTITY);
    }

    public void registerRenderer() {
        RenderingRegistry.registerEntityRenderingHandler(BLOCK_TILE_ENTITY, new EntityBlockRenderer());
    }

    public void onClientSetup(final FMLClientSetupEvent event) {
        registerRenderer();
    }

}
 

package me.cirex.fluidships.registry;

import me.cirex.fluidships.FluidShips;
import me.cirex.fluidships.block.InvisibleBlock;
import me.cirex.fluidships.entity.EntityBlock;
import me.cirex.fluidships.entity.renderer.EntityBlockRenderer;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ShipRegistry {

	public static TileEntityType<?> BLOCK_TILE_ENTITY;

	@SubscribeEvent
	public void onBlockRegistry(final RegistryEvent.Register<Block> event) {

	}

	@SubscribeEvent
	public void onEntityTypeRegistry(final RegistryEvent.Register<TileEntityType<?>> event) {
		BLOCK_TILE_ENTITY = TileEntityType.Builder.create(null, null).build(null);
		event.getRegistry().register(BLOCK_TILE_ENTITY);
	}

	public void registerRenderer() {
		RenderingRegistry.registerEntityRenderingHandler(BLOCK_TILE_ENTITY, new EntityBlockRenderer());
	}

	public void onClientSetup(final FMLClientSetupEvent event) {
		registerRenderer();
	}

}

 

Link to post
Share on other sites
20 hours ago, diesieben07 said:

That cannot work. A tile entity is bound to specific blocks only. You cannot apply a tile entity to blocks you don't own (e.g. vanilla minecraft blocks).

Well then, apparently a TileEntity isn't the right tool either.

 

21 hours ago, diesieben07 said:

An entity is the wrong tool for this.

Show your attempt with a TE.

 

Link to post
Share on other sites
1 hour ago, diesieben07 said:

Your original post says that you want to make blocks that move smoothly.

That means you want to add a block. You need to implement this block (your own block class) and give it a tile entity.

Well, basically I want to make ships moving like in this video. I don't want a block by block movement though

 (4

Link to post
Share on other sites
12 minutes ago, diesieben07 said:

This is what happens when you don't describe your problem properly.

Why did you not post this information in the first place?

well, that's what I meant with blocks moving smoothly. I'm sorry, anyway, do you know how I'm going to do this?

Link to post
Share on other sites

Try taking a look at Archimedes Ships mod for 1.15 or something, I recall seeing one in reddit but I don't remember the name, since probably nothing much has changed from 1.15 to 1.16 just look at its code and try immitating it, I don't know if it has a github tho.

Edited by MostafaSabry55
Link to post
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.

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

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.