diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/block/be/MatrixEnchantingTableBlockEntity.java b/src/main/java/org/violetmoon/quark/addons/oddities/block/be/MatrixEnchantingTableBlockEntity.java index d617902e22..099d1ccb76 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/block/be/MatrixEnchantingTableBlockEntity.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/block/be/MatrixEnchantingTableBlockEntity.java @@ -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; @@ -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; diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java b/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java index 2cd90c9c1c..a4a95cc700 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java @@ -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; @@ -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() @@ -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; } @@ -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; } @@ -137,9 +129,8 @@ public boolean canBeDepleted() { return false; } - //TODO: IForgeITem @Override - public int damageItem(ItemStack stack, int amount, T entity, Consumer onBroken) { + public int damageItemZeta(ItemStack stack, int amount, T entity, Consumer onBroken) { return 0; } @@ -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; @@ -241,9 +231,8 @@ public Multimap 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; } diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/item/TinyPotatoBlockItem.java b/src/main/java/org/violetmoon/quark/addons/oddities/item/TinyPotatoBlockItem.java index cbdaf15a67..1339c19c64 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/item/TinyPotatoBlockItem.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/item/TinyPotatoBlockItem.java @@ -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; @@ -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 TYPOS = List.of("vaskii", "vazki", "voskii", "vazkkii", "vazkki", "vazzki", "vaskki", "vozkii", "vazkil", "vaskil", "vazkill", "vaskill", "vaski"); @@ -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); } @@ -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 diff --git a/src/main/java/org/violetmoon/quark/base/item/QuarkItem.java b/src/main/java/org/violetmoon/quark/base/item/QuarkItem.java index f4e6d7e6d9..ad5718c0e0 100644 --- a/src/main/java/org/violetmoon/quark/base/item/QuarkItem.java +++ b/src/main/java/org/violetmoon/quark/base/item/QuarkItem.java @@ -2,7 +2,6 @@ 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; @@ -10,11 +9,12 @@ 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; diff --git a/src/main/java/org/violetmoon/quark/content/building/block/RopeBlock.java b/src/main/java/org/violetmoon/quark/content/building/block/RopeBlock.java index fa0941b2fa..dea11bc772 100755 --- a/src/main/java/org/violetmoon/quark/content/building/block/RopeBlock.java +++ b/src/main/java/org/violetmoon/quark/content/building/block/RopeBlock.java @@ -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; @@ -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; } }; diff --git a/src/main/java/org/violetmoon/quark/content/management/module/AutomaticToolRestockModule.java b/src/main/java/org/violetmoon/quark/content/management/module/AutomaticToolRestockModule.java index 0fbe030085..cbc04c9f87 100644 --- a/src/main/java/org/violetmoon/quark/content/management/module/AutomaticToolRestockModule.java +++ b/src/main/java/org/violetmoon/quark/content/management/module/AutomaticToolRestockModule.java @@ -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)); } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java index 11a6674d14..adec558299 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java @@ -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); diff --git a/src/main/java/org/violetmoon/quark/content/mobs/item/ForgottenHatItem.java b/src/main/java/org/violetmoon/quark/content/mobs/item/ForgottenHatItem.java index 0da671990c..f4ebd77d10 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/item/ForgottenHatItem.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/item/ForgottenHatItem.java @@ -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"; @@ -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; } diff --git a/src/main/java/org/violetmoon/quark/content/tools/config/PickarangType.java b/src/main/java/org/violetmoon/quark/content/tools/config/PickarangType.java index 7e88c6c18d..8846f4e510 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/config/PickarangType.java +++ b/src/main/java/org/violetmoon/quark/content/tools/config/PickarangType.java @@ -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; @@ -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> 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; @@ -47,6 +51,7 @@ public class PickarangType> 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; diff --git a/src/main/java/org/violetmoon/quark/content/tools/item/AncientTomeItem.java b/src/main/java/org/violetmoon/quark/content/tools/item/AncientTomeItem.java index a2f73f6aee..c03ee448e7 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/item/AncientTomeItem.java +++ b/src/main/java/org/violetmoon/quark/content/tools/item/AncientTomeItem.java @@ -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; } diff --git a/src/main/java/org/violetmoon/quark/content/tools/item/PathfindersQuillItem.java b/src/main/java/org/violetmoon/quark/content/tools/item/PathfindersQuillItem.java index 2d4c6c739c..0438b9656f 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/item/PathfindersQuillItem.java +++ b/src/main/java/org/violetmoon/quark/content/tools/item/PathfindersQuillItem.java @@ -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()); } diff --git a/src/main/java/org/violetmoon/quark/content/tools/item/PickarangItem.java b/src/main/java/org/violetmoon/quark/content/tools/item/PickarangItem.java index 4463ce2ead..b3bfdb9f12 100755 --- a/src/main/java/org/violetmoon/quark/content/tools/item/PickarangItem.java +++ b/src/main/java/org/violetmoon/quark/content/tools/item/PickarangItem.java @@ -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; @@ -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); } @@ -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; } @@ -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 @@ -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); } } diff --git a/src/main/java/org/violetmoon/quark/content/tools/item/TrowelItem.java b/src/main/java/org/violetmoon/quark/content/tools/item/TrowelItem.java index 8d344b0a38..b08b36d49d 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/item/TrowelItem.java +++ b/src/main/java/org/violetmoon/quark/content/tools/item/TrowelItem.java @@ -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; } diff --git a/src/main/java/org/violetmoon/quark/content/tweaks/module/HoeHarvestingModule.java b/src/main/java/org/violetmoon/quark/content/tweaks/module/HoeHarvestingModule.java index 386ac48eac..3c794e4141 100644 --- a/src/main/java/org/violetmoon/quark/content/tweaks/module/HoeHarvestingModule.java +++ b/src/main/java/org/violetmoon/quark/content/tweaks/module/HoeHarvestingModule.java @@ -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 diff --git a/src/main/java/org/violetmoon/quark/integration/jei/QuarkJeiPlugin.java b/src/main/java/org/violetmoon/quark/integration/jei/QuarkJeiPlugin.java index 563177e735..0d25284432 100644 --- a/src/main/java/org/violetmoon/quark/integration/jei/QuarkJeiPlugin.java +++ b/src/main/java/org/violetmoon/quark/integration/jei/QuarkJeiPlugin.java @@ -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); diff --git a/src/main/java/org/violetmoon/quark/integration/lootr/LootrVariantChestBlock.java b/src/main/java/org/violetmoon/quark/integration/lootr/LootrVariantChestBlock.java index ad13b17569..a019b6365c 100644 --- a/src/main/java/org/violetmoon/quark/integration/lootr/LootrVariantChestBlock.java +++ b/src/main/java/org/violetmoon/quark/integration/lootr/LootrVariantChestBlock.java @@ -41,6 +41,7 @@ import org.violetmoon.quark.base.Quark; import org.violetmoon.quark.content.building.block.VariantChestBlock; +import org.violetmoon.zeta.item.ZetaBlockItem; import org.violetmoon.zeta.module.ZetaModule; import org.violetmoon.zeta.registry.IZetaBlockItemProvider; import org.violetmoon.zeta.registry.IZetaItemPropertiesFiller; @@ -158,7 +159,7 @@ public BlockItem provideItemBlock(Block block, Item.Properties props) { return new Item(block, props, false); } - public static class Item extends BlockItem { + public static class Item extends ZetaBlockItem { private final boolean trap; @@ -168,7 +169,7 @@ public Item(Block block, Properties props, boolean trap) { } @Override - public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) { + public InteractionResult onItemUseFirstZeta(ItemStack stack, UseOnContext context) { if (!context.isSecondaryUseActive()) { Player player = context.getPlayer(); Level level = context.getLevel(); @@ -192,7 +193,7 @@ public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) { } } - return super.onItemUseFirst(stack, context); + return super.onItemUseFirstZeta(stack, context); } } diff --git a/src/main/java/org/violetmoon/quark/mixin/DiggerItemMixin.java b/src/main/java/org/violetmoon/quark/mixin/DiggerItemMixin.java index 04b86fcd42..624205dc25 100644 --- a/src/main/java/org/violetmoon/quark/mixin/DiggerItemMixin.java +++ b/src/main/java/org/violetmoon/quark/mixin/DiggerItemMixin.java @@ -10,6 +10,7 @@ @Mixin(DiggerItem.class) public class DiggerItemMixin { + //TODO: IForgeItem @ModifyExpressionValue(method = "isCorrectToolForDrops(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/block/state/BlockState;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/DiggerItem;getTier()Lnet/minecraft/world/item/Tier;")) private Tier getTier(Tier prev) { diff --git a/src/main/java/org/violetmoon/quark/mixin/ElytraItemMixin.java b/src/main/java/org/violetmoon/quark/mixin/ElytraItemMixin.java index baca26c979..a118a01ca6 100644 --- a/src/main/java/org/violetmoon/quark/mixin/ElytraItemMixin.java +++ b/src/main/java/org/violetmoon/quark/mixin/ElytraItemMixin.java @@ -11,6 +11,7 @@ @Mixin(ElytraItem.class) public class ElytraItemMixin { + //TODO: IForgeItem @ModifyReturnValue(method = "canElytraFly", at = @At("RETURN"), remap = false) private boolean canApply(boolean prev, ItemStack stack, LivingEntity living) { return GameNerfsModule.canEntityUseElytra(living, prev); diff --git a/src/main/java/org/violetmoon/zeta/item/ZetaArmorItem.java b/src/main/java/org/violetmoon/zeta/item/ZetaArmorItem.java new file mode 100644 index 0000000000..95b80374af --- /dev/null +++ b/src/main/java/org/violetmoon/zeta/item/ZetaArmorItem.java @@ -0,0 +1,12 @@ +package org.violetmoon.zeta.item; + +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterial; +import org.violetmoon.zeta.item.ext.IZetaItemExtensions; + +public class ZetaArmorItem extends ArmorItem implements IZetaItemExtensions { + public ZetaArmorItem(ArmorMaterial mat, EquipmentSlot slot, Properties props) { + super(mat, slot, props); + } +} diff --git a/src/main/java/org/violetmoon/zeta/item/ZetaBlockItem.java b/src/main/java/org/violetmoon/zeta/item/ZetaBlockItem.java new file mode 100644 index 0000000000..a0bd7b0b7a --- /dev/null +++ b/src/main/java/org/violetmoon/zeta/item/ZetaBlockItem.java @@ -0,0 +1,15 @@ +package org.violetmoon.zeta.item; + +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.level.block.Block; +import org.violetmoon.zeta.item.ext.IZetaItemExtensions; + +public class ZetaBlockItem extends BlockItem implements IZetaItemExtensions { + public ZetaBlockItem(Block toPlace, Properties props) { + super(toPlace, props); + + //TODO maybe some stuff about constructor registration or whatever + // ZetaBlockItem is used when registering "regular" blocks as well, so that's something + // to watch out for wrt constructor registration + } +} diff --git a/src/main/java/org/violetmoon/zeta/item/ZetaItem.java b/src/main/java/org/violetmoon/zeta/item/ZetaItem.java new file mode 100644 index 0000000000..b6e32df264 --- /dev/null +++ b/src/main/java/org/violetmoon/zeta/item/ZetaItem.java @@ -0,0 +1,12 @@ +package org.violetmoon.zeta.item; + +import net.minecraft.world.item.Item; +import org.violetmoon.zeta.item.ext.IZetaItemExtensions; + +public class ZetaItem extends Item implements IZetaItemExtensions { + public ZetaItem(Properties props) { + super(props); + + //TODO maybe some stuff about constructor registration or whatever + } +} diff --git a/src/main/java/org/violetmoon/zeta/item/ext/IZetaItemExtensions.java b/src/main/java/org/violetmoon/zeta/item/ext/IZetaItemExtensions.java index fd7bc16717..fc48a2923a 100644 --- a/src/main/java/org/violetmoon/zeta/item/ext/IZetaItemExtensions.java +++ b/src/main/java/org/violetmoon/zeta/item/ext/IZetaItemExtensions.java @@ -1,38 +1,76 @@ package org.violetmoon.zeta.item.ext; import java.util.Map; +import java.util.function.Consumer; +import net.minecraft.core.BlockPos; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ElytraItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.ShearsItem; +import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.LevelReader; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -//TODO ZETA: more extensions (remove all usages of IForgeItem, implement this interface on Quark's items) @SuppressWarnings("deprecation") //forge ext public interface IZetaItemExtensions { - int getBurnTimeZeta(ItemStack stack, @Nullable RecipeType recipeType); + default InteractionResult onItemUseFirstZeta(ItemStack stack, UseOnContext context) { + return InteractionResult.PASS; + } - default boolean canElytraFlyZeta(ItemStack stack, LivingEntity entity) { - //forge has a funky little extension for this - return stack.getItem() instanceof ElytraItem && ElytraItem.isFlyEnabled(stack); + default boolean isRepairableZeta(ItemStack stack) { + return false; } - default boolean isEnderMaskZeta(ItemStack stack, Player player, EnderMan enderboy) { - return stack.getItem() == Items.CARVED_PUMPKIN; + default boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity ent) { + return false; + } + + default boolean doesSneakBypassUseZeta(ItemStack stack, LevelReader level, BlockPos pos, Player player) { + return false; + } + + default boolean canEquipZeta(ItemStack stack, EquipmentSlot armorType, Entity ent) { + return false; } - default boolean canShearZeta(ItemStack stack) { + default boolean isBookEnchantableZeta(ItemStack stack, ItemStack book) { + return true; + } + + @Nullable + default String getArmorTextureZeta(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { + return null; + } + + default int getMaxDamageZeta(ItemStack stack) { + return stack.getItem().getMaxDamage(); + } + + default boolean canShearZeta(ItemStack stack) { //canPerformAction return stack.getItem() instanceof ShearsItem; } + default int getEnchantmentValueZeta(ItemStack stack) { + return stack.getItem().getEnchantmentValue(); + } + + default boolean canApplyAtEnchantingTableZeta(ItemStack stack, Enchantment enchantment) { + return enchantment.category.canEnchant(stack.getItem()); + } + default int getEnchantmentLevelZeta(ItemStack stack, Enchantment enchantment) { return EnchantmentHelper.getTagEnchantmentLevel(enchantment, stack); } @@ -41,8 +79,31 @@ default Map getAllEnchantmentsZeta(ItemStack stack) { return EnchantmentHelper.deserializeEnchantments(stack.getEnchantmentTags()); } - default int getEnchantmentValueZeta(ItemStack stack) { - return stack.getItem().getEnchantmentValue(); + default boolean shouldCauseReequipAnimationZeta(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { + return !oldStack.equals(newStack); + } + + //TODO: initCapabilities + + default int getBurnTimeZeta(ItemStack stack, @Nullable RecipeType recipeType) { + return 0; + } + + default int damageItemZeta(ItemStack stack, int amount, T entity, Consumer onBroken) { + return amount; + } + + default boolean isEnderMaskZeta(ItemStack stack, Player player, EnderMan enderboy) { + return stack.getItem() == Items.CARVED_PUMPKIN; + } + + default boolean canElytraFlyZeta(ItemStack stack, LivingEntity entity) { + //forge has a funky little extension for this + return stack.getItem() instanceof ElytraItem && ElytraItem.isFlyEnabled(stack); + } + + default int getDefaultTooltipHideFlagsZeta(@NotNull ItemStack stack) { + return 0; } } diff --git a/src/main/java/org/violetmoon/zeta/registry/ZetaRegistry.java b/src/main/java/org/violetmoon/zeta/registry/ZetaRegistry.java index 93a4fd8012..2cfb23c174 100644 --- a/src/main/java/org/violetmoon/zeta/registry/ZetaRegistry.java +++ b/src/main/java/org/violetmoon/zeta/registry/ZetaRegistry.java @@ -21,6 +21,7 @@ import net.minecraft.world.level.block.Block; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.Zeta; +import org.violetmoon.zeta.item.ZetaBlockItem; //Mash of arl's RegistryHelper and its ModData innerclass. //You're expected to create one of these per modid instead, avoiding a dependency on Forge's "current mod id" notion. @@ -129,7 +130,7 @@ private Item createItemBlock(Block block) { BlockItem blockitem; if(block instanceof IZetaBlockItemProvider) blockitem = ((IZetaBlockItemProvider) block).provideItemBlock(block, props); - else blockitem = new BlockItem(block, props); + else blockitem = new ZetaBlockItem(block, props); if(block instanceof IZetaItemColorProvider prov && prov.getItemColorProviderName() != null) itemsToColorProviderName.put(blockitem, prov.getItemColorProviderName()); diff --git a/src/main/java/org/violetmoon/zetaimplforge/item/IForgeItemItemExtensions.java b/src/main/java/org/violetmoon/zetaimplforge/item/IForgeItemItemExtensions.java index 6f3a9fd101..864808ae97 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/item/IForgeItemItemExtensions.java +++ b/src/main/java/org/violetmoon/zetaimplforge/item/IForgeItemItemExtensions.java @@ -1,15 +1,23 @@ package org.violetmoon.zetaimplforge.item; import java.util.Map; +import java.util.function.Consumer; +import net.minecraft.core.BlockPos; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraftforge.common.ForgeHooks; +import net.minecraft.world.level.LevelReader; import net.minecraftforge.common.ToolActions; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.item.ext.IZetaItemExtensions; @@ -17,18 +25,43 @@ public class IForgeItemItemExtensions implements IZetaItemExtensions { public static final IForgeItemItemExtensions INSTANCE = new IForgeItemItemExtensions(); @Override - public int getBurnTimeZeta(ItemStack stack, @Nullable RecipeType recipeType) { - return ForgeHooks.getBurnTime(stack, recipeType); + public InteractionResult onItemUseFirstZeta(ItemStack stack, UseOnContext context) { + return stack.onItemUseFirst(context); } @Override - public boolean canElytraFlyZeta(ItemStack stack, LivingEntity entity) { - return stack.canElytraFly(entity); + public boolean isRepairableZeta(ItemStack stack) { + return stack.isRepairable(); } @Override - public boolean isEnderMaskZeta(ItemStack stack, Player player, EnderMan enderboy) { - return stack.isEnderMask(player, enderboy); + public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity ent) { + return stack.onEntityItemUpdate(ent); + } + + @Override + public boolean doesSneakBypassUseZeta(ItemStack stack, LevelReader level, BlockPos pos, Player player) { + return stack.doesSneakBypassUse(level, pos, player); + } + + @Override + public boolean canEquipZeta(ItemStack stack, EquipmentSlot armorType, Entity ent) { + return stack.canEquip(armorType, ent); + } + + @Override + public boolean isBookEnchantableZeta(ItemStack stack, ItemStack book) { + return stack.isBookEnchantable(book); + } + + @Override + public @Nullable String getArmorTextureZeta(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { + return stack.getItem().getArmorTexture(stack, entity, slot, type); + } + + @Override + public int getMaxDamageZeta(ItemStack stack) { + return stack.getMaxDamage(); } @Override @@ -36,6 +69,16 @@ public boolean canShearZeta(ItemStack stack) { return stack.canPerformAction(ToolActions.SHEARS_CARVE); } + @Override + public int getEnchantmentValueZeta(ItemStack stack) { + return stack.getItem().getEnchantmentValue(stack); + } + + @Override + public boolean canApplyAtEnchantingTableZeta(ItemStack stack, Enchantment enchantment) { + return stack.canApplyAtEnchantingTable(enchantment); + } + @Override public int getEnchantmentLevelZeta(ItemStack stack, Enchantment enchantment) { return stack.getEnchantmentLevel(enchantment); @@ -47,7 +90,32 @@ public Map getAllEnchantmentsZeta(ItemStack stack) { } @Override - public int getEnchantmentValueZeta(ItemStack stack) { - return stack.getEnchantmentValue(); + public boolean shouldCauseReequipAnimationZeta(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { + return oldStack.getItem().shouldCauseReequipAnimation(oldStack, newStack, slotChanged); + } + + @Override + public int getBurnTimeZeta(ItemStack stack, @Nullable RecipeType recipeType) { + return stack.getBurnTime(recipeType); + } + + @Override + public int damageItemZeta(ItemStack stack, int amount, T entity, Consumer onBroken) { + return stack.getItem().damageItem(stack, amount, entity, onBroken); + } + + @Override + public boolean isEnderMaskZeta(ItemStack stack, Player player, EnderMan enderboy) { + return stack.isEnderMask(player, enderboy); + } + + @Override + public boolean canElytraFlyZeta(ItemStack stack, LivingEntity entity) { + return stack.canElytraFly(entity); + } + + @Override + public int getDefaultTooltipHideFlagsZeta(@NotNull ItemStack stack) { + return stack.getItem().getDefaultTooltipHideFlags(stack); } } diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/client/ItemMixin.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/client/ItemMixin.java index 6e6f9f80cf..a2d012f946 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/mixin/client/ItemMixin.java +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/client/ItemMixin.java @@ -15,7 +15,7 @@ @Mixin(Item.class) public class ItemMixin implements IZetaForgeItemStuff { - @Shadow private Object renderProperties; + @Shadow(remap = false) private Object renderProperties; @Override public void zeta$setBlockEntityWithoutLevelRenderer(BlockEntityWithoutLevelRenderer bewlr) { diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/self/IZetaItemMixin.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/self/IZetaItemMixin.java new file mode 100644 index 0000000000..350f299842 --- /dev/null +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/self/IZetaItemMixin.java @@ -0,0 +1,134 @@ +package org.violetmoon.zetaimplforge.mixin.self; + +import java.util.Map; +import java.util.function.Consumer; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.level.LevelReader; +import net.minecraftforge.common.ToolAction; +import net.minecraftforge.common.ToolActions; +import net.minecraftforge.common.extensions.IForgeItem; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.violetmoon.zeta.item.ZetaArmorItem; +import org.violetmoon.zeta.item.ZetaBlockItem; +import org.violetmoon.zeta.item.ZetaItem; +import org.violetmoon.zeta.item.ext.IZetaItemExtensions; + +@Mixin({ + ZetaArmorItem.class, + ZetaBlockItem.class, + ZetaItem.class, +}) +public class IZetaItemMixin implements IForgeItem, IZetaItemExtensions { + @Override + public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) { + return onItemUseFirstZeta(stack, context); + } + + @Override + public boolean isRepairable(ItemStack stack) { + return isRepairableZeta(stack); + } + + @Override + public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { + return onEntityItemUpdateZeta(stack, entity); + } + + @Override + public boolean doesSneakBypassUse(ItemStack stack, LevelReader level, BlockPos pos, Player player) { + return doesSneakBypassUseZeta(stack, level, pos, player); + } + + @Override + public boolean canEquip(ItemStack stack, EquipmentSlot armorType, Entity entity) { + return canEquipZeta(stack, armorType, entity); + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return isBookEnchantableZeta(stack, book); + } + + @Override + public @Nullable String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { + return getArmorTextureZeta(stack, entity, slot, type); + } + + @Override + public int getMaxDamage(ItemStack stack) { + return getMaxDamageZeta(stack); + } + + @Override + public boolean canPerformAction(ItemStack stack, ToolAction toolAction) { + if(toolAction == ToolActions.SHEARS_CARVE) + return canShearZeta(stack); + else + return false; + } + + @Override + public int getEnchantmentValue(ItemStack stack) { + return getEnchantmentValueZeta(stack); + } + + @Override + public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { + return canApplyAtEnchantingTableZeta(stack, enchantment); + } + + @Override + public int getEnchantmentLevel(ItemStack stack, Enchantment enchantment) { + return getEnchantmentLevelZeta(stack, enchantment); + } + + @Override + public Map getAllEnchantments(ItemStack stack) { + return getAllEnchantmentsZeta(stack); + } + + @Override + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { + return shouldCauseReequipAnimationZeta(oldStack, newStack, slotChanged); + } + + @Override + public int getBurnTime(ItemStack itemStack, @Nullable RecipeType recipeType) { + return getBurnTimeZeta(itemStack, recipeType); + } + + @Override + public int damageItem(ItemStack stack, int amount, T entity, Consumer onBroken) { + return damageItemZeta(stack, amount, entity, onBroken); + } + + @Override + public boolean isEnderMask(ItemStack stack, Player player, EnderMan endermanEntity) { + return isEnderMaskZeta(stack, player, endermanEntity); + } + + @Override + public boolean canElytraFly(ItemStack stack, LivingEntity entity) { + return canElytraFlyZeta(stack, entity); + } + + @Override + public int getDefaultTooltipHideFlags(@NotNull ItemStack stack) { + return getDefaultTooltipHideFlagsZeta(stack); + } + +} diff --git a/src/main/resources/zeta_forge.mixins.json b/src/main/resources/zeta_forge.mixins.json index 22b519971e..91afd6f10e 100644 --- a/src/main/resources/zeta_forge.mixins.json +++ b/src/main/resources/zeta_forge.mixins.json @@ -7,7 +7,8 @@ "mixins": [ "WeatheringCopperMixin", "IngredientMixin", - "self.IQuarkBlockMixin" + "self.IQuarkBlockMixin", + "self.IZetaItemMixin" ], "client": [ "client.AccessorBlockColors",