Skip to content

Commit

Permalink
Merged 1.7.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz committed Jun 3, 2023
2 parents 077c8b3 + 93239df commit ad8bbf2
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 92 deletions.
16 changes: 11 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'

version = '1.7.4'
version = versions_mod
group = 'com.majruszsdifficulty'
archivesBaseName = 'majruszs-difficulty-1.19.3'
archivesBaseName = "majruszs-difficulty-${versions_minecraft}"

// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
mappings channel: 'official', version: '1.19.3'
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 @@ -74,9 +74,15 @@ repositories {
}
}

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

dependencies {
minecraft 'net.minecraftforge:forge:1.19.3-44.0.18'
implementation fg.deobf( 'com.mlib:majrusz-library-1.19.3:4.0.0' )
minecraft "net.minecraftforge:forge:${versions_minecraft}-${versions_forge}"
implementation fg.deobf( "com.mlib:majrusz-library-${versions_minecraft}:${versions_mlib}" )
}

// Example for how to get properties into the manifest for reading at runtime.
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.3
versions_minecraft_range=[1.19.3,1.20)
versions_forge=44.0.18
versions_forge_range=[44.0.0,)
versions_mod=1.7.5
versions_mlib=4.1.0
versions_mlib_range=[4.1.0,5.0.0)
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public void tick() {
this.hasTarget = hasTarget;
PacketHandler.CHANNEL.send( PacketDistributor.DIMENSION.with( ()->this.level.dimension() ), new TargetMessage( this ) );
}
if( this.isSunBurnTick() ) {
this.setSecondsOnFire( 8 );
}
}

@Override
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/majruszsdifficulty/entities/TankEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ public void tick() {
super.tick();

this.skills.tick();
if( this.isSunBurnTick() ) {
this.setSecondsOnFire( 8 );
}
}

