Skip to content

Commit

Permalink
1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DakotaPride committed Feb 25, 2025
1 parent ec65fa5 commit 413ee7c
Show file tree
Hide file tree
Showing 65 changed files with 1,476 additions and 32 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod_name=Hibernal Herbs
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.4
mod_version=1.4.1
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
112 changes: 111 additions & 1 deletion src/main/java/net/dakotapride/hibernalherbs/HibernalHerbsMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,37 @@
import net.dakotapride.hibernalherbs.init.enum_registry.*;
import net.dakotapride.hibernalherbs.init.enum_registry.tag.Tags;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.PotionBrewing;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.functions.SetPotionFunction;
import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.LootTableLoadEvent;
import net.neoforged.neoforge.event.brewing.RegisterBrewingRecipesEvent;
import net.neoforged.neoforge.event.server.ServerStartingEvent;
import org.slf4j.Logger;

import java.util.List;

// The value here should match an entry in the META-INF/neoforge.mods.toml file
@Mod(HibernalHerbsMod.MOD_ID)
public class HibernalHerbsMod {
// Define mod id in a common place for everything to reference
public static final String MOD_ID = "hibernalherbs";
// Directly reference a slf4j logger
private static final Logger LOGGER = LogUtils.getLogger();
public static final Logger LOGGER = LogUtils.getLogger();

// The constructor for the mod class is the first code that is run when your mod is loaded.
// FML will recognize some parameter types like IEventBus or ModContainer and pass them in automatically.
Expand All @@ -38,10 +53,12 @@ public HibernalHerbsMod(IEventBus modEventBus, ModContainer modContainer) {
EntityTypeInit.register(modEventBus);
RecipeInit.register(modEventBus);
StatusEffectInit.register(modEventBus);
PotionsInit.register(modEventBus);
ItemGroupInit.register(modEventBus);
EnchantmentKeys.load();
StructureKeys.load();

ParticleTypeInit.load(modEventBus);
DataComponentInit.load(modEventBus);
StatsInit.load(modEventBus);
CriteriaTriggersInit.load(modEventBus);
Expand Down Expand Up @@ -92,10 +109,103 @@ public static ResourceLocation asResource(String id) {

private void commonSetup(final FMLCommonSetupEvent event) {}

// @SubscribeEvent
// public void lootTableEvents(LootTableLoadEvent event) {
//// if (event.getTable().getLootTableId().equals(BuiltInLootTables.SPAWNER_TRIAL_ITEMS_TO_DROP_WHEN_OMINOUS)) {
//// LootPool swarming_potion = LootPool.lootPool()
//// .setRolls(ConstantValue.exactly(1))
//// .when(LootItemRandomChanceCondition.randomChance(1.00F))//0.15
//// .add(
//// LootItem.lootTableItem(Items.LINGERING_POTION)
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// .apply(SetPotionFunction.setPotion(PotionsInit.SWARMING))
//// )
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1))).build();
//// LootPool instability_potion = LootPool.lootPool()
//// .setRolls(ConstantValue.exactly(1))
//// .when(LootItemRandomChanceCondition.randomChance(0.05F))//0.05
//// .add(
//// LootItem.lootTableItem(Items.LINGERING_POTION)
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// .apply(SetPotionFunction.setPotion(PotionsInit.INSTABILITY))
//// )
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1))).build();
//// LootPool shrieking_potion = LootPool.lootPool()
//// .setRolls(ConstantValue.exactly(1))
//// .when(LootItemRandomChanceCondition.randomChance(0.35F))//0.35
//// .add(
//// LootItem.lootTableItem(Items.LINGERING_POTION)
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// .apply(SetPotionFunction.setPotion(PotionsInit.SHRIEKING))
//// )
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1))).build();
////
//// event.setTable((LootTable) List.of(swarming_potion, instability_potion, shrieking_potion));
//// }
//
//// if (event.getTable().getLootTableId().equals(BuiltInLootTables.TRIAL_CHAMBERS_REWARD_OMINOUS_UNIQUE)) {
//// LootPool herbal_sigils = LootPool.lootPool()
//// .setRolls(ConstantValue.exactly(1))
//// .when(LootItemRandomChanceCondition.randomChance(0.35F))//35%
//// .add(
//// LootItem.lootTableItem(HerbalSigilTypes.PRIDE.getHerbalSigilItem())
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// )
//// .add(
//// LootItem.lootTableItem(HerbalSigilTypes.ENVY.getHerbalSigilItem())
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// )
//// .add(
//// LootItem.lootTableItem(HerbalSigilTypes.WRATH.getHerbalSigilItem())
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// )
//// .add(
//// LootItem.lootTableItem(HerbalSigilTypes.GREED.getHerbalSigilItem())
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// )
//// .add(
//// LootItem.lootTableItem(HerbalSigilTypes.GLUTTONY.getHerbalSigilItem())
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// )
//// .add(
//// LootItem.lootTableItem(HerbalSigilTypes.SLOTH.getHerbalSigilItem())
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// )
//// .add(
//// LootItem.lootTableItem(HerbalSigilTypes.LUST.getHerbalSigilItem())
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
//// )
//// .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1))).build();
////
//// event.setTable((LootTable) List.of(herbal_sigils));
//// }
// }

// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
public void onServerStarting(ServerStartingEvent event) {
// Do something when the server starts
//LOGGER.info("HELLO from server starting");
}

@SubscribeEvent
public void onBrewingRecipeRegister(RegisterBrewingRecipesEvent event) {
PotionBrewing.Builder builder = event.getBuilder();

builder.addContainer(ItemInit.ENIGMATIC_POTION.asItem());
builder.addContainer(ItemInit.SOLAR_POTION.asItem());
builder.addContainer(ItemInit.LUNAR_POTION.asItem());

builder.addMix(Potions.AWKWARD, HerbTypes.SAGE.getDriedHerb(), PotionsInit.FROST_RESISTANCE);

builder.addMix(Potions.AWKWARD, Items.BEE_NEST, PotionsInit.SWARMING);
builder.addMix(Potions.AWKWARD, Items.END_ROD, PotionsInit.INSTABILITY);
builder.addMix(Potions.AWKWARD, Items.SCULK_SHRIEKER, PotionsInit.SHRIEKING);

builder.addContainerRecipe(Items.POTION, ItemInit.MYSTICAL_ASHES.get(), ItemInit.ENIGMATIC_POTION.get());
builder.addContainerRecipe(Items.POTION, Items.CLOCK, ItemInit.SOLAR_POTION.get());
builder.addContainerRecipe(ItemInit.SOLAR_POTION.get(), Items.SCULK, ItemInit.LUNAR_POTION.get());

HibernalHerbsMod.LOGGER.info("[Hibernal Herbs Dev Environment] POTION RECIPES REGISTRAR");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import net.dakotapride.hibernalherbs.entity.render.ModBoatRenderer;
import net.dakotapride.hibernalherbs.init.BlockEntityTypeInit;
import net.dakotapride.hibernalherbs.init.EntityTypeInit;
import net.dakotapride.hibernalherbs.init.ItemInit;
import net.dakotapride.hibernalherbs.init.ParticleTypeInit;
import net.dakotapride.hibernalherbs.init.enum_registry.FrozeBlockstates;
import net.dakotapride.hibernalherbs.init.enum_registry.WoodTypes;
import net.dakotapride.hibernalherbs.item.HerbalPadlockItem;
import net.minecraft.Util;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.model.BoatModel;
import net.minecraft.client.model.ChestBoatModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.particle.SpellParticle;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Sheets;
Expand All @@ -19,13 +23,18 @@
import net.minecraft.client.renderer.blockentity.SignRenderer;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.component.DataComponents;
import net.minecraft.util.FastColor;
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.level.block.Block;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
import net.neoforged.neoforge.client.event.RegisterParticleProvidersEvent;

import java.util.Map;

Expand All @@ -51,6 +60,20 @@ public static void registerEntityModelLayers(EntityRenderersEvent.RegisterLayerD
event.registerLayerDefinition(new ModelLayerLocation(asResource("chest_boat/myqueste"), "main"), ChestBoatModel::createBodyModel);
}

@SubscribeEvent
public static void registerParticleRenderers(RegisterParticleProvidersEvent event) {
event.registerSpriteSet(ParticleTypeInit.SWARMING.get(), SpellParticle.Provider::new);
event.registerSpriteSet(ParticleTypeInit.INSTABILITY.get(), SpellParticle.Provider::new);
event.registerSpriteSet(ParticleTypeInit.SHRIEKING.get(), SpellParticle.Provider::new);
}

@SubscribeEvent
public static void registerColourHandlers(RegisterColorHandlersEvent.Item event) {
event.register((itemStack, i) -> i > 0 ? -1 : FastColor.ARGB32.opaque(
itemStack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).getColor()),
ItemInit.ENIGMATIC_POTION, ItemInit.SOLAR_POTION, ItemInit.LUNAR_POTION);
}

