feat: elytra craftable

This commit is contained in:
zly2006 committed 2024-07-11 12:14:02 +08:00
1 parent ab3495d6c7
commit 6e9913e469
8 files changed
+101 -4

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx1G
# Mod Properties # Mod Properties
mod_version = 0.12 mod_version = 0.20
maven_group = com.github.zly2006 maven_group = com.github.zly2006
archives_base_name = carpet-sls-addition archives_base_name = carpet-sls-addition
@@ -2,7 +2,6 @@ package com.github.zly2006.carpetslsaddition;
import carpet.api.settings.Rule; import carpet.api.settings.Rule;
import carpet.api.settings.RuleCategory; import carpet.api.settings.RuleCategory;
import net.minecraft.block.RedstoneBlock;
import static com.github.zly2006.carpetslsaddition.ServerMain.CARPET_ID; import static com.github.zly2006.carpetslsaddition.ServerMain.CARPET_ID;
@@ -55,5 +54,5 @@ public class SLSCarpetSettings {
public static boolean optimizedOnDragonRespawn = false; public static boolean optimizedOnDragonRespawn = false;
@Rule(categories = {CARPET_ID, RuleCategory.FEATURE}) @Rule(categories = {CARPET_ID, RuleCategory.FEATURE})
public static boolean printStackTraceOnVillagerSpawn = false; public static boolean elytraCraftable = false;
} }
@@ -0,0 +1,36 @@
package com.github.zly2006.carpetslsaddition.mixin.datapack;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourceType;
import net.minecraft.resource.VanillaResourcePackProvider;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.function.BiConsumer;
import java.util.function.Function;
@Mixin(VanillaResourcePackProvider.class)
public abstract class MixinVanillaResourcePackProvider {
@Shadow protected abstract void forEachProfile(@Nullable Path namespacedPath, BiConsumer<String, Function<String, ResourcePackProfile>> consumer);
@Shadow @Final private ResourceType type;
@Inject(
method = "forEachProfile(Ljava/util/function/BiConsumer;)V",
at = @At("RETURN")
)
private void andMe(BiConsumer<String, Function<String, ResourcePackProfile>> consumer, CallbackInfo ci) throws URISyntaxException {
if (type == ResourceType.SERVER_DATA) {
Path path = Path.of(SLSCarpetSettings.class.getClassLoader().getResource("data/slsa/datapacks").toURI());
this.forEachProfile(path, consumer);
}
}
}
@@ -0,0 +1,25 @@
package com.github.zly2006.carpetslsaddition.mixin.elytra;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import net.minecraft.item.*;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(ElytraItem.class)
public abstract class MixinElytraItem extends Item implements Equipment {
public MixinElytraItem(Settings settings) {
super(settings);
}
@Override
public boolean hasRecipeRemainder() {
return SLSCarpetSettings.elytraCraftable;
}
@Override
public ItemStack getRecipeRemainder(ItemStack stack) {
if (SLSCarpetSettings.elytraCraftable) {
return stack;
}
else return ItemStack.EMPTY;
}
}
@@ -50,5 +50,6 @@
"carpet.rule.maxUpdateQueueSize.extra.0": "If set to a value not greater than 0, turn off this function and run according to Vanilla", "carpet.rule.maxUpdateQueueSize.extra.0": "If set to a value not greater than 0, turn off this function and run according to Vanilla",
"carpet.rule.maxUpdateQueueSize.extra.1": "Otherwise, when the number of single updates exceeds the set value, an OutOfMemoryError will be thrown to generate update suppression", "carpet.rule.maxUpdateQueueSize.extra.1": "Otherwise, when the number of single updates exceeds the set value, an OutOfMemoryError will be thrown to generate update suppression",
"carpet.rule.emptyShulkerBoxStack.extra.0": "Empty shulker boxes can stack in a player's inventory or hand", "carpet.rule.emptyShulkerBoxStack.extra.0": "Empty shulker boxes can stack in a player's inventory or hand",
"carpet.rule.emptyShulkerBoxStack.extra.1": "Empty shulker boxes will not stack in other inventories, such as chests or hoppers" "carpet.rule.emptyShulkerBoxStack.extra.1": "Empty shulker boxes will not stack in other inventories, such as chests or hoppers",
"carpet.rule.elytraCraftable.desc": "Make elytra craftable for Minecraft 1.20.6+ (eltra wont disappear when crafting)"
} }
@@ -0,0 +1,26 @@
{
"type": "crafting_shaped",
"pattern": [
"XAX",
"XKX",
"XBX"
],
"key": {
"A": {
"item": "minecraft:end_crystal"
},
"B": {
"item": "minecraft:nether_star"
},
"X": {
"item": "minecraft:phantom_membrane"
},
"K": {
"item": "minecraft:elytra"
}
},
"category": "equipment",
"result": {
"id": "minecraft:elytra"
}
}
@@ -0,0 +1,8 @@
{
"pack": {
"description": {
"translate": "Elytra Craftable by zly2006, made for Starlight Server and licensed under MIT License."
},
"pack_format": 48
}
}
@@ -13,6 +13,8 @@
"block.BlockPatternTestTransformInvoker", "block.BlockPatternTestTransformInvoker",
"block.MixinRedstoneWireBlock", "block.MixinRedstoneWireBlock",
"carpet.MixinSettingsManager", "carpet.MixinSettingsManager",
"datapack.MixinVanillaResourcePackProvider",
"elytra.MixinElytraItem",
"entity.MixinArmorStandEntity", "entity.MixinArmorStandEntity",
"entity.MixinEnderDragonFight", "entity.MixinEnderDragonFight",
"entity.MixinEndermanGoal", "entity.MixinEndermanGoal",