Posted July 9, 20205 yr 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(); } }
July 9, 20205 yr Author 1 hour ago, diesieben07 said: You don't need an entity. Look at e.g. shulker boxes (ShulkerBoxTileEntityRenderer). well, okay, thank you
July 9, 20205 yr Author 1 hour ago, diesieben07 said: You don't need an entity. Look at e.g. shulker boxes (ShulkerBoxTileEntityRenderer). I can't really get it working using a TileEntity. Can you maybe answer my original question?
July 9, 20205 yr Author 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(); } }
July 9, 20205 yr Author 9 minutes ago, diesieben07 said: Look at vanilla for examples. Ah okay, makes sense. What do I put in if I want it to be for all blocks
July 9, 20205 yr Author 6 minutes ago, diesieben07 said: That does not make sense. Well, the second parameter of the Builder is blocks that the tileentity can be applied to. But I want the TE to be applied to any block
July 10, 20205 yr Author 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.
July 10, 20205 yr Author 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
July 10, 20205 yr Author 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?
July 10, 20205 yr Author 1 minute ago, diesieben07 said: With lots and lots of pain. Minecraft's engine is not designed to do this and you'll have a hard time. That being said, no, i don't know how to do this. hm, okay, thank you anyway
July 10, 20205 yr 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 July 10, 20205 yr by MostafaSabry55
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.