Skip to content

Commit

Permalink
Mythril Drill rework
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
Noaaan committed Jul 15, 2024
1 parent be69699 commit 85cff62
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 121 deletions.
22 changes: 17 additions & 5 deletions src/main/java/nourl/mythicmetals/MythicMetalsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
30 changes: 16 additions & 14 deletions src/main/java/nourl/mythicmetals/component/DrillComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,36 @@

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;
import net.minecraft.text.Style;
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;
import java.util.HashMap;
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<DrillComponent> 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
Expand All @@ -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<Text> 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)));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nourl/mythicmetals/data/MythicTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +30,7 @@ public class MythicTags {
public static final TagKey<Biome> OSMIUM_BIOMES = TagKey.of(RegistryKeys.BIOME, RegistryHelper.id("osmium_biomes"));
public static final TagKey<Biome> MYTHIC_ORE_BIOMES = TagKey.of(RegistryKeys.BIOME, RegistryHelper.id("mythic_ore_biomes"));
public static final TagKey<Enchantment> SILK_TOUCH_LIKE = TagKey.of(RegistryKeys.ENCHANTMENT, RegistryHelper.id("silk_touch_like"));
public static final TagKey<Block> MINEABLE_MYTHRIL_DRILL = TagKey.of(RegistryKeys.BLOCK, RegistryHelper.id("mineable/mythril_drill"));
}


22 changes: 17 additions & 5 deletions src/main/java/nourl/mythicmetals/item/tools/MythicTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -142,7 +154,7 @@ public class MythicTools implements SimpleFieldProcessingSubject<ToolSet> {
.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));
Expand Down
Loading

0 comments on commit 85cff62

Please sign in to comment.