Skip to content

Commit

Permalink
added rainy
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Sep 7, 2023
1 parent 71994c8 commit d515849
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Modifier> BREAKERS = Set.of(EXPLODE, LEARNING, ATTRACTING);
public static final Set<Modifier> USERS = Set.of(TORCH_PLACE, DIRT_PLACE);
public static final Set<Modifier> HURTERS = Set.of(CRITICAL, CHARGING, FLAMING, COMBO);
public static final Set<Modifier> HOLDERS = Set.of(HASTY, ABSORBTION, FILLING);
public static final Set<Modifier> HOLDERS = Set.of(HASTY, ABSORBTION, FILLING, RAINY);

public static Modifier register(Modifier modifier) {

Expand Down
131 changes: 131 additions & 0 deletions src/main/java/dev/marston/randomloot/loot/modifiers/holders/Rainy.java
Original file line number Diff line number Diff line change
@@ -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<Component> 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);
}
}



}
}

0 comments on commit d515849

Please sign in to comment.