-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Enchantments: Vitality & Enlightenment
+ new enchantment: Enlightenment + new enchantment: Vitality + fishing items were printing information to console (now it is disabled) + maximum Fishing Fanatic level name changed (from Fishing Fanatic VI to True Fishing Fanatic) + shield is now enchantable + new shield enchantments will be visible in Combat Tab Group + fixed wrong particles for HumanSlayerEnchantment (in version 1.16.3) + minor cod changes
- Loading branch information
Showing
24 changed files
with
480 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...1-15-2/src/main/java/com/wonderfulenchantments/enchantments/EnlightenmentEnchantment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.wonderfulenchantments.enchantments; | ||
|
||
import com.wonderfulenchantments.RegistryHandler; | ||
import com.wonderfulenchantments.WonderfulEnchantments; | ||
import net.minecraft.enchantment.*; | ||
import net.minecraft.inventory.EquipmentSlotType; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.event.entity.player.PlayerXpEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
|
||
@Mod.EventBusSubscriber | ||
public class EnlightenmentEnchantment extends Enchantment { | ||
public EnlightenmentEnchantment() { | ||
super( Rarity.RARE, EnchantmentType.ARMOR, new EquipmentSlotType[]{ EquipmentSlotType.HEAD, EquipmentSlotType.CHEST, EquipmentSlotType.LEGS, EquipmentSlotType.FEET } ); | ||
} | ||
|
||
@Override | ||
public int getMinEnchantability( int enchantmentLevel ) { | ||
return 6 + enchantmentLevel * 12; | ||
} | ||
|
||
@Override | ||
public int getMaxEnchantability( int enchantmentLevel ) { | ||
return this.getMinEnchantability( enchantmentLevel ) + 20; | ||
} | ||
|
||
@Override | ||
public int getMaxLevel() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public boolean canApply( ItemStack stack ) { | ||
return super.canApply( stack ); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onXPPickUp( PlayerXpEvent.PickupXp event ) { | ||
int levelSum = 0; | ||
for( ItemStack armor : event.getPlayer().getArmorInventoryList() ) | ||
levelSum += EnchantmentHelper.getEnchantmentLevel( RegistryHandler.ENLIGHTENMENT.get(), armor ); | ||
|
||
if( levelSum > 0 ) { | ||
double bonusRatio = 0.25D * (double) levelSum; | ||
double randomBonus = bonusRatio * WonderfulEnchantments.RANDOM.nextDouble(); | ||
int bonusExp = (int) (Math.round(randomBonus * (double) event.getOrb().getXpValue())); | ||
|
||
event.getPlayer().giveExperiencePoints(bonusExp); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...ments1-15-2/src/main/java/com/wonderfulenchantments/enchantments/VitalityEnchantment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.wonderfulenchantments.enchantments; | ||
|
||
import com.wonderfulenchantments.RegistryHandler; | ||
import com.wonderfulenchantments.WonderfulEnchantments; | ||
import net.minecraft.enchantment.Enchantment; | ||
import net.minecraft.enchantment.EnchantmentHelper; | ||
import net.minecraft.entity.SharedMonsterAttributes; | ||
import net.minecraft.entity.ai.attributes.AttributeModifier; | ||
import net.minecraft.entity.ai.attributes.IAttributeInstance; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.inventory.EquipmentSlotType; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.ShieldItem; | ||
import net.minecraftforge.event.TickEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
|
||
import java.util.HashMap; | ||
import java.util.UUID; | ||
|
||
@Mod.EventBusSubscriber | ||
public class VitalityEnchantment extends Enchantment { | ||
public VitalityEnchantment() { | ||
super( Rarity.RARE, RegistryHandler.EnchantmentTypes.SHIELD, new EquipmentSlotType[]{ EquipmentSlotType.OFFHAND } ); | ||
} | ||
|
||
@Override | ||
public int getMinEnchantability( int level ) { | ||
return 5 + 8 * ( level ); | ||
} | ||
|
||
@Override | ||
public int getMaxEnchantability( int level ) { | ||
return this.getMinEnchantability( level ) + 10; | ||
} | ||
|
||
@Override | ||
public int getMaxLevel() { | ||
return 3; | ||
} | ||
|
||
@Override | ||
protected boolean canApplyTogether( Enchantment enchant ) { | ||
return super.canApplyTogether( enchant ); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void checkIfPlayerHasShield( TickEvent.PlayerTickEvent event ) { | ||
PlayerEntity player = event.player; | ||
String nickname = player.getDisplayName().getString(); | ||
|
||
if( !bonuses.containsKey( nickname ) ) | ||
VitalityEnchantment.bonuses.put( nickname, 0 ); | ||
|
||
int totalVitality = getVitalityBonus( player ); | ||
int currentMaxHealthBonus = getMaxHealthBonus( nickname ); | ||
|
||
if( totalVitality != currentMaxHealthBonus ) { | ||
setMaxHealthBonus( nickname, totalVitality ); | ||
updateMaxHealthBonus( player ); | ||
} | ||
} | ||
|
||
private static int getVitalityBonus( PlayerEntity player ) { | ||
int sum = 0; | ||
|
||
ItemStack item1 = player.getHeldItemMainhand(), | ||
item2 = player.getHeldItemOffhand(); | ||
|
||
if( item1.getItem() instanceof ShieldItem ) | ||
sum += EnchantmentHelper.getEnchantmentLevel( RegistryHandler.VITALITY.get(), item1 ); | ||
|
||
if( item2.getItem() instanceof ShieldItem ) | ||
sum += EnchantmentHelper.getEnchantmentLevel( RegistryHandler.VITALITY.get(), item2 ); | ||
|
||
return sum; | ||
} | ||
|
||
protected static HashMap< String, Integer > bonuses = new HashMap<>(); | ||
protected static final UUID MODIFIER_UUID = UUID.fromString( "575cb29a-1ee4-11eb-adc1-0242ac120002" ); | ||
protected static final String MODIFIER_NAME = "VitalityBonus"; | ||
private static void updateMaxHealthBonus( PlayerEntity player ) { | ||
String nickname = player.getDisplayName().getString(); | ||
IAttributeInstance maxHealth = player.getAttribute( SharedMonsterAttributes.MAX_HEALTH ); | ||
|
||
maxHealth.removeModifier( MODIFIER_UUID ); | ||
AttributeModifier modifier = new AttributeModifier( MODIFIER_UUID, MODIFIER_NAME, 2*getMaxHealthBonus( nickname ), AttributeModifier.Operation.ADDITION ); | ||
maxHealth.applyModifier( modifier ); | ||
} | ||
|
||
private static void setMaxHealthBonus( String nickname, int value ) { | ||
VitalityEnchantment.bonuses.replace( nickname, value ); | ||
} | ||
|
||
private static int getMaxHealthBonus( String nickname ) { | ||
return VitalityEnchantment.bonuses.get( nickname ); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...chantments1-15-2/src/main/java/com/wonderfulenchantments/items/ShieldReplacementItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.wonderfulenchantments.items; | ||
|
||
import net.minecraft.item.*; | ||
|
||
public class ShieldReplacementItem extends ShieldItem { | ||
public ShieldReplacementItem() { | ||
super( ( new Item.Properties() ) | ||
.maxDamage( 336 ) | ||
.group( ItemGroup.COMBAT ) | ||
); | ||
} | ||
|
||
@Override | ||
public int getItemEnchantability() { | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
WonderfulEnchantments1-15-2/src/main/resources/assets/wonderful_enchantments/lang/en_gb.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ | ||
"enchantment.wonderful_enchantments.fishing_fanatic": "Fishing Fanatic", | ||
"wonderful_enchantments.fanatic_level_up": "You have become greater Fishing Fanatic!", | ||
"wonderful_enchantments.true_level": "True", | ||
"enchantment.wonderful_enchantments.human_slayer": "Enchantment Against Humanity", | ||
"enchantment.wonderful_enchantments.dodge": "Dodge" | ||
"enchantment.wonderful_enchantments.dodge": "Dodge", | ||
"enchantment.wonderful_enchantments.enlightenment": "Enlightenment", | ||
"enchantment.wonderful_enchantments.vitality": "Vitality" | ||
} |
5 changes: 4 additions & 1 deletion
5
WonderfulEnchantments1-15-2/src/main/resources/assets/wonderful_enchantments/lang/en_us.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ | ||
"enchantment.wonderful_enchantments.fishing_fanatic": "Fishing Fanatic", | ||
"wonderful_enchantments.fanatic_level_up": "You have become greater Fishing Fanatic!", | ||
"wonderful_enchantments.true_level": "True", | ||
"enchantment.wonderful_enchantments.human_slayer": "Enchantment Against Humanity", | ||
"enchantment.wonderful_enchantments.dodge": "Dodge" | ||
"enchantment.wonderful_enchantments.dodge": "Dodge", | ||
"enchantment.wonderful_enchantments.enlightenment": "Enlightenment", | ||
"enchantment.wonderful_enchantments.vitality": "Vitality" | ||
} |
5 changes: 4 additions & 1 deletion
5
WonderfulEnchantments1-15-2/src/main/resources/assets/wonderful_enchantments/lang/pl_pl.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ | ||
"enchantment.wonderful_enchantments.fishing_fanatic": "Fanatyk wędkarstwa", | ||
"wonderful_enchantments.fanatic_level_up": "Stałeś się większym fanatykiem wędkarstwa!", | ||
"wonderful_enchantments.true_level": "Prawdziwy", | ||
"enchantment.wonderful_enchantments.human_slayer": "Zaklęcie przeciwko ludzkości", | ||
"enchantment.wonderful_enchantments.dodge": "Unik" | ||
"enchantment.wonderful_enchantments.dodge": "Unik", | ||
"enchantment.wonderful_enchantments.enlightenment": "Oświecenie", | ||
"enchantment.wonderful_enchantments.vitality": "Witalność" | ||
} |
Oops, something went wrong.