Skip to content

Commit

Permalink
feat: Other tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Jun 15, 2024
1 parent 7ebb9ae commit b0182df
Show file tree
Hide file tree
Showing 9 changed files with 382 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/zepalesque/redux/data/ReduxData.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void dataSetup(GatherDataEvent event) {
generator.addProvider(event.includeServer(), blockTags);
generator.addProvider(event.includeServer(), new ReduxItemTagsData(packOutput, lookupProvider, blockTags.contentsGetter(), fileHelper));
generator.addProvider(event.includeServer(), new ReduxEntityTagsData(packOutput, lookupProvider, fileHelper));

generator.addProvider(event.includeServer(), new ReduxBiomeTagsData(packOutput, lookupProvider, fileHelper));

// pack.mcmeta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ protected void registerModels() {

this.handheldItem(ReduxItems.VERIDIUM_PICKAXE.get(), "tools/");
this.handheldGlow(ReduxItems.INFUSED_VERIDIUM_PICKAXE.get(), "tools/");
this.handheldItem(ReduxItems.VERIDIUM_AXE.get(), "tools/");
this.handheldGlow(ReduxItems.INFUSED_VERIDIUM_AXE.get(), "tools/");
this.handheldItem(ReduxItems.VERIDIUM_SHOVEL.get(), "tools/");
this.handheldGlow(ReduxItems.INFUSED_VERIDIUM_SHOVEL.get(), "tools/");
this.handheldItem(ReduxItems.VERIDIUM_HOE.get(), "tools/");
this.handheldGlow(ReduxItems.INFUSED_VERIDIUM_HOE.get(), "tools/");

}

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/net/zepalesque/redux/data/gen/ReduxLanguageData.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ protected void addTranslations() {
add(ReduxItems.INFUSED_VERIDIUM_PICKAXE);
addLore(ReduxItems.INFUSED_VERIDIUM_PICKAXE, "A pickaxe made of Veridium. This can be infused by right-clicking with an Ambrosium Shard to make it far more powerful for a short time!");

add(ReduxItems.VERIDIUM_AXE);
addLore(ReduxItems.VERIDIUM_AXE, "A axe made of Veridium. This can be infused by right-clicking with an Ambrosium Shard to make it far more powerful for a short time!");
add(ReduxItems.INFUSED_VERIDIUM_AXE);
addLore(ReduxItems.INFUSED_VERIDIUM_AXE, "A axe made of Veridium. This can be infused by right-clicking with an Ambrosium Shard to make it far more powerful for a short time!");

add(ReduxItems.VERIDIUM_SHOVEL);
addLore(ReduxItems.VERIDIUM_SHOVEL, "A shovel made of Veridium. This can be infused by right-clicking with an Ambrosium Shard to make it far more powerful for a short time!");
add(ReduxItems.INFUSED_VERIDIUM_SHOVEL);
addLore(ReduxItems.INFUSED_VERIDIUM_SHOVEL, "A shovel made of Veridium. This can be infused by right-clicking with an Ambrosium Shard to make it far more powerful for a short time!");

add(ReduxItems.VERIDIUM_HOE);
addLore(ReduxItems.VERIDIUM_HOE, "A hoe made of Veridium. This can be infused by right-clicking with an Ambrosium Shard to make it far more powerful for a short time!");
add(ReduxItems.INFUSED_VERIDIUM_HOE);
addLore(ReduxItems.INFUSED_VERIDIUM_HOE, "A hoe made of Veridium. This can be infused by right-clicking with an Ambrosium Shard to make it far more powerful for a short time!");



addGuiText("shift_info", "Hold [%s] for more info...");
addTooltip("infusion_charge", "Infusion Charge: %s");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ protected void addTags(HolderLookup.Provider provider) {
Redux.STONE_SETS.forEach(set -> set.itemTagData(this));

this.tag(ItemTags.PICKAXES).add(ReduxItems.VERIDIUM_PICKAXE.get(), ReduxItems.INFUSED_VERIDIUM_PICKAXE.get());
// this.tag(ItemTags.SHOVELS).add(ReduxItems.VERIDIUM_SHOVEL.get(), ReduxItems.INFUSED_VERIDIUM_SHOVEL.get());
// this.tag(ItemTags.HOES).add(ReduxItems.VERIDIUM_HOE.get(), ReduxItems.INFUSED_VERIDIUM_HOE.get());
// this.tag(ItemTags.AXES).add(ReduxItems.VERIDIUM_AXE.get(), ReduxItems.INFUSED_VERIDIUM_AXE.get());
this.tag(ItemTags.SHOVELS).add(ReduxItems.VERIDIUM_SHOVEL.get(), ReduxItems.INFUSED_VERIDIUM_SHOVEL.get());
this.tag(ItemTags.HOES).add(ReduxItems.VERIDIUM_HOE.get(), ReduxItems.INFUSED_VERIDIUM_HOE.get());
this.tag(ItemTags.AXES).add(ReduxItems.VERIDIUM_AXE.get(), ReduxItems.INFUSED_VERIDIUM_AXE.get());
// this.tag(ItemTags.SWORDS).add(ReduxItems.VERIDIUM_SWORD.get(), ReduxItems.INFUSED_VERIDIUM_SWORD.get());

this.tag(AetherTags.Items.SLIDER_DAMAGING_ITEMS).add(ReduxItems.VERIDIUM_PICKAXE.get(), ReduxItems.INFUSED_VERIDIUM_PICKAXE.get());

this.tag(AetherTags.Items.TREATED_AS_AETHER_ITEM).add(
ReduxItems.VERIDIUM_PICKAXE.get(),
// ReduxItems.VERIDIUM_AXE.get(),
// ReduxItems.VERIDIUM_HOE.get(),
// ReduxItems.VERIDIUM_SHOVEL.get(),
ReduxItems.VERIDIUM_AXE.get(),
ReduxItems.VERIDIUM_HOE.get(),
ReduxItems.VERIDIUM_SHOVEL.get(),
// ReduxItems.VERIDIUM_SWORD.get(),
ReduxItems.INFUSED_VERIDIUM_PICKAXE.get()/*,*/
// ReduxItems.INFUSED_VERIDIUM_AXE.get(),
// ReduxItems.INFUSED_VERIDIUM_HOE.get(),
// ReduxItems.INFUSED_VERIDIUM_SHOVEL.get(),
ReduxItems.INFUSED_VERIDIUM_PICKAXE.get(),
ReduxItems.INFUSED_VERIDIUM_AXE.get(),
ReduxItems.INFUSED_VERIDIUM_HOE.get(),
ReduxItems.INFUSED_VERIDIUM_SHOVEL.get()
// ReduxItems.INFUSED_VERIDIUM_SWORD.get()
);
this.tag(AetherTags.Items.SENTRY_BLOCKS).add(
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/net/zepalesque/redux/item/ReduxItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import net.zepalesque.redux.Redux;
import net.zepalesque.redux.block.ReduxBlocks;
import net.zepalesque.redux.item.combat.ReduxItemTiers;
import net.zepalesque.redux.item.tools.VeridiumAxeItem;
import net.zepalesque.redux.item.tools.VeridiumHoeItem;
import net.zepalesque.redux.item.tools.VeridiumPickaxeItem;
import net.zepalesque.redux.item.tools.VeridiumShovelItem;

import java.util.function.UnaryOperator;

Expand All @@ -36,5 +39,13 @@ public class ReduxItems {
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()));
public static final DeferredItem<VeridiumAxeItem.Uninfused> VERIDIUM_AXE = ITEMS.register("veridium_axe", () -> new VeridiumAxeItem.Uninfused(ReduxItemTiers.VERIDIUM, 1, 0 -3.2F, new Item.Properties()));
public static final DeferredItem<VeridiumShovelItem.Uninfused> VERIDIUM_SHOVEL = ITEMS.register("veridium_shovel", () -> new VeridiumShovelItem.Uninfused(ReduxItemTiers.VERIDIUM, 0, -3.1F, new Item.Properties()));
public static final DeferredItem<VeridiumHoeItem.Uninfused> VERIDIUM_HOE = ITEMS.register("veridium_hoe", () -> new VeridiumHoeItem.Uninfused(ReduxItemTiers.VERIDIUM, 0, -1.7F, 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(), VERIDIUM_PICKAXE));
public static final DeferredItem<VeridiumAxeItem> INFUSED_VERIDIUM_AXE = ITEMS.register("infused_veridium_axe", () -> new VeridiumAxeItem(ReduxItemTiers.INFUSED_VERIDIUM, 1, -2.9F, new Item.Properties(), VERIDIUM_AXE));
public static final DeferredItem<VeridiumShovelItem> INFUSED_VERIDIUM_SHOVEL = ITEMS.register("infused_veridium_shovel", () -> new VeridiumShovelItem(ReduxItemTiers.INFUSED_VERIDIUM, 0, -2.8F, new Item.Properties(), VERIDIUM_SHOVEL));
public static final DeferredItem<VeridiumHoeItem> INFUSED_VERIDIUM_HOE = ITEMS.register("infused_veridium_hoe", () -> new VeridiumHoeItem(ReduxItemTiers.INFUSED_VERIDIUM, 0, -1.4F, new Item.Properties(), VERIDIUM_HOE));


}
123 changes: 123 additions & 0 deletions src/main/java/net/zepalesque/redux/item/tools/VeridiumAxeItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package net.zepalesque.redux.item.tools;

import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.AxeItem;
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.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.zepalesque.redux.data.ReduxTags;
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;
import java.util.function.Supplier;

public class VeridiumAxeItem extends AxeItem implements VeridiumItem {
private final Supplier<? extends Item> uninfused;

public VeridiumAxeItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties, Supplier<? extends Item> uninfused) {
super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties);
this.uninfused = uninfused;
}

