Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I've been working on my first implementation of a basic Entity. I pulled from a few different sources on trying to make sure I register and implement everything properly, but on my first attempt using it in the client, I get a crash, once mcforge actually completes loading the client, that has inexplicable origins to me. In the debug client, I can also see a bunch of errors popping up before the crash happens, which also seem to have nothing to do with my mod, and yet never happened until I tried to create a basic entity. My model class was mostly made by Blockbench. I will include code snippets pertinent to the entity. *Please note you may see items related to "Mana and Artifice", this is just a dependency of my mod, since it's being developed as an addon.

 

Sorry for all the code, but I really don't know where this could be coming from. It's not my workspace either because I've tried rebuilding my workspace and also attempting to run an actual client using the built jar. It may also seem like it's coming from Mana and Artifice, but I assure you, it's not. Here is a link to the crash report if that may also help: https://pastebin.com/hifFKCQu

 

Let me know if I may have left something out that is needed to see where the problem might be.

 

Entity class (just basic implementation, not fully finished)

 


public class EmpowermentEntity extends Entity {

    private static final String KEY_POTIONSTACK = "itemstack";
    private static final String KEY_EFFECT = "effect";

    private ItemStack potionStack;
    private Effect effect;

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

    @Override
    protected void registerData() {

    }

    @Override
    protected void readAdditional(CompoundNBT compound) {

    }

    @Override
    protected void writeAdditional(CompoundNBT compound) {

    }

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

    @Override
    public boolean canBeCollidedWith(){
        return false;
    }

    @Override
    protected boolean canBeRidden(Entity entityIn){
        return false;
    }

    @Override
    public boolean canBeAttackedWithItem(){
        return false;
    }

}

 

 

 

Mod class constructor

 

public BlueMagic() {
    // Register ourselves for server and other game events we are interested in
    IEventBus eventBus = MinecraftForge.EVENT_BUS;

    EntityInit.ENTITY_TYPES.register(eventBus);

    eventBus.register(this);
}

 

 

 

EntityInit class (includes deferred register)

 


public class EntityInit {
    public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, BlueMagic.MOD_ID);

    public static final RegistryObject<EntityType<EmpowermentEntity>> EMPOWERMENT_ENTITY =
            ENTITY_TYPES
                    .register("empowerment_entity",
                            () -> EntityType.Builder.create(EmpowermentEntity::new, EntityClassification.MISC)
                                    .setShouldReceiveVelocityUpdates(false)
                                    .disableSummoning()
                                    .build(new ResourceLocation(BlueMagic.MOD_ID, "empowerment_entity").toString()));
    
}

 

 

 

ClientEventBusSubscriber class

 

@Mod.EventBusSubscriber(modid = BlueMagic.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientEventBusSubscriber {

    @SubscribeEvent
    public static void clientSetupEvent(FMLClientSetupEvent event){
        RenderingRegistry.registerEntityRenderingHandler(EntityInit.EMPOWERMENT_ENTITY.get(), EmpowermentEntityRenderer::new);

    }
}

 

 

 

Renderer class

 

public class EmpowermentEntityRenderer extends EntityRenderer<EmpowermentEntity> {

    protected static final ResourceLocation TEXTURE = new ResourceLocation(BlueMagic.MOD_ID, "textures/entity/empowerment_entity.png");

    public EmpowermentEntityRenderer(EntityRendererManager renderManager) {
        super(renderManager);
    }

    @Override
    public ResourceLocation getEntityTexture(EmpowermentEntity entity){
        return TEXTURE;
    }
}

 

 

 

 

Model class

 

public class EmpowermentEntityModel<T extends EmpowermentEntity> extends EntityModel<T> {
    private final ModelRenderer Body;
    private final ModelRenderer Torso;
    private final ModelRenderer Legs;
    private final ModelRenderer Leg1;
    private final ModelRenderer Leg2;
    private final ModelRenderer Leg3;
    private final ModelRenderer Leg4;

    public EmpowermentEntityModel() {
        textureWidth = 32;
        textureHeight = 32;

        Body = new ModelRenderer(this);
        Body.setRotationPoint(0.0F, 24.0F, 0.0F);


        Torso = new ModelRenderer(this);
        Torso.setRotationPoint(0.0F, 0.0F, 0.0F);
        Body.addChild(Torso);
        Torso.setTextureOffset(0, 0).addBox(-3.0F, -11.0F, -3.0F, 6.0F, 6.0F, 6.0F, 0.0F, false);

        Legs = new ModelRenderer(this);
        Legs.setRotationPoint(0.0F, 0.0F, 0.0F);
        Body.addChild(Legs);


        Leg1 = new ModelRenderer(this);
        Leg1.setRotationPoint(0.0F, 0.0F, 0.0F);
        Legs.addChild(Leg1);


        Leg2 = new ModelRenderer(this);
        Leg2.setRotationPoint(0.0F, 0.0F, 0.0F);
        Legs.addChild(Leg2);


        Leg3 = new ModelRenderer(this);
        Leg3.setRotationPoint(0.0F, 0.0F, 0.0F);
        Legs.addChild(Leg3);


        Leg4 = new ModelRenderer(this);
        Leg4.setRotationPoint(0.0F, 0.0F, 0.0F);
        Legs.addChild(Leg4);

    }

    @Override
    public void setRotationAngles(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {

    }


    @Override
    public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
        Body.render(matrixStack, buffer, packedLight, packedOverlay);
    }

    public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
        modelRenderer.rotateAngleX = x;
        modelRenderer.rotateAngleY = y;
        modelRenderer.rotateAngleZ = z;
    }
}

Edited by BlueMond

Caused by: java.io.FileNotFoundException: mana-and-artifice:particles/sparkle.json

This is your problem, you are missing a particle json file.

  • Author

Please read the post. This is coming from a dependency and I have verified the file being present in the dependency. Something is cascading issues with the registry, coming from my mod as the source of the problem.

Try changing the BlueMagic() method like so:

public BlueMagic() {
	EntityInit.ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus());
}

 

What vemerion said will work because deferred registers need to be registered on the Mod bus...while with this code:

IEventBus eventBus = MinecraftForge.EVENT_BUS;
EntityInit.ENTITY_TYPES.register(eventBus);

you are registering your deferred register to the Forge event bus, which is where in-game events are posted. Registry events (for items, blocks, entities etc....) happen during the loading of the game and are posted on the mod bus (which is different from the forge bus), which can be retrieved with:

FMLJavaModLoadingContext.get().getModEventBus()

 

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

  • Author

Ah okay, I see what youre saying. I'll make that change and give it a try. Thanks vemerion and beethoven.

 

EDIT: Oh boy, it still seems to be having the same exact issue. So I guess it wasnt coming from my entity as expected. I found a typo in one of my registries I was sending to the dependency mod that also had to do with the new entity, but not directly. Fixing that seems to allow it to load properly. Oops

 

Thanks for that though because that would have probably been my next problem regardless of this issue

 

Edited by BlueMond

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.