Jump to content

Recommended Posts

Posted (edited)

Is this a valid way to register entities? Be it entities extending classes such as ProjectileItemEntity or MonsterEntity class.

The reason I ask is because while the mob entity is registring and showing in game just fine, the throwable entity is not, and is completely invisible in game when spawned (even when I don't register entity rendering with the RenderingRegistry class - this would in turn render it as a white box which is not happening).

    public static EntityType<?> ENT_MOB = null;
    public static EntityType<EntityModProjectile> ENT_PROJECTILE = null;

        static
        {
			ENT_MOB = registerEntityAndEgg(event.getRegistry(), EntityType.Builder.create(EntityModMob::new, EntityClassification.MONSTER).size(0.6F, 1.95F), 0xdcdcdc, 0xe21a1a, "ent_mob");
			ENT_PROJECTILE = registerEntity(EntityType.Builder.<EntityModProjectile>create(EntityModProjectile::new, EntityClassification.MISC).size(0.25F, 0.25F).setTrackingRange(64).setUpdateInterval(20).setShouldReceiveVelocityUpdates(false), "ent_projectile");
		}

        @SubscribeEvent
        public static void registerItems(final RegistryEvent.Register<EntityType<?>> event)
        {
			event.getRegistry().registerAll(ENT_MOB, ENT_PROJECTILE);
		}

        public static <T extends Entity> EntityType<T> registerEntity(EntityType.Builder builder, String name)
        {
            EntityType<T> type = (EntityType<T>) builder.build(Main.MODID + '.' + name).setRegistryName(name);
            return type;
        }

 

And this is how I register entity rendering:

RenderingRegistry.registerEntityRenderingHandler(EntityModMob.class, renderManager -> new RenderModMob(renderManager));
RenderingRegistry.registerEntityRenderingHandler(EntityModProjectile.class, renderManager -> new SpriteRenderer<EntityModProjectile>(renderManager, Minecraft.getInstance().getItemRenderer()));

 

EntityModProjectile class:

public class EntityModProjectile extends ProjectileItemEntity
{
    public EntityModProjectile(EntityType<? extends EntityModProjectile> entityTypeIn, World worldIn)
    {
        super(entityTypeIn, worldIn);
    }

    public EntityModProjectile(World worldIn, LivingEntity throwerIn)
    {
        super(ModEntityType.ENT_PROJECTILE, throwerIn, worldIn);
    }

    public EntityModProjectile(World worldIn, double x, double y, double z)
    {
        super(ModEntityType.ENT_PROJECTILE, x, y, z, worldIn);
    }

    @Override
    protected Item func_213885_i()
    {
        return ModItems.MOD_PROJECTILE;
    }
}

 

Edited by TheUnnamed
Posted (edited)

You need to avoid putting static fields in your registry events.

Build the EntityTypes in the RegisterAll parameter list.

 

If you need to cross-reference between your EntityTypes and renderers, use ObjectHolders 

 

Here's a snippet from my [simple] mod where create my Events for 1 block (and its BlockItem), 1 Item and a custom [Mob] Entity

    //Mod Event bus for receiving Registry Events)
    @Mod.EventBusSubscriber(modid=ChickenMod.MODID, bus=Mod.EventBusSubscriber.Bus.MOD)
    @ObjectHolder(ChickenMod.MODID)
    public static class RegistryEvents {
    	
    	public static final Block test_block=null;
    	public static final Item test_item=null;
    	public static final EntityType<EntityProtoChicken> protochicken=null;
    	
        @SubscribeEvent
        public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
    			blockRegistryEvent.getRegistry().registerAll(
    					new Block(Block.Properties.create(Material.IRON)).setRegistryName(ChickenMod.MODID,"test_block")); 
        }
        
        @SubscribeEvent
        public static void onItemsRegistry(final RegistryEvent.Register<Item> itemRegistryEvent) {
        	itemRegistryEvent.getRegistry().registerAll(
        			(Item)new BlockItem(test_block,new Item.Properties().group(ITEMTAB)).setRegistryName(test_block.getRegistryName()),
        			new Item(new Item.Properties().group(ITEMTAB)).setRegistryName(ChickenMod.MODID,"test_item")
        			);
        }
        
    	//Register Entities
    	@SubscribeEvent
    	public static void onEntitiesRegistry(final RegistryEvent.Register<EntityType<?>> entityRegistryEvent) {	
    		entityRegistryEvent.getRegistry().registerAll(		    	
    		    EntityType.Builder.create(EntityProtoChicken::new,EntityClassification.MISC)
    		    	.setShouldReceiveVelocityUpdates(true).setTrackingRange(24).setUpdateInterval(60)
    		    	.build("protochicken").setRegistryName(MODID, "protochicken")
    			);	
    	}

 

...and this is where I register the renderer:

    private void doClientStuff(final FMLClientSetupEvent event) {
        // do something that can only be done on the client
                RenderingRegistry.registerEntityRenderingHandler(EntityProtoChicken.class,RenderProtoChicken :: new);
    }

 

YMMV

/p

Edited by PhilipChonacky
Posted

Thank you for your input PhilipChonacky.

I've done exactly as you've suggested, but the issue still persists, the entity I'm summoning with the /summon command is still invisible.

 

It says the entity has been registered in the console, so I'm not quite sure what could be the problem.

Keep in mind that this only occurs with entities that are created with SSpawnObjectPacket and not SSpawnMobPacket in the IPacket<?> createSpawnPacket() method it seems, because mob entities register and render just fine in-game, as previously stated.

Posted

I think something may be missing in the forge registry/spawn code. I have an entity that is mountable and I get a [minecraft/ClientPlayNetHandler]: Received passengers for unknown entity warning in the console. The entity is not visible and cannot be controlled. So you're not the only one experiencing this type of issue. 

  • 2 weeks later...
Posted

I'm having exactly the same problem now. My Mobs are showing up great but my projectiles do not show up on the client at all, anything spawned via SSpawnMobPacket is great but SSpawnObjectPacket is not showing.

I use an EntityFactory object rather than the entity constructors and that also isn't being called by SSpawnObjectPacket on the client.

Posted

I solved it. Here's how I did it:

 

When I set the EntityType variable for my named variable "ENT_PROJECTILE" and build, I use the setCustomClientFactory method, so it would look exactly like this:

ENT_PROJECTILE = registerEntity(EntityType.Builder.<EntityModProjectile>create(EntityClassification.MISC).setCustomClientFactory(EntityModProjectile::new).size(0.25F, 0.25F), "ent_projectile");

 

Inside of my EntityModProjectile class I extended the ProjectileItemEntity class, overrided the createSpawnPacket method and returned getEntitySpawningPacket from NetworkHooks class. Like this:

    @Override
    public IPacket<?> createSpawnPacket()
    {
        return NetworkHooks.getEntitySpawningPacket(this);
    }

 

I then created another constructor inside of the EntityModProjectile class, like this:

    public EntityModProjectile(FMLPlayMessages.SpawnEntity packet, World worldIn)
    {
        super(ModEntityType.ENT_PROJECTILE, worldIn);
    }

 

  • Like 1

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

    • i have just made a modpack and i accidentally added a few fabric mods and after deleting them i can no longer launch the pack if any one could help these are my latest logs [22:42:24] [main/INFO]:additionalClassesLocator: [optifine., net.optifine.] [22:42:25] [main/INFO]:Compatibility level set to JAVA_17 [22:42:25] [main/ERROR]:Mixin config epicsamurai.mixins.json does not specify "minVersion" property [22:42:25] [main/INFO]:Launching target 'forgeclient' with arguments [--version, forge-43.4.0, --gameDir, C:\Users\Mytht\curseforge\minecraft\Instances\overseer (1), --assetsDir, C:\Users\Mytht\curseforge\minecraft\Install\assets, --uuid, 4c176bf14d4041cba29572aa4333ca1d, --username, mythtitan0, --assetIndex, 1.19, --accessToken, ????????, --clientId, MGJiMTEzNGEtMjc3Mi00ODE0LThlY2QtNzFiODMyODEyYjM4, --xuid, 2535469006485684, --userType, msa, --versionType, release, --width, 854, --height, 480] [22:42:25] [main/WARN]:Reference map 'insanelib.refmap.json' for insanelib.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'corpsecurioscompat.refmap.json' for gravestonecurioscompat.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'nitrogen_internals.refmap.json' for nitrogen_internals.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'arclight.mixins.refmap.json' for epicsamurai.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'simplyswords-common-refmap.json' for simplyswords-common.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'simplyswords-forge-refmap.json' for simplyswords.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map '${refmap_target}refmap.json' for corgilib.forge.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:25] [main/WARN]:Reference map 'MysticPotions-forge-refmap.json' for mysticpotions.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:26] [main/WARN]:Reference map 'packetfixer-forge-forge-refmap.json' for packetfixer-forge.mixins.json could not be read. If this is a development environment you can ignore this message [22:42:26] [main/WARN]:Error loading class: atomicstryker/multimine/client/MultiMineClient (java.lang.ClassNotFoundException: atomicstryker.multimine.client.MultiMineClient) [22:42:26] [main/WARN]:@Mixin target atomicstryker.multimine.client.MultiMineClient was not found treechop.forge.compat.mixins.json:MultiMineMixin [22:42:26] [main/WARN]:Error loading class: com/simibubi/create/content/contraptions/components/fan/AirCurrent (java.lang.ClassNotFoundException: com.simibubi.create.content.contraptions.components.fan.AirCurrent) [22:42:26] [main/WARN]:Error loading class: shadows/apotheosis/ench/table/ApothEnchantContainer (java.lang.ClassNotFoundException: shadows.apotheosis.ench.table.ApothEnchantContainer) [22:42:26] [main/WARN]:@Mixin target shadows.apotheosis.ench.table.ApothEnchantContainer was not found origins_classes.mixins.json:common.apotheosis.ApotheosisEnchantmentMenuMixin [22:42:26] [main/WARN]:Error loading class: se/mickelus/tetra/blocks/workbench/WorkbenchTile (java.lang.ClassNotFoundException: se.mickelus.tetra.blocks.workbench.WorkbenchTile) [22:42:26] [main/WARN]:@Mixin target se.mickelus.tetra.blocks.workbench.WorkbenchTile was not found origins_classes.mixins.json:common.tetra.WorkbenchTileMixin [22:42:27] [main/WARN]:Error loading class: tfar/davespotioneering/blockentity/AdvancedBrewingStandBlockEntity (java.lang.ClassNotFoundException: tfar.davespotioneering.blockentity.AdvancedBrewingStandBlockEntity) [22:42:27] [main/WARN]:@Mixin target tfar.davespotioneering.blockentity.AdvancedBrewingStandBlockEntity was not found itemproductionlib.mixins.json:davespotioneering/AdvancedBrewingStandBlockEntityMixin [22:42:27] [main/WARN]:Error loading class: fuzs/visualworkbench/world/inventory/ModCraftingMenu (java.lang.ClassNotFoundException: fuzs.visualworkbench.world.inventory.ModCraftingMenu) [22:42:27] [main/WARN]:@Mixin target fuzs.visualworkbench.world.inventory.ModCraftingMenu was not found itemproductionlib.mixins.json:visualworkbench/ModCraftingMenuMixin [22:42:27] [main/WARN]:Error loading class: fuzs/easymagic/world/inventory/ModEnchantmentMenu (java.lang.ClassNotFoundException: fuzs.easymagic.world.inventory.ModEnchantmentMenu) [22:42:27] [main/WARN]:@Mixin target fuzs.easymagic.world.inventory.ModEnchantmentMenu was not found skilltree.mixins.json:easymagic/ModEnchantmentMenuMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/ench/table/ApothEnchantmentMenu (java.lang.ClassNotFoundException: shadows.apotheosis.ench.table.ApothEnchantmentMenu) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.ench.table.ApothEnchantmentMenu was not found skilltree.mixins.json:apotheosis/ApothEnchantContainerMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/adventure/affix/socket/SocketingRecipe (java.lang.ClassNotFoundException: shadows.apotheosis.adventure.affix.socket.SocketingRecipe) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.adventure.affix.socket.SocketingRecipe was not found skilltree.mixins.json:apotheosis/SocketingRecipeMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/adventure/affix/socket/gem/bonus/AttributeBonus (java.lang.ClassNotFoundException: shadows.apotheosis.adventure.affix.socket.gem.bonus.AttributeBonus) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.adventure.affix.socket.gem.bonus.AttributeBonus was not found skilltree.mixins.json:apotheosis/AttributeBonusMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/adventure/affix/socket/gem/bonus/EnchantmentBonus (java.lang.ClassNotFoundException: shadows.apotheosis.adventure.affix.socket.gem.bonus.EnchantmentBonus) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.adventure.affix.socket.gem.bonus.EnchantmentBonus was not found skilltree.mixins.json:apotheosis/EnchantmentBonusMixin [22:42:27] [main/WARN]:Error loading class: shadows/apotheosis/adventure/client/AdventureModuleClient (java.lang.ClassNotFoundException: shadows.apotheosis.adventure.client.AdventureModuleClient) [22:42:27] [main/WARN]:@Mixin target shadows.apotheosis.adventure.client.AdventureModuleClient was not found skilltree.mixins.json:apotheosis/AdventureModuleClientMixin [22:42:27] [main/WARN]:Error loading class: me/shedaniel/rei/RoughlyEnoughItemsCoreClient (java.lang.ClassNotFoundException: me.shedaniel.rei.RoughlyEnoughItemsCoreClient) [22:42:27] [main/WARN]:Error loading class: com/replaymod/replay/ReplayHandler (java.lang.ClassNotFoundException: com.replaymod.replay.ReplayHandler) [22:42:27] [main/WARN]:Error loading class: net/coderbot/iris/pipeline/newshader/ExtendedShader (java.lang.ClassNotFoundException: net.coderbot.iris.pipeline.newshader.ExtendedShader) [22:42:27] [main/WARN]:Error loading class: net/irisshaders/iris/pipeline/programs/ExtendedShader (java.lang.ClassNotFoundException: net.irisshaders.iris.pipeline.programs.ExtendedShader) [22:42:27] [main/INFO]:Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.3.6).
    • My Mohist server crashed as well but all it says in logs is " C:\Minecraft Mohist server>java -Xm6G -jar mohist.jar nogul  Error: Unable to access jarfile mohist.jar   C:\Minecraft Mohist server>PAUSE press any key to continue  .  .  . " Any ideas? i have the server file that its looking for where its looking for it.
    • It is an issue with Pixelmon - maybe report it to the creators
  • Topics

×
×
  • Create New...

Important Information

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