Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -11,32 +11,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
import net.minecraft.resource.NamespaceResourceManager;
import net.minecraft.resource.Resource;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import ru.betterend.BetterEnd;
import ru.betterend.patterns.BlockPatterned;
@Mixin(NamespaceResourceManager.class)
public abstract class NamespaceResourceManagerMixin {
@Shadow
public abstract Resource getResource(Identifier id);
@Inject(method = "getAllResources", cancellable = true, at = @At(
value = "NEW",
target = "java/io/FileNotFoundException",
shift = Shift.BEFORE))
public void be_getStatesPattern(Identifier id, CallbackInfoReturnable<List<Resource>> info) {
public abstract Resource getResource(ResourceLocation id);
@Inject(method = "getAllResources", cancellable = true, at = @At(value = "NEW", target = "java/io/FileNotFoundException", shift = Shift.BEFORE))
public void be_getStatesPattern(ResourceLocation id, CallbackInfoReturnable<List<Resource>> info) {
if (id.getNamespace().equals(BetterEnd.MOD_ID)) {
String[] data = id.getPath().split("/");
if (data.length > 1) {
Identifier blockId = BetterEnd.makeID(data[1].replace(".json", ""));
ResourceLocation blockId = BetterEnd.makeID(data[1].replace(".json", ""));
Block block = Registry.BLOCK.get(blockId);
if (block instanceof BlockPatterned) {
Identifier stateId = ((BlockPatterned) block).statePatternId();
ResourceLocation stateId = ((BlockPatterned) block).statePatternId();
try {
List<Resource> resources = Lists.newArrayList();
Resource stateRes = this.getResource(stateId);