Jump to content

Recommended Posts

Posted

I'm having trouble making my entity be summoned and can't find a solution. It's based off of a normal Silverfish with the render of it using the code of the original to have the same look. 

MobEntity
https://pastebin.com/34LqbRFQ

MobRegistration

https://pastebin.com/RrdMBs0s

MobRenderer

https://pastebin.com/en6h49wT

MobModel

https://pastebin.com/KwAM6kmr

Error Log

https://pastebin.com/hF25X9pH

 

I appreciate any help I can get on this.

Posted

Thank you for the help. I ended up adding it, but I'm still tinkering with it trying to make it work. I think the problem now relies in my MobRegistration. Here are also the new updated files.

Main

https://pastebin.com/U4D0XhEK

MobEntity

https://pastebin.com/KYV5fb5f

MobRegistration

https://pastebin.com/Rb44ZRdg

New Log Error (just in case)

https://pastebin.com/f8yRiyC7

 

If I end up finding a solution on my own then I will add a new reply and leave the code up for anyone else with the same problem.

Posted

I understand about half of what you said. I'm guessing you mean since it's a void and not being called anywhere, that it won't do anything.  I'm trying to figure out where to call back to it in the Mob Registry so that it uses the attributes. I just don't know how to rewrite my Registry for it to work.

Posted

Ok, so I added this to it. I'm unsure as to how to remove the static, unless you mean just remove the word static from the EntityAttributeCreationEvent.

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)

 

    @SubscribeEvent
    public static void entityAttributeCreationEvent(EntityAttributeCreationEvent event) {
    	LOGGER.info("Entity Attribute Event");
		event.put(WeirdMobEntity.TYPE, WeirdMobEntity.MAP);
	}

 

Posted

Yes, I am new to this language I have a lot to learn and I'm willing to. I just can't learn through being told something I need examples, that's how my brain works. Anyway alright I'll just go and figure out how static works.

Posted
2 hours ago, Avien said:

 


    @SubscribeEvent
    public static <---- void entityAttributeCreationEvent(EntityAttributeCreationEvent event) {
    	LOGGER.info("Entity Attribute Event");
		event.put(WeirdMobEntity.TYPE, WeirdMobEntity.MAP);
	}

 

Just remove the static modifier : p to make the method non-staticc

Posted

Thank you. I've made the change and got rid of the @Mod.EventBusSubscriber at the top. As for adding it to the event bus I think its this section.

public CrystalMain() {
    	IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        bus.addListener(this::setup);
        
        ItemInit.ITEMS.register(bus);
        BlockInit.BLOCKS.register(bus);
        MobRegistration.ENTITIES.register(bus);

        MinecraftForge.EVENT_BUS.register(this);
        
    }

So I tried adding this in it.

    public CrystalMain() {
    	IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        bus.addListener(this::setup);
        
        ItemInit.ITEMS.register(bus);
        BlockInit.BLOCKS.register(bus);
        MobRegistration.ENTITIES.register(bus);

        MinecraftForge.EVENT_BUS.register(this);
        
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::entityAttributeCreationEvent); //This Part
    }

But I still am unable to summon it.

Error Log

https://pastebin.com/dtprYkG5

Posted

I don't think it is being called. Here's everything I have so far.

Main

public class CrystalMain
{
    public static final Logger LOGGER = LogManager.getLogger();
    public static final String Mod_ID = "crystalcodex";
    public static final ItemGroup CRYSTAL_GROUP = new CrystalGroup("crystaltab");

    public CrystalMain() {
    	IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        bus.addListener(this::setup);
        
        ItemInit.ITEMS.register(bus);
        BlockInit.BLOCKS.register(bus);
        MobRegistration.ENTITIES.register(bus);

        MinecraftForge.EVENT_BUS.register(this);
        
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::entityAttributeCreationEvent);
    }

    @SubscribeEvent
    public void entityAttributeCreationEvent(EntityAttributeCreationEvent event) {
    	LOGGER.info("Entity Attribute Event");
		event.put(WeirdMobEntity.TYPE, WeirdMobEntity.MAP);
	}

Mob Registration

public class MobRegistration {
	
	 public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, CrystalMain.Mod_ID);

	    public static final RegistryObject<EntityType<WeirdMobEntity>> WEIRD_MOB =
	            ENTITIES.register("weirdmobentity", () -> EntityType.Builder
	                    .<WeirdMobEntity>of(WeirdMobEntity::new, EntityClassification
	                    .CREATURE)
	                    .sized(0.9f, 0.9f )
	                    .build("weirdmobentity"));
}

Mob Entity

public class WeirdMobEntity  extends MonsterEntity{

	public static final String REG = "weirdmobentity";
	public static final EntityType<WeirdMobEntity> TYPE = EntityType.Builder.<WeirdMobEntity>of(WeirdMobEntity::new, EntityClassification.MISC)
			.sized(0.98F, 0.7F)
			.clientTrackingRange(8)
			.build(REG);
	public static final AttributeModifierMap MAP = AttributeModifierMap.builder().add(Attributes.MAX_HEALTH, 20.0)
			.add(Attributes.MOVEMENT_SPEED, 20.0)
			.add(Attributes.FOLLOW_RANGE, 20.0)
			.build();
	
	public WeirdMobEntity(EntityType<? extends MonsterEntity> type, World worldIn) {
        super(type, worldIn);
    }
}

 

Posted (edited)

Ok, so I fixed the event handler problem. I'm going to see what I can do for the Entity type to fix it.

Main

public class CrystalMain
{
    public static final Logger LOGGER = LogManager.getLogger();
    public static final String Mod_ID = "crystalcodex";
    public static final ItemGroup CRYSTAL_GROUP = new CrystalGroup("crystaltab");

    public CrystalMain() {
    	IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        bus.addListener(this::setup);
        
        ItemInit.ITEMS.register(bus);
        BlockInit.BLOCKS.register(bus);
        MobRegistration.ENTITIES.register(bus);
        
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::entityAttributeCreationEvent);
    }

	public void entityAttributeCreationEvent(EntityAttributeCreationEvent event) {
    	LOGGER.info("Entity Attribute Event");
		event.put(WeirdMobEntity.TYPE, WeirdMobEntity.MAP);
	}
    

Entity 

public class WeirdMobEntity  extends MonsterEntity{

	public static final String REG = "weirdmobentity";
	public static final EntityType<WeirdMobEntity> TYPE = EntityType.Builder.<WeirdMobEntity>of(WeirdMobEntity::new, EntityClassification.MISC)
			.sized(0.98F, 0.7F)
			.clientTrackingRange(8) //<--Problem area
			.build(REG);
	public static final AttributeModifierMap MAP = AttributeModifierMap.builder().add(Attributes.MAX_HEALTH, 20.0)
			.add(Attributes.MOVEMENT_SPEED, 20.0)
			.add(Attributes.FOLLOW_RANGE, 20.0)
			.build();
	
	public WeirdMobEntity(EntityType<? extends MonsterEntity> type, World worldIn) {
        super(type, worldIn);
    }
}

 

Edited by Avien

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



×
×
  • Create New...

Important Information

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