@Override
public Item getUninfusedItem(ItemStack stack) {
return this.uninfused.get();
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltips, TooltipFlag advanced) {
MutableComponent infusion = Component.translatable("tooltip.aether_redux.infusion_charge", stack.getTag() == null ? 0 : stack.getTag().getByte(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) {
boolean bool = super.hurtEnemy(stack, target, attacker);
ItemStack transform = this.deplete(stack, attacker, 1);
if (!attacker.level().isClientSide() && transform != null && transform != stack) {
attacker.setItemSlot(EquipmentSlot.MAINHAND, transform);
if (attacker instanceof ServerPlayer sp) {
this.sendSound(sp);
}
}
return bool;
}

@Override
public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity user) {
// Call the vanilla method do do things like tool damaging
boolean bool = super.mineBlock(stack, level, state, pos, 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 = this.deplete(stack, user, amount);
if (!user.level().isClientSide() && transform != null && transform != stack) {
user.setItemSlot(EquipmentSlot.MAINHAND, transform);
if (user instanceof ServerPlayer sp) {
this.sendSound(sp);
}
}
}
}
return bool;
}

@Override
public InteractionResult useOn(UseOnContext context) {
InteractionResult result = super.useOn(context);
if (result == InteractionResult.sidedSuccess(context.getLevel().isClientSide()) && !context.getPlayer().level().isClientSide() && !context.getPlayer().isCreative()) {
ItemStack stack = context.getItemInHand();
Player player = context.getPlayer();
ItemStack transform = this.deplete(stack, player, 1);
if (!player.level().isClientSide() && transform != null && transform != stack) {
player.setItemSlot(EquipmentSlot.MAINHAND, transform);
if (player instanceof ServerPlayer sp) {
this.sendSound(sp);
}
}
}
return result;
}

@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 AxeItem {

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);
}
}
}
104 changes: 104 additions & 0 deletions src/main/java/net/zepalesque/redux/item/tools/VeridiumHoeItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package net.zepalesque.redux.item.tools;

import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.HoeItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ShovelItem;
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.data.ReduxTags;
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;
import java.util.function.Supplier;

public class VeridiumHoeItem extends HoeItem implements VeridiumItem {
private final Supplier<? extends Item> uninfused;

public VeridiumHoeItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties, Supplier<? extends Item> uninfused) {
super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties);
this.uninfused = uninfused;
}

@Override
public Item getUninfusedItem(ItemStack stack) {
return this.uninfused.get();
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltips, TooltipFlag advanced) {
MutableComponent infusion = Component.translatable("tooltip.aether_redux.infusion_charge", stack.getTag() == null ? 0 : stack.getTag().getByte(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) {
int amount = target.getType().is(ReduxTags.Entities.VALID_PICKAXE_TARGETS) ? 1 : 2;
boolean bool = super.hurtEnemy(stack, target, attacker);
ItemStack transform = this.deplete(stack, attacker, amount);
if (!attacker.level().isClientSide() && transform != null && transform != stack) {
attacker.setItemSlot(EquipmentSlot.MAINHAND, transform);
if (attacker instanceof ServerPlayer sp) {
this.sendSound(sp);
}
}
return bool;
}

@Override
public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity user) {
// Call the vanilla method do do things like tool damaging
boolean bool = super.mineBlock(stack, level, state, pos, 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 = this.deplete(stack, user, amount);
if (!user.level().isClientSide() && transform != null && transform != stack) {
user.setItemSlot(EquipmentSlot.MAINHAND, transform);
if (user instanceof ServerPlayer sp) {
this.sendSound(sp);
}
}
}
}
return bool;
}

@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 HoeItem {

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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@

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

public class VeridiumPickaxeItem extends PickaxeItem implements VeridiumItem {
public VeridiumPickaxeItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties) {
private final Supplier<? extends Item> uninfused;

public VeridiumPickaxeItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties, Supplier<? extends Item> uninfused) {
super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties);
this.uninfused = uninfused;
}

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

@Override
Expand All @@ -47,7 +51,6 @@ public void appendHoverText(ItemStack stack, @Nullable Level level, List<Compone

@Override
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
// TODO: Entity tag
int amount = target.getType().is(ReduxTags.Entities.VALID_PICKAXE_TARGETS) ? 1 : 2;
boolean bool = super.hurtEnemy(stack, target, attacker);
ItemStack transform = this.deplete(stack, attacker, amount);
Expand Down
Loading

0 comments on commit b0182df

Please sign in to comment.