mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
xp IV bags
This commit is contained in:
parent
0eb71db3a6
commit
0579ef7ad1
@ -43,7 +43,7 @@ public class ConsumableRecipes {
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.apple_euphemium, 1), new Object[] { "EEE", "EAE", "EEE", 'E', EUPH.nugget(), 'A', Items.apple });
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.tem_flakes, 1, 0), new Object[] { GOLD.nugget(), Items.paper });
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.tem_flakes, 1, 1), new Object[] { GOLD.nugget(), GOLD.nugget(), GOLD.nugget(), Items.paper });
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.tem_flakes, 1, 2), new Object[] { Items.gold_ingot, Items.gold_ingot, GOLD.nugget(), GOLD.nugget(), Items.paper });
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.tem_flakes, 1, 2), new Object[] { GOLD.ingot(), GOLD.ingot(), GOLD.nugget(), GOLD.nugget(), Items.paper });
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.glowing_stew, 1), new Object[] { Items.bowl, Item.getItemFromBlock(ModBlocks.mush), Item.getItemFromBlock(ModBlocks.mush) });
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.balefire_scrambled, 1), new Object[] { Items.bowl, ModItems.egg_balefire });
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.balefire_and_ham, 1), new Object[] { ModItems.balefire_scrambled, Items.cooked_beef });
|
||||
@ -99,8 +99,8 @@ public class ConsumableRecipes {
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_antidote, 6), new Object[] { "SPS", "SMS", "SPS", 'S', ModItems.syringe_empty, 'P', Items.pumpkin_seeds, 'M', Items.reeds });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_poison, 1), new Object[] { "SLS", "LCL", "SLS", 'C', ModItems.syringe_empty, 'S', Items.spider_eye, 'L', PB.dust() });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_poison, 1), new Object[] { "SLS", "LCL", "SLS", 'C', ModItems.syringe_empty, 'S', Items.spider_eye, 'L', ModItems.powder_poison });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_awesome, 1), new Object[] { "SPS", "NCN", "SPS", 'C', ModItems.syringe_empty, 'S', S.dust(), 'P', PU239.nugget(), 'N', ModItems.nugget_pu238 });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_awesome, 1), new Object[] { "SNS", "PCP", "SNS", 'C', ModItems.syringe_empty, 'S', S.dust(), 'P', PU239.nugget(), 'N', ModItems.nugget_pu238 });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_awesome, 1), new Object[] { "SPS", "NCN", "SPS", 'C', ModItems.syringe_empty, 'S', S.dust(), 'P', PU239.nugget(), 'N', PU238.nugget() });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_awesome, 1), new Object[] { "SNS", "PCP", "SNS", 'C', ModItems.syringe_empty, 'S', S.dust(), 'P', PU239.nugget(), 'N', PU238.nugget() });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_metal_empty, 6), new Object[] { "P", "C", "B", 'B', Blocks.iron_bars, 'C', ModItems.rod_empty, 'P', IRON.plate() });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_metal_stimpak, 1), new Object[] { " N ", "NSN", " N ", 'N', Items.nether_wart, 'S', ModItems.syringe_metal_empty });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.syringe_metal_medx, 1), new Object[] { " N ", "NSN", " N ", 'N', Items.quartz, 'S', ModItems.syringe_metal_empty });
|
||||
@ -132,6 +132,7 @@ public class ConsumableRecipes {
|
||||
|
||||
//IV Bags
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.iv_empty, 4), new Object[] { "S", "I", "S", 'S', ModItems.plate_polymer, 'I', IRON.plate() });
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.iv_xp_empty, 1), new Object[] { ModItems.iv_empty, ModItems.powder_magic });
|
||||
|
||||
//Radaway
|
||||
CraftingManager.addShapelessAuto(new ItemStack(ModItems.radaway, 1), new Object[] { ModItems.iv_blood, COAL.dust(), Items.pumpkin_seeds });
|
||||
|
||||
@ -23,6 +23,7 @@ import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.potion.HbmPotion;
|
||||
import com.hbm.tileentity.machine.rbmk.IRBMKFluxReceiver.NType;
|
||||
import com.hbm.util.EnchantmentUtil;
|
||||
|
||||
import api.hbm.block.IToolable.ToolType;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@ -843,6 +844,8 @@ public class ModItems {
|
||||
public static Item syringe_mkunicorn;
|
||||
public static Item iv_empty;
|
||||
public static Item iv_blood;
|
||||
public static Item iv_xp_empty;
|
||||
public static Item iv_xp;
|
||||
public static Item radaway;
|
||||
public static Item radaway_strong;
|
||||
public static Item radaway_flush;
|
||||
@ -3277,6 +3280,18 @@ public class ModItems {
|
||||
user.heal(5F);
|
||||
}).setUnlocalizedName("iv_blood").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_blood");
|
||||
|
||||
iv_xp_empty = new ItemSimpleConsumable().setUseActionServer((stack, user) -> {
|
||||
if(user.experienceTotal >= 100) {
|
||||
ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "hbm:item.syringe", new ItemStack(ModItems.iv_xp));
|
||||
EnchantmentUtil.setExperience(user, user.experienceTotal - 100);
|
||||
}
|
||||
}).setUnlocalizedName("iv_xp_empty").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_xp_empty");
|
||||
|
||||
iv_xp = new ItemSimpleConsumable().setUseActionServer((stack, user) -> {
|
||||
ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "random.orb", new ItemStack(ModItems.iv_xp_empty));
|
||||
EnchantmentUtil.addExperience(user, 100, false);
|
||||
}).setUnlocalizedName("iv_xp").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":iv_xp");
|
||||
|
||||
radaway = new ItemSimpleConsumable().setUseActionServer((stack, user) -> {
|
||||
ItemSimpleConsumable.giveSoundAndDecrement(stack, user, "hbm:item.radaway", new ItemStack(ModItems.iv_empty));
|
||||
user.addPotionEffect(new PotionEffect(HbmPotion.radaway.id, 14, 9));
|
||||
@ -7498,6 +7513,8 @@ public class ModItems {
|
||||
GameRegistry.registerItem(med_bag, med_bag.getUnlocalizedName());
|
||||
GameRegistry.registerItem(iv_empty, iv_empty.getUnlocalizedName());
|
||||
GameRegistry.registerItem(iv_blood, iv_blood.getUnlocalizedName());
|
||||
GameRegistry.registerItem(iv_xp_empty, iv_xp_empty.getUnlocalizedName());
|
||||
GameRegistry.registerItem(iv_xp, iv_xp.getUnlocalizedName());
|
||||
GameRegistry.registerItem(radaway, radaway.getUnlocalizedName());
|
||||
GameRegistry.registerItem(radaway_strong, radaway_strong.getUnlocalizedName());
|
||||
GameRegistry.registerItem(radaway_flush, radaway_flush.getUnlocalizedName());
|
||||
|
||||
@ -15,7 +15,7 @@ import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSimpleConsumable extends Item {
|
||||
public class ItemSimpleConsumable extends ItemCustomLore {
|
||||
|
||||
//if java is giving me the power of generics and delegates then i'm going to use them, damn it!
|
||||
private BiConsumer<ItemStack, EntityPlayer> useAction;
|
||||
|
||||
@ -1,15 +1,27 @@
|
||||
package com.hbm.util;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class EnchantmentUtil {
|
||||
|
||||
/**
|
||||
* Adds an enchantment of the given level to the supplied itemstack
|
||||
* @param stack
|
||||
* @param enchantment
|
||||
* @param level
|
||||
*/
|
||||
public static void addEnchantment(ItemStack stack, Enchantment enchantment, int level) {
|
||||
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an enchantment from the given itemstack, regardless of level
|
||||
* @param stack
|
||||
* @param enchantment
|
||||
*/
|
||||
public static void removeEnchantment(ItemStack stack, Enchantment enchantment) {
|
||||
|
||||
if(stack.getEnchantmentTagList() == null)
|
||||
@ -27,4 +39,78 @@ public class EnchantmentUtil {
|
||||
if(stack.getEnchantmentTagList().tagCount() == 0)
|
||||
stack.getTagCompound().removeTag("ench");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the XP bar for the given level
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
public static int xpBarCap(int level) {
|
||||
return level >= 30 ? 62 + (level - 30) * 7 : (level >= 15 ? 17 + (level - 15) * 3 : 17);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param targetXp
|
||||
* @return
|
||||
*/
|
||||
public static int getLevelForExperience(int xp) {
|
||||
|
||||
int level = 0;
|
||||
|
||||
while (true) {
|
||||
|
||||
int xpCap = xpBarCap(level);
|
||||
|
||||
if (xp < xpCap)
|
||||
return level;
|
||||
|
||||
xp -= xpCap;
|
||||
level++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identical to EntityPlayer.addExperience but without increasing the player's score
|
||||
* @param player
|
||||
* @param xp
|
||||
*/
|
||||
public static void addExperience(EntityPlayer player, int xp, boolean silent) {
|
||||
|
||||
int j = Integer.MAX_VALUE - player.experienceTotal;
|
||||
|
||||
if(xp > j) {
|
||||
xp = j;
|
||||
}
|
||||
|
||||
player.experience += (float)xp / (float)player.xpBarCap();
|
||||
|
||||
for(player.experienceTotal += xp; player.experience >= 1.0F; player.experience /= (float)player.xpBarCap()) {
|
||||
player.experience = (player.experience - 1.0F) * (float)player.xpBarCap();
|
||||
|
||||
if(silent)
|
||||
addExperienceLevelSilent(player, 1);
|
||||
else
|
||||
player.addExperienceLevel(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setExperience(EntityPlayer player, int xp) {
|
||||
|
||||
player.experienceLevel = 0;
|
||||
player.experience = 0.0F;
|
||||
player.experienceTotal = 0;
|
||||
|
||||
addExperience(player, xp, true);
|
||||
}
|
||||
|
||||
public static void addExperienceLevelSilent(EntityPlayer player, int level) {
|
||||
player.experienceLevel += level;
|
||||
|
||||
if (player.experienceLevel < 0) {
|
||||
player.experienceLevel = 0;
|
||||
player.experience = 0.0F;
|
||||
player.experienceTotal = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/main/resources/assets/hbm/textures/items/iv_xp.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/iv_xp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 443 B |
BIN
src/main/resources/assets/hbm/textures/items/iv_xp_empty.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/iv_xp_empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Loading…
x
Reference in New Issue
Block a user