public static class Skills extends CustomSkills< SkillType > {
Expand Down Expand Up @@ -159,7 +162,7 @@ public boolean tryToStart( LivingEntity entity, double distanceSquared ) {
this.start( Random.tryChance( 0.5 ) ? SkillType.STANDARD_LEFT_ATTACK : SkillType.STANDARD_RIGHT_ATTACK, Utility.secondsToTicks( 0.6 ) )
.onRatio( 0.45f, ()->{
if( Math.sqrt( this.mob.distanceTo( entity ) ) < 2.5 ) {
this.hitEntity( entity );
this.tryToHitEntity( entity );
this.playHitSound();
}
} );
Expand Down Expand Up @@ -205,7 +208,11 @@ private Optional< BlockState > getBlockStateBelowPosition( Level level, Vec3 pos
return Optional.empty();
}

private void hitEntity( LivingEntity entity ) {
private void tryToHitEntity( LivingEntity entity ) {
if( !this.mob.canAttack( entity, TargetingConditions.DEFAULT ) ) {
return;
}

this.mob.doHurtTarget( entity );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class CreeperChainReaction {
public CreeperChainReaction() {
ConfigGroup group = ModConfigs.registerSubgroup( Registries.Groups.DEFAULT )
.name( "CreeperChainReaction" )
.comment( "Makes a Creeper ignite once any other Creeper explode nearby." );
.comment( "Makes a Creeper ignite when any other Creeper explodes nearby." );

OnDamaged.listen( this::igniteCreeper )
.addCondition( CustomConditions.gameStageAtLeast( GameStage.EXPERT ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ private void makeMobsStronger( OnSpawned.Data data ) {
LivingEntity entity = data.target;
double nightMultiplier = data.getServerLevel().isNight() ? this.nightMultiplier.get() : 1.0;

MAX_HEALTH_ATTRIBUTE.apply( entity ).setValue( this.healthBonus.getCurrentGameStageValue() * nightMultiplier );
DAMAGE_ATTRIBUTE.apply( entity ).setValue( this.damageBonus.getCurrentGameStageValue() * nightMultiplier );
MAX_HEALTH_ATTRIBUTE.setValue( this.healthBonus.getCurrentGameStageValue() * nightMultiplier ).apply( entity );
DAMAGE_ATTRIBUTE.setValue( this.damageBonus.getCurrentGameStageValue() * nightMultiplier ).apply( entity );
entity.setHealth( entity.getMaxHealth() );
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/majruszsdifficulty/items/SoulJarItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ private void updateAttributes( OnItemEquipped.Data data ) {
float luckBonus = hasBonus( data.entity, BonusType.LUCK ) ? LUCK_BONUS : 0.0f;
float swimBonus = hasBonus( data.entity, BonusType.SWIM ) ? SWIM_BONUS : 0.0f;

MOVE_ATTRIBUTE.apply( entity ).setValue( multiplier * moveBonus );
ARMOR_ATTRIBUTE.apply( entity ).setValue( multiplier * armorBonus );
REACH_ATTRIBUTE.apply( entity ).setValue( multiplier * rangeBonus );
RANGE_ATTRIBUTE.apply( entity ).setValue( multiplier * rangeBonus );
LUCK_ATTRIBUTE.apply( entity ).setValue( multiplier * luckBonus );
SWIM_ATTRIBUTE.apply( entity ).setValue( multiplier * swimBonus );
MOVE_ATTRIBUTE.setValue( multiplier * moveBonus ).apply( entity );
ARMOR_ATTRIBUTE.setValue( multiplier * armorBonus ).apply( entity );
REACH_ATTRIBUTE.setValue( multiplier * rangeBonus ).apply( entity );
RANGE_ATTRIBUTE.setValue( multiplier * rangeBonus ).apply( entity );
LUCK_ATTRIBUTE.setValue( multiplier * luckBonus ).apply( entity );
SWIM_ATTRIBUTE.setValue( multiplier * swimBonus ).apply( entity );
}

private void increaseDamage( OnPreDamaged.Data data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,16 @@ public InteractionResultHolder< ItemStack > use( Level level, Player player, Int
ItemStack itemStack = player.getItemInHand( hand );

if( !level.isClientSide ) {
if( player instanceof ServerPlayer serverPlayer ) {
this.triggerTreasureBagAdvancement( serverPlayer );
}

SoundHandler.ITEM_PICKUP.play( level, player.position() );
List< ItemStack > loot = generateLoot( player );
List< ItemStack > loot = this.generateLoot( player );
OnTreasureBagOpened.dispatch( player, this, loot );
if( level instanceof ServerLevel serverLevel ) {
loot.forEach( reward->ItemHelper.giveItemStackToPlayer( reward, player, serverLevel ) );
}
ItemHelper.consumeItemOnUse( itemStack, player );
if( player instanceof ServerPlayer serverPlayer ) {
this.triggerTreasureBagAdvancement( serverPlayer );
}
}

return InteractionResultHolder.sidedSuccess( itemStack, level.isClientSide() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void applyRottenFleshBoost( OnFoodPropertiesGet.Data data ) {
private void updateArmorBonus( OnItemEquipped.Data data ) {
int armorBonus = BONUS_3.isConditionMet( this, data.entity ) ? EXTRA_ARMOR : 0;

ARMOR_ATTRIBUTE.apply( data.entity ).setValue( armorBonus );
ARMOR_ATTRIBUTE.setValue( armorBonus ).apply( data.entity );
}

private void increaseMultiplier( OnSoulJarMultiplier.Data data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mlib.Utility;
import com.mlib.annotations.AutoInstance;
import com.mlib.config.ConfigGroup;
import com.mlib.data.SerializableStructure;
import com.mlib.gamemodifiers.Condition;
import com.mlib.gamemodifiers.ModConfigs;
import com.mlib.gamemodifiers.contexts.OnDamaged;
Expand All @@ -15,10 +16,13 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.raid.Raid;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;

import javax.annotation.Nullable;
import java.util.ArrayList;
Expand All @@ -30,8 +34,6 @@
public class TreasureBagManager {
static final String PARTICIPANT_LIST_TAG = "TreasureBagPlayersToReward";
static final String PLAYER_TAG = "TreasureBagPlayerUUID";
static final String FISHING_TAG = "TreasureBagFishingCounter";
static final String RAID_TAG = "TreasureBagLastPillagerRaidID";
static final List< Register > REGISTERS = new ArrayList<>();

public static void addTreasureBagTo( EntityType< ? > entityType, TreasureBagItem treasureBag ) {
Expand Down Expand Up @@ -78,33 +80,39 @@ public TreasureBagManager() {
return treasureBag != null && treasureBag.isEnabled();
} ) ).insertTo( group );

/*OnItemFished.listen( this::giveTreasureBagToAngler )
OnItemFished.listen( this::giveTreasureBagToAngler )
.addCondition( Condition.isServer() )
.addCondition( Condition.predicate( data->{
int requiredFishCount = TreasureBagItem.Fishing.REQUIRED_FISH_COUNT.getCurrentGameStageValue();
NBTHelper.IntegerData fishedItems = new NBTHelper.IntegerData( data.player, FISHING_TAG );
fishedItems.set( x->( x + 1 ) % requiredFishCount );
CompoundTag tag = data.player.getPersistentData();
FishingData fishingData = new FishingData();
fishingData.read( tag );
fishingData.fishedItems = ( fishingData.fishedItems + 1 ) % TreasureBagItem.Fishing.REQUIRED_FISH_COUNT.getCurrentGameStageValue();
fishingData.write( tag );

return fishedItems.get() == 0;
return fishingData.fishedItems == 0;
} ) ).addCondition( Condition.predicate( data->TreasureBagItem.Fishing.CONFIG.isEnabled() ) )
.insertTo( group );

OnPlayerTick.listen( this::giveTreasureBagToHero )
.addCondition( Condition.isServer() )
.addCondition( Condition.predicate( data->TimeHelper.hasServerTicksPassed( 20 ) ) )
.addCondition( Condition.< OnPlayerTick.Data > cooldown( 20, Dist.DEDICATED_SERVER ).configurable( false ) )
.addCondition( Condition.predicate( data->{
assert data.level != null;
Raid raid = data.level.getRaidAt( data.player.blockPosition() );
if( raid == null || !raid.isVictory() || !data.player.hasEffect( MobEffects.HERO_OF_THE_VILLAGE ) )
Raid raid = data.getServerLevel().getRaidAt( data.player.blockPosition() );
if( raid == null || !raid.isVictory() || !data.player.hasEffect( MobEffects.HERO_OF_THE_VILLAGE ) ) {
return false;
}

NBTHelper.IntegerData lastRaidId = new NBTHelper.IntegerData( data.player, RAID_TAG );
if( lastRaidId.get() == raid.getId() )
CompoundTag tag = data.player.getPersistentData();
RaidData raidData = new RaidData();
raidData.read( tag );
if( raidData.raidId == raid.getId() ) {
return false;
}

lastRaidId.set( raid.getId() );
raidData.raidId = raid.getId();
raidData.write( tag );
return true;
} ) ).insertTo( group );*/
} ) ).insertTo( group );
}

private void addPlayerToParticipantList( OnDamaged.Data damagedData ) {
Expand Down Expand Up @@ -166,5 +174,21 @@ private void giveTreasureBagToHero( OnPlayerTick.Data tickData ) {
giveTreasureBagTo( tickData.player, Registries.PILLAGER_TREASURE_BAG.get(), tickData.getServerLevel() );
}

static class FishingData extends SerializableStructure {
int fishedItems = 0;

public FishingData() {
this.define( "TreasureBagFishingCounter", ()->this.fishedItems, x->this.fishedItems = x );
}
}

static class RaidData extends SerializableStructure {
int raidId = -1;

public RaidData() {
this.define( "TreasureBagLastPillagerRaidID", ()->this.raidId, x->this.raidId = x );
}
}

record Register( EntityType< ? > entityType, TreasureBagItem treasureBag ) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private MobInfo getNextMobToSpawn() {
}

private void spawnMob( MobInfo mobInfo ) {
Vec3 position = AnyPos.from( mobInfo.position ).sub( 0.0, 0.5, 0.0 ).vec3();
Vec3 position = AnyPos.from( mobInfo.position ).add( 0.0, 0.25, 0.0 ).vec3();
Entity entity = EntityHelper.spawn( mobInfo.type, this.undeadArmy.level, position );
if( !( entity instanceof PathfinderMob mob ) ) {
this.undeadArmy.mobsLeft.remove( mobInfo ); // something went wrong, mob could not spawn, and we do not want to block the Undead Army
Expand All @@ -67,7 +67,7 @@ private void spawnMob( MobInfo mobInfo ) {

mobInfo.uuid = mob.getUUID();
this.updateWaveHealth( mobInfo );
this.loadEquipment( mob, mobInfo );
this.tryToLoadEquipment( mob, mobInfo );
this.addGoals( mob );
this.makePersistent( mob );
ExtraLootInfo.addExtraLootTag( mob );
Expand Down Expand Up @@ -118,7 +118,11 @@ private Vec3 buildOffset() {
return AnyPos.from( direction.x * spawnRadius, 0, direction.z * spawnRadius ).add( Random.getRandomVector( -x, x, -y, y, -z, z ) ).vec3();
}

private void loadEquipment( PathfinderMob mob, MobInfo mobInfo ) {
private void tryToLoadEquipment( PathfinderMob mob, MobInfo mobInfo ) {
if( mobInfo.equipment == null ) {
return;
}

LootHelper.getLootTable( mobInfo.equipment )
.getRandomItems( LootHelper.toGiftContext( mob ) )
.forEach( itemStack->ItemHelper.equip( mob, itemStack ) );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.majruszsdifficulty.undeadarmy.data;


import com.mlib.data.SerializableStructure;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.storage.loot.LootTable;

public class MobDef extends SerializableStructure {
public EntityType< ? > type;
public int count = 1;
public ResourceLocation equipment = LootTable.EMPTY.getLootTableId();
public ResourceLocation equipment;

public MobDef() {
this.define( "type", ()->this.type, x->this.type = x );
Expand Down
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/MajruszsProgressiveDifficultyMod/i

[[mods]]
modId = "majruszsdifficulty"
version = "1.7.4"
version = "${versions_mod}"
displayName = "Majrusz's Progressive Difficulty"
updateJSONURL = "https://raw.githubusercontent.com/Majrusz/MinecraftCommon/main/ProgressiveDifficulty/update.json"
displayURL = "https://www.curseforge.com/minecraft/mc-mods/majruszs-progressive-difficulty"
Expand All @@ -17,20 +17,20 @@ issueTrackerURL = "https://github.com/Majrusz/MajruszsProgressiveDifficultyMod/i
[[dependencies.majruszsdifficulty]]
modId = "forge"
mandatory = true
versionRange = "[44.0.0,)"
versionRange = "${versions_forge_range}"
ordering = "NONE"
side = "BOTH"

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

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

0 comments on commit ad8bbf2

Please sign in to comment.