Skip to content

Commit

Permalink
Datafix quick armor stands
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Dec 6, 2024
1 parent a9cfebe commit b985c97
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.nucleoid.extras.mixin.lobby;
package xyz.nucleoid.extras.mixin.datafixer;

import com.mojang.serialization.Dynamic;
import net.minecraft.datafixer.fix.ItemStackComponentizationFix;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package xyz.nucleoid.extras.mixin.datafixer;

import com.mojang.datafixers.DSL;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.datafixers.types.templates.TypeTemplate;
import net.minecraft.datafixer.TypeReferences;
import net.minecraft.datafixer.schema.Schema1460;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Map;
import java.util.function.Supplier;

@Mixin(Schema1460.class)
public abstract class Schema1460Mixin extends Schema {
public Schema1460Mixin(int versionKey, Schema parent) {
super(versionKey, parent);
}

@Shadow protected static void targetEntityItems(Schema schema, Map<String, Supplier<TypeTemplate>> map, String entityId) {};

@Inject(method = "registerEntities", at = @At("RETURN"))
private void registerCustomEntities(Schema schema, CallbackInfoReturnable<Map<String, Supplier<TypeTemplate>>> cir) {
var map = cir.getReturnValue();

targetEntityItems(schema, map, mod("quick_armor_stand"));
registerSimple(map, mod("leaderboard_display"));
}

@Unique
private static String mod(String path) {
return "nucleoid_extras:" + path;
}
}
3 changes: 2 additions & 1 deletion src/main/resources/extras.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"ServerEntityManagerAccessor",
"ServerWorldAccessor",
"TextCodecMixin",
"datafixer.ItemStackComponentizationFixMixin",
"datafixer.Schema1460Mixin",
"debug.EntityMixin",
"lobby.ArmorStandEntityAccessor",
"lobby.ItemStackComponentizationFixMixin",
"lobby.LivingEntityAccessor",
"lobby.ServerChunkLoadingManagerAccessor",
"lobby.ServerPlayerEntityMixin",
Expand Down

0 comments on commit b985c97

Please sign in to comment.