Jump to content

[SOLVED] [1.16.2] Unknown Problems With Creating Basic Entity


Recommended Posts

Posted (edited)

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
Posted

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.

Posted

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()

 

  • Like 1

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

Posted (edited)

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

×   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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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