chore: format code
This commit is contained in:
parent
38a37cd7a9
commit
4acbedbfca
|
@ -8,20 +8,17 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||||
|
|
||||||
@EventBusSubscriber(modid = Ntx4Core.MODID, bus = Bus.MOD, value = {Dist.CLIENT})
|
@EventBusSubscriber(modid = Ntx4Core.MODID, bus = Bus.MOD, value = { Dist.CLIENT })
|
||||||
public class ClientEventHandler {
|
public class ClientEventHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void clientSetup(EntityRenderersEvent.AddLayers event) {
|
public static void clientSetup(EntityRenderersEvent.AddLayers event) {
|
||||||
Ntx4Core.LOGGER.info("Client Setup: adding CosmeticLayer");
|
Ntx4Core.LOGGER.info("Client Setup: adding CosmeticLayer");
|
||||||
for (String skin : event.getSkins()){
|
for (String skin : event.getSkins()) {
|
||||||
Ntx4Core.LOGGER.info("Client Setup: player check");
|
Ntx4Core.LOGGER.info("Client Setup: player check");
|
||||||
if (event.getSkin(skin) instanceof PlayerEntityRenderer render) {
|
if (event.getSkin(skin) instanceof PlayerEntityRenderer render) {
|
||||||
Ntx4Core.LOGGER.info("Client Setup: added CosmeticLayer");
|
Ntx4Core.LOGGER.info("Client Setup: added CosmeticLayer");
|
||||||
render.addFeature(new CosmeticFeatureRenderer(render, skin));
|
render.addFeature(new CosmeticFeatureRenderer(render, skin));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,231 +38,305 @@ import javax.annotation.Nullable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CosmeticArmorRenderer extends BipedEntityModel
|
public class CosmeticArmorRenderer extends BipedEntityModel
|
||||||
implements IGeoRenderer<CosmeticItem>, ModelFetcher<CosmeticItem> {
|
implements IGeoRenderer<CosmeticItem>, ModelFetcher<CosmeticItem> {
|
||||||
|
protected CosmeticItem currentArmorItem;
|
||||||
|
protected LivingEntity entityLiving;
|
||||||
|
protected float widthScale = 1;
|
||||||
|
protected float heightScale = 1;
|
||||||
|
protected Matrix4f dispatchedMat = new Matrix4f();
|
||||||
|
protected Matrix4f renderEarlyMat = new Matrix4f();
|
||||||
|
|
||||||
protected CosmeticItem currentArmorItem;
|
public String headBone = null;
|
||||||
protected LivingEntity entityLiving;
|
public String bodyBone = null;
|
||||||
protected float widthScale = 1;
|
public String rightArmBone = null;
|
||||||
protected float heightScale = 1;
|
public String leftArmBone = null;
|
||||||
protected Matrix4f dispatchedMat = new Matrix4f();
|
public String rightLegBone = null;
|
||||||
protected Matrix4f renderEarlyMat = new Matrix4f();
|
public String leftLegBone = null;
|
||||||
|
|
||||||
public String headBone = null;
|
private final AnimatedGeoModel<CosmeticItem> modelProvider;
|
||||||
public String bodyBone = null;
|
|
||||||
public String rightArmBone = null;
|
|
||||||
public String leftArmBone = null;
|
|
||||||
public String rightLegBone = null;
|
|
||||||
public String leftLegBone = null;
|
|
||||||
|
|
||||||
private final AnimatedGeoModel<CosmeticItem> modelProvider;
|
protected VertexConsumerProvider rtb = null;
|
||||||
|
|
||||||
protected VertexConsumerProvider rtb = null;
|
private IRenderCycle currentModelRenderCycle = EModelRenderCycle.INITIAL;
|
||||||
|
|
||||||
private IRenderCycle currentModelRenderCycle = EModelRenderCycle.INITIAL;
|
{ AnimationController.addModelFetcher(this); }
|
||||||
|
|
||||||
{
|
@Override
|
||||||
AnimationController.addModelFetcher(this);
|
@Nullable
|
||||||
}
|
public IAnimatableModel<CosmeticItem> apply(IAnimatable t) {
|
||||||
|
if (t instanceof CosmeticItem)
|
||||||
|
return this.getGeoModelProvider();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public CosmeticArmorRenderer() {
|
||||||
@Nullable
|
super(MinecraftClient.getInstance().getEntityModelLoader().getModelPart(
|
||||||
public IAnimatableModel<CosmeticItem> apply(IAnimatable t) {
|
EntityModelLayers.PLAYER_INNER_ARMOR
|
||||||
if (t instanceof CosmeticItem) return this.getGeoModelProvider();
|
));
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CosmeticArmorRenderer() {
|
this.modelProvider = new CosmeticModel();
|
||||||
super(MinecraftClient.getInstance().getEntityModelLoader().getModelPart(EntityModelLayers.PLAYER_INNER_ARMOR));
|
}
|
||||||
|
|
||||||
this.modelProvider = new CosmeticModel();
|
@Override
|
||||||
}
|
public void render(
|
||||||
|
MatrixStack poseStack,
|
||||||
|
VertexConsumer buffer,
|
||||||
|
int packedLight,
|
||||||
|
int packedOverlay,
|
||||||
|
float red,
|
||||||
|
float green,
|
||||||
|
float blue,
|
||||||
|
float alpha
|
||||||
|
) {
|
||||||
|
this.render(0, poseStack, buffer, packedLight);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public void render(
|
||||||
public void render(MatrixStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay,
|
float partialTick, MatrixStack poseStack, VertexConsumer buffer, int packedLight
|
||||||
float red, float green, float blue, float alpha) {
|
) {
|
||||||
this.render(0, poseStack, buffer, packedLight);
|
GeoModel model = this.modelProvider.getModel(
|
||||||
}
|
this.modelProvider.getModelLocation(this.currentArmorItem)
|
||||||
|
);
|
||||||
|
AnimationEvent animationEvent = new AnimationEvent(
|
||||||
|
this.currentArmorItem,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
MinecraftClient.getInstance().getTickDelta(),
|
||||||
|
false, // can also be getLastFrameDuration()
|
||||||
|
Arrays.asList(this.entityLiving)
|
||||||
|
);
|
||||||
|
|
||||||
public void render(float partialTick, MatrixStack poseStack, VertexConsumer buffer, int packedLight) {
|
poseStack.push();
|
||||||
GeoModel model = this.modelProvider.getModel(this.modelProvider.getModelLocation(this.currentArmorItem));
|
poseStack.translate(0, 24 / 16F, 0);
|
||||||
AnimationEvent animationEvent = new AnimationEvent(this.currentArmorItem, 0, 0,
|
poseStack.scale(-1, -1, 1);
|
||||||
MinecraftClient.getInstance().getTickDelta(), false, // can also be getLastFrameDuration()
|
|
||||||
Arrays.asList(this.entityLiving));
|
|
||||||
|
|
||||||
poseStack.push();
|
//this.dispatchedMat = poseStack.last().pose().copy();
|
||||||
poseStack.translate(0, 24 / 16F, 0);
|
|
||||||
poseStack.scale(-1, -1, 1);
|
|
||||||
|
|
||||||
//this.dispatchedMat = poseStack.last().pose().copy();
|
|
||||||
this.dispatchedMat = poseStack.peek().getPositionMatrix().copy();
|
this.dispatchedMat = poseStack.peek().getPositionMatrix().copy();
|
||||||
|
|
||||||
this.modelProvider.setLivingAnimations(this.currentArmorItem, getInstanceId(this.currentArmorItem), animationEvent);
|
this.modelProvider.setLivingAnimations(
|
||||||
setCurrentModelRenderCycle(EModelRenderCycle.INITIAL);
|
this.currentArmorItem, getInstanceId(this.currentArmorItem), animationEvent
|
||||||
fitToBiped();
|
);
|
||||||
RenderSystem.setShaderTexture(0, getTextureLocation(this.currentArmorItem));
|
setCurrentModelRenderCycle(EModelRenderCycle.INITIAL);
|
||||||
|
fitToBiped();
|
||||||
|
RenderSystem.setShaderTexture(0, getTextureLocation(this.currentArmorItem));
|
||||||
|
|
||||||
Color renderColor = getRenderColor(this.currentArmorItem, partialTick, poseStack, null, buffer, packedLight);
|
Color renderColor = getRenderColor(
|
||||||
RenderLayer renderType = getRenderType(this.currentArmorItem, partialTick, poseStack, null, buffer, packedLight,
|
this.currentArmorItem, partialTick, poseStack, null, buffer, packedLight
|
||||||
getTextureLocation(this.currentArmorItem));
|
);
|
||||||
|
RenderLayer renderType = getRenderType(
|
||||||
|
this.currentArmorItem,
|
||||||
|
partialTick,
|
||||||
|
poseStack,
|
||||||
|
null,
|
||||||
|
buffer,
|
||||||
|
packedLight,
|
||||||
|
getTextureLocation(this.currentArmorItem)
|
||||||
|
);
|
||||||
|
|
||||||
render(model, this.currentArmorItem, partialTick, renderType, poseStack, null, buffer, packedLight,
|
render(
|
||||||
OverlayTexture.DEFAULT_UV, renderColor.getRed() / 255f, renderColor.getGreen() / 255f,
|
model,
|
||||||
renderColor.getBlue() / 255f, renderColor.getAlpha() / 255f);
|
this.currentArmorItem,
|
||||||
|
partialTick,
|
||||||
|
renderType,
|
||||||
|
poseStack,
|
||||||
|
null,
|
||||||
|
buffer,
|
||||||
|
packedLight,
|
||||||
|
OverlayTexture.DEFAULT_UV,
|
||||||
|
renderColor.getRed() / 255f,
|
||||||
|
renderColor.getGreen() / 255f,
|
||||||
|
renderColor.getBlue() / 255f,
|
||||||
|
renderColor.getAlpha() / 255f
|
||||||
|
);
|
||||||
|
|
||||||
if (ModList.get().isLoaded("patchouli"))
|
if (ModList.get().isLoaded("patchouli"))
|
||||||
PatchouliCompat.patchouliLoaded(poseStack);
|
PatchouliCompat.patchouliLoaded(poseStack);
|
||||||
|
|
||||||
poseStack.pop();
|
poseStack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderEarly(CosmeticItem animatable, MatrixStack poseStack, float partialTick, VertexConsumerProvider bufferSource,
|
public void renderEarly(
|
||||||
VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue,
|
CosmeticItem animatable,
|
||||||
float alpha) {
|
MatrixStack poseStack,
|
||||||
//this.renderEarlyMat = poseStack.last().pose().copy();
|
float partialTick,
|
||||||
|
VertexConsumerProvider bufferSource,
|
||||||
|
VertexConsumer buffer,
|
||||||
|
int packedLight,
|
||||||
|
int packedOverlay,
|
||||||
|
float red,
|
||||||
|
float green,
|
||||||
|
float blue,
|
||||||
|
float alpha
|
||||||
|
) {
|
||||||
|
//this.renderEarlyMat = poseStack.last().pose().copy();
|
||||||
this.renderEarlyMat = poseStack.peek().getPositionMatrix().copy();
|
this.renderEarlyMat = poseStack.peek().getPositionMatrix().copy();
|
||||||
this.currentArmorItem = animatable;
|
this.currentArmorItem = animatable;
|
||||||
|
|
||||||
IGeoRenderer.super.renderEarly(animatable, poseStack, partialTick, bufferSource, buffer,
|
IGeoRenderer.super.renderEarly(
|
||||||
packedLight, packedOverlay, red, green, blue, alpha);
|
animatable,
|
||||||
}
|
poseStack,
|
||||||
|
partialTick,
|
||||||
|
bufferSource,
|
||||||
|
buffer,
|
||||||
|
packedLight,
|
||||||
|
packedOverlay,
|
||||||
|
red,
|
||||||
|
green,
|
||||||
|
blue,
|
||||||
|
alpha
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderRecursively(GeoBone bone, MatrixStack poseStack, VertexConsumer buffer, int packedLight,
|
public void renderRecursively(
|
||||||
int packedOverlay, float red, float green, float blue, float alpha) {
|
GeoBone bone,
|
||||||
if (bone.isTrackingXform()) {
|
MatrixStack poseStack,
|
||||||
//Matrix4f poseState = poseStack.last().pose();
|
VertexConsumer buffer,
|
||||||
|
int packedLight,
|
||||||
|
int packedOverlay,
|
||||||
|
float red,
|
||||||
|
float green,
|
||||||
|
float blue,
|
||||||
|
float alpha
|
||||||
|
) {
|
||||||
|
if (bone.isTrackingXform()) {
|
||||||
|
//Matrix4f poseState = poseStack.last().pose();
|
||||||
Matrix4f poseState = poseStack.peek().getPositionMatrix();
|
Matrix4f poseState = poseStack.peek().getPositionMatrix();
|
||||||
Vec3d renderOffset = getRenderOffset(this.currentArmorItem, 1);
|
Vec3d renderOffset = getRenderOffset(this.currentArmorItem, 1);
|
||||||
Matrix4f localMatrix = RenderUtils.invertAndMultiplyMatrices(poseState, this.dispatchedMat);
|
Matrix4f localMatrix
|
||||||
|
= RenderUtils.invertAndMultiplyMatrices(poseState, this.dispatchedMat);
|
||||||
|
|
||||||
bone.setModelSpaceXform(RenderUtils.invertAndMultiplyMatrices(poseState, this.renderEarlyMat));
|
bone.setModelSpaceXform(
|
||||||
//localMatrix.translate(new Vec3f(renderOffset));
|
RenderUtils.invertAndMultiplyMatrices(poseState, this.renderEarlyMat)
|
||||||
|
);
|
||||||
|
//localMatrix.translate(new Vec3f(renderOffset));
|
||||||
localMatrix.addToLastColumn(new Vec3f(renderOffset));
|
localMatrix.addToLastColumn(new Vec3f(renderOffset));
|
||||||
bone.setLocalSpaceXform(localMatrix);
|
bone.setLocalSpaceXform(localMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
IGeoRenderer.super.renderRecursively(bone, poseStack, buffer, packedLight, packedOverlay, red, green, blue,
|
IGeoRenderer.super.renderRecursively(
|
||||||
alpha);
|
bone, poseStack, buffer, packedLight, packedOverlay, red, green, blue, alpha
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public Vec3d getRenderOffset(CosmeticItem entity, float partialTick) {
|
public Vec3d getRenderOffset(CosmeticItem entity, float partialTick) {
|
||||||
return Vec3d.ZERO;
|
return Vec3d.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fitToBiped() {
|
protected void fitToBiped() {
|
||||||
if (this.headBone != null) {
|
if (this.headBone != null) {
|
||||||
IBone headBone = this.modelProvider.getBone(this.headBone);
|
IBone headBone = this.modelProvider.getBone(this.headBone);
|
||||||
|
|
||||||
GeoUtils.copyRotations(this.head, headBone);
|
GeoUtils.copyRotations(this.head, headBone);
|
||||||
headBone.setPositionX(this.head.pivotX);
|
headBone.setPositionX(this.head.pivotX);
|
||||||
headBone.setPositionY(-this.head.pivotY);
|
headBone.setPositionY(-this.head.pivotY);
|
||||||
headBone.setPositionZ(this.head.pivotZ);
|
headBone.setPositionZ(this.head.pivotZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.bodyBone != null) {
|
if (this.bodyBone != null) {
|
||||||
IBone bodyBone = this.modelProvider.getBone(this.bodyBone);
|
IBone bodyBone = this.modelProvider.getBone(this.bodyBone);
|
||||||
|
|
||||||
GeoUtils.copyRotations(this.body, bodyBone);
|
GeoUtils.copyRotations(this.body, bodyBone);
|
||||||
bodyBone.setPositionX(this.body.pivotX);
|
bodyBone.setPositionX(this.body.pivotX);
|
||||||
bodyBone.setPositionY(-this.body.pivotY);
|
bodyBone.setPositionY(-this.body.pivotY);
|
||||||
bodyBone.setPositionZ(this.body.pivotZ);
|
bodyBone.setPositionZ(this.body.pivotZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.rightArmBone != null) {
|
if (this.rightArmBone != null) {
|
||||||
IBone rightArmBone = this.modelProvider.getBone(this.rightArmBone);
|
IBone rightArmBone = this.modelProvider.getBone(this.rightArmBone);
|
||||||
|
|
||||||
GeoUtils.copyRotations(this.rightArm, rightArmBone);
|
GeoUtils.copyRotations(this.rightArm, rightArmBone);
|
||||||
rightArmBone.setPositionX(this.rightArm.pivotX + 5);
|
rightArmBone.setPositionX(this.rightArm.pivotX + 5);
|
||||||
rightArmBone.setPositionY(2 - this.rightArm.pivotY);
|
rightArmBone.setPositionY(2 - this.rightArm.pivotY);
|
||||||
rightArmBone.setPositionZ(this.rightArm.pivotZ);
|
rightArmBone.setPositionZ(this.rightArm.pivotZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.leftArmBone != null) {
|
if (this.leftArmBone != null) {
|
||||||
IBone leftArmBone = this.modelProvider.getBone(this.leftArmBone);
|
IBone leftArmBone = this.modelProvider.getBone(this.leftArmBone);
|
||||||
|
|
||||||
GeoUtils.copyRotations(this.leftArm, leftArmBone);
|
GeoUtils.copyRotations(this.leftArm, leftArmBone);
|
||||||
leftArmBone.setPositionX(this.leftArm.pivotX - 5);
|
leftArmBone.setPositionX(this.leftArm.pivotX - 5);
|
||||||
leftArmBone.setPositionY(2 - this.leftArm.pivotY);
|
leftArmBone.setPositionY(2 - this.leftArm.pivotY);
|
||||||
leftArmBone.setPositionZ(this.leftArm.pivotZ);
|
leftArmBone.setPositionZ(this.leftArm.pivotZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.rightLegBone != null) {
|
if (this.rightLegBone != null) {
|
||||||
IBone rightLegBone = this.modelProvider.getBone(this.rightLegBone);
|
IBone rightLegBone = this.modelProvider.getBone(this.rightLegBone);
|
||||||
|
|
||||||
GeoUtils.copyRotations(this.rightLeg, rightLegBone);
|
GeoUtils.copyRotations(this.rightLeg, rightLegBone);
|
||||||
rightLegBone.setPositionX(this.rightLeg.pivotX + 2);
|
rightLegBone.setPositionX(this.rightLeg.pivotX + 2);
|
||||||
rightLegBone.setPositionY(12 - this.rightLeg.pivotY);
|
rightLegBone.setPositionY(12 - this.rightLeg.pivotY);
|
||||||
rightLegBone.setPositionZ(this.rightLeg.pivotZ);
|
rightLegBone.setPositionZ(this.rightLeg.pivotZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.leftLegBone != null) {
|
if (this.leftLegBone != null) {
|
||||||
IBone leftLegBone = this.modelProvider.getBone(this.leftLegBone);
|
IBone leftLegBone = this.modelProvider.getBone(this.leftLegBone);
|
||||||
|
|
||||||
GeoUtils.copyRotations(this.leftLeg, leftLegBone);
|
GeoUtils.copyRotations(this.leftLeg, leftLegBone);
|
||||||
leftLegBone.setPositionX(this.leftLeg.pivotX - 2);
|
leftLegBone.setPositionX(this.leftLeg.pivotX - 2);
|
||||||
leftLegBone.setPositionY(12 - this.leftLeg.pivotY);
|
leftLegBone.setPositionY(12 - this.leftLeg.pivotY);
|
||||||
leftLegBone.setPositionZ(this.leftLeg.pivotZ);
|
leftLegBone.setPositionZ(this.leftLeg.pivotZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnimatedGeoModel<CosmeticItem> getGeoModelProvider() {
|
public AnimatedGeoModel<CosmeticItem> getGeoModelProvider() {
|
||||||
return this.modelProvider;
|
return this.modelProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailableSince(value = "3.1.24")
|
@AvailableSince(value = "3.1.24")
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public IRenderCycle getCurrentModelRenderCycle() {
|
public IRenderCycle getCurrentModelRenderCycle() {
|
||||||
return this.currentModelRenderCycle;
|
return this.currentModelRenderCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailableSince(value = "3.1.24")
|
@AvailableSince(value = "3.1.24")
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentModelRenderCycle(IRenderCycle currentModelRenderCycle) {
|
public void setCurrentModelRenderCycle(IRenderCycle currentModelRenderCycle) {
|
||||||
this.currentModelRenderCycle = currentModelRenderCycle;
|
this.currentModelRenderCycle = currentModelRenderCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailableSince(value = "3.1.24")
|
@AvailableSince(value = "3.1.24")
|
||||||
@Override
|
@Override
|
||||||
public float getWidthScale(CosmeticItem animatable) {
|
public float getWidthScale(CosmeticItem animatable) {
|
||||||
return this.widthScale;
|
return this.widthScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AvailableSince(value = "3.1.24")
|
@AvailableSince(value = "3.1.24")
|
||||||
@Override
|
@Override
|
||||||
public float getHeightScale(CosmeticItem entity) {
|
public float getHeightScale(CosmeticItem entity) {
|
||||||
return this.heightScale;
|
return this.heightScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier getTextureLocation(CosmeticItem animatable) {
|
public Identifier getTextureLocation(CosmeticItem animatable) {
|
||||||
return this.modelProvider.getTextureLocation(animatable);
|
return this.modelProvider.getTextureLocation(animatable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Everything after this point needs to be called every frame before rendering
|
* Everything after this point needs to be called every frame before rendering
|
||||||
*/
|
*/
|
||||||
public CosmeticArmorRenderer setCurrentItem(LivingEntity entity, CosmeticItem item) {
|
public CosmeticArmorRenderer setCurrentItem(LivingEntity entity, CosmeticItem item) {
|
||||||
this.entityLiving = entity;
|
this.entityLiving = entity;
|
||||||
this.currentArmorItem = item;
|
this.currentArmorItem = item;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CosmeticArmorRenderer applyEntityStats(BipedEntityModel defaultArmor) {
|
public final CosmeticArmorRenderer applyEntityStats(BipedEntityModel defaultArmor) {
|
||||||
this.child = defaultArmor.child;
|
this.child = defaultArmor.child;
|
||||||
this.sneaking = defaultArmor.sneaking;
|
this.sneaking = defaultArmor.sneaking;
|
||||||
this.riding = defaultArmor.riding;
|
this.riding = defaultArmor.riding;
|
||||||
this.rightArmPose = defaultArmor.rightArmPose;
|
this.rightArmPose = defaultArmor.rightArmPose;
|
||||||
this.leftArmPose = defaultArmor.leftArmPose;
|
this.leftArmPose = defaultArmor.leftArmPose;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void filterBones(){
|
public void filterBones() {
|
||||||
this.headBone = getCurrentCosmetic().getHead();
|
this.headBone = getCurrentCosmetic().getHead();
|
||||||
this.bodyBone = getCurrentCosmetic().getBody();
|
this.bodyBone = getCurrentCosmetic().getBody();
|
||||||
this.leftArmBone = getCurrentCosmetic().getLeftArm();
|
this.leftArmBone = getCurrentCosmetic().getLeftArm();
|
||||||
this.rightArmBone = getCurrentCosmetic().getRightArm();
|
this.rightArmBone = getCurrentCosmetic().getRightArm();
|
||||||
|
@ -273,61 +347,69 @@ public class CosmeticArmorRenderer extends BipedEntityModel
|
||||||
|
|
||||||
this.setBoneVisibility(this.headBone, getCurrentCosmetic().getHead() != null);
|
this.setBoneVisibility(this.headBone, getCurrentCosmetic().getHead() != null);
|
||||||
this.setBoneVisibility(this.bodyBone, getCurrentCosmetic().getBody() != null);
|
this.setBoneVisibility(this.bodyBone, getCurrentCosmetic().getBody() != null);
|
||||||
this.setBoneVisibility(this.leftArmBone, getCurrentCosmetic().getLeftArm() != null);
|
this.setBoneVisibility(
|
||||||
this.setBoneVisibility(this.rightArmBone, getCurrentCosmetic().getRightArm() != null);
|
this.leftArmBone, getCurrentCosmetic().getLeftArm() != null
|
||||||
this.setBoneVisibility(this.leftLegBone, getCurrentCosmetic().getLeftLeg() != null);
|
);
|
||||||
this.setBoneVisibility(this.rightLegBone, getCurrentCosmetic().getRightLeg() != null);
|
this.setBoneVisibility(
|
||||||
|
this.rightArmBone, getCurrentCosmetic().getRightArm() != null
|
||||||
|
);
|
||||||
|
this.setBoneVisibility(
|
||||||
|
this.leftLegBone, getCurrentCosmetic().getLeftLeg() != null
|
||||||
|
);
|
||||||
|
this.setBoneVisibility(
|
||||||
|
this.rightLegBone, getCurrentCosmetic().getRightLeg() != null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a specific bone (and its child-bones) to visible or not
|
* Sets a specific bone (and its child-bones) to visible or not
|
||||||
* @param boneName The name of the bone
|
* @param boneName The name of the bone
|
||||||
* @param isVisible Whether the bone should be visible
|
* @param isVisible Whether the bone should be visible
|
||||||
*/
|
*/
|
||||||
protected void setBoneVisibility(String boneName, boolean isVisible) {
|
protected void setBoneVisibility(String boneName, boolean isVisible) {
|
||||||
if (boneName == null)
|
if (boneName == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.modelProvider.getBone(boneName).setHidden(!isVisible);
|
this.modelProvider.getBone(boneName).setHidden(!isVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use {@link CosmeticArmorRenderer#setBoneVisibility(String, boolean)}
|
* Use {@link CosmeticArmorRenderer#setBoneVisibility(String, boolean)}
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
protected IBone getAndHideBone(String boneName) {
|
protected IBone getAndHideBone(String boneName) {
|
||||||
setBoneVisibility(boneName, false);
|
setBoneVisibility(boneName, false);
|
||||||
|
|
||||||
return this.modelProvider.getBone(boneName);
|
return this.modelProvider.getBone(boneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use {@link IGeoRenderer#getInstanceId(Object)}<br>
|
* Use {@link IGeoRenderer#getInstanceId(Object)}<br>
|
||||||
* Remove in 1.20+
|
* Remove in 1.20+
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public Integer getUniqueID(CosmeticItem animatable) {
|
public Integer getUniqueID(CosmeticItem animatable) {
|
||||||
return getInstanceId(animatable);
|
return getInstanceId(animatable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInstanceId(CosmeticItem animatable) {
|
public int getInstanceId(CosmeticItem animatable) {
|
||||||
return Objects.hash(this.currentArmorItem.getCosmetic().getID(), this.entityLiving.getUuid());
|
return Objects.hash(
|
||||||
}
|
this.currentArmorItem.getCosmetic().getID(), this.entityLiving.getUuid()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentRTB(VertexConsumerProvider bufferSource) {
|
public void setCurrentRTB(VertexConsumerProvider bufferSource) {
|
||||||
this.rtb = bufferSource;
|
this.rtb = bufferSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VertexConsumerProvider getCurrentRTB() {
|
public VertexConsumerProvider getCurrentRTB() {
|
||||||
return this.rtb;
|
return this.rtb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICosmetic getCurrentCosmetic() {
|
public ICosmetic getCurrentCosmetic() {
|
||||||
return this.currentArmorItem.getCosmetic();
|
return this.currentArmorItem.getCosmetic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,10 @@ import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||||
import net.minecraft.client.render.item.ItemRenderer;
|
import net.minecraft.client.render.item.ItemRenderer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
|
||||||
public class CosmeticFeatureRenderer extends ArmorFeatureRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>, BipedEntityModel<AbstractClientPlayerEntity>> {
|
public class CosmeticFeatureRenderer extends ArmorFeatureRenderer<
|
||||||
|
AbstractClientPlayerEntity,
|
||||||
|
PlayerEntityModel<AbstractClientPlayerEntity>,
|
||||||
|
BipedEntityModel<AbstractClientPlayerEntity>> {
|
||||||
private static final Map<ICosmetic, CosmeticItem> modelCache = new HashMap<>();
|
private static final Map<ICosmetic, CosmeticItem> modelCache = new HashMap<>();
|
||||||
private static CosmeticArmorRenderer cosmeticRenderer = null;
|
private static CosmeticArmorRenderer cosmeticRenderer = null;
|
||||||
PlayerEntityRenderer renderer;
|
PlayerEntityRenderer renderer;
|
||||||
|
@ -29,24 +31,50 @@ public class CosmeticFeatureRenderer extends ArmorFeatureRenderer<AbstractClient
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrix, VertexConsumerProvider buffer, int light, AbstractClientPlayerEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
|
public void render(
|
||||||
for (ICosmetic c : CosmeticsManager.getCosmeticsForPlayer(player.getUuid())) {
|
MatrixStack matrix,
|
||||||
if (c.readyToRender()) this.renderCosmetic(matrix, buffer, player, light, c, partialTicks);
|
VertexConsumerProvider buffer,
|
||||||
}
|
int light,
|
||||||
|
AbstractClientPlayerEntity player,
|
||||||
|
float limbSwing,
|
||||||
|
float limbSwingAmount,
|
||||||
|
float partialTicks,
|
||||||
|
float ageInTicks,
|
||||||
|
float netHeadYaw,
|
||||||
|
float headPitch
|
||||||
|
) {
|
||||||
|
for (ICosmetic c : CosmeticsManager.getCosmeticsForPlayer(player.getUuid())) {
|
||||||
|
if (c.readyToRender())
|
||||||
|
this.renderCosmetic(matrix, buffer, player, light, c, partialTicks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderCosmetic(MatrixStack matrix, VertexConsumerProvider buffer, AbstractClientPlayerEntity player, int light, ICosmetic cosmetic, float partialTicks) {
|
private void renderCosmetic(
|
||||||
if (cosmeticRenderer == null) cosmeticRenderer = new CosmeticArmorRenderer();
|
MatrixStack matrix,
|
||||||
if (!modelCache.containsKey(cosmetic)) modelCache.put(cosmetic, new CosmeticItem(cosmetic));
|
VertexConsumerProvider buffer,
|
||||||
|
AbstractClientPlayerEntity player,
|
||||||
|
int light,
|
||||||
|
ICosmetic cosmetic,
|
||||||
|
float partialTicks
|
||||||
|
) {
|
||||||
|
if (cosmeticRenderer == null)
|
||||||
|
cosmeticRenderer = new CosmeticArmorRenderer();
|
||||||
|
if (!modelCache.containsKey(cosmetic))
|
||||||
|
modelCache.put(cosmetic, new CosmeticItem(cosmetic));
|
||||||
CosmeticItem item = modelCache.get(cosmetic);
|
CosmeticItem item = modelCache.get(cosmetic);
|
||||||
copyRotations(this.renderer.getModel(), cosmeticRenderer);
|
copyRotations(this.renderer.getModel(), cosmeticRenderer);
|
||||||
cosmeticRenderer.applyEntityStats(this.renderer.getModel());
|
cosmeticRenderer.applyEntityStats(this.renderer.getModel());
|
||||||
cosmeticRenderer.setCurrentItem(player, item);
|
cosmeticRenderer.setCurrentItem(player, item);
|
||||||
cosmeticRenderer.filterBones();
|
cosmeticRenderer.filterBones();
|
||||||
|
|
||||||
VertexConsumer vertex = ItemRenderer.getArmorGlintConsumer(buffer, RenderLayer.getArmorCutoutNoCull(cosmetic.getTextureLocation()), false, false);
|
VertexConsumer vertex = ItemRenderer.getArmorGlintConsumer(
|
||||||
|
buffer,
|
||||||
|
RenderLayer.getArmorCutoutNoCull(cosmetic.getTextureLocation()),
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
cosmeticRenderer.render(partialTicks, matrix, vertex, light);
|
cosmeticRenderer.render(partialTicks, matrix, vertex, light);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyRotations(BipedEntityModel<?> from, BipedEntityModel<?> to) {
|
private static void copyRotations(BipedEntityModel<?> from, BipedEntityModel<?> to) {
|
||||||
copyRotations(from.head, to.head);
|
copyRotations(from.head, to.head);
|
||||||
|
@ -61,5 +89,4 @@ public class CosmeticFeatureRenderer extends ArmorFeatureRenderer<AbstractClient
|
||||||
private static void copyRotations(ModelPart from, ModelPart to) {
|
private static void copyRotations(ModelPart from, ModelPart to) {
|
||||||
to.copyTransform(from);
|
to.copyTransform(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import software.bernie.geckolib3.core.manager.AnimationFactory;
|
||||||
import software.bernie.geckolib3.util.GeckoLibUtil;
|
import software.bernie.geckolib3.util.GeckoLibUtil;
|
||||||
|
|
||||||
public class CosmeticItem implements IAnimatable {
|
public class CosmeticItem implements IAnimatable {
|
||||||
|
|
||||||
private ICosmetic cosmetic = null;
|
private ICosmetic cosmetic = null;
|
||||||
private AnimationBuilder animationBuilder = new AnimationBuilder();
|
private AnimationBuilder animationBuilder = new AnimationBuilder();
|
||||||
|
|
||||||
|
@ -27,11 +26,13 @@ public class CosmeticItem implements IAnimatable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerControllers(AnimationData data) {
|
public void registerControllers(AnimationData data) {
|
||||||
data.addAnimationController(new AnimationController<>(this, "controller", 20, this::predicate));
|
data.addAnimationController(
|
||||||
|
new AnimationController<>(this, "controller", 20, this::predicate)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
|
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AnimationFactory getFactory() {
|
public AnimationFactory getFactory() {
|
||||||
return this.factory;
|
return this.factory;
|
||||||
|
@ -40,5 +41,4 @@ public class CosmeticItem implements IAnimatable {
|
||||||
public ICosmetic getCosmetic() {
|
public ICosmetic getCosmetic() {
|
||||||
return this.cosmetic;
|
return this.cosmetic;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.util.Identifier;
|
||||||
import software.bernie.geckolib3.model.AnimatedGeoModel;
|
import software.bernie.geckolib3.model.AnimatedGeoModel;
|
||||||
|
|
||||||
public class CosmeticModel extends AnimatedGeoModel<CosmeticItem> {
|
public class CosmeticModel extends AnimatedGeoModel<CosmeticItem> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier getAnimationFileLocation(CosmeticItem animatable) {
|
public Identifier getAnimationFileLocation(CosmeticItem animatable) {
|
||||||
return animatable.getCosmetic().getAnimationFileLocation();
|
return animatable.getCosmetic().getAnimationFileLocation();
|
||||||
|
@ -19,6 +18,4 @@ public class CosmeticModel extends AnimatedGeoModel<CosmeticItem> {
|
||||||
public Identifier getTextureLocation(CosmeticItem animatable) {
|
public Identifier getTextureLocation(CosmeticItem animatable) {
|
||||||
return animatable.getCosmetic().getTextureLocation();
|
return animatable.getCosmetic().getTextureLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class CosmeticsManager {
|
public class CosmeticsManager {
|
||||||
|
|
||||||
private static List<ICosmeticProvider> providers = new ArrayList<>();
|
private static List<ICosmeticProvider> providers = new ArrayList<>();
|
||||||
private static Map<UUID, List<ICosmetic>> cosmeticCache = new HashMap<>();
|
private static Map<UUID, List<ICosmetic>> cosmeticCache = new HashMap<>();
|
||||||
private static Set<UUID> activePlayers = new HashSet<>();
|
private static Set<UUID> activePlayers = new HashSet<>();
|
||||||
|
@ -19,7 +18,8 @@ public class CosmeticsManager {
|
||||||
for (ICosmeticProvider provider : providers) {
|
for (ICosmeticProvider provider : providers) {
|
||||||
doRefresh = doRefresh || provider.requestsRefresh();
|
doRefresh = doRefresh || provider.requestsRefresh();
|
||||||
}
|
}
|
||||||
if (!doRefresh) return;
|
if (!doRefresh)
|
||||||
|
return;
|
||||||
cosmeticCache.clear();
|
cosmeticCache.clear();
|
||||||
for (UUID uuid : activePlayers) {
|
for (UUID uuid : activePlayers) {
|
||||||
loadPlayer(uuid);
|
loadPlayer(uuid);
|
||||||
|
@ -27,7 +27,8 @@ public class CosmeticsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadPlayer(UUID player) {
|
private static void loadPlayer(UUID player) {
|
||||||
if (cosmeticCache.containsKey(player)) return;
|
if (cosmeticCache.containsKey(player))
|
||||||
|
return;
|
||||||
cosmeticCache.put(player, new ArrayList<>());
|
cosmeticCache.put(player, new ArrayList<>());
|
||||||
List<ICosmetic> cosmetics = cosmeticCache.get(player);
|
List<ICosmetic> cosmetics = cosmeticCache.get(player);
|
||||||
for (ICosmeticProvider provider : providers) {
|
for (ICosmeticProvider provider : providers) {
|
||||||
|
@ -47,5 +48,4 @@ public class CosmeticsManager {
|
||||||
refresh();
|
refresh();
|
||||||
return cosmeticCache.get(uuid);
|
return cosmeticCache.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.util.Identifier;
|
||||||
import software.bernie.geckolib3.core.builder.AnimationBuilder;
|
import software.bernie.geckolib3.core.builder.AnimationBuilder;
|
||||||
|
|
||||||
public interface ICosmetic {
|
public interface ICosmetic {
|
||||||
|
|
||||||
Identifier getAnimationFileLocation();
|
Identifier getAnimationFileLocation();
|
||||||
|
|
||||||
Identifier getModelLocation();
|
Identifier getModelLocation();
|
||||||
|
@ -40,7 +39,6 @@ public interface ICosmetic {
|
||||||
default boolean readyToRender() {
|
default boolean readyToRender() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier getID();
|
|
||||||
|
|
||||||
|
Identifier getID();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,7 @@ import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public interface ICosmeticProvider {
|
public interface ICosmeticProvider {
|
||||||
|
|
||||||
boolean requestsRefresh();
|
boolean requestsRefresh();
|
||||||
|
|
||||||
void addCosmetics(UUID player, Consumer<ICosmetic> cosmeticAdder);
|
void addCosmetics(UUID player, Consumer<ICosmetic> cosmeticAdder);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class RecipeContainsPredicate implements Predicate<Recipe<?>> {
|
||||||
public boolean test(Recipe<?> r) {
|
public boolean test(Recipe<?> r) {
|
||||||
return r.getIngredients() == null
|
return r.getIngredients() == null
|
||||||
? false
|
? false
|
||||||
: r.getIngredients().stream().anyMatch(new StackIngredientCondition(this.item))
|
: r.getIngredients().stream().anyMatch(new StackIngredientCondition(this.item)
|
||||||
|| r.getOutput().isItemEqual(this.item);
|
) || r.getOutput().isItemEqual(this.item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,12 @@ public class InputReplacements {
|
||||||
ev.mapRecipeID(
|
ev.mapRecipeID(
|
||||||
new Identifier("projecte", "relay_mk1"),
|
new Identifier("projecte", "relay_mk1"),
|
||||||
new InputReplaceRecipeMapper().replace(
|
new InputReplaceRecipeMapper().replace(
|
||||||
"#forge:storage_blocks/diamond",
|
"#forge:storage_blocks/diamond", "mekanism:pellet_antimatter"
|
||||||
"mekanism:pellet_antimatter"
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
var philosopherStoneMapper = new InputReplaceRecipeMapper().replace(
|
var philosopherStoneMapper = new InputReplaceRecipeMapper().replace(
|
||||||
"#forge:gems/diamond",
|
"#forge:gems/diamond", "#ntx4core:darkmatter"
|
||||||
"#ntx4core:darkmatter"
|
|
||||||
);
|
);
|
||||||
ev.mapRecipeID(
|
ev.mapRecipeID(
|
||||||
new Identifier("projecte", "philosophers_stone"), philosopherStoneMapper
|
new Identifier("projecte", "philosophers_stone"), philosopherStoneMapper
|
||||||
|
|
|
@ -27,6 +27,5 @@ public class ShapedRecipes {
|
||||||
.ingredient('C', "mekanism:teleportation_core")
|
.ingredient('C', "mekanism:teleportation_core")
|
||||||
.ingredient('E', "mekanism:energy_tablet")
|
.ingredient('E', "mekanism:energy_tablet")
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue