From d5158496da2912b4d2b4ca9be87c3d39761e735a Mon Sep 17 00:00:00 2001 From: marston Date: Wed, 6 Sep 2023 22:45:42 -0400 Subject: [PATCH] added rainy --- .../loot/modifiers/ModifierRegistry.java | 4 +- .../loot/modifiers/holders/Rainy.java | 131 ++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 src/main/java/dev/marston/randomloot/loot/modifiers/holders/Rainy.java diff --git a/src/main/java/dev/marston/randomloot/loot/modifiers/ModifierRegistry.java b/src/main/java/dev/marston/randomloot/loot/modifiers/ModifierRegistry.java index 6aed18e..0060557 100644 --- a/src/main/java/dev/marston/randomloot/loot/modifiers/ModifierRegistry.java +++ b/src/main/java/dev/marston/randomloot/loot/modifiers/ModifierRegistry.java @@ -9,6 +9,7 @@ import dev.marston.randomloot.loot.modifiers.breakers.Learning; import dev.marston.randomloot.loot.modifiers.holders.Effect; import dev.marston.randomloot.loot.modifiers.holders.Hasty; +import dev.marston.randomloot.loot.modifiers.holders.Rainy; import dev.marston.randomloot.loot.modifiers.hurter.Charging; import dev.marston.randomloot.loot.modifiers.hurter.Combo; import dev.marston.randomloot.loot.modifiers.hurter.Critical; @@ -42,11 +43,12 @@ public class ModifierRegistry { public static Modifier REGENERATING = register(new Effect("Healing", "regeneration", 3, MobEffects.REGENERATION)); public static Modifier RESISTANT = register(new Effect("Resistant", "resistance", 1, MobEffects.DAMAGE_RESISTANCE)); public static Modifier FIRE_RESISTANT = register(new Effect("Heat Resistant", "fire_resistance", 1, MobEffects.FIRE_RESISTANCE)); + public static Modifier RAINY = register(new Rainy()); public static final Set BREAKERS = Set.of(EXPLODE, LEARNING, ATTRACTING); public static final Set USERS = Set.of(TORCH_PLACE, DIRT_PLACE); public static final Set HURTERS = Set.of(CRITICAL, CHARGING, FLAMING, COMBO); - public static final Set HOLDERS = Set.of(HASTY, ABSORBTION, FILLING); + public static final Set HOLDERS = Set.of(HASTY, ABSORBTION, FILLING, RAINY); public static Modifier register(Modifier modifier) { diff --git a/src/main/java/dev/marston/randomloot/loot/modifiers/holders/Rainy.java b/src/main/java/dev/marston/randomloot/loot/modifiers/holders/Rainy.java new file mode 100644 index 0000000..3dfaedf --- /dev/null +++ b/src/main/java/dev/marston/randomloot/loot/modifiers/holders/Rainy.java @@ -0,0 +1,131 @@ +package dev.marston.randomloot.loot.modifiers.holders; + +import java.util.List; + +import javax.annotation.Nullable; + +import dev.marston.randomloot.loot.LootUtils; +import dev.marston.randomloot.loot.LootItem.ToolType; +import dev.marston.randomloot.loot.modifiers.BlockBreakModifier; +import dev.marston.randomloot.loot.modifiers.HoldModifier; +import dev.marston.randomloot.loot.modifiers.Modifier; +import dev.marston.randomloot.loot.modifiers.ModifierRegistry; +import dev.marston.randomloot.loot.modifiers.users.TorchPlace; +import net.minecraft.ChatFormatting; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.Level.ExplosionInteraction; + +public class Rainy implements HoldModifier{ + + private String name; + private float power; + private final static String POWER = "power"; + + public Rainy(String name, float power) { + this.name = name; + this.power = power; + } + + public Rainy() { + this.name = "Rainy"; + this.power = 4.0f; + } + + public Modifier clone() { + return new Rainy(); + } + + + + @Override + public CompoundTag toNBT() { + + CompoundTag tag = new CompoundTag(); + + tag.putFloat(POWER, power); + + tag.putString(NAME, name); + + return tag; + } + + @Override + public Modifier fromNBT(CompoundTag tag) { + return new Rainy(tag.getString(NAME), tag.getFloat(POWER)); + } + + @Override + public String name() { + return name; + } + + @Override + public String tagName() { + return "rainy"; + } + + @Override + public String color() { + return ChatFormatting.BLUE.getName(); + } + + @Override + public String description() { + return "While holding the tool in the rain, mine faster!"; + } + + @Override + public void writeToLore(List list, boolean shift) { + + MutableComponent comp = Modifier.makeComp(this.name(), this.color()); + + list.add(comp); + } + + + @Override + public Component writeDetailsToLore(@Nullable Level level) { + + return null; + } + + @Override + public boolean compatible(Modifier mod) { + return true; + } + + @Override + public boolean forTool(ToolType type) { + return type.equals(ToolType.PICKAXE) || type.equals(ToolType.AXE) || type.equals(ToolType.SHOVEL); + } + + @Override + public void hold(ItemStack stack, Level level, Entity holder) { + if (level.isRainingAt(holder.blockPosition())) { + MobEffectInstance haste = new MobEffectInstance(MobEffects.DIG_SPEED, 3, 2, false, false); + + if (holder instanceof LivingEntity) { + haste.applyEffect((LivingEntity) holder); + } + if (holder instanceof Player) { + Player p = (Player) holder; + p.addEffect(haste); + } + } + + + + } +}