Jump to content

ExtendedEntityProperties not working properly[1.8]


ItsAMysteriousYT

Recommended Posts

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

 

 

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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