Skip to content

Implementation

TATHAN edited this page Oct 31, 2022 · 14 revisions

Want to implement Halloween Mood in your own mod? You can do it by adding the following lines to your build.gradle :

repositories {
     maven { url "https://cursemaven.com" }
}

dependencies {
    implementation fg.deobf("curse.maven:halloween-687184:FILEID") 
}

The FILEID can be found in the CurseForge page of the mod.

Exemples

Execute something when a player is in the Halloween Difficulty

@Mod.EventBusSubscriber(modid = "YOURMODID")
public class Events {

    @SubscribeEvent
    public static void TickEvent(TickEvent.PlayerTickEvent event) {

        Player player = event.player;
        Level level = player.getLevel();
        BlockPos pos = player.blockPosition();
        LevelDifficulty difficulty = level.getCapability(LevelDifficultyProvider.LEVEL_DIFFICULTY).orElseThrow(() -> new IllegalStateException("Damn! An Error ?! This is Spooky !!"));


       if (level.getCapability(LevelDifficultyProvider.LEVEL_DIFFICULTY).isPresent()) {
           if (difficulty.isHalloween()) {

          //Your Stuff

        }
    }
}

Add a candy

public class ItemsRegistry {

  public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "YOURMODID");

  public static final RegistryObject<Item> EXEMPLE_CANDY = ITEMS.register("exemple_candy",
          () -> new Candy(new Item.Properties().tab(TabsRegistry.HALLOWEEN_TAB).stacksTo(32).food(new FoodProperties.Builder().fast().nutrition(2).saturationMod(0.2F).build()), MobEffects.YOUR_EFFECT, duration, amplifier));
}

You can also add the candies tag to your candy : in ressources/data/halloween_mood/tags/items/candies.json

{
  "replace": false,
  "values": [
    "your_modid:candy_name"
  ]
}

Execute something when the player eat a candy

@Mod.EventBusSubscriber(modid = "YOURMODID")
public class Events {

    @SubscribeEvent
    public static void onCandyIsEat(OnPlayerEatCandy event) {

          //Your Stuff

    }   
}

Note : this event will be executed twice because it is call when the player is eating the candy

Add an item to the against_fear tag

You have an item for your mod or you making a modpack and you want that if we have this item in our hand, we don"t be afraid at night ? Put this file in data/halloween_mood/tags/items/against_fear.json :

{
  "replace": false,
  "values": [
    "minecraft:the_item_you_want",
    "modid:item"  
   ]
}