Skip to content

Commit

Permalink
Merged 1.8.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz committed Aug 17, 2023
1 parent 02e8c16 commit a86024b
Show file tree
Hide file tree
Showing 244 changed files with 3,533 additions and 1,983 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ processResources {
filesMatching('META-INF/mods.toml') {
expand project.properties
}
outputs.upToDateWhen { false }
}

dependencies {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ versions_minecraft=1.18.2
versions_minecraft_range=[1.18.2,1.19)
versions_forge=40.2.0
versions_forge_range=[40.2.0,)
versions_mod=1.7.7
versions_mlib=4.3.2
versions_mlib_range=[4.3.2,5.0.0)
versions_mod=1.8.0
versions_mlib=5.0.0
versions_mlib_range=[5.0.0,6.0.0)
Binary file removed libs/majrusz-library-1.18.2-4.3.2.jar
Binary file not shown.
Binary file added libs/majrusz-library-1.18.2-5.0.0.jar
Binary file not shown.
20 changes: 10 additions & 10 deletions src/main/java/com/majruszsdifficulty/GameDataSaver.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.majruszsdifficulty;

import com.majruszsdifficulty.gamestage.handlers.GameStageIncreaser;
import com.majruszsdifficulty.gamestage.GameStage;
import com.majruszsdifficulty.gamestage.handlers.GameStageIncreaser;
import com.majruszsdifficulty.treasurebags.TreasureBagProgressManager;
import com.majruszsdifficulty.undeadarmy.Config;
import com.majruszsdifficulty.undeadarmy.UndeadArmyManager;
import com.mlib.data.SerializableHelper;
import com.mlib.data.SerializableStructure;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
Expand All @@ -27,9 +28,7 @@ public GameDataSaver( ServerLevel overworld, CompoundTag tag ) {

@Override
public CompoundTag save( CompoundTag tag ) {
this.data.write( tag );

return tag;
return SerializableHelper.write( ()->this.data, tag );
}

public UndeadArmyManager getUndeadArmyManager() {
Expand All @@ -41,18 +40,19 @@ public TreasureBagProgressManager getTreasureBagProgressManager() {
}

public static class Data extends SerializableStructure {
final UndeadArmyManager undeadArmyManager;
final TreasureBagProgressManager treasureBagProgressManager;
UndeadArmyManager undeadArmyManager;
TreasureBagProgressManager treasureBagProgressManager;

public Data( ServerLevel overworld ) {
super( "MajruszsDifficulty" );

this.undeadArmyManager = new UndeadArmyManager( overworld, Registries.ANNOTATION_HANDLER.getInstance( Config.class ) );
Config config = Registries.HELPER.findInstance( Config.class ).orElseThrow();
this.undeadArmyManager = new UndeadArmyManager( overworld, config );
this.treasureBagProgressManager = new TreasureBagProgressManager();

this.define( "GameStage", GameStage::getCurrentStage, gameStage->GameStage.changeStage( gameStage, null ), GameStage::values );
this.define( "UndeadArmy", ()->this.undeadArmyManager );
this.define( "TreasureBags", ()->this.treasureBagProgressManager );
this.defineEnum( "GameStage", GameStage::getCurrentStage, gameStage->GameStage.changeStage( gameStage, null ), GameStage::values );
this.defineCustom( "UndeadArmy", ()->this.undeadArmyManager, x->this.undeadArmyManager = x, ()->new UndeadArmyManager( overworld, config ) );
this.defineCustom( "TreasureBags", ()->this.treasureBagProgressManager, x->this.treasureBagProgressManager = x, TreasureBagProgressManager::new );
}
}
}
3 changes: 0 additions & 3 deletions src/main/java/com/majruszsdifficulty/MajruszsDifficulty.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.majruszsdifficulty;

import com.mlib.config.ConfigHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;

/** Main modification class. */
@Mod( MajruszsDifficulty.MOD_ID )
public class MajruszsDifficulty {
public static final String MOD_ID = "majruszsdifficulty";
public static final String NAME = "Majrusz's Progressive Difficulty";
public static final ConfigHandler SERVER_CONFIG = new ConfigHandler( ModConfig.Type.SERVER );

public MajruszsDifficulty() {
com.majruszsdifficulty.Registries.initialize();
Expand Down
38 changes: 0 additions & 38 deletions src/main/java/com/majruszsdifficulty/MajruszsHelper.java

This file was deleted.

27 changes: 0 additions & 27 deletions src/main/java/com/majruszsdifficulty/PacketHandler.java

This file was deleted.

61 changes: 35 additions & 26 deletions src/main/java/com/majruszsdifficulty/Registries.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@
import com.majruszsdifficulty.blocks.InfestedEndStone;
import com.majruszsdifficulty.effects.BleedingEffect;
import com.majruszsdifficulty.effects.BleedingImmunityEffect;
import com.majruszsdifficulty.effects.GlassRegenerationEffect;
import com.majruszsdifficulty.entities.*;
import com.majruszsdifficulty.features.bleeding.ArmorBleeding;
import com.majruszsdifficulty.features.bleeding.ToolsBleeding;
import com.majruszsdifficulty.items.*;
import com.majruszsdifficulty.loot.CurseRandomlyFunction;
import com.majruszsdifficulty.treasurebags.TreasureBagManager;
import com.majruszsdifficulty.treasurebags.TreasureBagProgressManager;
import com.majruszsdifficulty.triggers.BandageTrigger;
import com.majruszsdifficulty.treasurebags.data.LootProgressData;
import com.majruszsdifficulty.triggers.GameStageTrigger;
import com.majruszsdifficulty.triggers.TreasureBagTrigger;
import com.majruszsdifficulty.undeadarmy.UndeadArmyManager;
import com.majruszsdifficulty.world.WorldGenHelper;
import com.mlib.Utility;
import com.mlib.annotations.AnnotationHandler;
import com.mlib.items.CreativeModeTabHelper;
import com.mlib.gamemodifiers.ModConfigs;
import com.mlib.registries.RegistryHelper;
import com.mlib.triggers.BasicTrigger;
import com.mlib.config.ConfigHandler;
import com.mlib.contexts.base.ModConfigs;
import com.mlib.modhelper.ModHelper;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.renderer.RenderType;
Expand Down Expand Up @@ -59,7 +61,7 @@
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
Expand All @@ -71,20 +73,22 @@
import java.util.function.Supplier;
import java.util.stream.Stream;

import static com.majruszsdifficulty.MajruszsDifficulty.MOD_ID;
import static com.majruszsdifficulty.MajruszsDifficulty.SERVER_CONFIG;
import static net.minecraft.core.Registry.LOOT_FUNCTION_REGISTRY;
import static net.minecraft.core.Registry.LOOT_FUNCTION_TYPE;

public class Registries {
private static final RegistryHelper HELPER = new RegistryHelper( MajruszsDifficulty.MOD_ID );
public static final ModHelper HELPER = ModHelper.create( MajruszsDifficulty.MOD_ID );

// Configs
public static final ConfigHandler SERVER_CONFIG = HELPER.createConfig( ModConfig.Type.SERVER );

static {
ModConfigs.init( SERVER_CONFIG, Groups.DEFAULT ).name( "GameModifiers" );
ModConfigs.init( SERVER_CONFIG, Groups.DEFAULT ).name( "Features" );
ModConfigs.init( SERVER_CONFIG, Groups.UNDEAD_ARMY ).name( "UndeadArmy" );
ModConfigs.init( SERVER_CONFIG, Groups.GAME_STAGE ).name( "GameStage" );
ModConfigs.init( SERVER_CONFIG, Groups.TREASURE_BAG ).name( "TreasureBag" );
ModConfigs.init( SERVER_CONFIG, Groups.MOBS ).name( "Mobs" );
ModConfigs.init( SERVER_CONFIG, Groups.BLEEDING ).name( "Bleeding" );
}

// Groups
Expand All @@ -104,7 +108,7 @@ public class Registries {
public static final RegistryObject< EntityType< TankEntity > > TANK = ENTITY_TYPES.register( "tank", TankEntity.createSupplier() );
public static final RegistryObject< EntityType< CursedArmorEntity > > CURSED_ARMOR = ENTITY_TYPES.register( "cursed_armor", CursedArmorEntity.createSupplier() );
public static final RegistryObject< EntityType< CerberusEntity > > CERBERUS = ENTITY_TYPES.register( "cerberus", CerberusEntity.createSupplier() );
public static final RegistryObject< EntityType< BlackWidowEntity > > BLACK_WIDOW = ENTITY_TYPES.register( "black_widow", BlackWidowEntity.createSupplier() );
public static final RegistryObject< EntityType< GiantEntity > > GIANT = ENTITY_TYPES.register( "giant", GiantEntity.createSupplier() );

// Items
public static final RegistryObject< BandageItem > BANDAGE = ITEMS.register( "bandage", BandageItem::new );
Expand All @@ -131,7 +135,7 @@ public class Registries {
public static final RegistryObject< EnderPouchItem > ENDER_POUCH = ITEMS.register( "ender_pouch", EnderPouchItem::new );
public static final RegistryObject< WitherSwordItem > WITHER_SWORD = ITEMS.register( "wither_sword", WitherSwordItem::new );
public static final RegistryObject< RecallPotionItem > RECALL_POTION = ITEMS.register( "recall_potion", RecallPotionItem::new );
public static final RegistryObject< BadOmenPotionItem > BAD_OMEN_POTION = ITEMS.register( "bad_omen_potion", BadOmenPotionItem::new );
public static final RegistryObject< EvokerFangScrollItem > EVOKER_FANG_SCROLL = ITEMS.register( "evoker_fang_scroll", EvokerFangScrollItem::new );
public static final RegistryObject< SoulJarItem > SOUL_JAR = ITEMS.register( "soul_jar", SoulJarItem::new );

// Potions
Expand All @@ -158,7 +162,7 @@ public class Registries {
public static final RegistryObject< SpawnEggItem > TANK_SPAWN_EGG = ITEMS.register( "tank_spawn_egg", createEggSupplier( TANK, 0xc1c1c1, 0x949494 ) );
public static final RegistryObject< SpawnEggItem > CURSED_ARMOR_SPAWN_EGG = ITEMS.register( "cursed_armor_spawn_egg", createEggSupplier( CURSED_ARMOR, 0x808080, 0xe1e1e1 ) );
public static final RegistryObject< SpawnEggItem > CERBERUS_SPAWN_EGG = ITEMS.register( "cerberus_spawn_egg", createEggSupplier( CERBERUS, 0x212121, 0xe0e0e0 ) );
public static final RegistryObject< SpawnEggItem > BLACK_WIDOW_SPAWN_EGG = ITEMS.register( "black_widow_spawn_egg", createEggSupplier( BLACK_WIDOW, 0x212121, 0xe12121 ) );
public static final RegistryObject< SpawnEggItem > GIANT_SPAWN_EGG = ITEMS.register( "giant_spawn_egg", createEggSupplier( GIANT, 0x00afaf, 0x799c65 ) );

static Supplier< SpawnEggItem > createEggSupplier( Supplier< ? extends EntityType< ? extends Mob > > type,
int backgroundColor, int highlightColor
Expand All @@ -180,6 +184,7 @@ static Supplier< SpawnEggItem > createEggSupplier( Supplier< ? extends EntityTyp
// Effects
public static final RegistryObject< BleedingEffect > BLEEDING = MOB_EFFECTS.register( "bleeding", BleedingEffect::new );
public static final RegistryObject< BleedingImmunityEffect > BLEEDING_IMMUNITY = MOB_EFFECTS.register( "bleeding_immunity", BleedingImmunityEffect::new );
public static final RegistryObject< GlassRegenerationEffect > GLASS_REGENERATION = MOB_EFFECTS.register( "glass_regeneration", GlassRegenerationEffect::new );

// Damage Sources
public static final DamageSource BLEEDING_SOURCE = new DamageSource( "bleeding" ).bypassArmor();
Expand All @@ -194,8 +199,6 @@ static Supplier< SpawnEggItem > createEggSupplier( Supplier< ? extends EntityTyp
// Triggers
public static final GameStageTrigger GAME_STATE_TRIGGER = CriteriaTriggers.register( new GameStageTrigger() );
public static final TreasureBagTrigger TREASURE_BAG_TRIGGER = CriteriaTriggers.register( new TreasureBagTrigger() );
public static final BandageTrigger BANDAGE_TRIGGER = CriteriaTriggers.register( new BandageTrigger() );
public static final BasicTrigger BASIC_TRIGGER = HELPER.registerBasicTrigger();

// Sounds
public static final RegistryObject< SoundEvent > UNDEAD_ARMY_APPROACHING = register( "undead_army.approaching" );
Expand All @@ -208,8 +211,17 @@ static RegistryObject< SoundEvent > register( String name ) {
// Loot Functions
public static final RegistryObject< LootItemFunctionType > CURSE_RANDOMLY = LOOT_FUNCTIONS.register( "curse_randomly", CurseRandomlyFunction::newType );

// Game Modifiers
public static final AnnotationHandler ANNOTATION_HANDLER = new AnnotationHandler( MajruszsDifficulty.MOD_ID );
// Network
static {
HELPER.createMessage( TankEntity.SkillMessage.class, TankEntity.SkillMessage::new );
HELPER.createMessage( CursedArmorEntity.AssembleMessage.class, CursedArmorEntity.AssembleMessage::new );
HELPER.createMessage( LootProgressData.class, LootProgressData::new );
HELPER.createMessage( BleedingEffect.BloodMessage.class, BleedingEffect.BloodMessage::new );
HELPER.createMessage( CerberusEntity.SkillMessage.class, CerberusEntity.SkillMessage::new );
HELPER.createMessage( ToolsBleeding.ToolsDef.class, ToolsBleeding.ToolsDef::new );
HELPER.createMessage( ArmorBleeding.ArmorsDef.class, ArmorBleeding.ArmorsDef::new );
HELPER.createMessage( CursedArmorEntity.LocationsDef.class, CursedArmorEntity.LocationsDef::new );
}

// Configured Feature
public static final RegistryObject< ConfiguredFeature< ?, ? > > ENDERIUM_ORE_SMALL_CONFIGURED = CONFIGURED_FEATURES.register( "enderium_ore_small", ()->WorldGenHelper.getEndConfigured( ENDERIUM_SHARD_ORE, 2, 0.99f ) );
Expand Down Expand Up @@ -250,20 +262,16 @@ public static RenderType getEyesRenderType( String register ) {
}

public static void initialize() {
FMLJavaModLoadingContext loadingContext = FMLJavaModLoadingContext.get();
final IEventBus modEventBus = loadingContext.getModEventBus();

HELPER.registerAll();
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
modEventBus.addListener( Registries::setup );
modEventBus.addListener( Registries::setupClient );
modEventBus.addListener( Registries::setupEntities );
modEventBus.addListener( PacketHandler::registerPacket );

IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
forgeEventBus.addListener( Registries::onLoadingLevel );
forgeEventBus.addListener( Registries::onSavingLevel );

SERVER_CONFIG.register( ModLoadingContext.get() );
HELPER.register();
}

private static void setupClient( final FMLClientSetupEvent event ) {
Expand All @@ -273,18 +281,18 @@ private static void setupClient( final FMLClientSetupEvent event ) {
public static void setupEntities( EntityAttributeCreationEvent event ) {
event.put( CREEPERLING.get(), CreeperlingEntity.getAttributeMap() );
event.put( TANK.get(), TankEntity.getAttributeMap() );
event.put( BLACK_WIDOW.get(), BlackWidowEntity.getAttributeMap() );
event.put( CURSED_ARMOR.get(), CursedArmorEntity.getAttributeMap() );
event.put( CERBERUS.get(), CerberusEntity.getAttributeMap() );
event.put( GIANT.get(), GiantEntity.getAttributeMap() );
}

private static void setup( final FMLCommonSetupEvent event ) {
// FORGE: use SpawnPlacementRegisterEvent to register and modify spawn placements
SpawnPlacements.register( CREEPERLING.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, CreeperlingEntity::checkMobSpawnRules );
SpawnPlacements.register( TANK.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, TankEntity::checkMonsterSpawnRules );
SpawnPlacements.register( BLACK_WIDOW.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, BlackWidowEntity::checkMonsterSpawnRules );
SpawnPlacements.register( CURSED_ARMOR.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, CursedArmorEntity::checkMonsterSpawnRules );
SpawnPlacements.register( CERBERUS.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, CursedArmorEntity::checkMonsterSpawnRules );
SpawnPlacements.register( CERBERUS.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, CerberusEntity::checkMonsterSpawnRules );
SpawnPlacements.register( GIANT.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, GiantEntity::checkMonsterSpawnRules );

event.enqueueWork( ()->{
addPotionRecipe( ()->Potions.WATER, CERBERUS_FANG, ()->Potions.MUNDANE );
Expand Down Expand Up @@ -349,5 +357,6 @@ public static class Groups {
public static final String GAME_STAGE = Registries.getLocationString( "game_stage" );
public static final String TREASURE_BAG = Registries.getLocationString( "treasure_bag" );
public static final String MOBS = Registries.getLocationString( "mobs" );
public static final String BLEEDING = Registries.getLocationString( "bleeding" );
}
}
Loading

0 comments on commit a86024b

Please sign in to comment.