Skip to content

Commit

Permalink
Merge pull request #1406 from TheGridExpert/1.21
Browse files Browse the repository at this point in the history
Event for Vampire Fog Distance and Blood Food Mod Parity
  • Loading branch information
Cheaterpaul authored Aug 22, 2024
2 parents d39fb6f + e2fa926 commit 2933ea0
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The following labeling scheme is used:
- BugraaK _Textures/Models_
- MrVityaTrash _Textures_
- FrostedOver _Textures_
- Grid _Textures_
- Grid _Models/Textures/Structures_
- T_Corvus _Textures_

## API
Expand Down
26 changes: 26 additions & 0 deletions src/api/java/de/teamlapen/vampirism/api/event/VampireFogEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package de.teamlapen.vampirism.api.event;

import net.neoforged.bus.api.Event;

@SuppressWarnings("unused")
public class VampireFogEvent extends Event {
private float fogDistanceMultiplier;

public VampireFogEvent(float fogDistanceMultiplier) {
this.fogDistanceMultiplier = fogDistanceMultiplier;
}

/**
* @return The fog distance multiplier of vampire fog.
*/
public float getFogDistanceMultiplier() {
return fogDistanceMultiplier;
}

/**
* @param fogDistanceMultiplier The fog distance multiplier of vampire fog
*/
public void setFogDistanceMultiplier(float fogDistanceMultiplier) {
this.fogDistanceMultiplier = fogDistanceMultiplier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.mojang.blaze3d.pipeline.RenderTarget;
import de.teamlapen.lib.util.OptifineHandler;
import de.teamlapen.vampirism.REFERENCE;
import de.teamlapen.vampirism.api.entity.IExtendedCreatureVampirism;
import de.teamlapen.vampirism.api.entity.hunter.IHunterMob;
import de.teamlapen.vampirism.api.event.VampireFogEvent;
import de.teamlapen.vampirism.api.items.IItemWithTier;
import de.teamlapen.vampirism.api.util.VResourceLocation;
import de.teamlapen.vampirism.blocks.CoffinBlock;
Expand All @@ -19,6 +19,7 @@
import de.teamlapen.vampirism.mixin.client.accessor.CameraAccessor;
import de.teamlapen.vampirism.util.Helper;
import de.teamlapen.vampirism.util.MixinHooks;
import de.teamlapen.vampirism.util.VampirismEventFactory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.PlayerModel;
Expand Down Expand Up @@ -52,6 +53,7 @@
/**
* Handle most general rendering related stuff
*/
@SuppressWarnings("unused")
public class RenderHandler implements ResourceManagerReloadListener {
private static final int ENTITY_NEAR_SQ_DISTANCE = 100;
@NotNull
Expand Down Expand Up @@ -147,6 +149,8 @@ public void onClientTick(ClientTickEvent.Pre event) {
vampireBiomeFogDistanceMultiplier = vampire.getLevel() > 0 ? 2 : 1;
vampireBiomeFogDistanceMultiplier += vampire.getSkillHandler().isRefinementEquipped(ModRefinements.VISTA.get()) ? VampirismConfig.BALANCE.vrVistaMod.get().floatValue() : 0;

vampireBiomeFogDistanceMultiplier = VampirismEventFactory.fireVampireFogEvent(vampireBiomeFogDistanceMultiplier);

} else {
insideFog = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/teamlapen/vampirism/core/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public boolean isFoil(ItemStack stack) {
public static final DeferredItem<HunterIntelItem> HUNTER_INTEL_8 = register("hunter_intel_8", () -> new HunterIntelItem(8));
public static final DeferredItem<HunterIntelItem> HUNTER_INTEL_9 = register("hunter_intel_9", () -> new HunterIntelItem(9));

public static final DeferredItem<VampirismItemBloodFoodItem> HUMAN_HEART = register("human_heart", () -> new VampirismItemBloodFoodItem((new FoodProperties.Builder()).nutrition(20).saturationModifier(1.5F).build(), new FoodProperties.Builder().nutrition(5).saturationModifier(1f).build()));
public static final DeferredItem<VampirismItemBloodFoodItem> HUMAN_HEART = register("human_heart", () -> new VampirismItemBloodFoodItem(new Item.Properties().food(new FoodProperties.Builder().nutrition(5).saturationModifier(1f).build()), new FoodProperties.Builder().nutrition(20).saturationModifier(1.5F).build()));

public static final DeferredItem<InjectionItem> INJECTION_EMPTY = register("injection_empty", () -> new InjectionItem(InjectionItem.TYPE.EMPTY));
public static final DeferredItem<InjectionItem> INJECTION_GARLIC = register("injection_garlic", () -> new InjectionItem(InjectionItem.TYPE.GARLIC));
Expand Down Expand Up @@ -191,7 +191,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable TooltipContext c
public static final DeferredItem<VampireBloodBottleItem> VAMPIRE_BLOOD_BOTTLE = register("vampire_blood_bottle", VampireBloodBottleItem::new);
public static final DeferredItem<VampireBookItem> VAMPIRE_BOOK = register("vampire_book", VampireBookItem::new);
public static final DeferredItem<VampireFangItem> VAMPIRE_FANG = register("vampire_fang", VampireFangItem::new);
public static final DeferredItem<VampirismItemBloodFoodItem> WEAK_HUMAN_HEART = register("weak_human_heart", () -> new VampirismItemBloodFoodItem((new FoodProperties.Builder()).nutrition(10).saturationModifier(0.9F).build(), new FoodProperties.Builder().nutrition(3).saturationModifier(1f).build()));
public static final DeferredItem<VampirismItemBloodFoodItem> WEAK_HUMAN_HEART = register("weak_human_heart", () -> new VampirismItemBloodFoodItem(new Item.Properties().food(new FoodProperties.Builder().nutrition(3).saturationModifier(1f).build()), new FoodProperties.Builder().nutrition(10).saturationModifier(0.9F).build()));

public static final DeferredItem<SpawnEggItem> VAMPIRE_SPAWN_EGG = register("vampire_spawn_egg", CreativeModeTabs.SPAWN_EGGS, () -> new DeferredSpawnEggItem(ModEntities.VAMPIRE, 0x8B15A3, 0xa735e3, new Item.Properties()));
public static final DeferredItem<SpawnEggItem> VAMPIRE_HUNTER_SPAWN_EGG = register("vampire_hunter_spawn_egg", CreativeModeTabs.SPAWN_EGGS, () -> new DeferredSpawnEggItem(ModEntities.HUNTER, 0x2d05f2, 0x2600e0, new Item.Properties()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.teamlapen.vampirism.items;

import de.teamlapen.vampirism.VampirismMod;
import de.teamlapen.vampirism.api.entity.vampire.IVampire;
import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer;
import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext;
Expand All @@ -15,13 +16,14 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class VampirismItemBloodFoodItem extends Item {

private final FoodProperties vampireFood;

public VampirismItemBloodFoodItem(FoodProperties vampireFood, @NotNull FoodProperties humanFood) {
super(new Properties().food(humanFood));
public VampirismItemBloodFoodItem(Properties properties, FoodProperties vampireFood) {
super(properties);
this.vampireFood = vampireFood;
}

Expand All @@ -45,5 +47,12 @@ public ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level worldI
return stack;
}

@Override
public @Nullable FoodProperties getFoodProperties(@NotNull ItemStack stack, @Nullable LivingEntity entity) {
if (entity == null) {
entity = VampirismMod.proxy.getClientPlayer();
}

return Helper.isVampire(entity) ? vampireFood : super.getFoodProperties(stack, entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
import de.teamlapen.vampirism.api.entity.player.vampire.IDrinkBloodContext;
import de.teamlapen.vampirism.api.entity.player.vampire.IVampirePlayer;
import de.teamlapen.vampirism.api.entity.vampire.IVampire;
import de.teamlapen.vampirism.api.event.ActionEvent;
import de.teamlapen.vampirism.api.event.BloodDrinkEvent;
import de.teamlapen.vampirism.api.event.PlayerFactionEvent;
import de.teamlapen.vampirism.api.event.VampirismVillageEvent;
import de.teamlapen.vampirism.api.event.*;
import de.teamlapen.vampirism.api.world.ITotem;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.npc.Villager;
import net.neoforged.neoforge.common.NeoForge;
Expand Down Expand Up @@ -80,11 +78,13 @@ public static boolean fireMakeAggressive(@NotNull ITotem totem, @NotNull Village
NeoForge.EVENT_BUS.post(event);
return event;
}

public static @NotNull ActionEvent.ActionActivatedEvent fireActionActivatedEvent(@NotNull IFactionPlayer<?> factionPlayer, @NotNull IAction<?> action, int cooldown, int duration) {
ActionEvent.ActionActivatedEvent event = new ActionEvent.ActionActivatedEvent(factionPlayer, action, cooldown, duration);
NeoForge.EVENT_BUS.post(event);
return event;
}

public static int fireActionDeactivatedEvent(@NotNull IFactionPlayer<?> factionPlayer, @NotNull IAction<?> action, int remainingDuration, int cooldown) {
ActionEvent.ActionDeactivatedEvent event = new ActionEvent.ActionDeactivatedEvent(factionPlayer, action, remainingDuration, cooldown);
NeoForge.EVENT_BUS.post(event);
Expand All @@ -97,4 +97,10 @@ public static ActionEvent.ActionUpdateEvent fireActionUpdateEvent(@NotNull IFact
return event;
}

public static float fireVampireFogEvent(float fogDistanceMultiplier) {
VampireFogEvent event = new VampireFogEvent(fogDistanceMultiplier);
NeoForge.EVENT_BUS.post(event);
return event.getFogDistanceMultiplier();
}

}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ config = "vampirism.mixins.json"
- BugraaK (textures/models)
- MrVityaTrash (textures)
- FrostedOver (textures)
- Grid (textures)
- Grid (textures/models/structures)
- T_Corvus (textures)
- freesound.org (sounds)
- freeSFX.co.uk (sounds)'''
Expand Down

0 comments on commit 2933ea0

Please sign in to comment.