Skip to content

Commit

Permalink
v2.0.1 - Adjust how status effects are handled by foods (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
DakotaPride committed Oct 16, 2024
1 parent 156e447 commit 6a22ef8
Show file tree
Hide file tree
Showing 78 changed files with 300 additions and 318 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
package net.dakotapride.garnished.item;

import org.jetbrains.annotations.NotNull;

import net.dakotapride.garnished.registry.GarnishedFoodValues;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;

public class AnniversaryCakeSliceFoodItem extends FarmersDelightItem {
public class AnniversaryCakeSliceFoodItem extends FarmersDelightItem implements IGarnishedUtilities{
public AnniversaryCakeSliceFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.ANNIVERSARY_CAKE_SLICE));
}

@Override
public @NotNull ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level world, @NotNull LivingEntity entity) {
Player playerentity = entity instanceof Player ? (Player) entity : null;
if (playerentity instanceof ServerPlayer)
CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer) playerentity, stack);

if (!world.isClientSide)
entity.addEffect(triggerConditionalEffect(0, 1.0F));

return super.finishUsingItem(stack, world, entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level pLevel, @N
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level pLevel, @N
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public BlazingDelightFoodItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public BottledEnderJellyFoodItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import net.minecraft.stats.Stats;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;

public class BottledMalodorousMixtureFoodItem extends Item implements IGarnishedUtilities {
public class BottledMalodorousMixtureFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {
public BottledMalodorousMixtureFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.BOTTLED_MALODOROUS_MIXTURE).stacksTo(16));
super(5, 0.15F, properties.food(GarnishedFoodValues.BOTTLED_MALODOROUS_MIXTURE).stacksTo(16));
}

@Override
Expand All @@ -37,7 +36,7 @@ public BottledMalodorousMixtureFoodItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level pLevel, @N
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
package net.dakotapride.garnished.item;

import org.jetbrains.annotations.NotNull;

import net.dakotapride.garnished.registry.GarnishedFoodValues;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;

public class BrowniePieceFoodItem extends FarmersDelightItem {
public class BrowniePieceFoodItem extends FarmersDelightItem implements IGarnishedUtilities{
public BrowniePieceFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.BROWNIE_PIECE));
}

@Override
public @NotNull ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level world, @NotNull LivingEntity entity) {
Player playerentity = entity instanceof Player ? (Player) entity : null;
if (playerentity instanceof ServerPlayer)
CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer) playerentity, stack);

if (!world.isClientSide)
entity.addEffect(triggerConditionalEffect(0, 0.25F));

return super.finishUsingItem(stack, world, entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUtils;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;

public class CashewSorbetDelightFoodItem extends Item implements IGarnishedUtilities {
public class CashewSorbetDelightFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {
public CashewSorbetDelightFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.CASHEW_SORBET_DELIGHT).stacksTo(1));
super(0, 0.80F, properties.food(GarnishedFoodValues.CASHEW_SORBET_DELIGHT).stacksTo(1));
}

@Override
Expand All @@ -40,7 +39,7 @@ public CashewSorbetDelightFoodItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package net.dakotapride.garnished.item;

import net.dakotapride.garnished.registry.GarnishedFoodValues;
import net.minecraft.world.item.Item;

public class CashewSorbetScoopFoodItem extends Item implements IGarnishedUtilities {
public class CashewSorbetScoopFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {
public CashewSorbetScoopFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.CASHEW_SORBET_SCOOP));
super(0, 0.65F, properties.food(GarnishedFoodValues.CASHEW_SORBET_SCOOP));
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package net.dakotapride.garnished.item;

import net.dakotapride.garnished.registry.GarnishedFoodValues;
import net.minecraft.world.item.Item;

public class ChampionsOmeletteFoodItem extends Item implements IGarnishedUtilities {
public class ChampionsOmeletteFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {
public ChampionsOmeletteFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.CHAMPIONS_OMELETTE).stacksTo(16));
super(3, 1.0F, properties.food(GarnishedFoodValues.CHAMPIONS_OMELETTE).stacksTo(16));
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package net.dakotapride.garnished.item;

import net.dakotapride.garnished.registry.GarnishedFoodValues;
import net.minecraft.world.item.Item;

