Posted July 18, 201510 yr Im trying to bind some customprops to the player, but when i call the method that acts like public static final RLMPlayerProps get(EntityPlayer player){ return (RLMPlayerProps)player.getExtendedEntityProperties(EXT_PROPS_NAME); } and i get a field of it, it sometimes doesn't work. Any suggestions?
July 18, 201510 yr Where are you calling the method from? Show code. http://i.imgur.com/NdrFdld.png[/img]
July 18, 201510 yr Author Here is the IExtendedProperties class: package itsamysterious.mods.reallifemod.core.lifesystem; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; public class RLMPlayerProps implements IExtendedEntityProperties { public EntityPlayer player; public World theWorld; public double toilet; public double water; private int timeWaterless = 0; private int waterlowmessagetime = 0; public float money; public String name; public String surname; public double energy; public static final String EXT_PROP_NAME = "RealLifeProperties"; public static final void register(EntityPlayer player) { player.registerExtendedProperties(EXT_PROP_NAME, new RLMPlayerProps()); } public static final RLMPlayerProps get(EntityPlayer player) { return (RLMPlayerProps) player.getExtendedProperties(EXT_PROP_NAME); } public void circleOfLife() { if (this.player != null && !player.capabilities.isCreativeMode) { if (this.water > 0.1) { this.water -= 0.00138888889D; } if (this.toilet < 100) { this.toilet += 0.00415151515151515D; } this.updateEffects(); } } private void updateEffects() { water = 100; if (!this.player.worldObj.isRemote) { if (this.water < 40 && waterlowmessagetime % 10 == 0) { this.player.addChatComponentMessage(LinesHelper.ThirstWarning); } if (this.water < 10) { this.player.addChatComponentMessage(LinesHelper.ThirstWarning2); this.player.addPotionEffect(new PotionEffect(Potion.confusion .getId(), 100)); } else if (player.getActivePotionEffect(Potion.confusion) != null) { this.player.removePotionEffect(Potion.confusion.id); } if (this.water < 0.1) { player.addPotionEffect(new PotionEffect( Potion.weakness.getId(), 100)); this.timeWaterless++; if (timeWaterless == 200) { this.player .addChatComponentMessage(LinesHelper.DyingOfThirst); this.player.setHealth(player.getHealth() - 1); } } // Toilet stuff if (toilet > 50) { this.player.addPotionEffect(new PotionEffect(Potion.digSlowdown .getId(), 1)); } else { player.removePotionEffect(Potion.digSlowdown.getId()); } } } @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound theTag = new NBTTagCompound(); compound.setTag(EXT_PROP_NAME, theTag); if (this.player != null) { theTag.setDouble("WATER", this.water); theTag.setDouble("TOILET", this.toilet); theTag.setString("NAME", this.name); theTag.setString("SURNAME", this.surname); theTag.setDouble("ENERGIE", this.energy); this.player.writeEntityToNBT(compound); } } @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound theTag = compound.getCompoundTag(EXT_PROP_NAME); if (this.player != null) { this.water = theTag.getDouble("WATER"); this.toilet = theTag.getDouble("TOILET"); this.name = theTag.getString("NAME"); this.surname = theTag.getString("SURNAME"); this.energy = theTag.getDouble("ENERGIE"); } } @Override public void init(Entity entity, World world) { if (entity instanceof EntityPlayer && entity.worldObj.isRemote) { this.player = (EntityPlayer) entity; if (entity.getExtendedProperties(EXT_PROP_NAME) == null) { this.name = "Please"; this.surname = "Select!"; this.water = 100; this.toilet = 0; } } } public void pee() { while(toilet>0){ toilet-=1; } } public boolean requestMariage(EntityPlayer requester){ return true; } } and here the method call (in a GuiScreen) in the drawScreen Method: RLMPlayerProps props = RLMPlayerProps.get(this.mc.thePlayer); int value = (int)(0.49*props.water); bindTexture( new ResourceLocation("reallifemod:textures/gui/overlay/waterbar_full.png")); drawModalRectWithCustomSizedTexture(20, 5, 0, 0, value,6, 49, 6);
July 18, 201510 yr Okay, you are trying to access your IEEP data on the CLIENT side - have you sent the data you need to from the server to the client? http://i.imgur.com/NdrFdld.png[/img]
July 19, 201510 yr Author Okay, you are trying to access your IEEP data on the CLIENT side - have you sent the data you need to from the server to the client? I don't know. SInce i never learned packet handling and how it basicly works. It seems like everyone knows it just me not. Can you help me plz?
July 19, 201510 yr There are several tutorials on that subject (use Google); surely they can help you more effectively than someone writing snippets of information post by post. http://i.imgur.com/NdrFdld.png[/img]
July 21, 201510 yr Author Okay, i have a packethandler now and i know how packets work. But still the IEEP won't work
July 21, 201510 yr You need to post your new code and write, what isn't working so that we can help you!
July 21, 201510 yr Author I figured it out now. Somehow the GuiOverlay method had some calculations wrong.
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.