Jump to content

Nereidregulus

Members
  • Posts

    8
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Nereidregulus's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Ok thanks I will check how to do that!
  2. Hello everyone! I'm trying to make a kind of experience bar for my mod. So I've created a RenderGameOverlayEvent event to show the Gui bar on screen, but to make it work, I need to access to the player NBT data to know how much xp does the player have. I've tried DataSaver props = DataSaver.get(this.mc.thePlayer); but it only show the initial data define by the NBT class.(in this case 0, even if my player level is not 0) Is there any way to do that? Here is my code: DataSaver public class DataSaver implements IExtendedEntityProperties { public final static String EXT_PROP_NAME = "DataSaver"; private EntityPlayer player; private int level, xplevel; public DataSaver(EntityPlayer player) { this.player = player; this.level = this.xplevel = 0; } public static void register(EntityPlayer player) { player.registerExtendedProperties(DataSaver.EXT_PROP_NAME, new DataSaver(player)); } public static DataSaver get(EntityPlayer player) { return (DataSaver) player.getExtendedProperties(EXT_PROP_NAME); } @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); properties.setInteger("CurrentLevel", this.level); properties.setInteger("XpLelvel", this.xplevel); compound.setTag(EXT_PROP_NAME, properties); } // Load whatever data you saved @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); this.level = properties.getInteger("CurrentLevel"); this.xplevel = properties.getInteger("XpLelvel"); } @Override public void init(Entity entity, World world) { } public void printInfo() { System.out.println("[Xp Player] XpTotal:" + this.xplevel); System.out.println("[Xp Player] Level:" + this.level); } public int returnXpLevel() { return this.xplevel; } public int returnLevel() { return this.level; } public void addXpToPlayer(int xp) { this.xplevel+=xp; int xptotal=this.xplevel; //Xp / mob: y=2 +(x/5)^1.902 //Xp to up lvl y=10+(2+(x/5)^1.4)^3 //Math.pow(a,b) => a^b //this.level=10+(int)Math.pow(Math.pow(xptotal/5, 1.4)+2, 1.4); if(xptotal>=19) this.level=(int)(5*Math.pow(Math.pow(xptotal-10, 0.333)-2, 0.714)); else this.level=0; System.out.println("[Xp Player] Test equation:" + Math.pow(xptotal-10, 0.33)); System.out.println("[Xp Player] XpTotal:" + this.xplevel); System.out.println("[Xp Player] Level:" + this.level); } public void resetxp() { this.xplevel=0; this.level=0; System.out.println("[Xp Player] XpTotal:" + this.xplevel); System.out.println("[Xp Player] Level:" + this.level); } } GuiXpBar public class GuiXpBar extends Gui { private Minecraft mc; NBTTagCompound nbt; EntityPlayer p; private static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":" + "textures/gui/bar.png"); public GuiXpBar(Minecraft mc) { super(); this.mc = mc; } @SubscribeEvent public void onRenderExperienceBar(RenderGameOverlayEvent event) { if(event.isCancelable() || event.type != ElementType.EXPERIENCE) { return; } p = mc.thePlayer; nbt = p.getEntityData(); DataSaver props = DataSaver.get(this.mc.thePlayer); int xPos = 2; int yPos = 2; this.mc.getTextureManager().bindTexture(texture); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_ALPHA_TEST); drawTexturedModalRect(xPos, yPos, 0, 0, 64, 5); int xpbarwidth = (int)(((float) props.returnXpLevel() / props.returnLevel()) * 49); //drawTexturedModalRect(xPos + 3, yPos + 3, 0, 9, xpbarwidth, 3); String s = "Level:" + props.returnLevel(); yPos += 10; this.mc.fontRenderer.drawString(s, xPos + 1, yPos, 0); this.mc.fontRenderer.drawString(s, xPos - 1, yPos, 0); this.mc.fontRenderer.drawString(s, xPos, yPos + 1, 0); this.mc.fontRenderer.drawString(s, xPos, yPos - 1, 0); this.mc.fontRenderer.drawString(s, xPos, yPos, 8453920); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); } }
  3. I fixed it! I needed to add the following line: DimensionManager.setWorld(dimensionId,null);
  4. Ok my mad, I have register the wrong type of event, I used FMLCommonHandler.instance().bus().register(new DungeonEventHandler()); instead of MinecraftForge.EVENT_BUS.register(new DungeonEventHandler()); Now the dimension is deleted when minecraft unload it, but I still can't do it by myself. Anyone here have a solution?
  5. Yes but the world can't be deleted if it is loaded. Also, I have a problem on the world unload event, it seems that i can't make it work properly. package com.MysteryDungeon.Main; import java.io.File; import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.event.world.WorldEvent; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; public class DungeonEventHandler { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionUnload(WorldEvent.Unload event) { System.out.println("Top"); //Rest of the code } } And when a dimension unload, or when i stop the game (all dimension should unload when i close the game), the "Top" doesn't appear on console. Did I miss something or did I do something wrong?
  6. Thank you, I've finally succeed to do it with a tickhandler, but i still have to wait the unloading of a dimension...
  7. Actually, I want the dimension to be recreated, and so i have to delete it and to unload it. Is there any way to call a function to unload a dimension? Moreover, I won't delete a dimension if a player is inside, but for now i will make this mod work for one player. I were thinking of adding a third dimension, so the first dimension will be deleted when the player leave the second to go to the third. I also know that dimension can be deleted because sometimes when i came back into the first one, it have been regenerated.
  8. Hi everybody! I'm trying to make a new mod for 1.7.10, but I have a problem: For my mod, I want to create a maze in a dimension, and at the end of the maze a block teleport you into the next floor of the maze. Actually I want to make one floor per dimension(similar to mystery dungeon series). I think I will create two dimension, and when the player leave the first one, he gets teleported into the second and the first dimension regenerate. If he leave the second one, he will teleport to the first and the second will regenerate until he found the exit. I've alredy created my dimension, the maze, the dimension regenerate but here is my problem: it seems like if the dimension is loaded, it cannot be deleted(logical), but i don't know how to force this unloading. I've try DimensionManager.setWorld(id,null); but it doesn't work... I also notice that sometimes the unloading is very long to operate ( I assume that the unloading is ongoing if the message "Unloading dimension x" is on the console). Please help me!
×
×
  • Create New...

Important Information

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