-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71994c8
commit d515849
Showing
2 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/main/java/dev/marston/randomloot/loot/modifiers/holders/Rainy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
|
||
|
||
} | ||
} |