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

Hey there,

 

So I have an Item here that need to set a string in a TE ,the string will check if the bounded player is the same, and do x if it is.

 

However, I'm having an issue with finding a way of accessing something that differentiates a player.

 

Thanks,

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Best thing is to store the

UUID

of the player. You can get the

UUID

from a player using

Entity#getUniqueID()

. To save it to NBT, save the

getLeastSignificantBits()

and

getMostSignificantBits

result (

longs

). To recreate the

UUID

, use the constructor that accepts 2

longs

(the most and least significant bits) which you saved to NBT.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

Okay, so like this:

    public long leastbit;
    public long mostbit;
    public UUID uuid = new UUID(leastbit, mostbit);

 

@Override
    public void writeSyncableNBT(NBTTagCompound compound, NBTType type) {
        if(type != NBTType.SAVE_BLOCK) {
            compound.setLong("UUID.LEASTBIT", uuid.getLeastSignificantBits());
            compound.setLong("UUID.MOSTBIT", uuid.getMostSignificantBits());

        }
        super.writeSyncableNBT(compound, type);
    }

    @Override
    public void readSyncableNBT(NBTTagCompound compound, NBTType type) {
        if(type != NBTType.SAVE_BLOCK) {
            leastbit = compound.getLong("UUID.LEASTBIT");
            mostbit = compound.getLong("UUID.MOSTBIT");

        }
        super.readSyncableNBT(compound, type);
    }

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

  • Author
    @Override
    public void readSyncableNBT(NBTTagCompound compound, NBTType type) {
        if(type != NBTType.SAVE_BLOCK) {
            uuid = new UUID(compound.getLong("UUID.LEASTBIT"), compound.getLong("UUID.MOSTBIT"));
        }
        super.readSyncableNBT(compound, type);
    }

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

  • Author

Ah, changed that, test works, but doesnt save, so something is wrong with my NBT still:


public class TileEntityChargeStand extends TileEntityCrystalSearchBase {

    public final int MANA_PER_TICK = 50;

    public UUID uuid;

    public TileEntityChargeStand() {
        super("chargeStand");
    }



    @Override
    public void updateEntity() {
        super.updateEntity();
        if(!worldObj.isRemote) {
            EntityPlayer player = worldObj.getClosestPlayer(pos.getX(), pos.getY() + 1, pos.getZ(), 1, false);
            if (player != null) {
                if (player.getUniqueID() == uuid && uuid != null) {
                    if (player.hasCapability(CapabilityMagic.MANA, null)) {
                        if (storage.getManaStored() >= 0) {
                            CapabilityManaData cap = player.getCapability(CapabilityMagic.MANA, null);
                            cap.receiveManaInternal(MANA_PER_TICK, false);
                            this.storage.extractMana(MANA_PER_TICK, false);
                        }
                    }
                }
            }
        }
    }


    @Override
    public void writeSyncableNBT(NBTTagCompound compound, NBTType type) {
        if(type != NBTType.SAVE_BLOCK) {
            compound.setUniqueId("ChargeUUID", uuid);
        }
        super.writeSyncableNBT(compound, type);
    }

    @Override
    public void readSyncableNBT(NBTTagCompound compound, NBTType type) {
        if(type != NBTType.SAVE_BLOCK) {
            uuid = compound.getUniqueId("ChargeUUID");
        }
        super.readSyncableNBT(compound, type);
    }

}

 

Thanks.

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

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.