Skip to content

Commit

Permalink
basically, Heart Replacements added
Browse files Browse the repository at this point in the history
  • Loading branch information
JaegerwaldDev committed Dec 27, 2024
1 parent 2dff2d5 commit f3bea6f
Show file tree
Hide file tree
Showing 28 changed files with 340 additions and 29 deletions.
30 changes: 30 additions & 0 deletions src/main/java/dev/jaegerwald/voidlings/item/HeartItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package dev.jaegerwald.voidlings.item;

import dev.jaegerwald.voidlings.sound.ModSounds;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundCategory;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;

public class HeartItem extends Item {
public HeartItem(Settings settings) {
super(settings);
}

public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack itemStack = user.getStackInHand(hand);
user.incrementStat(Stats.USED.getOrCreateStat(this));

if (!user.isCreative()) {
itemStack.decrement(1);
}

return TypedActionResult.pass(itemStack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class ModItemGroups {

entries.add(ModItems.SURGEONS_BLADE);
entries.add(ModItems.PIERCED_MURIA_HANDLE);

entries.add(ModItems.VOIDLING_HEART);
entries.add(ModItems.BROKEN_VOIDLING_HEART);
}).build());

public static void registerItemGroups() {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/dev/jaegerwald/voidlings/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public class ModItems {
public static final Item REPLICA_WHISKERS = registerItem("replica_whiskers", new Item(new Item.Settings()));

public static final Item PIERCED_MURIA_HANDLE = registerItem("pierced_muria_handle", new Item(new Item.Settings()));
public static final Item SURGEONS_BLADE = registerItem("surgeons_blade", new SwordItem(ToolMaterials.NETHERITE, new Item.Settings().attributeModifiers(SwordItem.createAttributeModifiers(ToolMaterials.NETHERITE, 6, -2.0F))));
public static final Item SURGEONS_BLADE = registerItem("surgeons_blade", new SurgeonsBladeItem(ModToolMaterials.MURIA, new Item.Settings().attributeModifiers(SwordItem.createAttributeModifiers(ModToolMaterials.MURIA, 6, -2.0F))));

public static final Item REPLACEMENT_HEART = registerItem("replacement_heart", new HeartItem(new Item.Settings().maxCount(1))); // debug item

public static final Item VOIDLING_HEART = registerItem("voidling_heart", new HeartItem(new Item.Settings().maxCount(1)));
public static final Item BROKEN_VOIDLING_HEART = registerItem("broken_voidling_heart", new Item(new Item.Settings().maxCount(16)));

private static Item registerItem(String name, Item item) {
return Registry.register(Registries.ITEM, Identifier.of(Voidlings.MOD_ID, name), item);
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/dev/jaegerwald/voidlings/item/ModToolMaterials.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package dev.jaegerwald.voidlings.item;

import com.google.common.base.Suppliers;
import net.minecraft.block.Block;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterial;
import net.minecraft.recipe.Ingredient;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.registry.tag.TagKey;

import java.util.Objects;
import java.util.function.Supplier;

public enum ModToolMaterials implements ToolMaterial {
MURIA(BlockTags.INCORRECT_FOR_NETHERITE_TOOL, 3046, 9.0F, 4.0F, 20, () -> Ingredient.ofItems(new ItemConvertible[]{ModItems.RAW_MURIA}));

private final TagKey<Block> inverseTag;
private final int itemDurability;
private final float miningSpeed;
private final float attackDamage;
private final int enchantability;
private final Supplier<Ingredient> repairIngredient;

private ModToolMaterials(final TagKey<Block> inverseTag, final int itemDurability, final float miningSpeed, final float attackDamage, final int enchantability, final Supplier<Ingredient> repairIngredient) {
this.inverseTag = inverseTag;
this.itemDurability = itemDurability;
this.miningSpeed = miningSpeed;
this.attackDamage = attackDamage;
this.enchantability = enchantability;
Objects.requireNonNull(repairIngredient);
this.repairIngredient = Suppliers.memoize(repairIngredient::get);
}

public int getDurability() {
return this.itemDurability;
}

public float getMiningSpeedMultiplier() {
return this.miningSpeed;
}

public float getAttackDamage() {
return this.attackDamage;
}

public TagKey<Block> getInverseTag() {
return this.inverseTag;
}

public int getEnchantability() {
return this.enchantability;
}

public Ingredient getRepairIngredient() {
return (Ingredient)this.repairIngredient.get();
}
}
2 changes: 1 addition & 1 deletion src/main/java/dev/jaegerwald/voidlings/item/Renderers.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Renderers {

public static void register() {
RENDERERS.put(ModItems.SURGEONS_BLADE, Map.of((stack, modelTransformationMode) -> {
return modelTransformationMode != ModelTransformationMode.GUI; // The condition to apply the model
return modelTransformationMode != ModelTransformationMode.GUI && modelTransformationMode != ModelTransformationMode.GROUND && modelTransformationMode != ModelTransformationMode.FIXED; // The condition to apply the model
}, forceLoad("surgeons_blade_in_hand")));
}

Expand Down
46 changes: 46 additions & 0 deletions src/main/java/dev/jaegerwald/voidlings/item/SurgeonsBladeItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package dev.jaegerwald.voidlings.item;

import dev.jaegerwald.voidlings.sound.ModSounds;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.ItemSteerable;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SurgeonsBladeItem extends SwordItem {
public SurgeonsBladeItem(ToolMaterial toolMaterial, Settings settings) {
super(toolMaterial, settings);
}

public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
ItemStack itemStack = user.getStackInHand(hand);
user.incrementStat(Stats.USED.getOrCreateStat(this));

world.playSound((PlayerEntity)null, user.getX(), user.getY(), user.getZ(), ModSounds.ITEM_SURGEONS_BLADE_STAB, SoundCategory.PLAYERS, 0.75F, 1.0F);

// mainly like this for testing purposes
if (!user.isCreative()) {
user.getItemCooldownManager().set(this, 600);
} else {
user.getItemCooldownManager().set(this, 100);
}

itemStack.damage(5, user, EquipmentSlot.MAINHAND);

user.damage(world.getDamageSources().playerAttack(user), 9.0F);

return TypedActionResult.pass(itemStack);
}
}
2 changes: 2 additions & 0 deletions src/main/java/dev/jaegerwald/voidlings/sound/ModSounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
public class ModSounds {
public static final SoundEvent BLOCK_VOID_VINES_PICK_LAMINA = registerSoundEvent("block.void_vines.pick_lamina");

public static final SoundEvent ITEM_SURGEONS_BLADE_STAB = registerSoundEvent("item.surgeons_blade.stab");

private static SoundEvent registerSoundEvent(String name) {
Identifier id = Identifier.of(Voidlings.MOD_ID, name);
return Registry.register(Registries.SOUND_EVENT, id, SoundEvent.of(id));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "voidlings:item/broken_voidling_heart"
}
}
49 changes: 25 additions & 24 deletions src/main/resources/assets/voidlings/models/item/handheld_large.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
{
"parent": "minecraft:item/generated",
"display": {
"thirdperson_righthand": {
"rotation": [ 0, -90, 55 ],
"translation": [ 0, 4.0, 0.5 ],
"scale": [ 1.7, 1.7, 0.85 ]
},
"thirdperson_lefthand": {
"rotation": [ 0, 90, -55 ],
"translation": [ 0, 4.0, 0.5 ],
"scale": [ 1.7, 1.7, 0.85 ]
},
"firstperson_righthand": {
"rotation": [ 0, -90, 25 ],
"translation": [ 1.13, 3.2, 1.13 ],
"scale": [ 1.36, 1.36, 0.68 ]
},
"firstperson_lefthand": {
"rotation": [ 0, 90, -25 ],
"translation": [ 1.13, 3.2, 1.13 ],
"scale": [ 1.36, 1.36, 0.68 ]
}
}
}
"credit": "Made by Jaegerwald",
"parent": "minecraft:item/generated",
"display": {
"thirdperson_righthand": {
"rotation": [0, -90, 55],
"translation": [0, 10, 1],
"scale": [1.7, 1.7, 0.85]
},
"thirdperson_lefthand": {
"rotation": [0, 90, -55],
"translation": [0, 10, 1],
"scale": [1.7, 1.7, 0.85]
},
"firstperson_righthand": {
"rotation": [0, -90, 25],
"translation": [1.13, 6.4, 2.26],
"scale": [1.36, 1.36, 0.68]
},
"firstperson_lefthand": {
"rotation": [0, 90, -25],
"translation": [1.13, 6.4, 2.26],
"scale": [1.36, 1.36, 0.68]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "voidlings:item/replacement_heart"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "voidlings:item/voidling_heart"
}
}
21 changes: 21 additions & 0 deletions src/main/resources/assets/voidlings/sounds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"item.surgeons_blade.stab": {
"subtitle": "subtitles.voidlings.item.surgeons_blade.stab",
"sounds": [
"voidlings:item/surgeons_blade/stab"
]
},
"item.surgeons_blade.voidling_breath": {
"subtitle": "subtitles.voidlings.item.surgeons_blade.voidling_breath",
"sounds": [
"voidlings:item/surgeons_blade/voidling_breath"
]
},
"block.void_vines.pick_lamina": {
"subtitle": "subtitles.voidlings.block.void_vines.pick_lamina",
"sounds": [
"minecraft:item/sweet_berries/pick_from_bush1",
"minecraft:item/sweet_berries/pick_from_bush2"
]
}
}
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
execute unless entity @s[tag=voidlings.stabbed] run effect give @s minecraft:regeneration 3 5 true
execute if entity @s[tag=voidlings.stabbed] run function voidlings:valid_heart_replacement
7 changes: 7 additions & 0 deletions src/main/resources/data/voidlings/function/stabbed.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
effect give @s minecraft:slowness 30 3 true
effect give @s minecraft:blindness 31 255 true

tag @s add voidlings.stabbed
tag @s remove voidlings.replaced_heart

schedule function voidlings:stabbed_bleed_out 600t replace
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
execute as @a[tag=voidlings.stabbed,tag=!voidlings.replaced_heart] run kill @s
tag @a[tag=voidlings.stabbed,tag=!voidlings.replaced_heart] remove voidlings.stabbed
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tag @s add voidlings.replaced_heart

effect clear @s minecraft:slowness
effect clear @s minecraft:blindness

tag @s remove voidlings.stabbed
9 changes: 6 additions & 3 deletions src/main/resources/data/voidlings/origins/voidling.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"powers": [
"voidlings:light_hearted",
"voidlings:voidling/light_hearted",
"voidlings:burn_in_daylight",
"voidlings:vanish",
"voidlings:dash",
"voidlings:fall_immunity"
"voidlings:voidling/dash",
"voidlings:fall_immunity",

"voidlings:voidling/stabbable",
"voidlings:replacable_heart"
],
"icon": {
"id": "vex_armor_trim_smithing_template"
Expand Down
33 changes: 33 additions & 0 deletions src/main/resources/data/voidlings/powers/replacable_heart.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "origins:action_on_item_use",
"trigger": "instant",
"hidden": true,

"entity_action": {
"type": "origins:and",
"actions": [
{
"type": "origins:execute_command",
"command": "function voidlings:replaced_heart"
}
]
},

"item_condition": {
"type": "origins:or",
"conditions": [
{
"type": "origins:ingredient",
"ingredient": {
"item": "voidlings:replacement_heart"
}
},
{
"type": "origins:ingredient",
"ingredient": {
"item": "voidlings:voidling_heart"
}
}
]
}
}
32 changes: 32 additions & 0 deletions src/main/resources/data/voidlings/powers/voidling/stabbable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"type": "origins:action_on_item_use",
"trigger": "instant",
"hidden": true,

"entity_action": {
"type": "origins:and",
"actions": [
{
"type": "origins:play_sound",
"sound": "voidlings:item.surgeons_blade.voidling_breath",
"volume": 0.75,
"pitch": 1
},
{
"type": "origins:execute_command",
"command": "function voidlings:stabbed"
},
{
"type": "origins:execute_command",
"command": "give @s voidlings:broken_voidling_heart 1"
}
]
},

"item_condition": {
"type": "origins:ingredient",
"ingredient": {
"item": "voidlings:surgeons_blade"
}
}
}
Loading

0 comments on commit f3bea6f

Please sign in to comment.