Skip to content

Commit

Permalink
added bezerk and busted
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed Jan 14, 2024
1 parent 69f4c69 commit 4c62c7d
Show file tree
Hide file tree
Showing 10 changed files with 350 additions and 48 deletions.
100 changes: 55 additions & 45 deletions MODIFIERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,48 @@
This is a full list of modifiers in the game and a description of what they do.
## Breakers
These effects are applied when breaking blocks.
### Learning
**id:** `learning` | **crafting:** `minecraft:book` ![book](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/book.png)
### Veiny
**id:** `veiny` | **crafting:** `minecraft:diamond_pickaxe` ![diamond_pickaxe](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/diamond_pickaxe.png)

**Decription:** After breaking 10 blocks as allowed by this tool, gain 3 experience points.
### Explosive
**id:** `explode` | **crafting:** `minecraft:tnt` ![tnt](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/tnt.png)
**Decription:** Breaking any block while crouching will cause all blocks of the same type adjacent to it to break up to 5 in each direction.
### Magnetic
**id:** `attracting` | **crafting:** `minecraft:iron_block` ![iron_block](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/iron_block.png)

**Decription:** Upon breaking a block (allowed by tool type), the current block position will explode causing damage to surrounding blocks.
**Decription:** Upon breaking a block (allowed by tool type), all items at that block's position will teleport to you.
### Melting
**id:** `melting` | **crafting:** `minecraft:magma_cream` ![magma_cream](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/magma_cream.png)

**Decription:** Items dropped by blocks broken with this tool will be smelted.
### Magnetic
**id:** `attracting` | **crafting:** `minecraft:iron_block` ![iron_block](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/iron_block.png)
### Explosive
**id:** `explode` | **crafting:** `minecraft:tnt` ![tnt](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/tnt.png)

**Decription:** Upon breaking a block (allowed by tool type), all items at that block's position will teleport to you.
### Veiny
**id:** `veiny` | **crafting:** `minecraft:diamond_pickaxe` ![diamond_pickaxe](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/diamond_pickaxe.png)
**Decription:** Upon breaking a block (allowed by tool type), the current block position will explode causing damage to surrounding blocks.
### Learning
**id:** `learning` | **crafting:** `minecraft:book` ![book](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/book.png)

**Decription:** Breaking any block while crouching will cause all blocks of the same type adjacent to it to break up to 5 in each direction.
**Decription:** After breaking 10 blocks as allowed by this tool, gain 3 experience points.
## Holders
These effects are applied when holding the tool.
### Hasty
**id:** `hasty` | **crafting:** `minecraft:sugar` ![sugar](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/sugar.png)

**Decription:** While holding the tool, get the Haste I effect.
### Detecting
**id:** `detecting` | **crafting:** `minecraft:spyglass` ![spyglass](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/spyglass.png)
### Appley
**id:** `absorption` | **crafting:** `minecraft:golden_apple` ![golden_apple](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/golden_apple.png)

**Decription:** While holding the tool, ores around you will glow.
**Decription:** While holding the tool, get the absorption I effect.
### Tomb Raider
**id:** `spawner` | **crafting:** `minecraft:mossy_cobblestone` ![mossy_cobblestone](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/mossy_cobblestone.png)

**Decription:** While holding the spawners around you will glow.
### Filling
**id:** `filling` | **crafting:** `minecraft:cake` ![cake](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/cake.png)

**Decription:** While holding the tool, get the saturation I effect.
### Tomb Raider
**id:** `spawner` | **crafting:** `minecraft:mossy_cobblestone` ![mossy_cobblestone](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/mossy_cobblestone.png)
### Detecting
**id:** `detecting` | **crafting:** `minecraft:spyglass` ![spyglass](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/spyglass.png)

**Decription:** While holding the spawners around you will glow.
**Decription:** While holding the tool, ores around you will glow.
### Rainy
**id:** `rainy` | **crafting:** `minecraft:cauldron` ![cauldron](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/cauldron.png)

Expand All @@ -48,12 +52,16 @@ These effects are applied when holding the tool.
**id:** `living` | **crafting:** `minecraft:moss_block` ![moss_block](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/moss_block.png)

