generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update coffee bottles and Caffeine effect
- Loading branch information
1 parent
875339c
commit ef10a4b
Showing
22 changed files
with
130 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletions
10
...inated/item/CafeMielCoffeeBottleItem.java → .../caffeinated/item/CafeMielBottleItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/net/chikorita_lover/caffeinated/mixin/HungerManagerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.chikorita_lover.caffeinated.mixin; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.chikorita_lover.caffeinated.item.CoffeeBottleItem; | ||
import net.chikorita_lover.caffeinated.registry.CaffeinatedStatusEffects; | ||
import net.minecraft.entity.effect.StatusEffectInstance; | ||
import net.minecraft.entity.player.HungerManager; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
@Mixin(HungerManager.class) | ||
public class HungerManagerMixin { | ||
@ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/HungerManager;addExhaustion(F)V")) | ||
private float modifyExhaustion(float exhaustion, @Local(argsOnly = true) PlayerEntity player) { | ||
if (player.hasStatusEffect(CaffeinatedStatusEffects.CAFFEINE)) { | ||
StatusEffectInstance effect = player.getStatusEffect(CaffeinatedStatusEffects.CAFFEINE); | ||
exhaustion *= CoffeeBottleItem.getEffectMultiplier(effect); | ||
} | ||
return exhaustion; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/net/chikorita_lover/caffeinated/mixin/InGameHudMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net.chikorita_lover.caffeinated.mixin; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.chikorita_lover.caffeinated.registry.CaffeinatedStatusEffects; | ||
import net.minecraft.client.gui.hud.InGameHud; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.util.math.MathHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
|
||
@Mixin(InGameHud.class) | ||
public class InGameHudMixin { | ||
@Shadow private int ticks; | ||
|
||
@ModifyVariable(method = "renderFood", at = @At("STORE"), ordinal = 4) | ||
private int offsetCaffeineHunger(int k, @Local(argsOnly = true) PlayerEntity player, @Local(ordinal = 3) int j) { | ||
if (player.hasStatusEffect(CaffeinatedStatusEffects.CAFFEINE) && j == this.ticks % MathHelper.ceil(50.0F)) { | ||
k -= 2; | ||
} | ||
return k; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.