Skip to content

Commit

Permalink
Side effects may include: Death
Browse files Browse the repository at this point in the history
  • Loading branch information
kckarnige committed Aug 21, 2024
1 parent 16bad19 commit 18c7c92
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
32 changes: 24 additions & 8 deletions src/main/java/com/kckarnige/oye/item/EndCatalyst.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.kckarnige.oye.item;

import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -15,16 +16,31 @@ public EndCatalyst(Settings settings) {
super(settings);
}

@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 100, 2, false, false, true), attacker);
target.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 100, 2, false, false, true), attacker);
target.addStatusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 100, 2, false, false, true), attacker);
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 100, 2, false, false, true), attacker);
target.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 60, 1, false, false, true), attacker);
return super.postHit(stack, target, attacker);
}

public void inventoryTick(ItemStack nullStack, World world, Entity entity, int slot, boolean selected) {
if (!world.isClient()) {
if (entity instanceof PlayerEntity player) {

if (player.getInventory().main.stream().anyMatch(stack -> stack.isOf(ModItems.VOID_MATTER))) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 100, 2, true, false, true));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 100, 2, true, false, true));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 100, 2, true, false, true));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 60, 1, true, false, true));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 60, 1, true, false, true));
if (player.getEquippedStack(EquipmentSlot.HEAD).isOf(ModItems.VOID_MATTER)) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 100, 3, false, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 100, 3, false, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 100, 3, false, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 100, 2, false, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 1, false, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 20, 3, true, false, false));
}
else if (player.getEquippedStack(EquipmentSlot.OFFHAND).isOf(ModItems.VOID_MATTER) || player.getInventory().main.stream().anyMatch(stack -> stack.isOf(ModItems.VOID_MATTER))) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 100, 1, false, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 100, 1, false, false, false));
player.addStatusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 100, 1, false, false, false));
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/kckarnige/oye/item/ItsInYourHead.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.kckarnige.oye.item;

import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;

public class ItsInYourHead implements EquipmentSlotProvider {
@Override
public EquipmentSlot getPreferredEquipmentSlot(LivingEntity entity, ItemStack stack) {
return EquipmentSlot.HEAD;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/kckarnige/oye/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class ModItems {

public static final Item VOID_MATTER = registerItem("end_matter", new EndCatalyst(new Item.Settings()));
public static final Item VOID_MATTER = registerItem("end_matter", new EndCatalyst(new Item.Settings().equipmentSlot(new ItsInYourHead())));

private static void addItemToIngredientItemGroup(FabricItemGroupEntries entries) {
entries.add(VOID_MATTER);
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/com/kckarnige/oye/mixin/ExampleMixin.java

This file was deleted.

3 changes: 0 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
"com.kckarnige.oye.oyeDataGenerator"
]
},
"mixins": [
"oye.mixins.json"
],
"depends": {
"fabricloader": ">=0.15.11",
"minecraft": "~1.21",
Expand Down
11 changes: 0 additions & 11 deletions src/main/resources/oye.mixins.json

This file was deleted.

0 comments on commit 18c7c92

Please sign in to comment.