@SubscribeEvent
public static void clientSetup(final FMLClientSetupEvent event) {
// ItemProperties.register(ItemRegistry.CANISTER.get(), new ResourceLocation(MOD_ID, "filled"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.dakotapride.hibernalherbs.effect;

import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;

Expand All @@ -8,5 +9,8 @@ public BasicStatusEffect(MobEffectCategory category, int colour) {
super(category, colour);
}

public BasicStatusEffect(MobEffectCategory category, int colour, ParticleOptions particleOptions) {
super(category, colour, particleOptions);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package net.dakotapride.hibernalherbs.effect;

import net.dakotapride.hibernalherbs.init.ParticleTypeInit;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.animal.Fox;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;

public class InstabilityStatusEffect extends BasicStatusEffect {
public InstabilityStatusEffect(MobEffectCategory category, int colour) {
super(category, colour);
}

@Override
public @NotNull ParticleOptions createParticleOptions(@NotNull MobEffectInstance effect) {
return ParticleTypeInit.INSTABILITY.get();
}

@Override
public boolean applyEffectTick(LivingEntity livingEntity, int j) {
Level level = livingEntity.level();

if (!level.isClientSide) {
for (int i = 0; i < 16; i++) {
double d = livingEntity.getX() + (livingEntity.getRandom().nextDouble() - 0.5) * 16.0;
double e = Mth.clamp(
livingEntity.getY() + (double)(livingEntity.getRandom().nextInt(16) - 8),
level.getMinBuildHeight(),
(level.getMinBuildHeight() + ((ServerLevel)level).getLogicalHeight() - 1)
);
double f = livingEntity.getZ() + (livingEntity.getRandom().nextDouble() - 0.5) * 16.0;
if (livingEntity.isPassenger()) {
livingEntity.stopRiding();
}

Vec3 vec3 = livingEntity.position();
if (livingEntity.randomTeleport(d, e, f, true)) {
level.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(livingEntity));
SoundSource soundSource;
SoundEvent soundEvent;
if (livingEntity instanceof Fox) {
soundEvent = SoundEvents.FOX_TELEPORT;
soundSource = SoundSource.NEUTRAL;
} else {
soundEvent = SoundEvents.CHORUS_FRUIT_TELEPORT;
soundSource = SoundSource.PLAYERS;
}

level.playSound(null, livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), soundEvent, soundSource);
livingEntity.resetFallDistance();
break;
}
}
}

return true;
}

@Override
public boolean shouldApplyEffectTickThisTick(int i, int j) {
int k = 50 >> j;
return k > 0 ? i % k == 0 : true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package net.dakotapride.hibernalherbs.effect;

import net.dakotapride.hibernalherbs.init.ParticleTypeInit;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.util.SpawnUtil;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.monster.warden.Warden;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.joml.Vector3f;

public class ShriekingStatusEffect extends BasicStatusEffect {
private final float chanceToSpawn;

public ShriekingStatusEffect(MobEffectCategory mobEffectCategory, int i, float f) {
super(mobEffectCategory, i);
this.chanceToSpawn = f;
}

@Override
public @NotNull ParticleOptions createParticleOptions(@NotNull MobEffectInstance effect) {
return ParticleTypeInit.SHRIEKING.get();
}

@Override
public void onMobHurt(LivingEntity livingEntity, int i, DamageSource damageSource, float f) {
if (livingEntity.getRandom().nextFloat() <= this.chanceToSpawn) {
this.spawnWarden(
livingEntity.level(), livingEntity, livingEntity.getX(), livingEntity.getY() + (double)livingEntity.getBbHeight() / 2.0, livingEntity.getZ()
);
}
}

private void spawnWarden(Level level, LivingEntity livingEntity, double d, double e, double f) {
Warden warden = EntityType.WARDEN.create(level);
if (warden != null) {
//warden.setAggressive(true);
//warden.setTarget(livingEntity);
//SpawnUtil.trySpawnMob(EntityType.WARDEN, MobSpawnType.TRIGGERED, serverLevel, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER)
RandomSource randomSource = livingEntity.getRandom();
float g = (float) (Math.PI / 2);
float h = Mth.randomBetween(randomSource, (float) (-Math.PI / 2), (float) (Math.PI / 2));
Vector3f vector3f = livingEntity.getLookAngle().toVector3f().mul(0.3F).mul(1.0F, 1.5F, 1.0F).rotateY(h);
warden.moveTo(d, e, f, level.getRandom().nextFloat() * 360.0F, 0.0F);
warden.setDeltaMovement(new Vec3(vector3f));
//level.addFreshEntity(warden);
if (level instanceof ServerLevel serverLevel)
SpawnUtil.trySpawnMob(EntityType.WARDEN, MobSpawnType.TRIGGERED, serverLevel, livingEntity.blockPosition(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER);
warden.playSound(SoundEvents.WARDEN_HURT);
}
}
}
Loading

0 comments on commit 413ee7c

Please sign in to comment.