Skip to content

Commit

Permalink
Merged 1.9.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz committed Jun 17, 2023
1 parent 09e94d2 commit 4678892
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 48 deletions.
19 changes: 13 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.+', changing: true
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
Expand All @@ -14,17 +14,17 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'

version = '1.8.2'
version = versions_mod
group = 'com.majruszsenchantments'
archivesBaseName = 'majruszs-enchantments-1.19.2'
archivesBaseName = "majruszs-enchantments-${versions_minecraft}"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
compileJava {
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
}

minecraft {
mappings channel: 'official', version: '1.19.2'
mappings channel: 'official', version: versions_minecraft

accessTransformer = file( 'src/main/resources/META-INF/accesstransformer.cfg' ) // Currently, this location cannot be changed from the default.

Expand Down Expand Up @@ -96,9 +96,16 @@ repositories {
}
}

processResources {
filesMatching('META-INF/mods.toml') {
expand project.properties
}
outputs.upToDateWhen { false }
}

dependencies {
minecraft 'net.minecraftforge:forge:1.19.2-43.2.0'
implementation fg.deobf( 'com.mlib:majrusz-library-1.19.2:4.0.0' )
minecraft "net.minecraftforge:forge:${versions_minecraft}-${versions_forge}"
implementation fg.deobf( "com.mlib:majrusz-library-${versions_minecraft}:${versions_mlib}" )
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

Expand Down
9 changes: 8 additions & 1 deletion gradle.properties
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.19.2
versions_minecraft_range=[1.19.2,1.20)
versions_forge=43.2.0
versions_forge_range=[43.2.0,)
versions_mod=1.9.0
versions_mlib=4.3.0
versions_mlib_range=[4.3.0,5.0.0)
Binary file not shown.
2 changes: 2 additions & 0 deletions src/main/java/com/majruszsenchantments/Registries.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class Registries {
public static final RegistryObject< LeechEnchantment > LEECH = ENCHANTMENTS.register( "leech", LeechEnchantment::new );
public static final RegistryObject< MagicProtectionEnchantment > MAGIC_PROTECTION = ENCHANTMENTS.register( "magic_protection", MagicProtectionEnchantment::new );
public static final RegistryObject< MisanthropyEnchantment > MISANTHROPY = ENCHANTMENTS.register( "misanthropy", MisanthropyEnchantment::new );
public static final RegistryObject< RepulsionEnchantment > REPULSION = ENCHANTMENTS.register( "repulsion", RepulsionEnchantment::new );
public static final RegistryObject< SixthSenseEnchantment > SIXTH_SENSE = ENCHANTMENTS.register( "sixth_sense", SixthSenseEnchantment::new );
public static final RegistryObject< SmelterEnchantment > SMELTER = ENCHANTMENTS.register( "smelter", SmelterEnchantment::new );
public static final RegistryObject< TelekinesisEnchantment > TELEKINESIS = ENCHANTMENTS.register( "telekinesis", TelekinesisEnchantment::new );
Expand All @@ -70,6 +71,7 @@ public class Registries {
public static final RegistryObject< CorrosionCurse > CORROSION = ENCHANTMENTS.register( "corrosion_curse", CorrosionCurse::new );
public static final RegistryObject< FatigueCurse > FATIGUE = ENCHANTMENTS.register( "fatigue_curse", FatigueCurse::new );
public static final RegistryObject< IncompatibilityCurse > INCOMPATIBILITY = ENCHANTMENTS.register( "incompatibility_curse", IncompatibilityCurse::new );
public static final RegistryObject< SlipperyCurse > SLIPPERY = ENCHANTMENTS.register( "slippery_curse", SlipperyCurse::new );
public static final RegistryObject< VampirismCurse > VAMPIRISM = ENCHANTMENTS.register( "vampirism_curse", VampirismCurse::new );

// Particles
Expand Down
66 changes: 66 additions & 0 deletions src/main/java/com/majruszsenchantments/curses/SlipperyCurse.java
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 );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import com.mlib.gamemodifiers.contexts.OnPreDamaged;
import com.mlib.math.Range;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
import net.minecraft.world.phys.Vec3;

Expand All @@ -34,8 +32,7 @@ public DodgeEnchantment() {

@AutoInstance
public static class Handler {
final DoubleConfig chance = new DoubleConfig( 0.125, new Range<>( 0.01, 0.4 ) );
final DoubleConfig pantsDamageMultiplier = new DoubleConfig( 0.5, new Range<>( 0.0, 10.0 ) );
final DoubleConfig chance = new DoubleConfig( 0.125, new Range<>( 0.01, 0.5 ) );
final Supplier< DodgeEnchantment > enchantment = Registries.DODGE;

public Handler() {
Expand All @@ -54,15 +51,13 @@ public Handler() {
.addCondition( OnPreDamaged.willTakeFullDamage() )
.addCondition( Condition.predicate( this::tryToDodge ) )
.addConfig( this.chance.name( "chance" ).comment( "Chance to completely ignore the damage per enchantment level." ) )
.addConfig( this.pantsDamageMultiplier.name( "pants_damage_multiplier" ).comment( "Percent of damage transferred to pants." ) )
.insertTo( group );
}

private void dodgeDamage( OnPreDamaged.Data data ) {
if( data.getLevel() instanceof ServerLevel level ) {
this.spawnEffects( data.target, level );
}
this.damagePants( data.target, data.damage );

OnPreDamaged.CANCEL.accept( data );
}
Expand All @@ -77,15 +72,6 @@ private void spawnEffects( LivingEntity entity, ServerLevel level ) {
SoundHandler.FIRE_EXTINGUISH.play( level, entity.position() );
}

private void damagePants( LivingEntity entity, float damage ) {
float multiplier = this.pantsDamageMultiplier.asFloat();
if( multiplier > 0.0f ) {
ItemStack pants = entity.getItemBySlot( EquipmentSlot.LEGS );
int totalDamage = Math.max( 1, ( int )( damage * multiplier ) );
pants.hurtAndBreak( totalDamage, entity, owner->owner.broadcastBreakEvent( EquipmentSlot.LEGS ) );
}
}

private boolean tryToDodge( OnPreDamaged.Data data ) {
return Random.tryChance( this.enchantment.get().getEnchantmentLevel( data.target ) * this.chance.get() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ public Handler() {
private void increaseExperience( OnPickupXp.Data data ) {
int enlightenmentSum = this.enchantment.get().getEnchantmentSum( data.player, EquipmentSlots.ARMOR );
int experiencePoints = Random.roundRandomly( enlightenmentSum * this.experienceMultiplier.get() * data.event.getOrb().getValue() );
if( experiencePoints > 1 ) {
data.player.giveExperiencePoints( Random.nextInt( 1, experiencePoints ) );
} else if( experiencePoints > 0 ) {
data.player.giveExperiencePoints( 1 );
if( experiencePoints > 0 ) {
data.player.giveExperiencePoints( experiencePoints );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ private void increaseLoot( OnExtraFishingLootCheck.Data data ) {
List< ItemStack > extraLoot = this.spawnExtraLoot( data, fanaticLevel );

data.extraExperience += extraLoot.size() + Random.nextInt( 1, 2 * extraLoot.size() + 1 );
data.extraRodDamage += extraLoot.size();
data.extraLoot.addAll( extraLoot );
}

Expand Down Expand Up @@ -160,9 +159,9 @@ private void tryToLevelUp( OnItemFished.Data data ) {

this.enchantment.get().increaseEnchantmentLevel( fishingRod );
if( data.player instanceof ServerPlayer player ) {
giveAdvancement( player, "nothing_can_stop_me", ()->isRaining );
giveAdvancement( player, "fishing_fanatic", ()->fanaticLevel + 1 == 1 );
giveAdvancement( player, "fishing_fanatic_true", ()->fanaticLevel + 1 == this.enchantment.get().getMaxLevel() );
giveAdvancement( player, "nothing_can_stop_me", ()->isRaining );
}
sendLevelUpMessage( data.player );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ private boolean isAnyoneBlockingWithFuseCutterNearby( OnExplosionStart.Data data

ItemStack itemStack = ItemHelper.getCurrentlyUsedItem( livingEntity );
if( this.enchantment.get().hasEnchantment( itemStack ) ) {
itemStack.hurtAndBreak( data.radius.intValue(), player, owner->owner.broadcastBreakEvent( livingEntity.getUsedItemHand() ) );
EntityHelper.disableCurrentItem( player, data.radius.doubleValue() * this.cooldownRatio.get() );
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.mlib.math.Range;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -46,7 +45,6 @@ public HarvesterEnchantment() {

@AutoInstance
public static class Handler {
final DoubleConfig durabilityPenalty = new DoubleConfig( 1.0, new Range<>( 0.0, 10.0 ) );
final DoubleConfig growChance = new DoubleConfig( 0.04, Range.CHANCE );
final Supplier< HarvesterEnchantment > enchantment = Registries.HARVESTER;

Expand All @@ -65,7 +63,6 @@ public Handler() {
.addCondition( Condition.predicate( data->this.enchantment.get().hasEnchantment( data.itemStack ) ) )
.addCondition( Condition.predicate( data->data.event instanceof PlayerInteractEvent.RightClickBlock ) )
.addCondition( Condition.predicate( data->BlockHelper.isCropAtMaxAge( data.getLevel(), new BlockPos( data.event.getPos() ) ) ) )
.addConfig( this.durabilityPenalty.name( "durability_penalty" ).comment( "Durability penalty per each successful increase of nearby crops." ) )
.addConfig( this.growChance.name( "extra_grow_chance" ).comment( "Chance to increase an age of nearby crops." ) )
.insertTo( group );

Expand All @@ -85,7 +82,7 @@ public Handler() {

private void increaseAgeOfNearbyCrops( OnPlayerInteract.Data data ) {
this.collectCrop( data.getServerLevel(), data.player, data.position, data.itemStack );
this.tickNearbyCrops( data.getServerLevel(), data.player, data.position, data.itemStack, data.event.getHand() );
this.tickNearbyCrops( data.getServerLevel(), data.position, data.itemStack );
SoundHandler.BONE_MEAL.play( data.getLevel(), AnyPos.from( data.position ).vec3() );
}

Expand All @@ -95,11 +92,8 @@ private void collectCrop( ServerLevel level, Player player, BlockPos position, I
block.playerDestroy( level, player, position, blockState, null, itemStack );
}

private void tickNearbyCrops( ServerLevel level, Player player, BlockPos position, ItemStack itemStack,
InteractionHand hand
) {
private void tickNearbyCrops( ServerLevel level, BlockPos position, ItemStack itemStack ) {
int range = this.enchantment.get().getEnchantmentLevel( itemStack );
double totalDamage = 0;
for( int z = -range; z <= range; ++z ) {
for( int x = -range; x <= range; ++x ) {
if( x == 0 && z == 0 )
Expand All @@ -114,17 +108,12 @@ private void tickNearbyCrops( ServerLevel level, Player player, BlockPos positio
int particlesCount = 1;
if( Random.tryChance( this.growChance.get() ) ) {
BlockHelper.growCrop( level, neighbourPosition );
totalDamage += this.durabilityPenalty.get();
particlesCount = 3;
}

ParticleHandler.AWARD.spawn( level, AnyPos.from( position ).vec3(), particlesCount );
}
}
int finalDamage = Random.roundRandomly( totalDamage );
if( finalDamage > 0 ) {
itemStack.hurtAndBreak( finalDamage, player, owner->owner.broadcastBreakEvent( hand ) );
}
}

private void replant( OnLoot.Data data ) {
Expand Down
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 ) ) );
}
}
}
8 changes: 4 additions & 4 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ issueTrackerURL="https://github.com/Majrusz/MajruszsEnchantmentsMod/issues"

[[mods]]
modId="majruszsenchantments"
version="1.8.2"
version="${versions_mod}"
displayName="Majrusz's Enchantments"
updateJSONURL="https://raw.githubusercontent.com/Majrusz/MinecraftCommon/main/Enchantments/update.json"
displayURL="https://www.curseforge.com/minecraft/mc-mods/wonderful-enchantments"
Expand All @@ -17,20 +17,20 @@ issueTrackerURL="https://github.com/Majrusz/MajruszsEnchantmentsMod/issues"
[[dependencies.majruszsenchantments]]
modId="forge"
mandatory=true
versionRange="[43.2.0,)"
versionRange="${versions_forge_range}"
ordering="NONE"
side="BOTH"

[[dependencies.majruszsenchantments]]
modId="minecraft"
mandatory=true
versionRange="[1.19.2,1.20)"
versionRange="${versions_minecraft_range}"
ordering="NONE"
side="BOTH"

[[dependencies.majruszsenchantments]]
modId="mlib"
mandatory=true
versionRange="[4.0.0,5.0.0)"
versionRange="${versions_mlib_range}"
ordering="NONE"
side="BOTH"
Loading

0 comments on commit 4678892

Please sign in to comment.