Skip to content

Commit

Permalink
feat: Veridium test 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Jun 13, 2024
1 parent a6e45fb commit 248d4a5
Show file tree
Hide file tree
Showing 23 changed files with 216 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ aether_version=1.20.4-1.4.1-neoforge
nitrogen_version=1.20.4-1.1.4-neoforge
cumulus_version=1.20.4-1.0.1-neoforge
curios_version=7.3.4
zenith_version=1.0.45
zenith_version=1.0.46
aeroblender_version=5271794
terrablender_version=1.20.4-3.3.0.12
terrablender_version_minimum=1.20.4-3.3.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ protected void registerModels() {
this.item(ReduxBlocks.SENTRITE_LANTERN.get().asItem(), "misc/");
this.item(ReduxBlocks.SENTRITE_CHAIN.get().asItem(), "misc/");

this.handheldItem(ReduxItems.VERIDIUM_PICKAXE.get(), "tools/");
this.handheldItem(ReduxItems.INFUSED_VERIDIUM_PICKAXE.get(), "tools/");

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ protected void addTranslations() {
add(ReduxBlocks.SENTRITE_LANTERN);
addLore(ReduxBlocks.SENTRITE_LANTERN, "A lantern made of Sentrite. You can place it on the ground or hang it on the ceiling!");

addGuiText("shift_info", "Hold [%s] for more info...");
addTooltip("infusion_level", "Infusion Level: %s");
addGuiText("infusion_info", "Can be infused by right-clicking with an Ambrosium Shard");



Expand Down
10 changes: 8 additions & 2 deletions src/main/java/net/zepalesque/redux/data/gen/ReduxRecipeGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.Items;
Expand All @@ -18,6 +19,7 @@
import net.zepalesque.redux.blockset.stone.ReduxStoneSets;
import net.zepalesque.redux.data.prov.ReduxRecipeProvider;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.redux.recipe.recipes.InfusionRecipe;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -77,8 +79,12 @@ protected void buildRecipes(@NotNull RecipeOutput output) {
.unlockedBy(ReduxRecipeProvider.getHasName(AetherBlocks.SENTRY_STONE.get()), ReduxRecipeProvider.has(AetherBlocks.SENTRY_STONE.get()))
.save(output);

// Temporary test recipe
infuse(ReduxItems.VERIDIUM_INGOT.get(), Items.IRON_INGOT).withSound(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(SoundEvents.ENCHANTMENT_TABLE_USE))
CompoundTag infusionInfo = new CompoundTag();
infusionInfo.putByte(InfusionRecipe.ADDED_INFUSION, (byte) 4);

infuse(ReduxItems.INFUSED_VERIDIUM_PICKAXE.get(), ReduxItems.VERIDIUM_PICKAXE.get())
// .withSound(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(SoundEvents.ENCHANTMENT_TABLE_USE))
.withExtra(infusionInfo)
.save(output, Redux.loc("infusion_test"));

ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ReduxBlocks.SENTRITE_LANTERN.get(), 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredItem;
import net.zepalesque.redux.Redux;
import net.zepalesque.zenith.util.DatagenUtil;

public abstract class ReduxLanguageProvider extends AetherLanguageProvider {
Expand All @@ -27,4 +28,8 @@ public void add(DeferredBlock<? extends Block> key) {
public void add(DeferredHolder<EntityType<?>, ? extends EntityType<?>> key) {
this.addEntityType(key, DatagenUtil.getNameLocalized(key));
}

public void addTooltip(String key, String name) {
this.add("tooltip." + this.id + "." + key, name);
}
}
16 changes: 16 additions & 0 deletions src/main/java/net/zepalesque/redux/item/ReduxItems.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
package net.zepalesque.redux.item;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemNameBlockItem;
import net.minecraft.world.item.PickaxeItem;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.zepalesque.redux.Redux;
import net.zepalesque.redux.block.ReduxBlocks;
import net.zepalesque.redux.item.combat.ReduxItemTiers;
import net.zepalesque.redux.item.tools.VeridiumPickaxeItem;

import java.util.function.UnaryOperator;

public class ReduxItems {


public static final UnaryOperator<Component> TOOLTIP_SHIFT_FOR_INFO = (component -> Screen.hasShiftDown() ? component : Component.translatable("gui.aether_redux.shift_info", Minecraft.getInstance().options.keyShift.getKey().getDisplayName().getString()).withStyle(ChatFormatting.DARK_GRAY));


public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(Redux.MODID);

public static final DeferredItem<Item> WYND_OATS = ITEMS.register("wynd_oats", () -> new ItemNameBlockItem(ReduxBlocks.WYNDOATS.get(), new Item.Properties().food(ReduxFoods.WYND_OATS)));
Expand All @@ -21,4 +34,7 @@ public class ReduxItems {

public static final DeferredItem<Item> REFINED_SENTRITE = ITEMS.register("refined_sentrite", () -> new Item(new Item.Properties()));
public static final DeferredItem<Item> SENTRITE_CHUNK = ITEMS.register("sentrite_chunk", () -> new Item(new Item.Properties()));

public static final DeferredItem<VeridiumPickaxeItem.Uninfused> VERIDIUM_PICKAXE = ITEMS.register("veridium_pickaxe", () -> new VeridiumPickaxeItem.Uninfused(ReduxItemTiers.VERIDIUM, 0, -2.9F, new Item.Properties()));
public static final DeferredItem<VeridiumPickaxeItem> INFUSED_VERIDIUM_PICKAXE = ITEMS.register("infused_veridium_pickaxe", () -> new VeridiumPickaxeItem(ReduxItemTiers.INFUSED_VERIDIUM, 1, -2.6F, new Item.Properties()));
}
19 changes: 19 additions & 0 deletions src/main/java/net/zepalesque/redux/item/TooltipUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.zepalesque.redux.item;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;

import java.util.function.UnaryOperator;

public class TooltipUtils {
/**
* Returns the given component, or the default message if the shift key is up.
*/
public static final UnaryOperator<Component> TOOLTIP_SHIFT_FOR_INFO = (component -> Screen.hasShiftDown() ? component : Component.translatable("gui.aether_redux.shift_info", Minecraft.getInstance().options.keyShift.getKey().getDisplayName().getString()).withStyle(ChatFormatting.DARK_GRAY));
/**
* Returns the given component, or null if the shift key is up.
*/
public static final UnaryOperator<Component> TOOLTIP_HIDDEN_SHIFT_INFO = (component -> Screen.hasShiftDown() ? component : null);
}
10 changes: 4 additions & 6 deletions src/main/java/net/zepalesque/redux/item/VeridiumItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ public interface VeridiumItem extends CustomStackingBehavior {

String NBT_KEY = "infusion_level";
String INFUSION_AMOUNT = "infusion_increase";

static byte getInfusionLevel(ItemStack stack) {
CompoundTag compound = stack.getTag();
return compound == null ? 0 : compound.getByte(NBT_KEY);
}
int DURABILITY_DMG_MULTIPLIER = 4;

Item getUninfusedItem(ItemStack stack);

Expand Down Expand Up @@ -61,12 +57,14 @@ default ItemStack transformStack(Ingredient ingredient, ItemStack original, Reci
// If null is returned, do not change the item in the slot
@Nullable
static ItemStack deplete(ItemStack stack, @Nullable LivingEntity user, int amount) {
if (user != null && user.level().isClientSide()) {
return stack;
}
if (stack.getItem() instanceof VeridiumItem vi) {
CompoundTag tag = stack.getOrCreateTag();
if (tag.getByte(NBT_KEY) > amount) {
byte infusion = (byte) (tag.getByte(NBT_KEY) - amount);
stack.addTagElement(NBT_KEY, ByteTag.valueOf(infusion));
return null;
} else {
return vi.getUninfusedStack(stack);
}
Expand Down
64 changes: 64 additions & 0 deletions src/main/java/net/zepalesque/redux/item/combat/ReduxItemTiers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package net.zepalesque.redux.item.combat;

import com.aetherteam.aether.AetherTags;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.crafting.Ingredient;
import net.neoforged.neoforge.common.util.Lazy;
import net.zepalesque.redux.item.ReduxItems;
import org.jetbrains.annotations.NotNull;

import java.util.function.Supplier;

public enum ReduxItemTiers implements Tier {

VERIDIUM(2, 750, 2.25F, 1.0F, 0, () -> Ingredient.of(ReduxItems.VERIDIUM_INGOT.get())),
INFUSED_VERIDIUM(2, 750, 7.0F, 1.0F, 0, () -> Ingredient.of(ReduxItems.VERIDIUM_INGOT.get()));

private final int harvestLevel;
private final int maxUses;
private final float efficiency;
private final float attackDamage;
private final int enchantability;
private final Lazy<Ingredient> repairMaterial;

ReduxItemTiers(int harvestLevel, int maxUses, float efficiency, float attackDamage, int enchantability, Lazy<Ingredient> repairMaterial) {
this.harvestLevel = harvestLevel;
this.maxUses = maxUses;
this.efficiency = efficiency;
this.attackDamage = attackDamage;
this.enchantability = enchantability;
this.repairMaterial = repairMaterial;
}

@Override
public int getUses() {
return this.maxUses;
}

@Override
public float getSpeed() {
return this.efficiency;
}

@Override
public float getAttackDamageBonus() {
return this.attackDamage;
}

@Override
public int getLevel() {
return this.harvestLevel;
}

@Override
public int getEnchantmentValue() {
return this.enchantability;
}

@Override
@NotNull
public Ingredient getRepairIngredient() {
return this.repairMaterial.get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package net.zepalesque.redux.item.tools;

import com.aetherteam.aether.entity.monster.dungeon.boss.Slider;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.redux.item.TooltipUtils;
import net.zepalesque.redux.item.VeridiumItem;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.function.Consumer;

public class VeridiumPickaxeItem extends PickaxeItem implements VeridiumItem {
public VeridiumPickaxeItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties) {
super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties);
}

@Override
public Item getUninfusedItem(ItemStack stack) {
return ReduxItems.VERIDIUM_PICKAXE.get();
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltips, TooltipFlag advanced) {
MutableComponent infusion = Component.translatable("tooltip.aether_redux.infusion_level", stack.getTagElement(VeridiumItem.NBT_KEY)).withStyle(ChatFormatting.GRAY);

tooltips.add(infusion);
Component info = TooltipUtils.TOOLTIP_SHIFT_FOR_INFO.apply(Component.translatable("gui.aether_redux.infusion_info"));
tooltips.add(info);
super.appendHoverText(stack, level, tooltips, advanced);
}

@Override
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
// TODO: Entity tag
int amount = target instanceof Slider ? 1 : 2;
ItemStack transform = VeridiumItem.deplete(stack, attacker, amount);
if (!attacker.level().isClientSide() && transform != null && transform != stack) {
// TODO: play sound
attacker.setItemSlot(EquipmentSlot.MAINHAND, transform);
}
return super.hurtEnemy(stack, target, attacker);
}

@Override
public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity user) {
if (!user.level().isClientSide()) {
boolean instaBreak = state.getDestroySpeed(level, pos) <= 0.0F;
// Avoid decreasing infusion on insta-break blocks
if (!instaBreak) {
int amount = stack.isCorrectToolForDrops(state) ? 1 : 2;
ItemStack transform = VeridiumItem.deplete(stack, user, amount);
if (!user.level().isClientSide() && transform != null && transform != stack) {
// TODO: play sound
user.setItemSlot(EquipmentSlot.MAINHAND, transform);
}
}
}
return super.mineBlock(stack, level, state, pos, user);
}

@Override
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
return super.damageItem(stack, amount, entity, onBroken) * VeridiumItem.DURABILITY_DMG_MULTIPLIER;
}

public static class Uninfused extends PickaxeItem {

public Uninfused(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties) {
super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties);
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltips, TooltipFlag advanced) {
Component info = TooltipUtils.TOOLTIP_SHIFT_FOR_INFO.apply(Component.translatable("gui.aether_redux.infusion_info"));
tooltips.add(info);
super.appendHoverText(stack, level, tooltips, advanced);
}
}
}
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 248d4a5

Please sign in to comment.