Healing Campfire (Fabric)

Healing Campfire (Fabric)

374k Downloads

How do you build Collective?

elhertz opened this issue ยท 0 comments

commented

Information

Minecraft version: 1.21.4
Modloader: Fabric Loader 0.16.10

Mod name: Collective Library
Mod version: 1.21.3-7.89

Question

Hello. I don't know much about java, but I can get around editing functions just fine.
I edited the ExperienceFunctions.class in Collective to make Bottle Your Xp work with Fixed Levels
I know how to use gradle to build projects but this being a multi-modloader project I have no clue what to do. The jar built by gradle doesn't work and I guess it needs to be merged with the common build to work? How do you build the project? Thanks

The code I want to test:
package com.natamus.collective.functions;

import net.minecraft.network.protocol.game.ClientboundEntityEventPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;

public class ExperienceFunctions {
   public static boolean canConsumeXp(final Player ep, final int xp) {
   	if (ep.isCreative()) {
   		return true;
   	}
   	return xp <= 0 || getPlayerXP(ep) >= xp;
   }

   public static void consumeXp(final Player ep, final int xp) {
   	if (xp <= 0) {
   		return;
   	}

   	final int playerXP = getPlayerXP(ep);
   	if (playerXP >= xp) {
   		addPlayerXP(ep, -xp);
   	}

   	if (ep instanceof ServerPlayer) {
   		((ServerPlayer) ep).connection.send(new ClientboundEntityEventPacket(ep, (byte) 9));
   	}
   }

   public static int getPlayerXP(final Player player) {
   	return (int) (getExperienceForLevel(player.experienceLevel) + player.experienceProgress);
   }

   public static void addPlayerXP(final Player player, final int amount) {
   	final int experience = getPlayerXP(player) + amount;
   	player.totalExperience = experience;
   	player.experienceLevel = getLevelForExperience(experience);
   	final int expForLevel = getExperienceForLevel(player.experienceLevel);
   	player.experienceProgress = (float) (experience - expForLevel);
   }

   public static int getLevelForExperience(int targetXp) {
   	int target = targetXp / 30;
   	return target;
   }

   public static int getExperienceForLevel(final int level) {
   	if (level == 0) {
   		return 0;
   	} else {
   		return level * 30;
   	}
   }
}