CraftTweaker

CraftTweaker

151M Downloads

[1.11] /minetweaker entities - doesn't list entities from mods.

rinart73 opened this issue ยท 18 comments

commented

Issue Description:

I installed a few mods. Tinkers Construct, for example, Forestry, e.t.c.
I'm trying to get all entities that are exist in the game. I type "/minetweaker entities".

What happens:

In the minetweaker.log file I see only an entities from vanilla.

What you expected to happen:

I expected to see all entities from vanilla and mods, because this command refers to an "EntityList" which contains all entities, including mod's entities. I didn't delve in the source code too much, so maybe I'm mistaken.
I just need to know, is this bug or that works like it was intended to.

Actually I don't understand is there even support for an entities from other mods?
In the ZenScript I write
<entity:cow>
And I get cow, that's fine. But how to get an entity from other mod?

Script used

I used chat, not script.

Minetweaker.log file

https://pastebin.com/kWiXn5QJ


Affected Versions (Do not use "latest"):

  • Minecraft: 1.11.2
  • Forge: 1.11.2-13.20.1.2386
  • Crafttweaker: 1.11.2-3.0.26

Your most recent log file where the issue was present:

Already gave Minetweaker.log file.

commented

Just tested it, I can't reproduce.
http://i.blamejared.com/xkZqk.txt

commented

Can you please give your setup information like version of forge an the list of mods?
I tried to delete everything except CraftTweaker and mods that add entities. I tried to install mods that are in your list, like Mystical Agriculture. And still, all that it gives me - vanilla entities.
Can you just to not close everything instantly, please? I really need help.

commented

@jaredlll08, Found the issue. It is MTLib. Tested with:

  • MTLib-2.0.3
  • CraftTweaker-1.11.2-3.0.26
  • CodeChickenLib-1.11.2-3.0.0.284-universal
  • CoFHCore-1.11.2-4.2.7.15-universal
  • ThermalExpansion-1.11.2-5.2.6.21-universal
  • ThermalFoundation-1.11.2-2.2.5.16-universal

If you have MTLib, you only get Vanilla entities. Without MTLib you also get modded entities. Hope that helps.


@rinart73 As a temp work around remove MTlib to get the entity list.

commented

@bookerthegeek thanks. Unfortunately without MTLib any dependent mods (including ModTweaker) don't work.

commented

True, but do any of those dependances add entities you are worried about?

commented

@bookerthegeek No, but those dependent mods use entities. And I need them to use entities from mods. Anyway, we just need to wait for a fix, because I looked at the MTLib code and can't find anything that can mess with entities.

commented

So I'm an idiot... I forgot I had an entity command in mtlib... so I added one to Crafttweaker, so it is a command conflict, Problem is, I'm not really working on 1.11.2 anymore, so you will need to get a list of entities without MTLib and it's deps, run the command save the output, add MTLib back and work with the output

commented

The problem is actually modtweaker, not MTLib, so just remove modtweaker, get the entity list, and readd it

commented

@jaredlll08 but I can't remove nor ModTweaker, nor MTLib, because I'm working at ModTweaker. You know, for the pull request to add TConstruct support.
Fine, the only thing that isn't working as it should besides "entities" command is EntityBracket-s. It can be replaced by another method of getting entities.
So if you have time a fix would be really appreciated, but if you don't its fine. I just hope you will accept PR when it will be ready.

commented

@rinart73 what mod requires modtweaker? Could you not remove it just to get the entity list then add it back in?

commented
commented
commented

@jaredlll08

you can remove the entity dump command

Can you tell a bit more please? I can't find it.

commented
commented

@jaredlll08 okay then ๐Ÿ˜„ . I'll just try to find a way to fix it, if not, for TConstruct there will be entities without <brackets> (it will be a string "modname:entityname")

commented
commented

@jaredlll08 I know, for TConstruct I need to get a ResourceLocation instance, so yeah, I do some converting in any case, when I'm getting an Entity Definition or just string in the format that I described.

commented

@jaredlll08 ok, I found the source of the problem on the MTLib's side.
This line

I think it's because MTLib loads earlier than the most of the mods. And as I see it's a good practice to add Blocks/Entities/Recipes in the preInit() method. So, MTLib forces CraftTweaker to reload before any other mod adds anything.

In the MineTweakerImplementationAPI.reload() we can see a MineTweakerAPI.game.getEntities() call. And since MCGame.ENTITY_DEFINITIONS is empty at that moment, it takes all entities from ForgeRegistries.ENTITIES and 'caches' them.

So, when everything is loaded MCGame.ENTITY_DEFINITIONS contains only vanilla Entities. And there is only one way to reload it (besides using a workaround - ReflectionHelper to get ENTITY_DEFINITIONS list and clear it). Is to call MCGame.getEntity() with the name of an entity from the mod. Because it refreshes ENTITY_DEFINITIONS. But it's not really a good way.

So there is three (four?) ways I can suggest to fix this:

  1. Change the behavior of MCGame.getEntities() method to always get entities from ForgeRegistry. Or at least make a simple check. If the sizes of lists are different, refresh ENTITY_DEFINITIONS. As I understand mods just adding Entities, not removing them, so there should not be any problems with this code then.
  2. Add a method to refresh MCGame.ENTITY_DEFINITIONS (And tell every person who makes addons for CraftTweaker to use it).
  3. Remove preInit() stuff from MTLib.
  4. Use ReflectionHelper to get ENTITY_DEFINITIONS and clear it. (And tell every person who makes addons for CraftTweaker to use it)