Skip to content

Commit dddad8d

Browse files
committed
Smithing Table Relic Affixing
*Relic Armour is now affixable to regular armour using a Smithing Table, instead of using the sneak+right-click system.
1 parent 6584561 commit dddad8d

File tree

7 files changed

+71
-45
lines changed

7 files changed

+71
-45
lines changed

build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ dependencies {
5656
modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cardinal_components_version}") {
5757
exclude(group: "net.fabricmc.fabric-api")
5858
}
59+
modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-chunk:${project.cardinal_components_version}") {
60+
exclude(group: "net.fabricmc.fabric-api")
61+
}
5962

6063
modImplementation include("eu.pb4:placeholder-api:${project.placeholder_api}")
6164
implementation 'net.objecthunter:exp4j:0.4.8'
@@ -118,7 +121,7 @@ modrinth {
118121
loaders = ["fabric"]
119122
dependencies = [
120123
new VersionDependency("WiXqMygm", "required"),
121-
new VersionDependency("iv7dDXiw", "required"),
124+
new VersionDependency("h5tJ7cyw", "required"),
122125
new VersionDependency("tnq7cqef", "embedded")
123126
]
124127
}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ minecraft_version=1.19.2
44
yarn_mappings=1.19.2+build.28
55
loader_version=0.14.10
66

7-
mod_version = 3.2.6
7+
mod_version = 3.2.7
88
maven_group = com.github.clevernucleus
99
archives_base_name = relicex
1010

1111
fabric_version=0.66.0+1.19.2
12-
dataattributes_version=1.2.7
12+
dataattributes_version=1.4.0
1313
opc_version=0.6.4
1414

1515
# 5.0.2 is scuffed and causes problems
1616
cardinal_components_version=5.0.1
1717
placeholder_api=2.0.0-beta.7+1.19
18-
playerex_version=3.3.7
18+
playerex_version=3.5.0
1919
arl_version=0.2.6
2020
trinkets_version=3.4.0
2121
cloth_config_version=8.2.88

src/main/java/com/github/clevernucleus/relicex/item/ArmorRelicItem.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@
1616
import net.minecraft.entity.attribute.EntityAttribute;
1717
import net.minecraft.entity.attribute.EntityAttributeModifier;
1818
import net.minecraft.entity.attribute.EntityAttributes;
19-
import net.minecraft.entity.mob.MobEntity;
20-
import net.minecraft.entity.player.PlayerEntity;
2119
import net.minecraft.item.ArmorItem;
2220
import net.minecraft.item.ArmorMaterials;
2321
import net.minecraft.item.Item;
2422
import net.minecraft.item.ItemGroup;
2523
import net.minecraft.item.ItemStack;
2624
import net.minecraft.nbt.NbtCompound;
27-
import net.minecraft.nbt.NbtList;
28-
import net.minecraft.sound.SoundCategory;
2925
import net.minecraft.sound.SoundEvent;
3026
import net.minecraft.text.Text;
31-
import net.minecraft.util.Hand;
32-
import net.minecraft.util.TypedActionResult;
3327
import net.minecraft.world.World;
3428

