Skip to content

Commit

Permalink
Update coffee bottle
Browse files Browse the repository at this point in the history
Coffee bottles no longer clear Mining Fatigue
  • Loading branch information
Chikorita-Lover committed Dec 31, 2023
1 parent a77be08 commit 530d70d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@
import com.chikoritalover.caffeinated.block.entity.CauldronCampfireBlockEntity;
import com.chikoritalover.caffeinated.registry.CaffeinatedBlocks;
import com.chikoritalover.caffeinated.registry.CaffeinatedParticleTypes;
import com.mojang.datafixers.util.Pair;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.block.Block;
import net.minecraft.client.color.world.BiomeColors;
import net.minecraft.client.particle.BubblePopParticle;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.Item;
import net.minecraft.potion.PotionUtil;
import net.minecraft.registry.Registries;
import org.apache.commons.compress.utils.Lists;

import java.util.List;
import java.util.Objects;

public class CaffeinatedClient implements ClientModInitializer {
@Override
Expand All @@ -40,22 +30,5 @@ public void onInitializeClient() {
}, CauldronCampfireBlock.CAMPFIRE_TO_CAULDRON_CAMPFIRE.values().toArray(new Block[0]));

ParticleFactoryRegistry.getInstance().register(CaffeinatedParticleTypes.COFFEE_POP, BubblePopParticle.Factory::new);

ItemTooltipCallback.EVENT.register((stack, context, lines) -> {
Item item = stack.getItem();
if (!stack.isFood() || !Objects.equals(Registries.ITEM.getId(item).getNamespace(), Caffeinated.MODID)) {
return;
}
List<Pair<StatusEffectInstance, Float>> statusEffects = item.getFoodComponent().getStatusEffects();
List<StatusEffectInstance> list = Lists.newArrayList();
for (Pair<StatusEffectInstance, Float> statusEffect : statusEffects) {
if (statusEffect.getSecond() == 1.0F) {
list.add(statusEffect.getFirst());
}
}
if (!statusEffects.isEmpty()) {
PotionUtil.buildTooltip(list, lines, 1.0F);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.chikoritalover.caffeinated.item;

import com.chikoritalover.caffeinated.registry.CaffeinatedSoundEvents;
import com.mojang.datafixers.util.Pair;
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsage;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtil;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.stat.Stats;
Expand All @@ -19,6 +22,7 @@
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
import net.minecraft.world.World;
import org.apache.commons.compress.utils.Lists;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand All @@ -38,7 +42,6 @@ public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
}
if (!world.isClient) {
user.removeStatusEffect(StatusEffects.MINING_FATIGUE);
user.removeStatusEffect(StatusEffects.SLOWNESS);
}
if (stack.isEmpty()) {
Expand Down Expand Up @@ -82,6 +85,13 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand han
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
super.appendTooltip(stack, world, tooltip, context);
tooltip.add(Text.translatable(this.getTranslationKey() + ".desc").formatted(Formatting.GRAY));
List<StatusEffectInstance> list = Lists.newArrayList();
for (Pair<StatusEffectInstance, Float> statusEffect : this.getFoodComponent().getStatusEffects()) {
list.add(statusEffect.getFirst());
}
if (!list.isEmpty()) {
PotionUtil.buildTooltip(list, tooltip, 1.0F);
}
}
}

0 comments on commit 530d70d

Please sign in to comment.