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

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?

  • 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);

 

 

  • 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?

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.