Berserker Totem + effect

This commit is contained in:
Sunskimmer822 2022-08-02 15:28:23 -07:00
parent 60a48f3b0c
commit 6bd79f8aa3
6 changed files with 83 additions and 1 deletions

View File

@ -126,6 +126,10 @@ public class Shitmod implements ModInitializer {
public static final PickaxeItem HAMMER = new testHammer(ToolMaterials.NETHERITE, 3, -1, new Item.Settings().group(Shitmod.TOOLS_GROUP).fireproof().maxDamage(2031));
public static final StatusEffect BERSERK = new berserkEffect();
public static final Item BERSERKER_TOTEM = new berserkerTotem(new FabricItemSettings().group(Shitmod.GENERAL_GROUP).maxDamage(512).rarity(Rarity.EPIC));
@Override
public void onInitialize() {
@ -217,5 +221,9 @@ public class Shitmod implements ModInitializer {
Registry.register(Registry.ENCHANTMENT, new Identifier("shitmod", "lifesteal"), LIFESTEAL);
Registry.register(Registry.ITEM, new Identifier("shitmod", "hammer"), HAMMER);
Registry.register(Registry.STATUS_EFFECT, new Identifier("shitmod", "berserk"), BERSERK);
Registry.register(Registry.ITEM, new Identifier("shitmod", "berserker_totem"), BERSERKER_TOTEM);
}
}

View File

@ -0,0 +1,32 @@
package net.serenas.shitmod;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
public class berserkEffect extends StatusEffect{
protected berserkEffect() {
super(StatusEffectCategory.BENEFICIAL, 0xa80f12);
}
@Override
public boolean canApplyUpdateEffect(int duration, int amplifier) {
// In our case, we just make it return true so that it applies the status effect every tick.
return true;
}
// This method is called when it applies the status effect. We implement custom functionality here.
@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
if (entity instanceof PlayerEntity) {
((PlayerEntity) entity).damage(DamageSource.MAGIC, (0.25f));
((PlayerEntity) entity).addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 2, amplifier*2, true, false, false));
}
}
}

View File

@ -0,0 +1,34 @@
package net.serenas.shitmod;
import java.util.Random;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
public class berserkerTotem extends Item{
public berserkerTotem(Settings settings) {
super(settings);
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
int rand = new Random().nextInt(5);
if (rand == 0) {
rand++;
playerEntity.addStatusEffect(new StatusEffectInstance(Shitmod.BERSERK, 400, rand));
return new TypedActionResult<ItemStack>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand));
}
playerEntity.addStatusEffect(new StatusEffectInstance(Shitmod.BERSERK, 400, rand));
return new TypedActionResult<ItemStack>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand));
}
}

View File

@ -46,5 +46,7 @@
"enchantment.shitmod.lifesteal": "Life Steal",
"enchantment.shitmod.explosion_aspect": "Explosion Aspect",
"enchantment.shitmod.explosive_thorns": "Explosive Thorns",
"item.shitmod.hammer": "Hammer"
"item.shitmod.hammer": "Hammer",
"item.shitmod.berserker_totem": "Berserker Totem",
"effect.shitmod.berserk": "Berserk"
}

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "shitmod:item/berserker_totem"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB