-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure compatibility with RenderPlayerAPI
- Loading branch information
Showing
3 changed files
with
250 additions
and
2 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
82 changes: 82 additions & 0 deletions
82
src/main/java/lain/mods/skinport/compat/SkinPortModelPlayer_RPA.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,82 @@ | ||
package lain.mods.skinport.compat; | ||
|
||
import net.minecraft.client.model.ModelRenderer; | ||
import net.minecraft.entity.Entity; | ||
import api.player.model.ModelPlayer; | ||
|
||
public class SkinPortModelPlayer_RPA extends ModelPlayer | ||
{ | ||
|
||
public ModelRenderer bipedLeftArmwear; | ||
public ModelRenderer bipedRightArmwear; | ||
public ModelRenderer bipedLeftLegwear; | ||
public ModelRenderer bipedRightLegwear; | ||
public ModelRenderer bipedBodyWear; | ||
public boolean smallArms; | ||
|
||
public SkinPortModelPlayer_RPA(float z, boolean smallArms) | ||
{ | ||
super(z, 0.0F, 64, 64); | ||
|
||
this.smallArms = smallArms; | ||
|
||
if (smallArms) | ||
{ | ||
bipedLeftArm = new ModelRenderer(this, 32, 48); | ||
bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, z); | ||
bipedLeftArm.setRotationPoint(5.0F, 2.5F, 0.0F); | ||
|
||
bipedRightArm = new ModelRenderer(this, 40, 16); | ||
bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, z); | ||
bipedRightArm.setRotationPoint(-5.0F, 2.5F, 0.0F); | ||
|
||
bipedLeftArmwear = new ModelRenderer(this, 48, 48); | ||
bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, z + 0.25F); | ||
bipedLeftArm.addChild(bipedLeftArmwear); | ||
|
||
bipedRightArmwear = new ModelRenderer(this, 40, 32); | ||
bipedRightArmwear.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, z + 0.25F); | ||
bipedRightArm.addChild(bipedRightArmwear); | ||
} | ||
else | ||
{ | ||
bipedLeftArm = new ModelRenderer(this, 32, 48); | ||
bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, z); | ||
bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); | ||
|
||
bipedLeftArmwear = new ModelRenderer(this, 48, 48); | ||
bipedLeftArmwear.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, z + 0.25F); | ||
bipedLeftArm.addChild(bipedLeftArmwear); | ||
|
||
bipedRightArmwear = new ModelRenderer(this, 40, 32); | ||
bipedRightArmwear.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, z + 0.25F); | ||
bipedRightArm.addChild(bipedRightArmwear); | ||
} | ||
|
||
bipedLeftLeg = new ModelRenderer(this, 16, 48); | ||
bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, z); | ||
bipedLeftLeg.setRotationPoint(1.9F, 12.0F, 0.0F); | ||
|
||
bipedLeftLegwear = new ModelRenderer(this, 0, 48); | ||
bipedLeftLegwear.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, z + 0.25F); | ||
bipedLeftLeg.addChild(bipedLeftLegwear); | ||
|
||
bipedRightLegwear = new ModelRenderer(this, 0, 32); | ||
bipedRightLegwear.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, z + 0.25F); | ||
bipedRightLeg.addChild(bipedRightLegwear); | ||
|
||
bipedBodyWear = new ModelRenderer(this, 16, 32); | ||
bipedBodyWear.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, z + 0.25F); | ||
bipedBody.addChild(bipedBodyWear); | ||
} | ||
|
||
@Override | ||
public void render(Entity p_render_1_, float p_render_2_, float p_render_3_, float p_render_4_, float p_render_5_, float p_render_6_, float p_render_7_) | ||
{ | ||
super.render(p_render_1_, p_render_2_, p_render_3_, p_render_4_, p_render_5_, p_render_6_, p_render_7_); | ||
|
||
if (smallArms) | ||
bipedRightArm.rotationPointX += 1.0F; | ||
} | ||
|
||
} |
155 changes: 155 additions & 0 deletions
155
src/main/java/lain/mods/skinport/compat/SkinPortRenderPlayer_RPA.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,155 @@ | ||
package lain.mods.skinport.compat; | ||
|
||
import lain.mods.skinport.SkinCustomization; | ||
import lain.mods.skinport.SkinPort; | ||
import lain.mods.skinport.api.ISkin; | ||
import lain.mods.skinport.api.SkinProviderAPI; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.AbstractClientPlayer; | ||
import net.minecraft.client.model.ModelBiped; | ||
import net.minecraft.client.renderer.entity.RenderPlayer; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
public class SkinPortRenderPlayer_RPA extends RenderPlayer | ||
{ | ||
|
||
public SkinPortModelPlayer_RPA modelPlayer; | ||
|
||
public SkinPortRenderPlayer_RPA(boolean smallArms) | ||
{ | ||
super(); | ||
|
||
mainModel = new SkinPortModelPlayer_RPA(0.0F, smallArms); | ||
modelBipedMain = (ModelBiped) mainModel; | ||
modelPlayer = (SkinPortModelPlayer_RPA) mainModel; | ||
} | ||
|
||
@Override | ||
public void doRender(AbstractClientPlayer p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) | ||
{ | ||
boolean smHeadwear = modelPlayer.bipedHeadwear.showModel; | ||
boolean smLeftLegwear = modelPlayer.bipedLeftLegwear.showModel; | ||
boolean smRightLegwear = modelPlayer.bipedRightLegwear.showModel; | ||
boolean smLeftArmwear = modelPlayer.bipedLeftArmwear.showModel; | ||
boolean smRightArmwear = modelPlayer.bipedRightArmwear.showModel; | ||
boolean smBodyWear = modelPlayer.bipedBodyWear.showModel; | ||
boolean smCloak = modelPlayer.bipedCloak.showModel; | ||
|
||
int flags = SkinPort.clientCache.getUnchecked(p_76986_1_.getUniqueID()); | ||
if (modelPlayer.bipedHeadwear.showModel) | ||
modelPlayer.bipedHeadwear.showModel = SkinCustomization.contains(flags, SkinCustomization.hat); | ||
if (modelPlayer.bipedLeftLegwear.showModel) | ||
modelPlayer.bipedLeftLegwear.showModel = SkinCustomization.contains(flags, SkinCustomization.left_pants_leg); | ||
if (modelPlayer.bipedRightLegwear.showModel) | ||
modelPlayer.bipedRightLegwear.showModel = SkinCustomization.contains(flags, SkinCustomization.right_pants_leg); | ||
if (modelPlayer.bipedLeftArmwear.showModel) | ||
modelPlayer.bipedLeftArmwear.showModel = SkinCustomization.contains(flags, SkinCustomization.left_sleeve); | ||
if (modelPlayer.bipedRightArmwear.showModel) | ||
modelPlayer.bipedRightArmwear.showModel = SkinCustomization.contains(flags, SkinCustomization.right_sleeve); | ||
if (modelPlayer.bipedBodyWear.showModel) | ||
modelPlayer.bipedBodyWear.showModel = SkinCustomization.contains(flags, SkinCustomization.jacket); | ||
if (modelPlayer.bipedCloak.showModel) | ||
modelPlayer.bipedCloak.showModel = SkinCustomization.contains(flags, SkinCustomization.cape); | ||
|
||
super.doRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); | ||
|
||
modelPlayer.bipedHeadwear.showModel = smHeadwear; | ||
modelPlayer.bipedLeftLegwear.showModel = smLeftLegwear; | ||
modelPlayer.bipedRightLegwear.showModel = smRightLegwear; | ||
modelPlayer.bipedLeftArmwear.showModel = smLeftArmwear; | ||
modelPlayer.bipedRightArmwear.showModel = smRightArmwear; | ||
modelPlayer.bipedBodyWear.showModel = smBodyWear; | ||
modelPlayer.bipedCloak.showModel = smCloak; | ||
} | ||
|
||
@Override | ||
protected ResourceLocation getEntityTexture(AbstractClientPlayer player) | ||
{ | ||
ISkin skin = SkinProviderAPI.getSkin(player); | ||
if (!skin.isSkinReady()) | ||
skin = SkinProviderAPI.getDefaultSkin(player); | ||
return skin.getSkinLocation(); | ||
} | ||
|
||
@Override | ||
protected void renderEquippedItems(AbstractClientPlayer p_77029_1_, float p_77029_2_) | ||
{ | ||
boolean smHeadwear = modelPlayer.bipedHeadwear.showModel; | ||
boolean smLeftLegwear = modelPlayer.bipedLeftLegwear.showModel; | ||
boolean smRightLegwear = modelPlayer.bipedRightLegwear.showModel; | ||
boolean smLeftArmwear = modelPlayer.bipedLeftArmwear.showModel; | ||
boolean smRightArmwear = modelPlayer.bipedRightArmwear.showModel; | ||
boolean smBodyWear = modelPlayer.bipedBodyWear.showModel; | ||
boolean smCloak = modelPlayer.bipedCloak.showModel; | ||
|
||
int flags = SkinPort.clientCache.getUnchecked(p_77029_1_.getUniqueID()); | ||
if (modelPlayer.bipedHeadwear.showModel) | ||
modelPlayer.bipedHeadwear.showModel = SkinCustomization.contains(flags, SkinCustomization.hat); | ||
if (modelPlayer.bipedLeftLegwear.showModel) | ||
modelPlayer.bipedLeftLegwear.showModel = SkinCustomization.contains(flags, SkinCustomization.left_pants_leg); | ||
if (modelPlayer.bipedRightLegwear.showModel) | ||
modelPlayer.bipedRightLegwear.showModel = SkinCustomization.contains(flags, SkinCustomization.right_pants_leg); | ||
if (modelPlayer.bipedLeftArmwear.showModel) | ||
modelPlayer.bipedLeftArmwear.showModel = SkinCustomization.contains(flags, SkinCustomization.left_sleeve); | ||
if (modelPlayer.bipedRightArmwear.showModel) | ||
modelPlayer.bipedRightArmwear.showModel = SkinCustomization.contains(flags, SkinCustomization.right_sleeve); | ||
if (modelPlayer.bipedBodyWear.showModel) | ||
modelPlayer.bipedBodyWear.showModel = SkinCustomization.contains(flags, SkinCustomization.jacket); | ||
if (modelPlayer.bipedCloak.showModel) | ||
modelPlayer.bipedCloak.showModel = SkinCustomization.contains(flags, SkinCustomization.cape); | ||
|
||
super.renderEquippedItems(p_77029_1_, p_77029_2_); | ||
|
||
modelPlayer.bipedHeadwear.showModel = smHeadwear; | ||
modelPlayer.bipedLeftLegwear.showModel = smLeftLegwear; | ||
modelPlayer.bipedRightLegwear.showModel = smRightLegwear; | ||
modelPlayer.bipedLeftArmwear.showModel = smLeftArmwear; | ||
modelPlayer.bipedRightArmwear.showModel = smRightArmwear; | ||
modelPlayer.bipedBodyWear.showModel = smBodyWear; | ||
modelPlayer.bipedCloak.showModel = smCloak; | ||
} | ||
|
||
@Override | ||
public void renderFirstPersonArm(EntityPlayer player) | ||
{ | ||
boolean smHeadwear = modelPlayer.bipedHeadwear.showModel; | ||
boolean smLeftLegwear = modelPlayer.bipedLeftLegwear.showModel; | ||
boolean smRightLegwear = modelPlayer.bipedRightLegwear.showModel; | ||
boolean smLeftArmwear = modelPlayer.bipedLeftArmwear.showModel; | ||
boolean smRightArmwear = modelPlayer.bipedRightArmwear.showModel; | ||
boolean smBodyWear = modelPlayer.bipedBodyWear.showModel; | ||
boolean smCloak = modelPlayer.bipedCloak.showModel; | ||
|
||
int flags = SkinPort.clientCache.getUnchecked(player.getUniqueID()); | ||
if (modelPlayer.bipedHeadwear.showModel) | ||
modelPlayer.bipedHeadwear.showModel = SkinCustomization.contains(flags, SkinCustomization.hat); | ||
if (modelPlayer.bipedLeftLegwear.showModel) | ||
modelPlayer.bipedLeftLegwear.showModel = SkinCustomization.contains(flags, SkinCustomization.left_pants_leg); | ||
if (modelPlayer.bipedRightLegwear.showModel) | ||
modelPlayer.bipedRightLegwear.showModel = SkinCustomization.contains(flags, SkinCustomization.right_pants_leg); | ||
if (modelPlayer.bipedLeftArmwear.showModel) | ||
modelPlayer.bipedLeftArmwear.showModel = SkinCustomization.contains(flags, SkinCustomization.left_sleeve); | ||
if (modelPlayer.bipedRightArmwear.showModel) | ||
modelPlayer.bipedRightArmwear.showModel = SkinCustomization.contains(flags, SkinCustomization.right_sleeve); | ||
if (modelPlayer.bipedBodyWear.showModel) | ||
modelPlayer.bipedBodyWear.showModel = SkinCustomization.contains(flags, SkinCustomization.jacket); | ||
if (modelPlayer.bipedCloak.showModel) | ||
modelPlayer.bipedCloak.showModel = SkinCustomization.contains(flags, SkinCustomization.cape); | ||
|
||
// #blameMojang | ||
Minecraft.getMinecraft().getTextureManager().bindTexture(getEntityTexture(player)); | ||
|
||
modelPlayer.isRiding = modelPlayer.isSneak = false; | ||
super.renderFirstPersonArm(player); | ||
|
||
modelPlayer.bipedHeadwear.showModel = smHeadwear; | ||
modelPlayer.bipedLeftLegwear.showModel = smLeftLegwear; | ||
modelPlayer.bipedRightLegwear.showModel = smRightLegwear; | ||
modelPlayer.bipedLeftArmwear.showModel = smLeftArmwear; | ||
modelPlayer.bipedRightArmwear.showModel = smRightArmwear; | ||
modelPlayer.bipedBodyWear.showModel = smBodyWear; | ||
modelPlayer.bipedCloak.showModel = smCloak; | ||
} | ||
|
||
} |