Jump to content

Recommended Posts

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

Posted
  On 8/31/2016 at 3:04 PM, lukas2005 said:

is there a way to use NBTTag?

 

NBT should only be used to save data, it shouldn't be used to store it at runtime.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I believe you don't fully understand how data should be stored on players. Well - I might be wrong, but worth asking :)

 

Saving data to player data files is different from assigning data to player when he is online.

 

It would help us help you if you would describe your end goal and what you want to store.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted
  On 8/31/2016 at 4:28 PM, lukas2005 said:

i have a variable and i need to save it and i have no idea how to use capabilities

Read the docs

http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Do any of the existing capabilities (

IItemHandler

,

IFluidHandler

,

IAnimationStateMachine

) match the data you want to store?

 

If they do, use them. If they don't, create your own.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

few questions:

 

1.Where i shloud register my capabliity

2.i have an error when i am trying to register a capability

eclipse marks this with red line:

CapabilityManager.INSTANCE.register(PlayerDataCapabilityClass.PlayerDataCapability.class, PlayerDataCapabilityClass.PlayerDataCapabilityStorage.class, PlayerDataCapabilityClass.PlayerDataCapabilityFactory.class);

PlayerDataCapabilityClass.java:

public class PlayerDataCapabilityClass {

public interface PlayerDataCapability {



}

public static class PlayerDataCapabilityStorage implements Capability.IStorage<PlayerDataCapability> {

	  @Override
	  public NBTBase writeNBT(Capability<PlayerDataCapability> capability, PlayerDataCapability instance, EnumFacing side) {
		return null;
	    // return an NBT tag
	  }

		@Override
		public void readNBT(Capability<PlayerDataCapability> capability, PlayerDataCapability instance, EnumFacing side,
				NBTBase nbt) {
			// TODO Auto-generated method stub

		}

}

public static class PlayerDataCapabilityFactory implements Callable<PlayerDataCapability> {

	  @Override
	  public PlayerDataCapability call() throws Exception {
		  
	    return null;
	    
	  }
	  
}


}

 

Posted
  On 9/16/2016 at 1:22 PM, lukas2005 said:

few questions:

 

1.Where i shloud register my capabliity

2.i have an error when i am trying to register a capability

eclipse marks this with red line:

CapabilityManager.INSTANCE.register(PlayerDataCapabilityClass.PlayerDataCapability.class, PlayerDataCapabilityClass.PlayerDataCapabilityStorage.class, PlayerDataCapabilityClass.PlayerDataCapabilityFactory.class);

PlayerDataCapabilityClass.java:

public class PlayerDataCapabilityClass {

public interface PlayerDataCapability {



}

public static class PlayerDataCapabilityStorage implements Capability.IStorage<PlayerDataCapability> {

	  @Override
	  public NBTBase writeNBT(Capability<PlayerDataCapability> capability, PlayerDataCapability instance, EnumFacing side) {
		return null;
	    // return an NBT tag
	  }

		@Override
		public void readNBT(Capability<PlayerDataCapability> capability, PlayerDataCapability instance, EnumFacing side,
				NBTBase nbt) {
			// TODO Auto-generated method stub

		}

}

public static class PlayerDataCapabilityFactory implements Callable<PlayerDataCapability> {

	  @Override
	  public PlayerDataCapability call() throws Exception {
		  
	    return null;
	    
	  }
	  
}


}

Listen to eclipse it is probably an invalid arguement.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

It says

"The method register(Class<T>, Capability.IStorage<T>,Class<? extends T>) is not applicable for arguments(Class<PlayerDataCapabilityClass.PlayerDataCapability>,Class<PlayerDataCapabilityClass.PlayerDataCapabilityStorage>,Class<PlayerDataCapabilityClass.PlayerDataCapabilityFactory>)"

 

Posted
  On 9/16/2016 at 1:22 PM, lukas2005 said:

1.Where i shloud register my capabliity

Register it in preInit from your

@Mod

class or a class called from it.

 

 

  Quote

2.i have an error when i am trying to register a capability

There are two overloads of

CapabilityManager#registerCapability

that take a different third argument:

  • One takes the
    Class

    of the capability interface's default implementation

  • One takes an instance of
    Callable

    that returns an instance of the default implementation

 

You're trying to pass the

Class

of the

Callable

implementation, which is incorrect.

 

You haven't actually added any methods to your capability interface or implemented any of the methods in your

IStorage

and

Callable

implementations.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 9/16/2016 at 10:22 PM, lukas2005 said:

So i need to pass a PlayerDataCapabilityClass.PlayerDataCapabilityFactory.this as a third argument?

 

No, you need to create an instance of

PlayerDataCapabilityClass.PlayerDataCapabilityFactory

and pass that as the third argument.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 9/18/2016 at 10:37 AM, lukas2005 said:

ok i have created and registered capability but how do i use it?

 

Call

ICapabilityProvider#getCapability

to get the instance of your handler attached to the provider.

 

Every

Entity

(including

EntityPlayer

) is an

ICapabilityProvider

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 9/18/2016 at 10:44 AM, Choonster said:

  Quote

ok i have created and registered capability but how do i use it?

 

Call

ICapabilityProvider#getCapability

to get the instance of your handler attached to the provider.

 

Every

Entity

(including

EntityPlayer

) is an

ICapabilityProvider

.

where i need to call this and how do i read/write the data?

Posted
  On 9/18/2016 at 10:54 AM, lukas2005 said:

where i need to call this and how do i read/write the data?

 

Call it whenever you want to access your handler instance (i.e. the instance of

PlayerDataCapability

). This handler instance stores the data, you need to create methods in your interface to interact with the data (read/write it).

 

The

ICapabilitySerializable

is responsible for reading the handler from and writing the handler to NBT.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 9/18/2016 at 12:30 PM, lukas2005 said:

can you show me an example?

 

I linked several examples here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

i have this code:

package pl.minepack.gym.capabilities;

import java.util.concurrent.Callable;

import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;

public class PlayerDataCapabilityClass {

public interface PlayerDataCapability {

	int Strength = 0;

	public int addStrength(int count);
	public int subStrength(int count);

	public void setStrength(int count);
	public int getStrength();

}

public static class PlayerDataCapabilityStorage implements Capability.IStorage<PlayerDataCapability> {

	  @Override
	  public NBTBase writeNBT(Capability<PlayerDataCapability> capability, PlayerDataCapability instance, EnumFacing side) {
		  NBTTagCompound nbt = new NBTTagCompound();
		  
		  nbt.setInteger("Strength", instance.getStrength());
		  
		  return nbt;
	  }

		@Override
		public void readNBT(Capability<PlayerDataCapability> capability, PlayerDataCapability instance, EnumFacing side,
				NBTBase nbt) {

			instance.setStrength(((NBTTagCompound)nbt).getInteger("Strength"));

		}

}

public static class PlayerDataCapabilityFactory implements PlayerDataCapability {

	private int Strength = 0;

	@Override
	public int addStrength(int count) {

		return this.Strength += count;
	}

	@Override
	public int subStrength(int count) {

		return this.Strength -= count;
	}

	@Override
	public void setStrength(int count) {

		this.Strength = count;

	}

	@Override
	public int getStrength() {
		// TODO Auto-generated method stub
		return this.Strength;
	}  
}


}

and what now?

Guest
This topic is now closed to further replies.

Announcements




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
  • Topics

×
×
  • Create New...

Important Information

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