-
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.
- Loading branch information
Showing
13 changed files
with
179 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties. | ||
# This is required to provide enough memory for the Minecraft decompilation process. | ||
org.gradle.jvmargs=-Xmx3G | ||
org.gradle.daemon=false | ||
org.gradle.daemon=false | ||
versions_minecraft=1.20 | ||
versions_minecraft_range=[1.20,1.21) | ||
versions_forge=46.0.1 | ||
versions_forge_range=[46.0.1,) | ||
versions_mod=1.9.0 | ||
versions_mlib=4.3.0 | ||
versions_mlib_range=[4.3.0,5.0.0) |
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
66 changes: 66 additions & 0 deletions
66
src/main/java/com/majruszsenchantments/curses/SlipperyCurse.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,66 @@ | ||
package com.majruszsenchantments.curses; | ||
|
||
import com.majruszsenchantments.Registries; | ||
import com.mlib.EquipmentSlots; | ||
import com.mlib.annotations.AutoInstance; | ||
import com.mlib.config.ConfigGroup; | ||
import com.mlib.config.DoubleConfig; | ||
import com.mlib.enchantments.CustomEnchantment; | ||
import com.mlib.gamemodifiers.Condition; | ||
import com.mlib.gamemodifiers.ModConfigs; | ||
import com.mlib.gamemodifiers.contexts.OnEnchantmentAvailabilityCheck; | ||
import com.mlib.gamemodifiers.contexts.OnPlayerTick; | ||
import com.mlib.math.Range; | ||
import net.minecraft.world.entity.EquipmentSlot; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class SlipperyCurse extends CustomEnchantment { | ||
public SlipperyCurse() { | ||
this.rarity( Rarity.RARE ) | ||
.category( Registries.TOOLS ) | ||
.slots( EquipmentSlots.BOTH_HANDS ) | ||
.curse() | ||
.maxLevel( 1 ) | ||
.minLevelCost( level->10 ) | ||
.maxLevelCost( level->50 ); | ||
} | ||
|
||
@AutoInstance | ||
public static class Handler { | ||
final Supplier< SlipperyCurse > enchantment = Registries.SLIPPERY; | ||
|
||
public Handler() { | ||
ConfigGroup group = ModConfigs.registerSubgroup( Registries.Groups.CURSE ) | ||
.name( "Slippery" ) | ||
.comment( "Makes the item occasionally drop out of hand." ); | ||
|
||
OnEnchantmentAvailabilityCheck.listen( OnEnchantmentAvailabilityCheck.ENABLE ) | ||
.addCondition( OnEnchantmentAvailabilityCheck.is( this.enchantment ) ) | ||
.addCondition( OnEnchantmentAvailabilityCheck.excludable() ) | ||
.insertTo( group ); | ||
|
||
DoubleConfig dropCooldown = new DoubleConfig( 1.0, new Range<>( 0.1, 300.0 ) ); | ||
dropCooldown.name( "drop_cooldown" ).comment( "Cooldown in seconds between ticks." ); | ||
|
||
DoubleConfig dropChance = new DoubleConfig( 0.03, Range.CHANCE ); | ||
dropChance.name( "drop_chance" ).comment( "Chance to drop held item every tick." ); | ||
|
||
OnPlayerTick.listen( this::dropWeapon ) | ||
.addCondition( Condition.isServer() ) | ||
.addCondition( Condition.hasEnchantment( this.enchantment, data->data.player ) ) | ||
.addCondition( Condition.cooldown( dropCooldown, Dist.DEDICATED_SERVER ) ) | ||
.addCondition( Condition.chance( dropChance ) ) | ||
.insertTo( group ); | ||
} | ||
|
||
private void dropWeapon( OnPlayerTick.Data data ) { | ||
EquipmentSlot slot = this.enchantment.get().hasEnchantment( data.player.getMainHandItem() ) ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND; | ||
|
||
data.player.drop( data.player.getItemBySlot( slot ), false ); | ||
data.player.setItemSlot( slot, ItemStack.EMPTY ); | ||
} | ||
} | ||
} |
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
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
62 changes: 62 additions & 0 deletions
62
src/main/java/com/majruszsenchantments/enchantments/RepulsionEnchantment.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,62 @@ | ||
package com.majruszsenchantments.enchantments; | ||
|
||
import com.majruszsenchantments.Registries; | ||
import com.mlib.EquipmentSlots; | ||
import com.mlib.annotations.AutoInstance; | ||
import com.mlib.config.ConfigGroup; | ||
import com.mlib.config.DoubleConfig; | ||
import com.mlib.enchantments.CustomEnchantment; | ||
import com.mlib.gamemodifiers.Condition; | ||
import com.mlib.gamemodifiers.ModConfigs; | ||
import com.mlib.gamemodifiers.contexts.OnDamaged; | ||
import com.mlib.gamemodifiers.contexts.OnEnchantmentAvailabilityCheck; | ||
import com.mlib.items.ItemHelper; | ||
import com.mlib.math.Range; | ||
import net.minecraft.util.Mth; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class RepulsionEnchantment extends CustomEnchantment { | ||
public RepulsionEnchantment() { | ||
this.rarity( Rarity.RARE ) | ||
.category( Registries.SHIELD ) | ||
.slots( EquipmentSlots.BOTH_HANDS ) | ||
.maxLevel( 1 ) | ||
.minLevelCost( level->15 ) | ||
.maxLevelCost( level->45 ); | ||
} | ||
|
||
@AutoInstance | ||
public static class Handler { | ||
final DoubleConfig strength = new DoubleConfig( 1.0, new Range<>( 0.0, 10.0 ) ); | ||
final Supplier< RepulsionEnchantment > enchantment = Registries.REPULSION; | ||
|
||
public Handler() { | ||
ConfigGroup group = ModConfigs.registerSubgroup( Registries.Groups.ENCHANTMENT ) | ||
.name( "Repulsion" ) | ||
.comment( "Knocks back mobs when blocking their attack." ); | ||
|
||
OnEnchantmentAvailabilityCheck.listen( OnEnchantmentAvailabilityCheck.ENABLE ) | ||
.addCondition( OnEnchantmentAvailabilityCheck.is( this.enchantment ) ) | ||
.addCondition( OnEnchantmentAvailabilityCheck.excludable() ) | ||
.insertTo( group ); | ||
|
||
OnDamaged.listen( this::knockbackEnemy ) | ||
.addCondition( Condition.isServer() ) | ||
.addCondition( Condition.predicate( data->data.attacker != null ) ) | ||
.addCondition( OnDamaged.isDirect() ) | ||
.addCondition( OnDamaged.dealtAnyDamage().negate() ) | ||
.addCondition( this.isBlockingWithRepulsionShield() ) | ||
.addConfig( this.strength.name( "strength" ).comment( "Determines how strong the knock back is." ) ) | ||
.insertTo( group ); | ||
} | ||
|
||
private void knockbackEnemy( OnDamaged.Data data ) { | ||
data.attacker.knockback( this.strength.asFloat(), Mth.sin( data.attacker.getYRot() * ( float )Math.PI / 180.0f + ( float )Math.PI ), -Mth.cos( data.attacker.getYRot() * ( float )Math.PI / 180.0f + ( float )Math.PI ) ); | ||
} | ||
|
||
private Condition< OnDamaged.Data > isBlockingWithRepulsionShield() { | ||
return Condition.predicate( data->this.enchantment.get().hasEnchantment( ItemHelper.getCurrentlyUsedItem( data.target ) ) ); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.