**Decription:** While holding the tool, it will randomly heal itself
### Appley
**id:** `absorption` | **crafting:** `minecraft:golden_apple` ![golden_apple](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/golden_apple.png)

**Decription:** While holding the tool, get the absorption I effect.
## Users
These effects are applied when right clicking.
### Flame Thrower
**id:** `flame_thrower` | **crafting:** `minecraft:fire_charge` ![fire_charge](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/fire_charge.png)

**Decription:** Right clicking throws a fire ball.
### Fire Starter
**id:** `fire_place` | **crafting:** `minecraft:flint_and_steel` ![flint_and_steel](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/flint_and_steel.png)

**Decription:** Right clicking on the top of a block while crouching with the tool in hand will start a fire and use 2 durability points.
### Heartha's Grace
**id:** `dirt_place` | **crafting:** `minecraft:dirt` ![dirt](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/dirt.png)

Expand All @@ -62,48 +70,50 @@ These effects are applied when right clicking.
**id:** `torch_place` | **crafting:** `minecraft:glowstone` ![glowstone](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/glowstone.png)

**Decription:** Right clicking on the top of a block with the tool in hand will place a torch and use 10 durability points.
### Fire Starter
**id:** `fire_place` | **crafting:** `minecraft:flint_and_steel` ![flint_and_steel](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/flint_and_steel.png)

**Decription:** Right clicking on the top of a block while crouching with the tool in hand will start a fire and use 2 durability points.
### Flame Thrower
**id:** `flame_thrower` | **crafting:** `minecraft:fire_charge` ![fire_charge](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/fire_charge.png)

**Decription:** Right clicking throws a fire ball.
## Hurters
These effects are applied when hurting enemies.
### Dexterous
**id:** `combo` | **crafting:** `minecraft:chorus_fruit` ![chorus_fruit](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/chorus_fruit.png)
### Charged
**id:** `charged` | **crafting:** `minecraft:lightning_rod` ![lightning_rod](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/lightning_rod.png)

**Decription:** Hitting enemies within 2 seconds after hitting them deals an extra 25% damage.
**Decription:** After 7 seconds, hitting and enemy will summon a lightning bolt and empty the charge meter.
### Bezerk
**id:** `bezerk` | **crafting:** `minecraft:beef` ![beef](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/beef.png)

**Decription:** Deals more damage at lower player health.
### Flaming
**id:** `flaming` | **crafting:** `minecraft:blaze_rod` ![blaze_rod](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/blaze_rod.png)

**Decription:** Sets enemy on fire for 2 seconds.
### Blinding
**id:** `blinding` | **crafting:** `minecraft:carrot` ![carrot](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/carrot.png)

**Decription:** When attacking with tool, apply the blindness II effect to the target.
### Critical
**id:** `critical` | **crafting:** `minecraft:ghast_tear` ![ghast_tear](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/ghast_tear.png)

**Decription:** Always critically strikes enemy.
### Dexterous
**id:** `combo` | **crafting:** `minecraft:chorus_fruit` ![chorus_fruit](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/chorus_fruit.png)

**Decription:** Hitting enemies within 2 seconds after hitting them deals an extra 25% damage.
### Blinding
**id:** `blinding` | **crafting:** `minecraft:carrot` ![carrot](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/carrot.png)

**Decription:** When attacking with tool, apply the blindness I effect to the target.
### Necrotic
**id:** `necrotic` | **crafting:** `minecraft:wither_skeleton_skull` ![wither_skeleton_skull](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/wither_skeleton_skull.png)

**Decription:** Heals 10% of damage dealt to target.
### Withering
**id:** `wither` | **crafting:** `minecraft:wither_rose` ![wither_rose](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/wither_rose.png)

**Decription:** When attacking with tool, apply the wither I effect to the target.
### Poisonous
**id:** `poison` | **crafting:** `minecraft:poisonous_potato` ![poisonous_potato](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/poisonous_potato.png)

**Decription:** When attacking with tool, apply the poison II effect to the target.
### Charged
**id:** `charged` | **crafting:** `minecraft:lightning_rod` ![lightning_rod](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/lightning_rod.png)

**Decription:** After 7 seconds, hitting and enemy will summon a lightning bolt and empty the charge meter.
### Withering
**id:** `wither` | **crafting:** `minecraft:wither_rose` ![wither_rose](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/wither_rose.png)
**Decription:** When attacking with tool, apply the poison I effect to the target.
## Stats
These effects are used to calculate stats for tools.
### Busted
**id:** `busted` | **crafting:** `minecraft:cracked_stone_bricks` ![cracked_stone_bricks](https://raw.githubusercontent.com/anish-shanbhag/minecraft-api/master/public/images/items/cracked_stone_bricks.png)

**Decription:** When attacking with tool, apply the wither II effect to the target.
**Decription:** Dig speed is increased as tool durability drops.
## Misc.
These effects are general and don't fit into any other categories.
### Unbreaking
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/marston/randomloot/GenWiki.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ private static void writeModifiers(FileWriter f) throws IOException {
write("These effects are applied when hurting enemies.", f);
writeMods(ModifierRegistry.HURTERS, f);

write("## Stats", f);
write("These effects are used to calculate stats for tools.", f);
writeMods(ModifierRegistry.STATS, f);

write("## Misc.", f);
write("These effects are general and don't fit into any other categories.", f);
writeMods(ModifierRegistry.MISC, f);
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/dev/marston/randomloot/loot/LootItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import dev.marston.randomloot.loot.modifiers.EntityHurtModifier;
import dev.marston.randomloot.loot.modifiers.HoldModifier;
import dev.marston.randomloot.loot.modifiers.Modifier;
import dev.marston.randomloot.loot.modifiers.StatsModifier;
import dev.marston.randomloot.loot.modifiers.Unbreaking;
import dev.marston.randomloot.loot.modifiers.UseModifier;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -77,12 +78,27 @@ public LootItem() {

public static float getDigSpeed(ItemStack stack, ToolType type) {

float statMod = 1.0f;

List<Modifier> mods = LootUtils.getModifiers(stack);

for (Modifier mod : mods) {
if (mod instanceof StatsModifier) {
if (!Config.traitEnabled(mod.tagName())) {
continue;
}
StatsModifier ehm = (StatsModifier) mod;

statMod *= ehm.getStats(stack);
}
}

if (type.equals(ToolType.SWORD)) {
return 1.0f;
}

float speed = (LootUtils.getStats(stack) / 2.0f) + 6.0f;
return speed;
return speed * statMod;
}

public static float getAttackSpeed(ItemStack stack, ToolType type) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dev/marston/randomloot/loot/LootUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ public static void setStats(ItemStack stack, float goodness) {
public static float getStats(ItemStack stack) {
CompoundTag statTag = stack.getOrCreateTagElement("itemStats");

return statTag.getFloat("goodness");
float goodness = statTag.getFloat("goodness");

return goodness;
}

public static void setTexture(ItemStack stack, int texture) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
import dev.marston.randomloot.loot.modifiers.holders.OreFinder;
import dev.marston.randomloot.loot.modifiers.holders.Rainy;
import dev.marston.randomloot.loot.modifiers.holders.TreasureFinder;
import dev.marston.randomloot.loot.modifiers.hurter.Bezerk;
import dev.marston.randomloot.loot.modifiers.hurter.Charging;
import dev.marston.randomloot.loot.modifiers.hurter.Combo;
import dev.marston.randomloot.loot.modifiers.hurter.Critical;
import dev.marston.randomloot.loot.modifiers.hurter.Draining;
import dev.marston.randomloot.loot.modifiers.hurter.Fire;
import dev.marston.randomloot.loot.modifiers.hurter.HurtEffect;
import dev.marston.randomloot.loot.modifiers.stats.Busted;
import dev.marston.randomloot.loot.modifiers.users.DirtPlace;
import dev.marston.randomloot.loot.modifiers.users.FireBall;
import dev.marston.randomloot.loot.modifiers.users.FirePlace;
Expand Down Expand Up @@ -52,6 +54,7 @@ public class ModifierRegistry {
public static Modifier POISONOUS = register(new HurtEffect("Poisonous", "poison", 5, MobEffects.POISON));
public static Modifier WITHERING = register(new HurtEffect("Withering", "wither", 3, MobEffects.WITHER));
public static Modifier BLINDING = register(new HurtEffect("Blinding", "blinding", 4, MobEffects.BLINDNESS));
public static Modifier BEZERK = register(new Bezerk());

public static Modifier HASTY = register(new Hasty());
public static Modifier FILLING = register(new Effect("Filling", "filling", 2, MobEffects.SATURATION));
Expand All @@ -65,15 +68,19 @@ public class ModifierRegistry {
public static Modifier SPAWNER_FINDER = register(new TreasureFinder());
public static Modifier LIVING = register(new Healing());

public static Modifier BUSTED = register(new Busted());

public static Modifier UNBREAKING = register(new Unbreaking());

public static final Set<Modifier> BREAKERS = Set.of(EXPLODE, LEARNING, ATTRACTING, VEINY, MELTING);
public static final Set<Modifier> USERS = Set.of(TORCH_PLACE, DIRT_PLACE, FIRE_PLACE, FIRE_BALL);
public static final Set<Modifier> HURTERS = Set.of(CRITICAL, CHARGING, FLAMING, COMBO, DRAINING, POISONOUS,
WITHERING, BLINDING);
WITHERING, BLINDING, BEZERK);
public static final Set<Modifier> HOLDERS = Set.of(HASTY, ABSORBTION, FILLING, RAINY, ORE_FINDER, SPAWNER_FINDER,
LIVING);

public static final Set<Modifier> STATS = Set.of(BUSTED);

public static final Set<Modifier> MISC = Set.of(UNBREAKING);

public static Modifier register(Modifier modifier) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.marston.randomloot.loot.modifiers;

import net.minecraft.world.item.ItemStack;

public interface StatsModifier extends Modifier {
public float getStats(ItemStack itemstack);

}
124 changes: 124 additions & 0 deletions src/main/java/dev/marston/randomloot/loot/modifiers/hurter/Bezerk.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package dev.marston.randomloot.loot.modifiers.hurter;

import java.util.List;

import javax.annotation.Nullable;

import dev.marston.randomloot.loot.LootItem;
import dev.marston.randomloot.loot.LootItem.ToolType;
import dev.marston.randomloot.loot.LootUtils;
import dev.marston.randomloot.loot.modifiers.EntityHurtModifier;
import dev.marston.randomloot.loot.modifiers.Modifier;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
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 Bezerk implements EntityHurtModifier {
private String name;

public Bezerk(String name) {
this.name = name;
}

public Bezerk() {
this.name = "Bezerk";
}

public Modifier clone() {
return new Bezerk();
}

@Override
public CompoundTag toNBT() {

CompoundTag tag = new CompoundTag();

tag.putString(NAME, name);

return tag;
}

@Override
public Modifier fromNBT(CompoundTag tag) {
return new Bezerk(tag.getString(NAME));
}

@Override
public String name() {
return name;
}

@Override
public String tagName() {
return "bezerk";
}

@Override
public String color() {
return ChatFormatting.GOLD.getName();
}

@Override
public String description() {
return "Deals more damage at lower player health.";
}

@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.SWORD) || type.equals(ToolType.AXE);
}

@Override
public boolean hurtEnemy(ItemStack itemstack, LivingEntity hurtee, LivingEntity hurter) {
float dmg = LootItem.getAttackDamage(itemstack, LootUtils.getToolType(itemstack));

float maxHealth = hurter.getMaxHealth();
float currentHealth = hurter.getHealth();

float ratio = maxHealth / currentHealth;

float amt = dmg * 0.05f * (ratio - 1);

if (hurter instanceof Player) {
Player p = (Player) hurter;
hurtee.hurt(hurter.damageSources().playerAttack(p), amt);
return false;
}

hurtee.hurt(hurter.damageSources().mobAttack(hurter), amt);

return false;
}

public boolean canLevel() {
return false;
}

public void levelUp() {
return;
}
}
Loading

0 comments on commit 4c62c7d

Please sign in to comment.