Compare commits
2 Commits
6348679de7
...
288c1d6e59
Author | SHA1 | Date | |
---|---|---|---|
288c1d6e59 | |||
4e1b7d8ade |
@ -22,7 +22,7 @@ loom {
|
|||||||
splitEnvironmentSourceSets()
|
splitEnvironmentSourceSets()
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
"modid" {
|
"customenchants" {
|
||||||
sourceSet sourceSets.main
|
sourceSet sourceSets.main
|
||||||
sourceSet sourceSets.client
|
sourceSet sourceSets.client
|
||||||
}
|
}
|
||||||
@ -85,4 +85,8 @@ publishing {
|
|||||||
// The repositories here will be used for publishing your artifact, not for
|
// The repositories here will be used for publishing your artifact, not for
|
||||||
// retrieving dependencies.
|
// retrieving dependencies.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fabricApi {
|
||||||
|
configureDataGeneration()
|
||||||
}
|
}
|
@ -6,12 +6,12 @@ org.gradle.parallel=true
|
|||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.21.1
|
minecraft_version=1.21.1
|
||||||
yarn_mappings=1.21.1+build.3
|
yarn_mappings=1.21.1+build.3
|
||||||
loader_version=0.16.2
|
loader_version=0.16.5
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.0.0
|
mod_version=1.0.0
|
||||||
maven_group=com.example
|
maven_group=com.itzilly
|
||||||
archives_base_name=modid
|
archives_base_name=customenchants
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.102.1+1.21.1
|
fabric_version=0.105.0+1.21.1
|
@ -0,0 +1,2 @@
|
|||||||
|
// 1.21.1 2024-09-29T04:05:48.3198307 Custom Enchants/Enchantment Generator
|
||||||
|
4e507987cd1905de26693915dff86bcadec7e9a0 data\customenchants\enchantment\thundering.json
|
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"anvil_cost": 7,
|
||||||
|
"description": {
|
||||||
|
"translate": "enchantment.customenchants.thundering"
|
||||||
|
},
|
||||||
|
"effects": {
|
||||||
|
"minecraft:post_attack": [
|
||||||
|
{
|
||||||
|
"affected": "victim",
|
||||||
|
"effect": {
|
||||||
|
"type": "customenchants:lightning",
|
||||||
|
"amount": {
|
||||||
|
"type": "minecraft:linear",
|
||||||
|
"base": 0.5,
|
||||||
|
"per_level_above_first": 0.15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"enchanted": "attacker"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"max_cost": {
|
||||||
|
"base": 1,
|
||||||
|
"per_level_above_first": 15
|
||||||
|
},
|
||||||
|
"max_level": 5,
|
||||||
|
"min_cost": {
|
||||||
|
"base": 1,
|
||||||
|
"per_level_above_first": 10
|
||||||
|
},
|
||||||
|
"slots": [
|
||||||
|
"hand"
|
||||||
|
],
|
||||||
|
"supported_items": "#minecraft:enchantable/sword",
|
||||||
|
"weight": 15
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
package com.example;
|
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class ExampleMod implements ModInitializer {
|
|
||||||
public static final String MOD_ID = "modid";
|
|
||||||
|
|
||||||
// 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!");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.example.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
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.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(MinecraftServer.class)
|
|
||||||
public class ExampleMixin {
|
|
||||||
@Inject(at = @At("HEAD"), method = "loadWorld")
|
|
||||||
private void init(CallbackInfo info) {
|
|
||||||
// This code is injected into the start of MinecraftServer.loadWorld()V
|
|
||||||
}
|
|
||||||
}
|
|
24
src/main/java/com/itzilly/CustomEnchants.java
Normal file
24
src/main/java/com/itzilly/CustomEnchants.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package com.itzilly;
|
||||||
|
|
||||||
|
import com.itzilly.init.EnchantmentInit;
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class CustomEnchants implements ModInitializer {
|
||||||
|
public static final String MOD_ID = "customenchants";
|
||||||
|
|
||||||
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
|
||||||
|
public static Identifier id(String path) {
|
||||||
|
return Identifier.of(MOD_ID, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitialize() {
|
||||||
|
LOGGER.info("Starting Custom Enchants - Realm");
|
||||||
|
EnchantmentInit.load();
|
||||||
|
}
|
||||||
|
}
|
13
src/main/java/com/itzilly/DataGenerator.java
Normal file
13
src/main/java/com/itzilly/DataGenerator.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.itzilly;
|
||||||
|
|
||||||
|
import com.itzilly.enchantments.EnchantmentGenerator;
|
||||||
|
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||||
|
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||||
|
|
||||||
|
public class DataGenerator implements DataGeneratorEntrypoint {
|
||||||
|
@Override
|
||||||
|
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
|
||||||
|
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
|
||||||
|
pack.addProvider(EnchantmentGenerator::new);
|
||||||
|
}
|
||||||
|
}
|
19
src/main/java/com/itzilly/LanguageProvider.java
Normal file
19
src/main/java/com/itzilly/LanguageProvider.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.itzilly;
|
||||||
|
|
||||||
|
import com.itzilly.init.EnchantmentInit;
|
||||||
|
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||||
|
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
|
||||||
|
import net.minecraft.registry.RegistryWrapper;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class LanguageProvider extends FabricLanguageProvider {
|
||||||
|
protected LanguageProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||||
|
super(dataOutput, registryLookup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateTranslations(RegistryWrapper.WrapperLookup registryLookup, TranslationBuilder translationBuilder) {
|
||||||
|
translationBuilder.addEnchantment(EnchantmentInit.THUNDERING_KEY, "Thundering");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.itzilly.enchantments;
|
||||||
|
|
||||||
|
import com.itzilly.enchantments.effects.LightningEnchantmentEffect;
|
||||||
|
import com.itzilly.init.EnchantmentInit;
|
||||||
|
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||||
|
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
|
||||||
|
import net.fabricmc.fabric.api.resource.conditions.v1.ResourceCondition;
|
||||||
|
import net.minecraft.component.EnchantmentEffectComponentTypes;
|
||||||
|
import net.minecraft.component.type.AttributeModifierSlot;
|
||||||
|
import net.minecraft.enchantment.Enchantment;
|
||||||
|
import net.minecraft.enchantment.EnchantmentLevelBasedValue;
|
||||||
|
import net.minecraft.enchantment.effect.EnchantmentEffectTarget;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
import net.minecraft.registry.RegistryWrapper;
|
||||||
|
import net.minecraft.registry.tag.ItemTags;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class EnchantmentGenerator extends FabricDynamicRegistryProvider {
|
||||||
|
public EnchantmentGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
|
||||||
|
super(output, registriesFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) {
|
||||||
|
RegistryWrapper<Item> itemLookup = registries.getWrapperOrThrow(RegistryKeys.ITEM);
|
||||||
|
|
||||||
|
register(entries, EnchantmentInit.THUNDERING_KEY, Enchantment.builder(
|
||||||
|
Enchantment.definition(
|
||||||
|
itemLookup.getOrThrow(ItemTags.SWORD_ENCHANTABLE),
|
||||||
|
15, // probability of showing up in the enchantment table
|
||||||
|
5, // max level
|
||||||
|
Enchantment.leveledCost(1, 10), // cost per level (base)
|
||||||
|
Enchantment.leveledCost(1, 15), // cost per level (max)
|
||||||
|
7, // anvil applying cost
|
||||||
|
AttributeModifierSlot.HAND
|
||||||
|
))
|
||||||
|
.addEffect(EnchantmentEffectComponentTypes.POST_ATTACK,
|
||||||
|
EnchantmentEffectTarget.ATTACKER,
|
||||||
|
EnchantmentEffectTarget.VICTIM,
|
||||||
|
new LightningEnchantmentEffect(EnchantmentLevelBasedValue.linear(0.5f, 0.15f))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void register(Entries entries, RegistryKey<Enchantment> key, Enchantment.Builder builder, ResourceCondition... resourceConditions) {
|
||||||
|
entries.add(key, builder.build(key.getValue()), resourceConditions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Enchantment Generator";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.itzilly.enchantments.effects;
|
||||||
|
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import net.minecraft.enchantment.EnchantmentEffectContext;
|
||||||
|
import net.minecraft.enchantment.EnchantmentLevelBasedValue;
|
||||||
|
import net.minecraft.enchantment.effect.EnchantmentEntityEffect;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.SpawnReason;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
public record LightningEnchantmentEffect(EnchantmentLevelBasedValue amount) implements EnchantmentEntityEffect {
|
||||||
|
public static final MapCodec<LightningEnchantmentEffect> CODEC = RecordCodecBuilder.mapCodec(
|
||||||
|
instance -> instance.group(
|
||||||
|
EnchantmentLevelBasedValue.CODEC.fieldOf("amount").forGetter(LightningEnchantmentEffect::amount)
|
||||||
|
).apply(instance, LightningEnchantmentEffect::new));
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity target, Vec3d pos) {
|
||||||
|
if(target instanceof LivingEntity living) {
|
||||||
|
float numberOfStrikes = this.amount.getValue(level);
|
||||||
|
|
||||||
|
BlockPos targetPosition = living.getBlockPos();
|
||||||
|
for (int i = 0; i < numberOfStrikes; i++) {
|
||||||
|
EntityType.LIGHTNING_BOLT.spawn(world, targetPosition, SpawnReason.TRIGGERED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MapCodec<? extends EnchantmentEntityEffect> getCodec() {
|
||||||
|
return CODEC;
|
||||||
|
}
|
||||||
|
}
|
25
src/main/java/com/itzilly/init/EnchantmentInit.java
Normal file
25
src/main/java/com/itzilly/init/EnchantmentInit.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.itzilly.init;
|
||||||
|
|
||||||
|
import com.itzilly.CustomEnchants;
|
||||||
|
|
||||||
|
import com.itzilly.enchantments.effects.LightningEnchantmentEffect;
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
|
import net.minecraft.enchantment.Enchantment;
|
||||||
|
import net.minecraft.enchantment.effect.EnchantmentEntityEffect;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
|
||||||
|
|
||||||
|
public class EnchantmentInit {
|
||||||
|
public static final RegistryKey<Enchantment> THUNDERING_KEY = RegistryKey.of(RegistryKeys.ENCHANTMENT, CustomEnchants.id("thundering"));
|
||||||
|
|
||||||
|
public static final MapCodec<LightningEnchantmentEffect> LIGHTNING_EFFECT = register("lightning", LightningEnchantmentEffect.CODEC);
|
||||||
|
|
||||||
|
private static <T extends EnchantmentEntityEffect> MapCodec<T> register(String name, MapCodec<T> codec) {
|
||||||
|
return Registry.register(Registries.ENCHANTMENT_ENTITY_EFFECT_TYPE, CustomEnchants.id(name), codec);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void load() {}
|
||||||
|
}
|
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 453 B |
@ -1,34 +1,29 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "modid",
|
"id": "customenchants",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"name": "Example mod",
|
"name": "Custom Enchants",
|
||||||
"description": "This is an example description! Tell everyone what your mod is about!",
|
"description": "Simple server-side fabric mod to add custom enchantments",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Me!"
|
"itzilly",
|
||||||
|
"iillyum"
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://fabricmc.net/",
|
"homepage": "http://itzilly.com/",
|
||||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
"sources": "http://itzilly.com/CustomEnchants-Realm"
|
||||||
},
|
},
|
||||||
"license": "CC0-1.0",
|
"license": "CC0-1.0",
|
||||||
"icon": "assets/modid/icon.png",
|
"icon": "assets/customenchants/icon.png",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
|
"fabric-datagen": [
|
||||||
|
"com.itzilly.DataGenerator"
|
||||||
|
],
|
||||||
"main": [
|
"main": [
|
||||||
"com.example.ExampleMod"
|
"com.itzilly.CustomEnchants"
|
||||||
],
|
|
||||||
"client": [
|
|
||||||
"com.example.ExampleModClient"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [],
|
||||||
"modid.mixins.json",
|
|
||||||
{
|
|
||||||
"config": "modid.client.mixins.json",
|
|
||||||
"environment": "client"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.16.2",
|
"fabricloader": ">=0.16.2",
|
||||||
"minecraft": "~1.21.1",
|
"minecraft": "~1.21.1",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user