Skip to content

Commit

Permalink
Revert "why doesnt this work"
Browse files Browse the repository at this point in the history
This reverts commit a76e102.
  • Loading branch information
AViewFromTheTop committed Dec 30, 2024
1 parent a76e102 commit ce16776
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.DecoratedPotPattern;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.util.Map;

public interface DecoratedPotPatternRegistryEntrypoint {
void registerForItems(Map<Item, ResourceKey<DecoratedPotPattern>> map);

void bootstrap(Registry<DecoratedPotPattern> registry);

@Contract("_, _, _ -> new")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,27 @@

package net.frozenblock.lib.item.mixin.sherd;

import com.google.common.collect.ImmutableMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.fabricmc.loader.api.FabricLoader;
import net.frozenblock.lib.item.impl.sherd.DecoratedPotPatternRegistryEntrypoint;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.DecoratedPotPattern;
import net.minecraft.world.level.block.entity.DecoratedPotPatterns;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map;

@Mixin(value = DecoratedPotPatterns.class, priority = 50)
@Mixin(DecoratedPotPatterns.class)
public class DecoratedPotPatternsMixin {

@Shadow
public static Map<Item, ResourceKey<DecoratedPotPattern>> ITEM_TO_POT_TEXTURE;

@Inject(method = "<clinit>", at = @At(value = "TAIL"))
private static void frozenLib$createMap(CallbackInfo info) {
Map<Item, ResourceKey<DecoratedPotPattern>> mutableSherdMap = new Object2ObjectOpenHashMap<>(ITEM_TO_POT_TEXTURE);
FabricLoader.getInstance().getEntrypointContainers("frozenlib:decorated_pot_patterns", DecoratedPotPatternRegistryEntrypoint.class).forEach(entrypoint -> {
DecoratedPotPatternRegistryEntrypoint decoratedPotPatternRegistryEntrypoint = entrypoint.getEntrypoint();
decoratedPotPatternRegistryEntrypoint.registerForItems(mutableSherdMap);
});
ITEM_TO_POT_TEXTURE = ImmutableMap.copyOf(mutableSherdMap);
}

@Inject(
method = "bootstrap",
at = @At(
value = "RETURN",
shift = At.Shift.BEFORE
)
)
@Inject(method = "bootstrap", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private static void frozenLib$bootstrap(Registry<DecoratedPotPattern> registry, CallbackInfoReturnable<DecoratedPotPattern> info) {
FabricLoader.getInstance().getEntrypointContainers("frozenlib:decorated_pot_patterns", DecoratedPotPatternRegistryEntrypoint.class).forEach(entrypoint -> {
try {
DecoratedPotPatternRegistryEntrypoint decoratedPotPatternRegistryEntrypoint = entrypoint.getEntrypoint();
decoratedPotPatternRegistryEntrypoint.bootstrap(registry);
} catch (Throwable ignored) {}
} catch (Throwable ignored) {
}
});
}
}

0 comments on commit ce16776

Please sign in to comment.