Skip to content

Commit

Permalink
Rework Prometheum Auto Repair
Browse files Browse the repository at this point in the history
Make Prometheum Auto Repair happen onInventoryTick

Makes it so that it repairs slowly while in your inventory, regardless of being equipped or not

Also fixes a potential bug where the attribute for the armor was client only, and would not apply on servers

Signed-off-by: Noaaan <[email protected]>
  • Loading branch information
Noaaan committed Dec 31, 2023
1 parent 22897b9 commit 30ea813
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 101 deletions.
3 changes: 2 additions & 1 deletion PATCHNOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ To quickly summarize the following materials were updated in different regards:

- Increase the durability of Mythril Armor slightly (30 -> 31, on average 14 more durability)
- Decrease the durability of Orichalcum Armor (41 -> 39, on average 28 less durability)
- Increased the damage of Quadrillum tools slightly (6.5 -> 6.7)
- Increased the damage dealt by Quadrillum tools slightly (6.5 -> 6.7)
- Increased the mining speed of Quadrillum tools (5.0 -> 5.5)
- Reduced the attack speed of Quadrillum tools
- Reduced the attack speed of the Osmium Axe
- Made Silver Ore and Blocks easier to break
- Made Quadrillum Ore and Blocks much easier to break
- Prometheum now becomes overgrown much earlier (2000 -> 1200 durability repaired)
- Increased attack speed of Engrained Prometheum (5% -> 8%)
- Prometheum auto repair tick now happens anywhere in your inventory, instead of only while equipped. This should make the effect more noticable
- Increased Mythril Drill auto repair when it is activated
- Increased Aquarium Pearl drop rate (2% -> 2.5%)
- Increased Aquarium Ore spawn range (from 31 to 63 -> from 21 to 69)
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/nourl/mythicmetals/MythicMetals.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
import io.wispforest.owo.registration.reflect.FieldRegistrationHandler;
import me.shedaniel.mm.api.ClassTinkerers;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.item.v1.ModifyItemAttributeModifiersCallback;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.dispenser.ProjectileDispenserBehavior;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.projectile.PersistentProjectileEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
Expand All @@ -34,15 +39,19 @@
import nourl.mythicmetals.command.MythicCommands;
import nourl.mythicmetals.config.MythicMetalsConfig;
import nourl.mythicmetals.data.MythicOreKeys;
import nourl.mythicmetals.data.MythicTags;
import nourl.mythicmetals.effects.MythicStatusEffects;
import nourl.mythicmetals.entity.*;
import nourl.mythicmetals.item.MythicItems;
import nourl.mythicmetals.item.tools.MythicTools;
import nourl.mythicmetals.item.tools.PrometheumToolSet;
import nourl.mythicmetals.misc.*;
import nourl.mythicmetals.registry.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.UUID;

public class MythicMetals implements ModInitializer, EntityComponentInitializer {
public static Logger LOGGER = LogManager.getLogger();
public static final String MOD_ID = "mythicmetals";
Expand Down Expand Up @@ -106,6 +115,7 @@ public void onInitialize() {
factories.add(new TradeOffers.SellItemFactory(MythicItems.Templates.AEGIS_SMITHING_TEMPLATE, 48, 1, 2, 30));
});
registerDispenserBehaviour();
registerPrometheumAttributeEvent();


if (CONFIG.configVersion() < CONFIG_VERSION) {
Expand Down Expand Up @@ -177,4 +187,27 @@ public void registerEntityComponentFactories(EntityComponentFactoryRegistry regi
registry.registerFor(LivingEntity.class, COMBUSTION_COOLDOWN, CombustionCooldown::new);
registry.registerForPlayers(CARMOT_SHIELD, CarmotShield::new, RespawnCopyStrategy.INVENTORY);
}

private void registerPrometheumAttributeEvent() {
ModifyItemAttributeModifiersCallback.EVENT.register((stack, slot, attributeModifiers) -> {
if (stack.isIn(MythicTags.PROMETHEUM_ARMOR) && ((ArmorItem) stack.getItem()).getSlotType().equals(slot)) {
if (EnchantmentHelper.hasBindingCurse(stack)) {
attributeModifiers.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(
UUID.fromString("d42e82c8-166d-46f1-bc76-df84e91b5531"),
"Bound Prometheum bonus",
0.08,
EntityAttributeModifier.Operation.MULTIPLY_BASE
));
}
if (PrometheumToolSet.isOvergrown(stack)) {
attributeModifiers.put(EntityAttributes.GENERIC_ARMOR_TOUGHNESS, new EntityAttributeModifier(
UUID.fromString("37bb6460-e896-44e2-8e71-29335d5ce709"),
"Prometheum bonus toughness",
EnchantmentHelper.hasBindingCurse(stack) ? 2 : 1,
EntityAttributeModifier.Operation.ADDITION
));
}
}
});
}
}
47 changes: 16 additions & 31 deletions src/main/java/nourl/mythicmetals/MythicMetalsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.fabricmc.fabric.api.client.rendering.v1.*;
import net.fabricmc.fabric.api.item.v1.ModifyItemAttributeModifiersCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.ShapeContext;
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 @@ -24,10 +26,7 @@
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.Item;
import net.minecraft.item.trim.ArmorTrim;
import net.minecraft.registry.Registries;
Expand All @@ -39,7 +38,10 @@
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.World;
import nourl.mythicmetals.abilities.Ability;
import nourl.mythicmetals.armor.*;
import nourl.mythicmetals.armor.CelestiumElytra;
import nourl.mythicmetals.armor.HallowedArmor;
import nourl.mythicmetals.armor.MythicArmor;
import nourl.mythicmetals.armor.TidesingerArmor;
import nourl.mythicmetals.blocks.IndevBlocks;
import nourl.mythicmetals.blocks.MythicBlocks;
import nourl.mythicmetals.client.CarmotShieldHudHandler;
Expand All @@ -49,10 +51,15 @@
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.*;

