Skip to content

Commit 468825d

Browse files
committed
Move mod mixins to subpackages, Gaia guardian fix
Signed-off-by: roadhog360 <[email protected]>
1 parent a65c5d0 commit 468825d

File tree

9 files changed

+110
-21
lines changed

9 files changed

+110
-21
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ Current Features:
1717
- Hat layers on head blocks
1818
- New default skins alongside just Steve
1919
- Patch for Twilight Forest giants
20+
- Patch for Botania's Gaia Guardian
2021

2122
Todo:
2223
- Config
24+
- Fix regular heads not working without a UUID when worn as a helmet
2325
- Toggle head block inventory icon render
24-
- Toggle new default skins (Either Steve/Alex or JUST Steve)
2526

2627
Current incompatibility todo:
27-
- Twilight Forest heads
28+
- Twilight Forest heads are not 3D
2829
- Smart Moving (it's like 90% working slim models are just slightly wrong)
29-
- Botania Gaia Guardian
3030

3131
Current wontfix incompatibilities: (Might change my mind later, PRs welcome)
3232
- OptiFine

dependencies.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ dependencies {
3737
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
3838
compileOnly('com.github.GTNewHorizons:twilightforest:2.6.33:dev')
3939
compileOnly deobfCurse("headcrumbs-222838:2279949")
40+
compileOnly deobfCurse("botania-225643:2283837")
4041
}

src/main/java/roadhog360/simpleskinbackport/core/Utils.java

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.mojang.authlib.GameProfile;
77
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
88
import com.mojang.authlib.properties.Property;
9+
import cpw.mods.fml.client.FMLClientHandler;
910
import net.minecraft.client.model.ModelBase;
1011
import net.minecraft.client.model.ModelBox;
1112
import net.minecraft.client.model.ModelRenderer;
@@ -178,6 +179,13 @@ public static void changeTextureSize(ModelBase base, int width, int height) {
178179
base.boxList.forEach(Utils::remakeBoxes);
179180
}
180181

182+
public static boolean isClientPlayerSlim() {
183+
if(FMLClientHandler.instance().getClientPlayerEntity() instanceof IArmsState player) {
184+
return player.simpleSkinBackport$isSlim();
185+
}
186+
return false;
187+
}
188+
181189
/**
182190
* I got sick of constantly updating the util funcs whenever I needed to pass in a new setting lol
183191
*/

src/main/java/roadhog360/simpleskinbackport/mixinplugin/SimpleSkinBackportLateMixins.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ public String getMixinConfig() {
2222
@Override
2323
public List<String> getMixins(Set<String> loadedMods) {
2424
List<String> mixins = new ArrayList<>();
25-
if(loadedMods.contains("TwilightForest")) {
26-
if(SIDE == MixinEnvironment.Side.CLIENT) {
27-
mixins.add("MixinRenderTFGiant");
25+
if(SIDE == MixinEnvironment.Side.CLIENT) {
26+
if(loadedMods.contains("TwilightForest")) {
27+
mixins.add("twilightforest.MixinRenderTFGiant");
28+
}
29+
if(loadedMods.contains("Botania")) {
30+
mixins.add("botania.MixinClientProxy");
31+
mixins.add("botania.MixinRenderTileSkullOverride");
32+
mixins.add("botania.MixinRenderDoppelganger");
2833
}
2934
}
3035
return mixins;

src/main/java/roadhog360/simpleskinbackport/mixins/early/MixinModelBiped.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,19 @@ private void checkPlayerModelAndSetDim(ModelBiped instance, int value, Operation
5656

5757
if(!simpleSkinBackport$isPlayerModel()) {
5858
boolean isPlayerRenderer;
59+
boolean isGaia;
5960
//Do all this OUTSIDE of the if bracket, so we can find and add cases for classes that use size > 0
6061
try {
6162
Class<?> caller = Class.forName(Utils.getCallerClassName());
62-
isPlayerRenderer = caller.isAssignableFrom(RenderPlayer.class)
63+
isGaia = caller.getName().equals("vazkii.botania.client.render.entity.RenderDoppleganger");
64+
isPlayerRenderer = caller.isAssignableFrom(RenderPlayer.class) || isGaia
6365
|| caller.getName().equals("net.smart.render.ModelPlayer") || caller.getName().contains("RenderTFGiant");
6466
//We need a way to check if it's a player model, without modifying the RenderPlayer.
6567
} catch (ClassNotFoundException e) {
6668
throw new RuntimeException(e);
6769
}
6870

69-
if (size == 0 || size == 0.0625F) {
71+
if (size == 0 || size == 0.0625F || isGaia) {
7072
//TODO: Might have to add special exceptions for big models, I think this is model size so I named it as such.
7173
// Mods that add giant (or small) players will need special treatment.
7274
if (isPlayerRenderer) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package roadhog360.simpleskinbackport.mixins.late.botania;
2+
3+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
5+
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
6+
import net.minecraft.tileentity.TileEntity;
7+
import net.minecraft.tileentity.TileEntitySkull;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
11+
@Mixin(vazkii.botania.client.core.proxy.ClientProxy.class)
12+
public class MixinClientProxy extends vazkii.botania.common.core.proxy.CommonProxy {
13+
@WrapOperation(method = "initRenderers", remap = false, at = @At(value = "INVOKE", target = "Lcpw/mods/fml/client/registry/ClientRegistry;bindTileEntitySpecialRenderer(Ljava/lang/Class;Lnet/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer;)V"))
14+
private void disarmSkullRenderReplacer(Class<? extends TileEntity> tileEntityClass, TileEntitySpecialRenderer specialRenderer, Operation<Void> original) {
15+
if(tileEntityClass != TileEntitySkull.class) {
16+
//We provide our own hat layer directly on the skull, so Botania doesn't need to do this.
17+
original.call(tileEntityClass, specialRenderer);
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package roadhog360.simpleskinbackport.mixins.late.botania;
2+
3+
import net.minecraft.client.model.ModelBiped;
4+
import net.minecraft.client.renderer.entity.RenderBiped;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.util.ResourceLocation;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
11+
import roadhog360.simpleskinbackport.core.Utils;
12+
import roadhog360.simpleskinbackport.ducks.INewBipedModel;
13+
import vazkii.botania.client.render.entity.RenderDoppleganger;
14+
15+
@Mixin(RenderDoppleganger.class)
16+
public class MixinRenderDoppelganger extends RenderBiped {
17+
public MixinRenderDoppelganger(ModelBiped p_i1257_1_, float p_i1257_2_) {
18+
super(p_i1257_1_, p_i1257_2_);
19+
}
20+
21+
@Inject(method = "getEntityTexture", at = @At(value = "HEAD"))
22+
private void overrideSkinAndSetResourceLocation(Entity par1Entity, CallbackInfoReturnable<ResourceLocation> cir) {
23+
if(this.modelBipedMain instanceof INewBipedModel model) {
24+
model.simpleSkinBackport$setSlim(Utils.isClientPlayerSlim());
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package roadhog360.simpleskinbackport.mixins.late.botania;
2+
3+
import net.minecraft.client.model.ModelSkeletonHead;
4+
import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer;
5+
import net.minecraft.entity.Entity;
6+
import net.minecraft.util.ResourceLocation;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Redirect;
10+
import roadhog360.simpleskinbackport.core.DefaultPlayerSkin;
11+
import vazkii.botania.client.model.ModelSkullOverride;
12+
import vazkii.botania.client.render.tile.RenderTileSkullOverride;
13+
14+
@Mixin(RenderTileSkullOverride.class)
15+
public class MixinRenderTileSkullOverride extends TileEntitySkullRenderer {
16+
17+
private ModelSkeletonHead skull = new ModelSkeletonHead(0, 0, 64, 64);
18+
//The new one isn't needed
19+
20+
/**
21+
* 64x64 model needs new Steve textures
22+
*/
23+
@Redirect(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;locationStevePng:Lnet/minecraft/util/ResourceLocation;"))
24+
private ResourceLocation fixDefaultTexture() {
25+
return DefaultPlayerSkin.STEVE.getResource();
26+
}
27+
28+
/**
29+
* Botania's model override isn't necessary; it's easier to provide the vanilla one to set the 64x64 textures.
30+
* We need the 64x64 texture head since Gaia Guardians copy the player's texture, which uses 64x64 textures.
31+
*/
32+
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lvazkii/botania/client/model/ModelSkullOverride;render(Lnet/minecraft/entity/Entity;FFFFFF)V"))
33+
private void changeModel(ModelSkullOverride instance, Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {
34+
skull.render(par1Entity, par2, par3, par4, par5, par6, par7);
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
package roadhog360.simpleskinbackport.mixins.late;
1+
package roadhog360.simpleskinbackport.mixins.late.twilightforest;
22

3-
import cpw.mods.fml.client.FMLClientHandler;
43
import net.minecraft.client.model.ModelBiped;
54
import net.minecraft.client.renderer.entity.RenderBiped;
65
import net.minecraft.entity.Entity;
76
import net.minecraft.util.ResourceLocation;
87
import org.spongepowered.asm.mixin.Mixin;
9-
import org.spongepowered.asm.mixin.Unique;
108
import org.spongepowered.asm.mixin.injection.At;
119
import org.spongepowered.asm.mixin.injection.Inject;
1210
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1311
import roadhog360.simpleskinbackport.configuration.configs.ConfigModCompat;
14-
import roadhog360.simpleskinbackport.ducks.IArmsState;
12+
import roadhog360.simpleskinbackport.core.Utils;
1513
import roadhog360.simpleskinbackport.ducks.INewBipedModel;
1614
import twilightforest.client.renderer.entity.RenderTFGiant;
1715

@@ -24,20 +22,12 @@ public MixinRenderTFGiant(ModelBiped p_i1257_1_, float p_i1257_2_) {
2422
@Inject(method = "getEntityTexture", at = @At(value = "HEAD"), cancellable = true)
2523
private void overrideSkinAndSetResourceLocation(Entity par1Entity, CallbackInfoReturnable<ResourceLocation> cir) {
2624
boolean usePlayerModel = ConfigModCompat.TFgiantSkinSet == null;
27-
boolean slim = usePlayerModel ? simpleSkinBackport$isClientPlayerSlim() : ConfigModCompat.TFgiantSkinSet.getDefaultSkin(par1Entity.getPersistentID()).isSlim();
25+
boolean slim = usePlayerModel ? Utils.isClientPlayerSlim() : ConfigModCompat.TFgiantSkinSet.getDefaultSkin(par1Entity.getPersistentID()).isSlim();
2826
if(this.modelBipedMain instanceof INewBipedModel model) {
2927
model.simpleSkinBackport$setSlim(slim);
3028
}
3129
if(!usePlayerModel) {
3230
cir.setReturnValue(ConfigModCompat.TFgiantSkinSet.getDefaultSkin(par1Entity.getPersistentID()).getResource());
3331
}
3432
}
35-
36-
@Unique
37-
private boolean simpleSkinBackport$isClientPlayerSlim() {
38-
if(FMLClientHandler.instance().getClientPlayerEntity() instanceof IArmsState player) {
39-
return player.simpleSkinBackport$isSlim();
40-
}
41-
return false;
42-
}
4333
}

0 commit comments

Comments
 (0)