mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-15 23:55:53 +01:00
Added model data refresh mixin
This commit is contained in:
parent
6c3bec250f
commit
e916b06862
2 changed files with 39 additions and 1 deletions
|
@ -0,0 +1,37 @@
|
||||||
|
package com.simibubi.create.foundation.mixin;
|
||||||
|
|
||||||
|
import com.simibubi.create.content.schematics.SchematicWorld;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.model.ModelDataManager;
|
||||||
|
|
||||||
|
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.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@Mixin(ModelDataManager.class)
|
||||||
|
public class ModelDataRefreshMixin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normally ModelDataManager will throw an exception if a tile entity tries
|
||||||
|
* to refresh its model data from a world the client isn't currently in,
|
||||||
|
* but we need that to not happen for tile entities in fake schematic
|
||||||
|
* worlds, so in those cases just do nothing instead.
|
||||||
|
*/
|
||||||
|
@Inject(at = @At("HEAD"), method = "requestModelDataRefresh", cancellable = true, remap = false)
|
||||||
|
private static void requestModelDataRefresh(TileEntity te, CallbackInfo ci) {
|
||||||
|
if (te != null) {
|
||||||
|
World world = te.getWorld();
|
||||||
|
if (world != Minecraft.getInstance().world && world instanceof SchematicWorld)
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,7 +18,8 @@
|
||||||
"StoreProjectionMatrixMixin",
|
"StoreProjectionMatrixMixin",
|
||||||
"TileRemoveMixin",
|
"TileRemoveMixin",
|
||||||
"TileWorldHookMixin",
|
"TileWorldHookMixin",
|
||||||
"WindowResizeMixin"
|
"WindowResizeMixin",
|
||||||
|
"ModelDataRefreshMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|
Loading…
Reference in a new issue