-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
99 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
package mc.duzo.timeless; | ||
|
||
import mc.duzo.timeless.suit.SuitRegistry; | ||
import net.fabricmc.api.ModInitializer; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class Timeless implements ModInitializer { | ||
public static final String MOD_ID = "timeless"; | ||
|
||
// This logger is used to write text to the console and the log file. | ||
// It is considered best practice to use your mod id as the logger's name. | ||
// That way, it's clear which mod wrote info, warnings, and errors. | ||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); | ||
|
||
@Override | ||
public void onInitialize() { | ||
// This code runs as soon as Minecraft is in a mod-load-ready state. | ||
// However, some things (like resources) may still be uninitialized. | ||
// Proceed with mild caution. | ||
|
||
LOGGER.info("Hello Fabric world!"); | ||
SuitRegistry.init(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/mc/duzo/timeless/mixin/EnchantmentHelperMixin.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,19 @@ | ||
package mc.duzo.timeless.mixin; | ||
|
||
import mc.duzo.timeless.suit.SuitItem; | ||
import net.minecraft.enchantment.EnchantmentHelper; | ||
import net.minecraft.item.ItemStack; | ||
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(EnchantmentHelper.class) | ||
public class EnchantmentHelperMixin { | ||
@Inject(method="hasBindingCurse", at=@At("HEAD"), cancellable = true) | ||
private void timeless$hasBindingCurse(ItemStack stack, CallbackInfoReturnable<Boolean> cir) { | ||
if (!(stack.getItem() instanceof SuitItem suit)) return; | ||
|
||
cir.setReturnValue(suit.isBinding()); | ||
} | ||
} |
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,6 @@ | ||
package mc.duzo.timeless.registry; | ||
|
||
import net.minecraft.util.Identifier; | ||
public interface Identifiable { | ||
Identifier id(); | ||
} |
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,8 @@ | ||
package mc.duzo.timeless.suit; | ||
|
||
import net.minecraft.nbt.NbtCompound; | ||
|
||
public interface Serializable { | ||
NbtCompound serialize(); | ||
void deserialize(NbtCompound data); | ||
} |
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,7 @@ | ||
package mc.duzo.timeless.suit; | ||
|
||
import mc.duzo.timeless.registry.Identifiable; | ||
|
||
public abstract class Suit implements Identifiable { | ||
public abstract boolean isBinding(); | ||
} |
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,18 @@ | ||
package mc.duzo.timeless.suit; | ||
|
||
import net.minecraft.item.ArmorItem; | ||
import net.minecraft.item.ArmorMaterial; | ||
|
||
public abstract class SuitItem extends ArmorItem { | ||
private final Suit parent; | ||
|
||
protected SuitItem(Suit suit, ArmorMaterial material, Type type, Settings settings) { | ||
super(material, type, settings.maxCount(1)); | ||
|
||
this.parent = suit; | ||
} | ||
|
||
public boolean isBinding() { | ||
return this.parent.isBinding(); | ||
} | ||
} |
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,20 @@ | ||
package mc.duzo.timeless.suit; | ||
|
||
import mc.duzo.timeless.Timeless; | ||
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.registry.RegistryKey; | ||
import net.minecraft.registry.SimpleRegistry; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class SuitRegistry { | ||
public static final SimpleRegistry<Suit> REGISTRY = FabricRegistryBuilder.createSimple(RegistryKey.<Suit>ofRegistry(new Identifier(Timeless.MOD_ID, "suit"))).buildAndRegister(); | ||
|
||
public static Suit register(Suit suit) { | ||
return Registry.register(REGISTRY, suit.id(), suit); | ||
} | ||
|
||
public static void init() { | ||
|
||
} | ||
} |
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,18 @@ | ||
package mc.duzo.timeless.suit; | ||
|
||
public class SuitSet { | ||
private final Suit suit; | ||
private final SuitItem head; | ||
private final SuitItem chest; | ||
private final SuitItem legs; | ||
private final SuitItem feet; | ||
|
||
public SuitSet(Suit suit, SuitItem head, SuitItem chest, SuitItem legs, SuitItem feet) { | ||
this.suit = suit; | ||
|
||
this.head = head; | ||
this.chest = chest; | ||
this.legs = legs; | ||
this.feet = feet; | ||
} | ||
} |
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