-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shields can now be repaired, also vanilla shields now require Iron to…
… be repaired
- Loading branch information
Showing
6 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/insane96mcp/shieldsplus/mixin/ShieldItemMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.insane96mcp.shieldsplus.mixin; | ||
|
||
import com.insane96mcp.shieldsplus.setup.SPShieldMaterials; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.ShieldItem; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(ShieldItem.class) | ||
public abstract class ShieldItemMixin extends Item { | ||
|
||
public ShieldItemMixin(Properties p_41383_) { | ||
super(p_41383_); | ||
} | ||
|
||
@Inject(at = @At("RETURN"), method = "isValidRepairItem", cancellable = true) | ||
public void isValidRepairItem(ItemStack p_43091_, ItemStack repairingMaterial, CallbackInfoReturnable<Boolean> callbackInfo) { | ||
if (SPShieldMaterials.IRON.repairItem != null) { | ||
callbackInfo.setReturnValue(repairingMaterial.is(SPShieldMaterials.IRON.repairItem)); | ||
return; | ||
} | ||
callbackInfo.setReturnValue(repairingMaterial.is(SPShieldMaterials.IRON.repairTag)); | ||
} | ||
|
||
@Inject(at = @At("RETURN"), method = "getDescriptionId", cancellable = true) | ||
public void getDescriptionId(ItemStack stack, CallbackInfoReturnable<String> callbackInfo) { | ||
callbackInfo.setReturnValue(super.getDescriptionId()); | ||
} | ||
} |
16 changes: 9 additions & 7 deletions
16
src/main/java/com/insane96mcp/shieldsplus/setup/SPShieldMaterials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package com.insane96mcp.shieldsplus.setup; | ||
|
||
import com.insane96mcp.shieldsplus.world.item.SPShieldMaterial; | ||
import net.minecraft.tags.ItemTags; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.item.Rarity; | ||
|
||
public class SPShieldMaterials { | ||
public static final SPShieldMaterial WOODEN = new SPShieldMaterial("wooden", 1, 84, Rarity.COMMON); | ||
public static final SPShieldMaterial STONE = new SPShieldMaterial("stone", 2, 112, Rarity.COMMON); | ||
public static final SPShieldMaterial COPPER = new SPShieldMaterial("copper", 3, 134, Rarity.COMMON); | ||
public static final SPShieldMaterial GOLDEN = new SPShieldMaterial("golden", 1, 42, Rarity.COMMON); | ||
public static final SPShieldMaterial IRON = new SPShieldMaterial("iron", 5, 332, Rarity.COMMON); | ||
public static final SPShieldMaterial DIAMOND = new SPShieldMaterial("diamond", 7, 588, Rarity.COMMON); | ||
public static final SPShieldMaterial NETHERITE = new SPShieldMaterial("netherite", 8, 672, Rarity.COMMON); | ||
public static final SPShieldMaterial WOODEN = new SPShieldMaterial("wooden", 1, 84, ItemTags.PLANKS, Rarity.COMMON); | ||
public static final SPShieldMaterial STONE = new SPShieldMaterial("stone", 2, 112, ItemTags.STONE_TOOL_MATERIALS, Rarity.COMMON); | ||
public static final SPShieldMaterial COPPER = new SPShieldMaterial("copper", 3, 134, Items.COPPER_INGOT, Rarity.COMMON); | ||
public static final SPShieldMaterial GOLDEN = new SPShieldMaterial("golden", 1, 42, Items.GOLD_INGOT, Rarity.COMMON); | ||
public static final SPShieldMaterial IRON = new SPShieldMaterial("iron", 5, 332, Items.IRON_INGOT, Rarity.COMMON); | ||
public static final SPShieldMaterial DIAMOND = new SPShieldMaterial("diamond", 7, 588, Items.DIAMOND, Rarity.COMMON); | ||
public static final SPShieldMaterial NETHERITE = new SPShieldMaterial("netherite", 8, 672, Items.NETHERITE_INGOT, Rarity.COMMON); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters