mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-10 12:02:48 +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",
|
||||
"TileRemoveMixin",
|
||||
"TileWorldHookMixin",
|
||||
"WindowResizeMixin"
|
||||
"WindowResizeMixin",
|
||||
"ModelDataRefreshMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue