From 475059df8f474645953b6346c24283cf9d1c1304 Mon Sep 17 00:00:00 2001 From: limepotato Date: Wed, 11 Sep 2024 04:49:04 -0600 Subject: [PATCH] Add effects for various blocks --- .../nelle/edible_blocks/mixin/ItemsMixin.java | 70 +++++++++++++++++-- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/src/main/java/observer/nelle/edible_blocks/mixin/ItemsMixin.java b/src/main/java/observer/nelle/edible_blocks/mixin/ItemsMixin.java index e4d7058..2e4bcdc 100644 --- a/src/main/java/observer/nelle/edible_blocks/mixin/ItemsMixin.java +++ b/src/main/java/observer/nelle/edible_blocks/mixin/ItemsMixin.java @@ -1,7 +1,11 @@ package observer.nelle.edible_blocks.mixin; import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.entity.effect.StatusEffects; import net.minecraft.item.FoodComponent; +import net.minecraft.item.FoodComponents; import net.minecraft.item.Item; import net.minecraft.item.Items; import org.spongepowered.asm.mixin.Mixin; @@ -9,19 +13,71 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; - @Mixin(Items.class) public abstract class ItemsMixin { + @ModifyArg( method = "register(Lnet/minecraft/block/Block;)Lnet/minecraft/item/Item;", - at = @At(value="INVOKE",target = "Lnet/minecraft/item/BlockItem;(Lnet/minecraft/block/Block;Lnet/minecraft/item/Item$Settings;)V") + at = @At(value = "INVOKE", target = "Lnet/minecraft/item/BlockItem;(Lnet/minecraft/block/Block;Lnet/minecraft/item/Item$Settings;)V") ) - private static Item.Settings ModifySettings (Block block, Item.Settings settings) { + private static Item.Settings ModifySettings(Block block, Item.Settings settings) { + /* TODO: Make pumpkin give player a carved pumpkin + if (block == Blocks.PUMPKIN) { + return settings.food(new FoodComponent.Builder() + .hunger(6) + .saturationModifier(0.9F) + .build()); + }*/ + if (block == Blocks.MELON) { + return settings.food(new FoodComponent.Builder() + .hunger(6) + .saturationModifier(0.9F) + .build()); + } + if (block == Blocks.HONEY_BLOCK) { + return settings.food(new FoodComponent.Builder() + .hunger(9) + .saturationModifier(0.3F) + .statusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 5, 1 / 2), 0.7f) + .build()); + } + if (block == Blocks.HONEYCOMB_BLOCK) { + return settings.food(new FoodComponent.Builder() + .hunger(9) + .saturationModifier(0.3F) + .statusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 5, 1 / 2), 0.7f) + .build()); + } + if (block == Blocks.BEEHIVE) { + return settings.food(new FoodComponent.Builder() + .hunger(9) + .saturationModifier(0.3F) + .statusEffect(new StatusEffectInstance(StatusEffects.INSTANT_DAMAGE, 1, 1 / 2), 1f) + .statusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 5, 1 / 2), 0.7f) + .build()); + } + if (block == Blocks.BEE_NEST) { + return settings.food(new FoodComponent.Builder() + .hunger(9) + .saturationModifier(0.3F) + .statusEffect(new StatusEffectInstance(StatusEffects.INSTANT_DAMAGE, 1, 1 / 2), 1f) + .statusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 5, 1 / 2), 0.4f) + .build()); + } + if (block == Blocks.CACTUS) { + return settings.food(new FoodComponent.Builder() + .hunger(9) + .saturationModifier(0.3F) + .statusEffect(new StatusEffectInstance(StatusEffects.INSTANT_DAMAGE, 1, 1 / 3), 1f) + .build()); + } + else { return settings.food( new FoodComponent.Builder() - .snack() - .hunger(1) - .alwaysEdible() - .build()); + .snack() + .hunger(1) + .alwaysEdible() + .build()); + } } }