Jump to content

[1.7.10] How can I tweak the xpBarCap?


SleepingxForest

Recommended Posts

Hey ive been sitting on this for a few days and have acquired a nice collection of crashlogs

 

im trying to make leveling a little harder to do by tweaking the multipliers in the xpBarCap method that returns how much xp you need to level again after doing a little math.

 

i have a bit of game modding under my belt from previous games ive played but im not all that knowledgeable in java however enough to read+understand whats going on for the most part

 

ive been looking into using event handlers to look for the playerpickupxp but im not sure if thats a viable solution and havent been able to figure out how i can use it to override the method in entityplayer that determines what to set the cap at when you level up.

 

i deleted my initial class files out of frustration last night so i dont have my source anymore :P

 

anyone care to point me in the right direction?

 

it seems like it should be pretty simple right? im probably thinking about it too hard and missing obvious solutions

 

ill probably also be looking to decrease the amount lost on death to make reaching a level harder but a little more sustainable

 

kind of like a MMO style leveling system but with risk still included and makes enchanting more worthwhile

i have alot of other ideas in mind but i havent seen any mods that do something like this so ill share my source code when its finished

Link to comment
Share on other sites

I was just messing around and came up with this without using an event handler

got:

Caused by: java.lang.InstantiationException: mint.mods.levelupevent

 

 

import com.mojang.authlib.GameProfile;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;

@Mod(modid = "exptest", name = "exptest", version = "1.0.0")
public class levelupevent extends EntityPlayer {
private GameProfile field_146106_i;
  
   

public levelupevent(World p_i45324_1_, GameProfile p_i45324_2_)
    {
        super(p_i45324_1_, p_i45324_2_);
        this.entityUniqueID = func_146094_a(p_i45324_2_);
        this.field_146106_i = p_i45324_2_;
        this.inventoryContainer = new ContainerPlayer(this.inventory, !p_i45324_1_.isRemote, this);
        this.openContainer = this.inventoryContainer;
        this.yOffset = 1.62F;
        ChunkCoordinates chunkcoordinates = p_i45324_1_.getSpawnPoint();
        this.setLocationAndAngles((double)chunkcoordinates.posX + 0.5D, (double)(chunkcoordinates.posY + 1), (double)chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F);
        this.field_70741_aB = 180.0F;
        this.fireResistance = 20;
        this.eyeHeight = this.getDefaultEyeHeight();
    }

   public void addExperience(int p_71023_1_)
    {
        this.addScore(p_71023_1_);
        int j = Integer.MAX_VALUE - this.experienceTotal;

        if (p_71023_1_ > j)
        {
            p_71023_1_ = j;
        }

        this.experience += (float)p_71023_1_ / (float)this.xpBarCap();

        for (this.experienceTotal += p_71023_1_; this.experience >= 1.0F; this.experience /= (float)this.xpBarCap())
        {
            this.experience = (this.experience - 1.0F) * (float)this.xpBarCap();
            this.addExperienceLevel(5);
        }
    }

   public int xpBarCap()
    {
        return this.experienceLevel >= 30 ? 1 + (this.experienceLevel - 30) * 1 : (this.experienceLevel >= 15 ? 1 + (this.experienceLevel - 1) * 1 : 1);
    }
        



@Override
public void addChatMessage(IChatComponent p_145747_1_) {
// TODO Auto-generated method stub

}


@Override
public boolean canCommandSenderUseCommand(int p_70003_1_, String p_70003_2_) {
// TODO Auto-generated method stub
return false;
}


@Override
public ChunkCoordinates getPlayerCoordinates() {
// TODO Auto-generated method stub
return null;
}



}

Link to comment
Share on other sites

Time: 10/13/14 11:55 PM
Description: There was a severe problem during mod loading that has caused the game to fail

cpw.mods.fml.common.LoaderException: java.lang.InstantiationException: mint.mods.levelupevent
at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:502)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)
at net.minecraft.client.Minecraft.run(Minecraft.java:931)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at GradleStart.bounce(GradleStart.java:107)
at GradleStart.startClient(GradleStart.java:100)
at GradleStart.main(GradleStart.java:55)
Caused by: java.lang.InstantiationException: mint.mods.levelupevent
at java.lang.Class.newInstance(Unknown Source)
at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:173)
at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:486)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:492)
... 17 more

Link to comment
Share on other sites

mind helping me understand how i can call out the entityxporb?

 

i kinda guessed on using the entityjoinworld event

so far i have this. keep in mind its just a guess because im still trying to find what actually determines who drops "x"f of orbs

public class levelupevent extends EntityJoinWorldEvent
{

    public levelupevent(Entity entity) {
	super(entity, world);
	// TODO Auto-generated constructor stub
               // does the auto gen even make a constructor right?
}

public final levelupevent entity;

    public void EntityEvent(levelupevent entity)
    {
        this.entity = entity;
    }
    
}

 

Im not looking to have someone finish the code for me, im looking for the how and why :P

all help is very appreciated!

Link to comment
Share on other sites

@Mod(modid = "exptest", name = "exptest", version = "1.0.0")

public class levelupevent extends EntityPlayer {

In case you haven't learned it yet, that is not how @Mod is used. Look at the basic tutorials on the wiki.

 

As for events, i recommend PlayerPickupXpEvent.

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.