Skip to content

Commit

Permalink
Kill IForgeItem (mostly)
Browse files Browse the repository at this point in the history
  • Loading branch information
quat1024 committed Nov 9, 2023
1 parent fd797e5 commit 5a1c490
Show file tree
Hide file tree
Showing 27 changed files with 377 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.violetmoon.quark.addons.oddities.module.MatrixEnchantingModule;
import org.violetmoon.quark.addons.oddities.util.Influence;
import org.violetmoon.quark.api.IEnchantmentInfluencer;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.zeta.util.ItemNBTHelper;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -240,7 +241,7 @@ private void updateEnchantPower() {
if(item.isEmpty())
return;

enchantability = item.getItem().getEnchantmentValue(item);
enchantability = Quark.ZETA.itemExtensions.get(item).getEnchantmentValueZeta(item);

boolean allowWater = MatrixEnchantingModule.allowUnderwaterEnchanting;
boolean allowShort = MatrixEnchantingModule.allowShortBlockEnchanting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.violetmoon.quark.base.client.handler.RequiredModTooltipHandler;
import org.violetmoon.quark.base.handler.ProxiedItemStackHandler;
import org.violetmoon.zeta.item.IZetaItem;
import org.violetmoon.zeta.item.ext.IZetaItemExtensions;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.util.ItemNBTHelper;

Expand Down Expand Up @@ -46,24 +47,19 @@
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;

public class BackpackItem extends DyeableArmorItem implements IZetaItem, MenuProvider {
public class BackpackItem extends DyeableArmorItem implements IZetaItem, IZetaItemExtensions, MenuProvider {

private static final String WORN_TEXTURE = Quark.MOD_ID + ":textures/misc/backpack_worn.png";
private static final String WORN_OVERLAY_TEXTURE = Quark.MOD_ID + ":textures/misc/backpack_worn_overlay.png";

private final ZetaModule module;

@OnlyIn(Dist.CLIENT)
@SuppressWarnings("rawtypes")
private HumanoidModel model;

public BackpackItem(ZetaModule module) {
super(ArmorMaterials.LEATHER, EquipmentSlot.CHEST,
new Item.Properties()
Expand All @@ -79,9 +75,8 @@ public BackpackItem(ZetaModule module) {
RequiredModTooltipHandler.map(this, module.category.requiredMod);
}

//TODO: IForgeItem
@Override
public int getDefaultTooltipHideFlags(@Nonnull ItemStack stack) {
public int getDefaultTooltipHideFlagsZeta(@Nonnull ItemStack stack) {
return stack.isEnchanted() ? ItemStack.TooltipPart.ENCHANTMENTS.getMask() : 0;
}

Expand Down Expand Up @@ -114,21 +109,18 @@ public static boolean doesBackpackHaveItems(ItemStack stack) {
return false;
}

//TODO: IForgeItem
@Override
public boolean isBookEnchantable(ItemStack stack, ItemStack book) {
public boolean isBookEnchantableZeta(ItemStack stack, ItemStack book) {
return false;
}

//TODO: IForgeItem
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
public boolean canApplyAtEnchantingTableZeta(ItemStack stack, Enchantment enchantment) {
return false;
}

//TODO: IForgeItem
@Override
public int getEnchantmentValue(ItemStack stack) {
public int getEnchantmentValueZeta(ItemStack stack) {
return 0;
}

Expand All @@ -137,9 +129,8 @@ public boolean canBeDepleted() {
return false;
}

//TODO: IForgeITem
@Override
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
public <T extends LivingEntity> int damageItemZeta(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
return 0;
}

Expand Down Expand Up @@ -184,9 +175,8 @@ public void inventoryTick(@Nonnull ItemStack stack, Level worldIn, @Nonnull Enti
EnchantmentHelper.setEnchantments(enchants, stack);
}

//TODO: IForgeItem
@Override
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entityItem) {
public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity entityItem) {
if(BackpackModule.superOpMode || entityItem.level.isClientSide)
return false;

Expand Down Expand Up @@ -241,9 +231,8 @@ public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(Equip
return ImmutableMultimap.of();
}

//TODO: IForgeItem
@Override
public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
public String getArmorTextureZeta(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
return type != null && type.equals("overlay") ? WORN_OVERLAY_TEXTURE : WORN_TEXTURE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.violetmoon.quark.addons.oddities.util.TinyPotatoInfo;
import org.violetmoon.quark.api.IRuneColorProvider;
import org.violetmoon.quark.base.handler.ContributorRewardHandler;
import org.violetmoon.zeta.item.ZetaBlockItem;
import org.violetmoon.zeta.util.ItemNBTHelper;

import net.minecraft.ChatFormatting;
Expand All @@ -19,12 +20,11 @@
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;

public class TinyPotatoBlockItem extends BlockItem implements IRuneColorProvider {
public class TinyPotatoBlockItem extends ZetaBlockItem implements IRuneColorProvider {
private static final int NOT_MY_NAME = 17;
private static final List<String> TYPOS = List.of("vaskii", "vazki", "voskii", "vazkkii", "vazkki", "vazzki", "vaskki", "vozkii", "vazkil", "vaskil", "vazkill", "vaskill", "vaski");

Expand All @@ -34,10 +34,9 @@ public TinyPotatoBlockItem(Block block, Properties properties) {
super(block, properties);
}

//TODO: IForgeItem
@Override
public boolean canEquip(ItemStack stack, EquipmentSlot armorType, Entity entity) {
return super.canEquip(stack, armorType, entity) ||
public boolean canEquipZeta(ItemStack stack, EquipmentSlot armorType, Entity entity) {
return super.canEquipZeta(stack, armorType, entity) ||
(entity instanceof Player player && ContributorRewardHandler.getTier(player) > 0);
}

Expand Down Expand Up @@ -74,9 +73,9 @@ else if (TinyPotatoBlock.isAngry(stack))
}

@Override
public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) {
public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity entity) {
updateData(stack);
return super.onEntityItemUpdate(stack, entity);
return super.onEntityItemUpdateZeta(stack, entity);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/violetmoon/quark/base/item/QuarkItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import net.minecraft.core.NonNullList;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

import javax.annotation.Nonnull;

import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.client.handler.RequiredModTooltipHandler;
import org.violetmoon.zeta.item.IZetaItem;
import org.violetmoon.zeta.item.ZetaItem;
import org.violetmoon.zeta.module.ZetaModule;

import java.util.function.BooleanSupplier;

public class QuarkItem extends Item implements IZetaItem {
public class QuarkItem extends ZetaItem implements IZetaItem {

private final ZetaModule module;
private BooleanSupplier enabledSupplier = () -> true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.violetmoon.quark.base.block.QuarkBlock;
import org.violetmoon.quark.content.automation.module.PistonsMoveTileEntitiesModule;
import org.violetmoon.quark.content.building.module.RopeModule;
import org.violetmoon.zeta.item.ZetaBlockItem;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.registry.IZetaBlockItemProvider;
import org.violetmoon.zeta.registry.RenderLayerRegistry;
Expand All @@ -59,10 +60,9 @@ public RopeBlock(String regname, ZetaModule module, CreativeModeTab creativeTab,

@Override
public BlockItem provideItemBlock(Block block, Item.Properties properties) {
return new BlockItem(block, properties) {
//TODO: IForgeItem
return new ZetaBlockItem(block, properties) {
@Override
public boolean doesSneakBypassUse(ItemStack stack, LevelReader world, BlockPos pos, Player player) {
public boolean doesSneakBypassUseZeta(ItemStack stack, LevelReader world, BlockPos pos, Player player) {
return world.getBlockState(pos).getBlock() instanceof RopeBlock;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ else if(item instanceof CrossbowItem)
classes.add("crossbow");

for(ToolAction action : ACTION_TO_CLASS.keySet()) {
if(item.canPerformAction(stack, action))
if(item.canPerformAction(stack, action)) //TODO: IForgeItem
classes.add(ACTION_TO_CLASS.get(action));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public boolean hurt(DamageSource source, float amount) {
if (e instanceof LivingEntity living) {
ItemStack held = living.getMainHandItem();

if (ore != 0 && held.getItem().canPerformAction(held, ToolActions.PICKAXE_DIG)) {
if (ore != 0 && held.getItem().canPerformAction(held, ToolActions.PICKAXE_DIG)) { //TODO: IForgeItem
if (level instanceof ServerLevel serverLevel) {
if (held.isDamageableItem() && e instanceof Player)
MiscUtil.damageStack((Player) e, InteractionHand.MAIN_HAND, held, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.client.handler.ModelHandler;
import org.violetmoon.zeta.item.IZetaItem;
import org.violetmoon.zeta.item.ZetaArmorItem;
import org.violetmoon.zeta.module.ZetaModule;

import java.util.UUID;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;

public class ForgottenHatItem extends ArmorItem implements IZetaItem {
public class ForgottenHatItem extends ZetaArmorItem implements IZetaItem {

private static final String TEXTURE = Quark.MOD_ID + ":textures/misc/forgotten_hat_worn.png";

Expand Down Expand Up @@ -62,9 +63,8 @@ public boolean doesConditionApply() {
return true;
}

//TODO: IForgeItem
@Override
public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
public String getArmorTextureZeta(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
return TEXTURE;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.violetmoon.quark.content.tools.config;

import net.minecraft.world.item.ItemStack;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.config.Config;
import org.violetmoon.quark.base.config.type.IConfigType;
import org.violetmoon.quark.content.tools.entity.rang.AbstractPickarang;
Expand All @@ -8,11 +10,13 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;
import org.violetmoon.zeta.item.ext.IZetaItemExtensions;

public class PickarangType<T extends AbstractPickarang<T>> implements IConfigType {

public final Item repairMaterial;
public final Item pickaxeEquivalent;
public final IZetaItemExtensions pickaxeEquivalentExt;

@Config(description = "How long it takes before the Pickarang starts returning to the player if it doesn't hit anything.")
public int timeout;
Expand Down Expand Up @@ -47,6 +51,7 @@ public class PickarangType<T extends AbstractPickarang<T>> implements IConfigTyp
public PickarangType(Item repairMaterial, Item pickaxeEquivalent, int timeout, int harvestLevel, int durability, double maxHardness, int attackDamage, int cooldown) {
this.repairMaterial = repairMaterial;
this.pickaxeEquivalent = pickaxeEquivalent;
this.pickaxeEquivalentExt = Quark.ZETA.itemExtensions.get(new ItemStack(pickaxeEquivalent));

this.timeout = timeout;
this.harvestLevel = harvestLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ public boolean isFoil(@Nonnull ItemStack stack) {
return true;
}

//TODO: IForgeItem
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
public boolean canApplyAtEnchantingTableZeta(ItemStack stack, Enchantment enchantment) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ public static void setBiome(ItemStack stack, String biome, int color, boolean un
return null;
}

//TODO: IForgeItem
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
public boolean shouldCauseReequipAnimationZeta(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
return slotChanged || (oldStack.getItem() != newStack.getItem());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.violetmoon.quark.content.tools.config.PickarangType;
import org.violetmoon.quark.content.tools.entity.rang.AbstractPickarang;
import org.violetmoon.quark.content.tools.module.PickarangModule;
import org.violetmoon.zeta.item.ext.IZetaItemExtensions;
import org.violetmoon.zeta.module.ZetaModule;

import java.util.HashMap;
Expand Down Expand Up @@ -79,9 +80,8 @@ public boolean isCorrectToolForDrops(@Nonnull BlockState blockIn) {
};
}

//TODO: IForgeItem
@Override
public int getMaxDamage(ItemStack stack) {
public int getMaxDamageZeta(ItemStack stack) {
return Math.max(type.durability, 0);
}

Expand Down Expand Up @@ -144,9 +144,8 @@ public float getDestroySpeed(@Nonnull ItemStack stack, @Nonnull BlockState state
return 0F;
}

//TODO: IForgeItem
@Override
public boolean isRepairable(@Nonnull ItemStack stack) {
public boolean isRepairableZeta(@Nonnull ItemStack stack) {
return true;
}

Expand All @@ -155,10 +154,10 @@ public boolean isValidRepairItem(@Nonnull ItemStack toRepair, ItemStack repair)
return type.repairMaterial != null && repair.getItem() == type.repairMaterial;
}

//TODO: IForgeItem
@Override
public int getEnchantmentValue(ItemStack stack) {
return type.pickaxeEquivalent != null ? type.pickaxeEquivalent.getEnchantmentValue(stack) : 0;
public int getEnchantmentValueZeta(ItemStack stack) {
//return type.pickaxeEquivalent != null ? type.pickaxeEquivalentExt.getEnchantmentValueZeta(stack) : 0; //TODO ZETA: stack overflows
return getEnchantmentValue();
}

@SuppressWarnings("deprecation") //Forge replacement
Expand All @@ -167,9 +166,8 @@ public int getEnchantmentValue() {
return type.pickaxeEquivalent != null ? type.pickaxeEquivalent.getEnchantmentValue() : 0;
}

//TODO: IForgeItem
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
return super.canApplyAtEnchantingTable(stack, enchantment) || ImmutableSet.of(Enchantments.BLOCK_FORTUNE, Enchantments.SILK_TOUCH, Enchantments.BLOCK_EFFICIENCY).contains(enchantment);
public boolean canApplyAtEnchantingTableZeta(ItemStack stack, Enchantment enchantment) {
return super.canApplyAtEnchantingTableZeta(stack, enchantment) || ImmutableSet.of(Enchantments.BLOCK_FORTUNE, Enchantments.SILK_TOUCH, Enchantments.BLOCK_EFFICIENCY).contains(enchantment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ public static ItemStack getLastStack(ItemStack stack) {
return ItemStack.of(cmp);
}

//TODO: IForgeItem
@Override
public int getMaxDamage(ItemStack stack) {
public int getMaxDamageZeta(ItemStack stack) {
return TrowelModule.maxDamage;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static boolean isHoe(ItemStack itemStack) {
return !itemStack.isEmpty() &&
(itemStack.getItem() instanceof HoeItem
|| itemStack.is(Tags.Items.TOOLS_HOES)
|| itemStack.getItem().canPerformAction(itemStack, ToolActions.HOE_DIG));
|| itemStack.getItem().canPerformAction(itemStack, ToolActions.HOE_DIG)); //TODO: IForgeItem
}

@LoadEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private void registerCustomAnvilRecipes(@Nonnull IRecipeRegistration registratio
ItemStack left = new ItemStack(item);
ItemStack out = left.copy();

int max = item.getMaxDamage(left);
int max = Quark.ZETA.itemExtensions.get(left).getMaxDamageZeta(left);

left.setDamageValue(max - 1);
out.setDamageValue(max - max / 4);
Expand Down
Loading

0 comments on commit 5a1c490

Please sign in to comment.