import java.util.ArrayList;
import java.util.Calendar;

public class MythicMetalsClient implements ClientModInitializer {
private long lastTick;
Expand All @@ -70,7 +77,6 @@ public void onInitializeClient() {

registerTidesingerTooltips();
registerPrometheumTooltips();
registerPrometheumAttributeEvent();

LivingEntityFeatureRenderEvents.ALLOW_CAPE_RENDER.register(player -> !CelestiumElytra.isWearing(player));

Expand All @@ -97,28 +103,7 @@ public void onInitializeClient() {
}
}

private void registerPrometheumAttributeEvent() {
ModifyItemAttributeModifiersCallback.EVENT.register((stack, slot, attributeModifiers) -> {
if (stack.isIn(MythicTags.PROMETHEUM_ARMOR) && ((ArmorItem) stack.getItem()).getSlotType().equals(slot)) {
if (EnchantmentHelper.hasBindingCurse(stack)) {
attributeModifiers.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(
UUID.fromString("d42e82c8-166d-46f1-bc76-df84e91b5531"),
"Bound Prometheum bonus",
0.08,
EntityAttributeModifier.Operation.MULTIPLY_BASE
));
}
if (PrometheumToolSet.isOvergrown(stack)) {
attributeModifiers.put(EntityAttributes.GENERIC_ARMOR_TOUGHNESS, new EntityAttributeModifier(
UUID.fromString("37bb6460-e896-44e2-8e71-29335d5ce709"),
"Prometheum bonus toughness",
EnchantmentHelper.hasBindingCurse(stack) ? 2 : 1,
EntityAttributeModifier.Operation.ADDITION
));
}
}
});
}


private void registerPrometheumTooltips() {
ItemTooltipCallback.EVENT.register((stack, context, lines) -> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nourl/mythicmetals/armor/MythicArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MythicArmor implements SimpleFieldProcessingSubject<ArmorSet> {
public static final ArmorSet OSMIUM = new ArmorSet(MythicArmorMaterials.OSMIUM);
public static final ArmorSet OSMIUM_CHAINMAIL = new ArmorSet(MythicArmorMaterials.OSMIUM_CHAINMAIL);
public static final ArmorSet PALLADIUM = new ArmorSet(MythicArmorMaterials.PALLADIUM, OwoItemSettings::fireproof);
public static final ArmorSet PROMETHEUM = new ArmorSet(MythicArmorMaterials.PROMETHEUM);
public static final ArmorSet PROMETHEUM = new PrometheumArmorSet(MythicArmorMaterials.PROMETHEUM);
public static final ArmorSet RUNITE = new RuniteArmorSet(MythicArmorMaterials.RUNITE);
public static final ArmorSet SILVER = new ArmorSet(MythicArmorMaterials.SILVER);
public static final ArmorSet STAR_PLATINUM = new ArmorSet(MythicArmorMaterials.STAR_PLATINUM);
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/nourl/mythicmetals/armor/PrometheumArmorItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package nourl.mythicmetals.armor;

import net.minecraft.entity.Entity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import nourl.mythicmetals.item.tools.PrometheumToolSet;

public class PrometheumArmorItem extends ArmorItem {
public PrometheumArmorItem(ArmorMaterial material, Type type, Settings settings) {
super(material, type, settings);
}

@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (!world.isClient()) PrometheumToolSet.tickAutoRepair(stack, world.getRandom());
super.inventoryTick(stack, world, entity, slot, selected);
}
}
16 changes: 16 additions & 0 deletions src/main/java/nourl/mythicmetals/armor/PrometheumArmorSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package nourl.mythicmetals.armor;

import io.wispforest.owo.itemgroup.OwoItemSettings;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;

public class PrometheumArmorSet extends ArmorSet {
public PrometheumArmorSet(ArmorMaterial material) {
super(material);
}

@Override
protected ArmorItem makeItem(ArmorMaterial material, ArmorItem.Type slot, OwoItemSettings settings) {
return new PrometheumArmorItem(material, slot, settings);
}
}
Loading

0 comments on commit 30ea813

Please sign in to comment.