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

  • Author

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.

  • Author

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.

  • Author

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);
	}

 

  • Author

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.

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

  • Author

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

  • Author

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);
    }
}

 

  • Author

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

  • Author

What do you mean it doesn't compile. As in that part does nothing?

  • Author

Ohh, I see what you mean. I did that so it would be easier on here to see what I was talking about. I'll fix that real quick.

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.