From 70c1354a4a96698758a88c032866288f79de6f5a Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Sat, 24 Aug 2024 08:16:37 -0400 Subject: Initial commit --- .../alchemy/characteristic/CharacteristicExp.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/main/java/jp/plusplus/fbs/alchemy/characteristic/CharacteristicExp.java (limited to 'src/main/java/jp/plusplus/fbs/alchemy/characteristic/CharacteristicExp.java') diff --git a/src/main/java/jp/plusplus/fbs/alchemy/characteristic/CharacteristicExp.java b/src/main/java/jp/plusplus/fbs/alchemy/characteristic/CharacteristicExp.java new file mode 100644 index 0000000..f206c73 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/alchemy/characteristic/CharacteristicExp.java @@ -0,0 +1,53 @@ +package jp.plusplus.fbs.alchemy.characteristic; + +import com.mojang.realmsclient.gui.ChatFormatting; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemExpBottle; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +/** + * Created by plusplus_F on 2015/09/24. + */ +public class CharacteristicExp extends CharacteristicBase { + protected boolean reverse; + public CharacteristicExp(boolean minus){ + reverse=minus; + setUnlocalizedName("fbs.exp."+(reverse?"lose":"gain")); + } + + @Override + public Type getType() { + return Type.SCALE; + } + + @Override + public void affectEntity(World world, EntityLivingBase entity){ + if(!(entity instanceof EntityPlayer)) return; + EntityPlayer ep=(EntityPlayer)entity; + + int d=6+6*getType().getCorrectedValue(value); + + if(reverse) { + ep.experience -= (float) d / (float) ep.xpBarCap(); + for (ep.experienceTotal -= d; ep.experience < 0.0F; ep.experience /= (float) ep.xpBarCap()) { + ep.experience = (1.0f - ep.experience) * (float) ep.xpBarCap(); + ep.addExperienceLevel(-1); + } + } + else ((EntityPlayer) entity).addExperience(d); + } + + @Override + public ChatFormatting getNameColor(){ + return reverse?ChatFormatting.RED:ChatFormatting.DARK_GREEN; + } + + public static class Gain extends CharacteristicExp { + public Gain(){ super(false); } + } + public static class Lose extends CharacteristicExp { + public Lose(){ super(true); } + } +} -- cgit v1.2.3