ItsAMysteriousYT Posted July 18, 2015 Posted July 18, 2015 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? Quote
coolAlias Posted July 18, 2015 Posted July 18, 2015 Where are you calling the method from? Show code. Quote http://i.imgur.com/NdrFdld.png[/img]
ItsAMysteriousYT Posted July 18, 2015 Author Posted July 18, 2015 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); Quote
coolAlias Posted July 18, 2015 Posted July 18, 2015 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? Quote http://i.imgur.com/NdrFdld.png[/img]
ItsAMysteriousYT Posted July 19, 2015 Author Posted July 19, 2015 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? Quote
coolAlias Posted July 19, 2015 Posted July 19, 2015 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. Quote http://i.imgur.com/NdrFdld.png[/img]
ItsAMysteriousYT Posted July 21, 2015 Author Posted July 21, 2015 Okay, i have a packethandler now and i know how packets work. But still the IEEP won't work Quote
Stjubit Posted July 21, 2015 Posted July 21, 2015 You need to post your new code and write, what isn't working so that we can help you! Quote
ItsAMysteriousYT Posted July 21, 2015 Author Posted July 21, 2015 I figured it out now. Somehow the GuiOverlay method had some calculations wrong. Quote
Recommended Posts
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.