This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix vanilla datafixer bug causing block entity translation to fail
- Loading branch information
1 parent
9189f3b
commit d566357
Showing
3 changed files
with
38 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/net/earthcomputer/multiconnect/mixin/bridge/MixinSchemas.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.earthcomputer.multiconnect.mixin.bridge; | ||
|
||
import com.mojang.datafixers.DataFixUtils; | ||
import com.mojang.datafixers.DataFixerBuilder; | ||
import com.mojang.datafixers.schemas.Schema; | ||
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap; | ||
import net.minecraft.datafixer.Schemas; | ||
import net.minecraft.datafixer.TypeReferences; | ||
import net.minecraft.datafixer.fix.ChoiceTypesFix; | ||
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.Slice; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
@Mixin(Schemas.class) | ||
public class MixinSchemas { | ||
@SuppressWarnings("unchecked") | ||
@Inject(method = "build", | ||
slice = @Slice(from = @At(value = "CONSTANT", args = "intValue=1466")), | ||
at = @At(value = "INVOKE", target = "Lcom/mojang/datafixers/DataFixerBuilder;addFixer(Lcom/mojang/datafixers/DataFix;)V", ordinal = 0, remap = false)) | ||
private static void fixBlockEntityType(DataFixerBuilder builder, CallbackInfo ci) { | ||
Int2ObjectSortedMap<Schema> schemas; | ||
try { | ||
Field field = DataFixerBuilder.class.getDeclaredField("schemas"); | ||
field.setAccessible(true); | ||
schemas = (Int2ObjectSortedMap<Schema>) field.get(builder); | ||
} catch (ReflectiveOperationException e) { | ||
throw new AssertionError(e); | ||
} | ||
|
||
Schema schema1466 = schemas.get(DataFixUtils.makeKey(1466, 0)); | ||
builder.addFixer(new ChoiceTypesFix(schema1466, "multiconnect: fix block entity type", TypeReferences.BLOCK_ENTITY)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters