-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathBlockModelWrapperMixin.java
More file actions
43 lines (35 loc) · 1.49 KB
/
BlockModelWrapperMixin.java
File metadata and controls
43 lines (35 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.geysermc.rainbow.mixin;
import net.minecraft.client.renderer.item.BlockModelWrapper;
import net.minecraft.client.renderer.item.ItemModel;
import net.minecraft.resources.ResourceLocation;
import org.geysermc.rainbow.accessor.BlockModelWrapperLocationAccessor;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(BlockModelWrapper.class)
public abstract class BlockModelWrapperMixin implements ItemModel, BlockModelWrapperLocationAccessor {
@Unique
private ResourceLocation modelOrigin;
@Override
public ResourceLocation rainbow$getModelOrigin() {
return modelOrigin;
}
@Override
public void rainbow$setModelOrigin(ResourceLocation model) {
modelOrigin = model;
}
@Mixin(BlockModelWrapper.Unbaked.class)
public abstract static class UnbakedMixin implements Unbaked {
@Shadow
@Final
private ResourceLocation model;
@Inject(method = "bake", at = @At("TAIL"))
public void setModelOrigin(BakingContext context, CallbackInfoReturnable<ItemModel> callbackInfoReturnable) {
((BlockModelWrapperLocationAccessor) callbackInfoReturnable.getReturnValue()).rainbow$setModelOrigin(model);
}
}
}