-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Boundarybreaker/master
clean up renderer, add armor stand support
- Loading branch information
Showing
11 changed files
with
149 additions
and
45 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
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
This file was deleted.
Oops, something went wrong.
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
85 changes: 85 additions & 0 deletions
85
src/main/java/party/lemons/villagerhats/client/VillagerHatModel.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,85 @@ | ||
package party.lemons.villagerhats.client; | ||
|
||
import net.minecraft.client.model.Cuboid; | ||
import net.minecraft.client.render.entity.model.EntityModel; | ||
import net.minecraft.client.render.entity.model.ModelWithHat; | ||
import net.minecraft.client.render.entity.model.ModelWithHead; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.decoration.ArmorStandEntity; | ||
import net.minecraft.entity.passive.AbstractTraderEntity; | ||
import net.minecraft.util.math.MathHelper; | ||
|
||
public class VillagerHatModel<T extends Entity> extends EntityModel<T> implements ModelWithHead, ModelWithHat { | ||
private Cuboid head; | ||
private Cuboid headOverlay; | ||
private Cuboid hat; | ||
|
||
public VillagerHatModel(float scale) { | ||
this(scale, 64, 64); | ||
} | ||
|
||
public VillagerHatModel(float scale, int u, int v) { | ||
this.head = (new Cuboid(this)).setTextureSize(u, v); | ||
this.head.setRotationPoint(0.0F, 0.0F, 0.0F); | ||
this.head.setTextureOffset(0, 0).addBox(-4.0F, -10.0F, -4.0F, 8, 10, 8, scale); | ||
this.headOverlay = (new Cuboid(this)).setTextureSize(u, v); | ||
this.headOverlay.setRotationPoint(0.0F, 0.0F, 0.0F); | ||
this.headOverlay.setTextureOffset(32, 0).addBox(-4.0F, -10.0F, -4.0F, 8, 10, 8, scale + 0.5F); | ||
this.head.addChild(this.headOverlay); | ||
this.hat = (new Cuboid(this)).setTextureSize(u, v); | ||
this.hat.setRotationPoint(0.0F, 0.0F, 0.0F); | ||
this.hat.setTextureOffset(30, 47).addBox(-8.0F, -8.0F, -6.0F, 16, 16, 1, scale); | ||
this.hat.pitch = -1.5707964F; | ||
this.headOverlay.addChild(this.hat); | ||
} | ||
|
||
@Override | ||
public void setHatVisible(boolean visible) { | ||
this.head.visible = visible; | ||
this.headOverlay.visible = visible; | ||
this.hat.visible = visible; | ||
} | ||
|
||
@Override | ||
public void render(T entity, float float_1, float float_2, float headRoll, float headYaw, float headPitch, float scale) { | ||
this.setAngles(entity, float_1, float_2, headRoll, headYaw, headPitch, scale); | ||
this.head.render(scale); | ||
} | ||
|
||
@Override | ||
public void setAngles(T entity, float float_1, float float_2, float headRoll, float headYaw, float headPitch, float scale) | ||
{ | ||
boolean isRollingHead = false; | ||
if (entity instanceof AbstractTraderEntity) | ||
{ | ||
isRollingHead = ((AbstractTraderEntity)entity).getHeadRollingTimeLeft() > 0; | ||
} | ||
|
||
if (entity instanceof ArmorStandEntity) | ||
{ | ||
ArmorStandEntity stand = (ArmorStandEntity) entity; | ||
this.head.yaw = stand.getHeadRotation().getYaw() * 0.017453292F; | ||
this.head.pitch = stand.getHeadRotation().getPitch() * 0.017453292F; | ||
this.head.roll = stand.getHeadRotation().getRoll() * 0.017453292F; | ||
} else | ||
{ | ||
this.head.yaw = headYaw * 0.017453292F; | ||
this.head.pitch = headPitch * 0.017453292F; | ||
if (isRollingHead) | ||
{ | ||
this.head.roll = 0.3F * MathHelper.sin(0.45F * headRoll); | ||
this.head.pitch = 0.4F; | ||
} else | ||
{ | ||
this.head.roll = 0.0F; | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
@Override | ||
public Cuboid getHead() { | ||
return head; | ||
} | ||
} |
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
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
33 changes: 33 additions & 0 deletions
33
src/main/java/party/lemons/villagerhats/mixin/ArmorStandRenderMixin.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,33 @@ | ||
package party.lemons.villagerhats.mixin; | ||
|
||
import net.minecraft.client.render.entity.ArmorStandEntityRenderer; | ||
import net.minecraft.client.render.entity.EntityRenderDispatcher; | ||
import net.minecraft.client.render.entity.LivingEntityRenderer; | ||
import net.minecraft.client.render.entity.model.ArmorStandEntityModel; | ||
import net.minecraft.entity.decoration.ArmorStandEntity; | ||
import net.minecraft.util.Identifier; | ||
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 party.lemons.villagerhats.client.PlayerVillagerHatRenderLayer; | ||
|
||
@Mixin(ArmorStandEntityRenderer.class) | ||
public class ArmorStandRenderMixin extends LivingEntityRenderer<ArmorStandEntity, ArmorStandEntityModel> { | ||
public ArmorStandRenderMixin(EntityRenderDispatcher entityRenderDispatcher_1, ArmorStandEntityModel entityModel_1, float float_1) | ||
{ | ||
super(entityRenderDispatcher_1, entityModel_1, float_1); | ||
} | ||
|
||
@Inject(at = @At("RETURN"), method = "<init>") | ||
public void onConstruct(EntityRenderDispatcher dispatcher, CallbackInfo info) | ||
{ | ||
this.addFeature(new PlayerVillagerHatRenderLayer<>(this)); | ||
} | ||
|
||
@Override | ||
protected Identifier getTexture(ArmorStandEntity armorStandEntity) | ||
{ | ||
return null; | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"mixins": [ | ||
], | ||
"client": [ | ||
"ArmorStandRenderMixin", | ||
"PlayerRenderMixin" | ||
], | ||
"injectors": { | ||
|