public class ChilledAppleFoodItem extends Item implements IGarnishedUtilities {
public class ChilledAppleFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {
public ChilledAppleFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.CHILLED_APPLE));
super(1, 0.50F, properties.food(GarnishedFoodValues.CHILLED_APPLE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ChorusBowlFoodItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUtils;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.level.Level;

public class ChorusCocktailItem extends Item implements IGarnishedUtilities {
public class ChorusCocktailItem extends ConditionalEffectItem implements IGarnishedUtilities {
private static final int DRINK_DURATION = 40;
public ChorusCocktailItem(Properties properties) {
super(properties.food(GarnishedFoodValues.CHORUS_COCKTAIL).stacksTo(16));
super(3, 1.0F, properties.food(GarnishedFoodValues.CHORUS_COCKTAIL).stacksTo(16));
}

@Override
Expand All @@ -44,7 +43,7 @@ public ChorusCocktailItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package net.dakotapride.garnished.item;

import net.dakotapride.garnished.registry.GarnishedFoodValues;
import net.minecraft.world.item.Item;

public class CinderRollFoodItem extends Item implements IGarnishedUtilities {
public class CinderRollFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {
public CinderRollFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.CINDER_ROLL).stacksTo(16));
super(5, 1.0F, properties.food(GarnishedFoodValues.CINDER_ROLL).stacksTo(16));
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package net.dakotapride.garnished.item;

import net.dakotapride.garnished.registry.GarnishedFoodValues;
import net.minecraft.world.item.Item;

public class CoalTruffleFoodItem extends Item implements IGarnishedUtilities {
public class CoalTruffleFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {

public CoalTruffleFoodItem(Properties properties) {
super(properties.stacksTo(16).food(GarnishedFoodValues.COAL_TRUFFLE));
super(0, 0.80F, properties.stacksTo(16).food(GarnishedFoodValues.COAL_TRUFFLE));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.dakotapride.garnished.item;

import org.jetbrains.annotations.NotNull;

import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;

public class ConditionalEffectItem extends Item implements IGarnishedUtilities {
int value;
float chance;

public ConditionalEffectItem(int value, float chance, Properties pProperties) {
super(pProperties);
this.value = value;
this.chance = chance;
}

@Override
public @NotNull ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level world, @NotNull LivingEntity entity) {
Player playerentity = entity instanceof Player ? (Player) entity : null;
if (playerentity instanceof ServerPlayer)
CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer) playerentity, stack);

if (!world.isClientSide)
entity.addEffect(triggerConditionalEffect(value, chance));

return super.finishUsingItem(stack, world, entity);
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package net.dakotapride.garnished.item;

import net.dakotapride.garnished.registry.GarnishedFoodValues;
import net.minecraft.world.item.Item;

public class CookedPolarBearMeatItem extends Item implements IGarnishedUtilities {
public class CookedPolarBearMeatItem extends ConditionalEffectItem implements IGarnishedUtilities {
public CookedPolarBearMeatItem(Properties properties) {
super(properties.food(GarnishedFoodValues.COOKED_POLAR_BEAR_MEAT));
super(1, 0.35F, properties.food(GarnishedFoodValues.COOKED_POLAR_BEAR_MEAT));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CosmicBrewFoodItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUtils;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.level.Level;

public class CrypticAppleCiderFoodItem extends Item implements IGarnishedUtilities {
public class CrypticAppleCiderFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {
private static final int DRINK_DURATION = 40;
public CrypticAppleCiderFoodItem(Properties properties) {
super(properties.stacksTo(8).food(GarnishedFoodValues.CRYPTIC_APPLE_CIDER));
super(6, 1.0F, properties.stacksTo(8).food(GarnishedFoodValues.CRYPTIC_APPLE_CIDER));
}

@Override
Expand Down Expand Up @@ -77,7 +76,7 @@ public void appendHoverText(@NotNull ItemStack stack, @Nullable Level level, @No
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public DesolateStewFoodItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUtils;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;

public class DustyRegaleFoodItem extends Item implements IGarnishedUtilities {
public class DustyRegaleFoodItem extends ConditionalEffectItem implements IGarnishedUtilities {
public DustyRegaleFoodItem(Properties properties) {
super(properties.food(GarnishedFoodValues.DUSTY_REGALE));
super(2, 0.35F, properties.food(GarnishedFoodValues.DUSTY_REGALE));
}

@Override
Expand All @@ -40,7 +39,7 @@ public DustyRegaleFoodItem(Properties properties) {
}
}

return stack;
return super.finishUsingItem(stack, level, livingEntity);
}

}
Expand Down
Loading

0 comments on commit 6a22ef8

Please sign in to comment.