Jump to content

Need assistance linking entity names in language file to datawatcher


Cyan

Recommended Posts

So, title kinda explains it all in a nutshell.

 

So, I have made a datawatcher to keep track of my entity names, but I cannot for the life of me figure out how I would link it to the language file. Currently I am using the EntityList to get the names of the entities, but the names are displayed as modid.entity instead.

 

Not sure this is making any sense, so here is all the relevant code.

 

 

public abstract class EntityTest extends EntityCreature
{




    public EntityTest(World world)
    {
      super(world);
dataWatcher.addObject(4, ""); //Name


      newEntity();
    }


    public void newTest()
    {
        setName(EntityList.getEntityString(this));
        
    }


//Naming process
public String getName() {

return dataWatcher.getWatchableObjectString(4);
}

public void setName(String name) {
dataWatcher.updateObject(4, name);
}

public void writeEntityToNBT(NBTTagCompound nbt)
    {
        super.writeEntityToNBT(nbt);

        nbt.setString("name", getName());
       
    }
    
   

    public void readEntityFromNBT(NBTTagCompound nbt)
    {
       super.readEntityFromNBT(nbt);

       setName(nbt.getString("name"));
     
    }


 

 

And then the code adding the entity, as well as what it is marked down as in the language file

 

EntityRegistry.registerModEntity(EntityTest.class, "TestEntity", 1, testmod.instance, 80, 3, true);

entity.testmod.TestEntity.name=TestEntity

 

 

Now, this will give be the "Player has been slain by TestEntity" when killed, but when setName() is displayed in my render over the mob, it is shown as testmod.TestEntity

 

I figure this is somehow related to the way getEntityString() reads the names from mods. So is is possible to get setName() to read from the Lanuage file names?

 

Thanks for any help you can provide

 

 

 

Link to comment
Share on other sites

Consider reading "CustomNameTag" stuff. It is object 10 in the datawatcher for EntityLiving.

 

Not necessarily what I am looking for.

 

I have a rather large amount of custom entities, and there is nothing there that really satisfies what I am trying to do. I would still need to go through and set each entities name individually in their respective files.

 

Which:

A) Is irrelevant. I am trying to figure out if there is a way I can use EntityList to return the names without it returning as "modid.mobname", as EntityList seems like the best way to set names for over 240 entities without individually going through each file.

 

B) Use the language registry, so it will reflect the language(I.E. Using a spanish lanuage file rendering "Pollo" over a chicken, rather than "Chicken"

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Exception in thread "main" java.lang.IllegalStateException: Current Java is 1.8.0_271 but we require at least 17         at net.minecraftforge.bootstrap.shim.Main.main(Main.java:32) Never have successfully gotten a minecraft server up and running so I thought i'd try again. Instant unfixable issue.  
    • What MC version? What's the IP? Are any mods needed to be able to join?
    • Thank you for your answer ! Unfortunatly i have the same problem when i use setPos() public static int movingfunction(CommandContext<CommandSourceStack> context){ CommandSourceStack source = context.getSource(); if (!(source.getEntity() instanceof ServerPlayer)) { return 0; } ServerPlayer player = (ServerPlayer ) source.getEntity(); double moveSpeed = 0.5; for (int i =0; i<10000;i++) { LOGGER.info("running for the {} time", i); double x = player.getX() + player.getViewVector(1.0f).x * moveSpeed; double y = player.getY(); double z = player.getZ() + player.getViewVector(1.0f).z * moveSpeed ; Vec3 movementVec = new Vec3(x, y, z); LOGGER.info("x ={} y ={} z ={}", x, y, z); player.setPos( movementVec); } return 1; } With the logs i can see that x and z are increasing but once again my player is not moving. is there a function to use to sync the server and the client ? I also tried to use LocalPlayer instead of ServerPlayer but my code would stop when i got the object. Also i will change a bit the main topic but is there a way to similate key press ? i found KeyBinding.setKeyBindState on others post but it look like there is no more KeyBinding in 1.20   I found this code : KeyMapping.click(Minecraft.getInstance().options.keyUp.getKey()); But it doesn't seems to work   And i found this one : Minecraft.getInstance().options.keyUp.setDown(true); wich works but doesn't exactly do what i want , it doesn't release the key so for exemple i can't make him run. Minecraft.getInstance().options.keyUp.setDown(true); Minecraft.getInstance().options.keyUp.setDown(false); Minecraft.getInstance().options.keyUp.setDown(true); doesn't make him run
    • Add crash-reports with sites like https://paste.ee/ Maybe an issue with blur, essentials or cumulus_menus
  • Topics

×
×
  • Create New...

Important Information

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