3529
public class ArmorRelicItem extends ArmorItem implements ItemHelper {
@@ -53,37 +47,6 @@ public void onStackCreated(ItemStack itemStack, int count) {
5347
collection.writeToNbt(tag);
5448
}
5549

56-
@Override
57-
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
58-
if(!user.isSneaking()) return super.use(world, user, hand);
59-
60-
ItemStack itemStack = user.getStackInHand(hand);
61-
EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(itemStack);
62-
ItemStack itemStack2 = user.getEquippedStack(equipmentSlot);
63-
Item item = itemStack2.getItem();
64-
65-
if(item instanceof ArmorItem && !(item instanceof ArmorRelicItem)) {
66-
NbtCompound tag2 = itemStack2.getOrCreateNbt();
67-
68-
if(!tag2.contains(EntityAttributeCollection.KEY_ATTRIBUTES)) {
69-
if(!world.isClient) {
70-
NbtCompound tag = itemStack.getOrCreateNbt();
71-
NbtList list = tag.getList(EntityAttributeCollection.KEY_ATTRIBUTES, NbtType.COMPOUND);
72-
String rareness = tag.getString(EntityAttributeCollection.KEY_RARENESS);
73-
tag2.put(EntityAttributeCollection.KEY_ATTRIBUTES, list);
74-
tag2.putString(EntityAttributeCollection.KEY_RARENESS, rareness);
75-
} else {
76-
user.playSound(this.getEquipSound(itemStack), SoundCategory.NEUTRAL, 0.75F, 1.0F);
77-
}
78-
79-
itemStack.setCount(0);
80-
return TypedActionResult.success(itemStack, world.isClient);
81-
}
82-
}
83-
84-
return super.use(world, user, hand);
85-
}
86-
8750
@Override
8851
public Multimap<EntityAttribute, EntityAttributeModifier> getAttributeModifiers(ItemStack stack, EquipmentSlot slot) {
8952
NbtCompound tag = stack.getOrCreateNbt();

src/main/java/com/github/clevernucleus/relicex/item/OrbOfRegretItem.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand han
4545
PlayerData playerData = ExAPI.PLAYER_DATA.get(user);
4646
int refundPoints = 0;
4747

48-
// Note: com.github.clevernucleus.playerex.impl.RefundConditionImpl is not yet exposed in the API
49-
for(var refundCondition : com.github.clevernucleus.playerex.impl.RefundConditionImpl.get()) {
48+
for(var refundCondition : ExAPI.getRefundConditions()) {
5049
refundPoints += refundCondition.apply(playerData, user);
5150
}
5251

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.github.clevernucleus.relicex.mixin;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.injection.At;
5+
import org.spongepowered.asm.mixin.injection.Inject;
6+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
7+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
8+
9+
import com.github.clevernucleus.relicex.impl.EntityAttributeCollection;
10+
import com.github.clevernucleus.relicex.item.ArmorRelicItem;
11+
12+
import net.fabricmc.fabric.api.util.NbtType;
13+
import net.minecraft.entity.player.PlayerEntity;
14+
import net.minecraft.entity.player.PlayerInventory;
15+
import net.minecraft.item.ArmorItem;
16+
import net.minecraft.item.Item;
17+
import net.minecraft.item.ItemStack;
18+
import net.minecraft.nbt.NbtCompound;
19+
import net.minecraft.nbt.NbtList;
20+
import net.minecraft.screen.ForgingScreenHandler;
21+
import net.minecraft.screen.ScreenHandlerContext;
22+
import net.minecraft.screen.ScreenHandlerType;
23+
import net.minecraft.screen.SmithingScreenHandler;
24+
25+
@Mixin(SmithingScreenHandler.class)
26+
abstract class SmithingScreenHandlerMixin extends ForgingScreenHandler {
27+
private SmithingScreenHandlerMixin(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) { super(type, syncId, playerInventory, context); }
28+
29+
@Inject(method = "canTakeOutput", at = @At("HEAD"), cancellable = true)
30+
private void relicex_canTakeOutput(PlayerEntity player, boolean present, CallbackInfoReturnable<Boolean> cir) {
31+
Item item = this.input.getStack(0).getItem();
32+
Item item2 = this.input.getStack(1).getItem();
33+
34+
if(item instanceof ArmorItem && !(item instanceof ArmorRelicItem) && item2 instanceof ArmorRelicItem) {
35+
cir.setReturnValue(true);
36+
}
37+
}
38+
39+
@Inject(method = "updateResult", at = @At("HEAD"), cancellable = true)
40+
private void relicex_updateResult(CallbackInfo ci) {
41+
ItemStack itemStack = this.input.getStack(0);
42+
ItemStack itemStack2 = this.input.getStack(1);
43+
Item item = itemStack.getItem();
44+
Item item2 = itemStack2.getItem();
45+
46+
if(item instanceof ArmorItem && !(item instanceof ArmorRelicItem) && item2 instanceof ArmorRelicItem) {
47+
if(((ArmorItem)item).getSlotType() == ((ArmorItem)item2).getSlotType() && !(itemStack.hasNbt() && itemStack.getNbt().contains(EntityAttributeCollection.KEY_ATTRIBUTES))) {
48+
ItemStack itemStack3 = itemStack.copy();
49+
NbtCompound tag = itemStack2.getNbt();
50+
NbtCompound tag2 = itemStack3.getOrCreateNbt();
51+
NbtList list = tag.getList(EntityAttributeCollection.KEY_ATTRIBUTES, NbtType.COMPOUND);
52+
String rareness = tag.getString(EntityAttributeCollection.KEY_RARENESS);
53+
tag2.put(EntityAttributeCollection.KEY_ATTRIBUTES, list);
54+
tag2.putString(EntityAttributeCollection.KEY_RARENESS, rareness);
55+
this.output.setStack(0, itemStack3);
56+
ci.cancel();
57+
}
58+
}
59+
}
60+
}

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"depends": {
3636
"fabricloader": ">=0.14.10",
3737
"fabric-api": ">=0.66.0",
38-
"playerex": ">=3.3.7",
38+
"playerex": ">=3.5.0",
3939
"trinkets": ">=3.4.0",
4040
"cloth-config": ">=8.0.0",
4141
"minecraft": "1.19.2",

src/main/resources/relicex.mixins.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"mixins": [
77
"LivingEntityMixin",
88
"ArmorItemMixin",
9-
"RepairItemRecipeMixin"
9+
"RepairItemRecipeMixin",
10+
"SmithingScreenHandlerMixin"
1011
],
1112
"client": [
1213
"client.ItemStackMixin"

0 commit comments

Comments
 (0)