Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package we;
- import static net.minecraft.enchantment.EnumEnchantmentType.*;
- import net.minecraft.enchantment.Enchantment;
- import net.minecraft.enchantment.EnchantmentHelper;
- import net.minecraft.enchantment.EnumEnchantmentType;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import cpw.mods.fml.common.FMLCommonHandler;
- import cpw.mods.fml.common.Mod;
- import cpw.mods.fml.common.event.FMLPreInitializationEvent;
- import cpw.mods.fml.common.eventhandler.SubscribeEvent;
- import cpw.mods.fml.common.gameevent.TickEvent;
- public @Mod(modid = "wastelandenchantments", version = "1.0.1710.b1", name = "WastelandEnchantments") class WastelandEnchantments {
- @Mod.Instance public static WastelandEnchantments instance;
- public static Enchantment movespeed = new EnchantmentMod(100, 5, armor_feet, "Speed", 4),
- digspeed = new EnchantmentMod(101, 6, armor_torso, "Haste", 2),
- damage = new EnchantmentMod(102, 7, armor_torso, "Strength",2),
- jumpboost = new EnchantmentMod(103, 5, armor_legs, "Jump Boost", 3),
- regen = new EnchantmentMod(104, 7, armor_torso, "Regeneration", 2),
- resistane = new EnchantmentMod(105, 5, armor_torso, "Resistance", 3),
- fireResistance = new EnchantmentMod(106, 6, armor_legs, "Fire Resistance", 1),
- breathe = new EnchantmentMod(107, 5, armor_head, "Underwater breathe", 3),
- invisibility = new EnchantmentMod(108, 7, armor_head, "Invisibility", 1),
- nightvision = new EnchantmentMod(109, 7, armor_head, "Night vision", 1),
- absorption = new EnchantmentMod(110, 7, armor_torso, "Absorption", 1),
- saturation = new EnchantmentMod(111, 8, armor_head, "Saturation", 1);
- public @Mod.EventHandler void preinit(FMLPreInitializationEvent e){
- FMLCommonHandler.instance().bus().register(this);
- }
- public @SubscribeEvent void playerTick(TickEvent.PlayerTickEvent event){
- if(event.player.worldObj.getTotalWorldTime() % 50 == 0){
- handleEnchantment(Potion.moveSpeed, movespeed, event.player, 0);
- handleEnchantment(Potion.digSpeed, digspeed, event.player, 2);
- handleEnchantment(Potion.damageBoost, damage, event.player, 0);
- handleEnchantment(Potion.jump, jumpboost, event.player, 1);
- handleEnchantment(Potion.regeneration, regen, event.player, 2);
- handleEnchantment(Potion.resistance, resistane, event.player, 2);
- handleEnchantment(Potion.fireResistance, fireResistance, event.player, 1);
- handleEnchantment(Potion.waterBreathing, breathe, event.player, 3);
- handleEnchantment(Potion.invisibility, invisibility, event.player, 3);
- handleEnchantment(Potion.nightVision, nightvision, event.player, 3);
- handleEnchantment(Potion.field_76443_y, saturation, event.player, 3);
- }
- if(event.player.worldObj.getTotalWorldTime() % 100 == 0) handleEnchantment(Potion.field_76444_x, absorption, event.player, 2);
- }
- public void handleEnchantment(Potion p, Enchantment e, EntityPlayer plr, int aromorpiece){
- int lvl = EnchantmentHelper.getEnchantmentLevel(e.effectId, plr.getCurrentArmor(aromorpiece));
- if(lvl != 0)plr.addPotionEffect(new PotionEffect(p.id, 100, lvl-1, false));
- }
- public static class EnchantmentMod extends Enchantment{
- private int mxlvl;
- public EnchantmentMod(int id, int rarity, EnumEnchantmentType eet, String name, int maxlevel) {
- super(id, rarity, eet);
- setName(name);
- mxlvl = maxlevel;
- }
- public @Override int getMinEnchantability(int l){
- return 5 + (l-1) * 10;
- }
- public @Override int getMaxEnchantability(int l){
- return getMinEnchantability(l) + 20;
- }
- public @Override int getMaxLevel(){
- return mxlvl;
- }
- public @Override String getName(){
- return name;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement