From 85cff626e90a3a711be2ecc10c4c614d1bf340d8 Mon Sep 17 00:00:00 2001 From: Noaaan Date: Mon, 15 Jul 2024 22:06:51 +0200 Subject: [PATCH] Mythril Drill rework - Drill no longer needs to be activated - Fuel is no longer consumed over time - One fuel is consumed per block broken - Increased max fuel capacity to 4000 - Fuel per Morkite: 10 -> 20 - Increased invisible durability reduction: 30% -> 60% chance of ignoring damage - yes this has always been a thing while the drill is active - Buffed upgrades: - Golden Luck Bonus: 1 -> 2 Luck - Golden Luck Gold Drop chance: 2.5% -> 3.33% - Aqua Affinity Air: 24 -> 60 ticks air restored when mining an ore - Regrowth: Will slowly increase fuel (NEW) --- .../mythicmetals/MythicMetalsClient.java | 22 ++- .../component/DrillComponent.java | 30 ++-- .../nourl/mythicmetals/data/MythicTags.java | 2 +- .../mythicmetals/item/tools/MythicTools.java | 22 ++- .../mythicmetals/item/tools/MythrilDrill.java | 138 ++++++------------ .../mythicmetals/mixin/LivingEntityMixin.java | 2 +- .../mixin/PlayerEntityRendererMixin.java | 2 +- .../tags/block/mineable/mythril_drill.json | 6 + 8 files changed, 103 insertions(+), 121 deletions(-) create mode 100644 src/main/resources/data/mythicmetals/tags/block/mineable/mythril_drill.json diff --git a/src/main/java/nourl/mythicmetals/MythicMetalsClient.java b/src/main/java/nourl/mythicmetals/MythicMetalsClient.java index b5addaed..04f80888 100644 --- a/src/main/java/nourl/mythicmetals/MythicMetalsClient.java +++ b/src/main/java/nourl/mythicmetals/MythicMetalsClient.java @@ -14,7 +14,10 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.item.ModelPredicateProviderRegistry; import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.render.*; +import net.minecraft.client.render.OverlayTexture; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.TexturedRenderLayers; +import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.block.entity.BlockEntityRendererFactories; import net.minecraft.client.render.entity.feature.FeatureRendererContext; import net.minecraft.client.render.entity.model.PlayerEntityModel; @@ -34,19 +37,28 @@ import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.World; -import nourl.mythicmetals.armor.*; +import nourl.mythicmetals.armor.CelestiumElytra; +import nourl.mythicmetals.armor.HallowedArmor; +import nourl.mythicmetals.armor.MythicArmor; import nourl.mythicmetals.blocks.MythicBlocks; import nourl.mythicmetals.client.CarmotShieldHudHandler; import nourl.mythicmetals.client.models.MythicModelHandler; import nourl.mythicmetals.client.rendering.*; import nourl.mythicmetals.compat.IsometricArmorStandExporter; -import nourl.mythicmetals.component.*; +import nourl.mythicmetals.component.DrillComponent; +import nourl.mythicmetals.component.GoldFoldedComponent; +import nourl.mythicmetals.component.MythicDataComponents; +import nourl.mythicmetals.component.PrometheumComponent; import nourl.mythicmetals.data.MythicTags; import nourl.mythicmetals.entity.MythicEntities; import nourl.mythicmetals.item.tools.*; -import nourl.mythicmetals.misc.*; +import nourl.mythicmetals.misc.BlockBreaker; +import nourl.mythicmetals.misc.RegistryHelper; +import nourl.mythicmetals.misc.ShieldUsePredicate; +import nourl.mythicmetals.misc.UsefulSingletonForColorUtil; import nourl.mythicmetals.mixin.WorldRendererInvoker; import nourl.mythicmetals.registry.RegisterBlockEntityTypes; + import java.util.ArrayList; import java.util.Calendar; @@ -212,7 +224,7 @@ private void registerModelPredicates() { ModelPredicateProviderRegistry.register( MythicTools.MYTHRIL_DRILL, RegistryHelper.id("is_active"), - (stack, world, entity, seed) -> stack.getOrDefault(MythicDataComponents.DRILL, DrillComponent.DEFAULT).isActive() ? 0 : 1 + (stack, world, entity, seed) -> stack.getOrDefault(MythicDataComponents.DRILL, DrillComponent.DEFAULT).hasFuel() ? 0 : 1 ); registerMidasPredicates(MythicTools.MIDAS_GOLD_SWORD); diff --git a/src/main/java/nourl/mythicmetals/component/DrillComponent.java b/src/main/java/nourl/mythicmetals/component/DrillComponent.java index c58760b3..6e3cc95a 100644 --- a/src/main/java/nourl/mythicmetals/component/DrillComponent.java +++ b/src/main/java/nourl/mythicmetals/component/DrillComponent.java @@ -2,7 +2,6 @@ import io.wispforest.endec.Endec; import io.wispforest.endec.impl.StructEndecBuilder; -import io.wispforest.owo.ui.core.Color; import net.minecraft.item.*; import net.minecraft.item.tooltip.TooltipAppender; import net.minecraft.item.tooltip.TooltipType; @@ -10,6 +9,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Util; +import net.minecraft.util.math.MathHelper; import nourl.mythicmetals.blocks.MythicBlocks; import nourl.mythicmetals.item.MythicItems; import nourl.mythicmetals.misc.UsefulSingletonForColorUtil; @@ -17,22 +17,21 @@ import java.util.Map; import java.util.function.Consumer; -public record DrillComponent(int fuel, boolean isActive) implements TooltipAppender { +public record DrillComponent(int fuel) implements TooltipAppender { public static final Endec ENDEC = StructEndecBuilder.of( Endec.INT.fieldOf("fuel", DrillComponent::fuel), - Endec.BOOLEAN.fieldOf("is_active", DrillComponent::isActive), DrillComponent::new ); - public static final DrillComponent DEFAULT = new DrillComponent(0, false); + public static final DrillComponent DEFAULT = new DrillComponent(0); /** - * A fully fueled drill should last 30 minutes + * One fuel lets you break one block with all the Drill perks */ - public static final int MAX_FUEL = 1000; + public static final int MAX_FUEL = 4000; /** * Each piece of Morkite will fuel the drill by this constant worth of units */ - public static final int FUEL_CONSTANT = 10; + public static final int FUEL_CONSTANT = 20; /** * Map used to store the different types of drill upgrades @@ -47,22 +46,25 @@ public record DrillComponent(int fuel, boolean isActive) implements TooltipAppen map.put(Items.AIR, "empty"); }); - public boolean hasFuel() { - return this.fuel > 0; + + public DrillComponent reduce(int fuel) { + return new DrillComponent(MathHelper.clamp(fuel - 1, 0, MAX_FUEL)); } - public static DrillComponent toggleActiveState(DrillComponent component) { - return new DrillComponent(component.fuel(), !component.isActive()); + public DrillComponent increase(int fuel) { + return new DrillComponent(MathHelper.clamp(fuel + 1, 0, MAX_FUEL)); + } + + public boolean hasFuel() { + return this.fuel > 0; } @Override public void appendTooltip(Item.TooltipContext context, Consumer tooltip, TooltipType type) { // Activation Status - if (this.isActive) { + if (this.hasFuel()) { tooltip.accept(Text.translatable("tooltip.mythril_drill.activated").formatted(Formatting.AQUA)); - } else { - tooltip.accept(Text.translatable("tooltip.mythril_drill.deactivated").setStyle(Style.EMPTY.withColor(Color.ofRgb(0x622622).rgb()).withFormatting(Formatting.ITALIC))); } if (this.fuel == 0) { tooltip.accept(Text.translatable("tooltip.mythril_drill.refuel").setStyle(Style.EMPTY.withColor(Formatting.GRAY))); diff --git a/src/main/java/nourl/mythicmetals/data/MythicTags.java b/src/main/java/nourl/mythicmetals/data/MythicTags.java index 0be29822..d989a6f0 100644 --- a/src/main/java/nourl/mythicmetals/data/MythicTags.java +++ b/src/main/java/nourl/mythicmetals/data/MythicTags.java @@ -4,7 +4,6 @@ import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntryList; import net.minecraft.registry.tag.TagKey; import net.minecraft.world.biome.Biome; import nourl.mythicmetals.misc.RegistryHelper; @@ -31,6 +30,7 @@ public class MythicTags { public static final TagKey OSMIUM_BIOMES = TagKey.of(RegistryKeys.BIOME, RegistryHelper.id("osmium_biomes")); public static final TagKey MYTHIC_ORE_BIOMES = TagKey.of(RegistryKeys.BIOME, RegistryHelper.id("mythic_ore_biomes")); public static final TagKey SILK_TOUCH_LIKE = TagKey.of(RegistryKeys.ENCHANTMENT, RegistryHelper.id("silk_touch_like")); + public static final TagKey MINEABLE_MYTHRIL_DRILL = TagKey.of(RegistryKeys.BLOCK, RegistryHelper.id("mineable/mythril_drill")); } diff --git a/src/main/java/nourl/mythicmetals/item/tools/MythicTools.java b/src/main/java/nourl/mythicmetals/item/tools/MythicTools.java index bc1079df..38497a68 100644 --- a/src/main/java/nourl/mythicmetals/item/tools/MythicTools.java +++ b/src/main/java/nourl/mythicmetals/item/tools/MythicTools.java @@ -5,18 +5,30 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.PotionContentsComponent; -import net.minecraft.entity.*; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.FrogEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.*; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.MinecartItem; +import net.minecraft.item.SwordItem; import net.minecraft.potion.Potion; import net.minecraft.registry.Registries; -import net.minecraft.util.*; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.Identifier; +import net.minecraft.util.Rarity; import nourl.mythicmetals.MythicMetals; import nourl.mythicmetals.armor.AquariumToolSet; import nourl.mythicmetals.component.*; -import nourl.mythicmetals.item.*; +import nourl.mythicmetals.item.RedAegisSword; +import nourl.mythicmetals.item.RuniteArrowItem; +import nourl.mythicmetals.item.StarPlatinumArrowItem; +import nourl.mythicmetals.item.TippedRuniteArrowItem; import nourl.mythicmetals.misc.RegistryHelper; + import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; @@ -142,7 +154,7 @@ public class MythicTools implements SimpleFieldProcessingSubject { .group(MythicMetals.TABBED_GROUP).tab(2) .rarity(Rarity.UNCOMMON) .attributeModifiers(createAttributeModifiers(3, 1.5f)) - .component(MythicDataComponents.DRILL, new DrillComponent(0, false)) + .component(MythicDataComponents.DRILL, new DrillComponent(0)) .component(MythicDataComponents.UPGRADES, UpgradeComponent.empty(2)) ); public static final Item PLATINUM_WATCH = new Item(new OwoItemSettings().group(MythicMetals.TABBED_GROUP).tab(2)); diff --git a/src/main/java/nourl/mythicmetals/item/tools/MythrilDrill.java b/src/main/java/nourl/mythicmetals/item/tools/MythrilDrill.java index 6a2ebe09..1265bc74 100644 --- a/src/main/java/nourl/mythicmetals/item/tools/MythrilDrill.java +++ b/src/main/java/nourl/mythicmetals/item/tools/MythrilDrill.java @@ -4,8 +4,12 @@ import net.minecraft.block.BlockState; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.AttributeModifierSlot; -import net.minecraft.enchantment.*; -import net.minecraft.entity.*; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.EntityAttributeModifier; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; @@ -13,29 +17,33 @@ import net.minecraft.item.*; import net.minecraft.item.tooltip.TooltipType; import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.tag.BlockTags; import net.minecraft.screen.slot.Slot; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; -import net.minecraft.util.*; +import net.minecraft.util.ActionResult; +import net.minecraft.util.ClickType; +import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import nourl.mythicmetals.blocks.MythicBlocks; -import nourl.mythicmetals.component.*; +import nourl.mythicmetals.component.DrillComponent; +import nourl.mythicmetals.component.MythicDataComponents; +import nourl.mythicmetals.component.PrometheumComponent; +import nourl.mythicmetals.component.UpgradeComponent; import nourl.mythicmetals.data.MythicTags; import nourl.mythicmetals.item.MythicItems; import nourl.mythicmetals.misc.RegistryHelper; -import nourl.mythicmetals.registry.RegisterSounds; + import java.util.List; import static nourl.mythicmetals.component.DrillComponent.*; -public class MythrilDrill extends PickaxeItem { +public class MythrilDrill extends MiningToolItem { public MythrilDrill(ToolMaterial material, Settings settings) { - super(material, settings); + super(material, MythicTags.MINEABLE_MYTHRIL_DRILL, settings); } @Override @@ -56,32 +64,6 @@ public ActionResult useOnBlock(ItemUsageContext context) { return super.useOnBlock(context); } - @Override - public TypedActionResult use(World world, PlayerEntity user, Hand hand) { - var stack = user.getStackInHand(hand); - var offHandStack = user.getStackInHand(Hand.OFF_HAND); - - if (user.getItemCooldownManager().isCoolingDown(stack.getItem())) { - return TypedActionResult.pass(stack); - } - - if (!offHandStack.equals(stack) && (respectFood(offHandStack, user)) || offHandStack.getUseAction().equals(UseAction.DRINK)) { - return TypedActionResult.pass(stack); - } - - // If you have fuel, toggle the state of the drill - if (stack.getOrDefault(MythicDataComponents.DRILL, DEFAULT).hasFuel()) { - toggleDrillState(world, user, stack); - return TypedActionResult.success(stack); - } - - if (world.isClient) { - user.sendMessage(Text.translatable("tooltip.mythril_drill.out_of_fuel"), true); - user.playSound(SoundEvents.BLOCK_NOTE_BLOCK_BASS.value(), 0.8f, 0.5f); - } - return TypedActionResult.pass(stack); - } - @Override public boolean onStackClicked(ItemStack drill, Slot slot, ClickType clickType, PlayerEntity player) { if (clickType == ClickType.RIGHT) { @@ -91,7 +73,7 @@ public boolean onStackClicked(ItemStack drill, Slot slot, ClickType clickType, P int morkiteCount = slot.getStack().getCount(); if (slot.tryTakeStackRange((MAX_FUEL - drillComponent.fuel()) / FUEL_CONSTANT, morkiteCount, player).isPresent()) { int fuel = MathHelper.clamp(drillComponent.fuel() + (morkiteCount * FUEL_CONSTANT), 0, MAX_FUEL); - drill.set(MythicDataComponents.DRILL, new DrillComponent(fuel, drillComponent.isActive())); + drill.set(MythicDataComponents.DRILL, new DrillComponent(fuel)); return true; } } @@ -116,7 +98,7 @@ public boolean onClicked(ItemStack drill, ItemStack cursorStack, Slot slot, Clic if (morkiteCount * FUEL_CONSTANT < (MAX_FUEL) - drillComponent.fuel()) { int fuel = MathHelper.clamp(drillComponent.fuel() + (morkiteCount * FUEL_CONSTANT), 0, MAX_FUEL); cursorStack.decrement(morkiteCount); - drill.set(MythicDataComponents.DRILL, new DrillComponent(fuel, drillComponent.isActive())); + drill.set(MythicDataComponents.DRILL, new DrillComponent(fuel)); return true; } // Manually calculate how much Morkite to take @@ -124,7 +106,7 @@ public boolean onClicked(ItemStack drill, ItemStack cursorStack, Slot slot, Clic int morkiteToTake = (MAX_FUEL / FUEL_CONSTANT) - (drillComponent.fuel() / FUEL_CONSTANT); int fuel = MathHelper.clamp(drillComponent.fuel() + (morkiteToTake * FUEL_CONSTANT), 0, MAX_FUEL); cursorStack.decrement(morkiteToTake); - drill.set(MythicDataComponents.DRILL, new DrillComponent(fuel, drillComponent.isActive())); + drill.set(MythicDataComponents.DRILL, new DrillComponent(fuel)); return true; } } @@ -146,14 +128,26 @@ public boolean onClicked(ItemStack drill, ItemStack cursorStack, Slot slot, Clic @Override public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner) { + if (world.isClient() && miner instanceof PlayerEntity player) { + player.sendMessage(Text.translatable("tooltip.mythril_drill.out_of_fuel"), true); + player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_BASS.value(), 0.8f, 0.5f); + } + if (!world.isClient && state.getHardness(world, pos) != 0.0F) { // Randomly cancel damage while active var random = world.getRandom(); var drillComponent = stack.getOrDefault(MythicDataComponents.DRILL, DEFAULT); var upgradeComponent = stack.getOrDefault(MythicDataComponents.UPGRADES, UpgradeComponent.empty(2)); - if (drillComponent.isActive() && random.nextInt(10) > 3) return true; - stack.damage(1, miner, EquipmentSlot.MAINHAND); + if (!drillComponent.hasFuel()) { + stack.damage(2, miner, EquipmentSlot.MAINHAND); + return true; + } + + if (random.nextInt(5) > 2) { + stack.damage(1, miner, EquipmentSlot.MAINHAND); + } + stack.set(MythicDataComponents.DRILL, drillComponent.reduce(drillComponent.fuel())); if (state.isIn(ConventionalBlockTags.ORES)) { // Do not perform this if silk touch is present @@ -165,10 +159,10 @@ public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos // Restore air when mining ores underwater if (upgradeComponent.hasUpgrade(MythicItems.Mats.AQUARIUM_PEARL)) { - miner.setAir(Math.min(miner.getAir() + 24, miner.getMaxAir())); + miner.setAir(Math.min(miner.getAir() + 60, miner.getMaxAir())); } // Randomly drop gold from midas gold - if (upgradeComponent.hasUpgrade(MythicBlocks.ENCHANTED_MIDAS_GOLD_BLOCK.asItem()) && random.nextInt(40) == 27) { + if (upgradeComponent.hasUpgrade(MythicBlocks.ENCHANTED_MIDAS_GOLD_BLOCK.asItem()) && random.nextInt(30) == 27) { miner.dropItem(Items.RAW_GOLD); } } @@ -184,36 +178,25 @@ public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, if (stack.get(MythicDataComponents.UPGRADES) == null) return; var drillComponent = stack.getOrDefault(MythicDataComponents.DRILL, DEFAULT); var upgradeComponent = stack.getOrDefault(MythicDataComponents.UPGRADES, UpgradeComponent.empty(2)); - if (drillComponent.hasFuel() && drillComponent.isActive() && world.getTime() % (4 * FUEL_CONSTANT) == 1) { - stack.set(MythicDataComponents.DRILL, new DrillComponent(drillComponent.fuel() - 1, true)); - } - if (!drillComponent.hasFuel()) { - stack.set(MythicDataComponents.DRILL, DrillComponent.DEFAULT); - } - if (upgradeComponent.hasUpgrade(MythicItems.Mats.PROMETHEUM_BOUQUET)) { // Initialize auto repair upgrades if (!stack.contains(MythicDataComponents.PROMETHEUM)) { stack.set(MythicDataComponents.PROMETHEUM, PrometheumComponent.DEFAULT); } + stack.set(MythicDataComponents.DRILL, drillComponent.increase(drillComponent.fuel())); PrometheumComponent.tickAutoRepair(stack, world); } } super.inventoryTick(stack, world, entity, slot, selected); } - @Override - public boolean allowComponentsUpdateAnimation(PlayerEntity player, Hand hand, ItemStack oldStack, ItemStack newStack) { - boolean didFuelChange = oldStack.getOrDefault(MythicDataComponents.DRILL, DEFAULT).fuel() == oldStack.getOrDefault(MythicDataComponents.DRILL, DEFAULT).fuel(); - return !didFuelChange && oldStack.getDamage() != newStack.getDamage(); - } - @Override public void appendTooltip(ItemStack stack, TooltipContext context, List lines, TooltipType type) { if (stack.contains(MythicDataComponents.DRILL)) { - stack.get(MythicDataComponents.DRILL).appendTooltip(context, lines::add, type); + stack.getOrDefault(MythicDataComponents.DRILL, DEFAULT).appendTooltip(context, lines::add, type); } if (stack.contains(MythicDataComponents.UPGRADES)) { + // TODO - Handle Default? stack.get(MythicDataComponents.UPGRADES).appendTooltip(context, lines::add, type); } } @@ -224,46 +207,12 @@ public boolean allowContinuingBlockBreaking(PlayerEntity player, ItemStack oldSt return oldStack.contains(MythicDataComponents.DRILL) && newStack.contains(MythicDataComponents.DRILL) || oldStack.getDamage() != newStack.getDamage(); } - @Override - public boolean isCorrectForDrops(ItemStack stack, BlockState state) { - if (stack.contains(MythicDataComponents.DRILL) && stack.getOrDefault(MythicDataComponents.DRILL, DEFAULT).isActive()) { - if (state.isIn(BlockTags.SHOVEL_MINEABLE)) - return true; - } - return super.isCorrectForDrops(stack, state); - } - @Override public float getMiningSpeed(ItemStack stack, BlockState state) { - if (stack.getOrDefault(MythicDataComponents.DRILL, DEFAULT).isActive()) { - if (this.isCorrectForDrops(stack, state)) { - return super.getMiningSpeed(stack, state) * this.getMaterial().getMiningSpeedMultiplier(); - } else return super.getMiningSpeed(stack, state); - } - return super.getMiningSpeed(stack, state) / 2.0f; - } - - /** - * Handles applying the drill active state by toggling its NBT keys - * Includes playing sound effects and applying a cooldown to prevent spam - */ - public void toggleDrillState(World world, PlayerEntity user, ItemStack drill) { - var drillComponent = drill.getOrDefault(MythicDataComponents.DRILL, DEFAULT); - if (world.isClient) { - var sound = drillComponent.isActive() ? RegisterSounds.MYTHRIL_DRILL_DEACTIVATE : RegisterSounds.MYTHRIL_DRILL_ACTIVATE; - user.playSound(sound, 1.0f, 1.0f); + if (stack.getOrDefault(MythicDataComponents.DRILL, DEFAULT).hasFuel()) { + return super.getMiningSpeed(stack, state); } - user.getItemCooldownManager().set(drill.getItem(), 20); - drill.set(MythicDataComponents.DRILL, DrillComponent.toggleActiveState(drillComponent)); - } - - /** - * Used for prioritizing eating food in off-hand over activating the drill - * - * @return whether you can eat the food-related itemstack in question - */ - private boolean respectFood(ItemStack foodStack, PlayerEntity user) { - return foodStack.contains(DataComponentTypes.FOOD) && user.canConsume(false); + return 1.0f; } @Override @@ -276,7 +225,7 @@ public void postProcessComponents(ItemStack stack) { if (upgrades.hasUpgrade(MythicBlocks.ENCHANTED_MIDAS_GOLD_BLOCK_ITEM)) { var modifier = new EntityAttributeModifier( RegistryHelper.id("mythril_drill_luck_bonus"), - 1.0, + 2.0, EntityAttributeModifier.Operation.ADD_VALUE ); attributes = attributes.with(EntityAttributes.GENERIC_LUCK, modifier, AttributeModifierSlot.MAINHAND); @@ -301,7 +250,8 @@ public void postProcessComponents(ItemStack stack) { 1 + (level * 2), EntityAttributeModifier.Operation.ADD_VALUE ); - attributes.with(EntityAttributes.PLAYER_MINING_EFFICIENCY, modifier, AttributeModifierSlot.MAINHAND); + attributes = attributes.with(EntityAttributes.PLAYER_MINING_EFFICIENCY, modifier, AttributeModifierSlot.MAINHAND); + changes = true; } } if (changes) { diff --git a/src/main/java/nourl/mythicmetals/mixin/LivingEntityMixin.java b/src/main/java/nourl/mythicmetals/mixin/LivingEntityMixin.java index 51275b54..d6b947dd 100644 --- a/src/main/java/nourl/mythicmetals/mixin/LivingEntityMixin.java +++ b/src/main/java/nourl/mythicmetals/mixin/LivingEntityMixin.java @@ -263,7 +263,7 @@ public LivingEntityMixin(EntityType type, World world) { var camera = MinecraftClient.getInstance().getEntityRenderDispatcher().camera; // This can be null, according to #252 if (camera == null) return; - if (camera.isThirdPerson() && stack.getOrDefault(MythicDataComponents.DRILL, DrillComponent.DEFAULT).isActive()) { + if (camera.isThirdPerson() && stack.getOrDefault(MythicDataComponents.DRILL, DrillComponent.DEFAULT).hasFuel()) { ci.cancel(); } } diff --git a/src/main/java/nourl/mythicmetals/mixin/PlayerEntityRendererMixin.java b/src/main/java/nourl/mythicmetals/mixin/PlayerEntityRendererMixin.java index b6afbed8..4796ceb4 100644 --- a/src/main/java/nourl/mythicmetals/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/nourl/mythicmetals/mixin/PlayerEntityRendererMixin.java @@ -80,7 +80,7 @@ public class PlayerEntityRendererMixin { @Inject(method = "getArmPose", at = @At("RETURN"), cancellable = true) private static void mythicmetals$mythrilDrillPose(AbstractClientPlayerEntity player, Hand hand, CallbackInfoReturnable cir) { var stack = player.getStackInHand(hand); - if (stack.getOrDefault(MythicDataComponents.DRILL, DrillComponent.DEFAULT).isActive()) { + if (stack.getOrDefault(MythicDataComponents.DRILL, DrillComponent.DEFAULT).hasFuel()) { cir.setReturnValue(BipedEntityModel.ArmPose.CROSSBOW_CHARGE); } } diff --git a/src/main/resources/data/mythicmetals/tags/block/mineable/mythril_drill.json b/src/main/resources/data/mythicmetals/tags/block/mineable/mythril_drill.json new file mode 100644 index 00000000..81da9cff --- /dev/null +++ b/src/main/resources/data/mythicmetals/tags/block/mineable/mythril_drill.json @@ -0,0 +1,6 @@ +{ + "values": [ + "#minecraft:mineable/shovel", + "#minecraft:mineable/pickaxe" + ] +} \ No newline at end of file