84 lines
3.8 KiB
Java
84 lines
3.8 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.datafixers.kinds.App
|
|
* com.mojang.datafixers.kinds.Applicative
|
|
* com.mojang.serialization.MapCodec
|
|
* com.mojang.serialization.codecs.RecordCodecBuilder
|
|
* org.joml.Vector3f
|
|
*/
|
|
package net.minecraft.client.renderer.special;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.datafixers.kinds.App;
|
|
import com.mojang.datafixers.kinds.Applicative;
|
|
import com.mojang.serialization.MapCodec;
|
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import net.minecraft.client.model.CopperGolemStatueModel;
|
|
import net.minecraft.client.model.geom.ModelLayerLocation;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
|
import net.minecraft.client.renderer.rendertype.RenderTypes;
|
|
import net.minecraft.client.renderer.special.NoDataSpecialModelRenderer;
|
|
import net.minecraft.client.renderer.special.SpecialModelRenderer;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.world.entity.animal.coppergolem.CopperGolemOxidationLevels;
|
|
import net.minecraft.world.item.ItemDisplayContext;
|
|
import net.minecraft.world.level.block.CopperGolemStatueBlock;
|
|
import net.minecraft.world.level.block.WeatheringCopper;
|
|
import org.joml.Vector3f;
|
|
|
|
public class CopperGolemStatueSpecialRenderer
|
|
implements NoDataSpecialModelRenderer {
|
|
private final CopperGolemStatueModel model;
|
|
private final Identifier texture;
|
|
private static final Map<CopperGolemStatueBlock.Pose, ModelLayerLocation> MODELS = Map.of(CopperGolemStatueBlock.Pose.STANDING, ModelLayers.COPPER_GOLEM, CopperGolemStatueBlock.Pose.SITTING, ModelLayers.COPPER_GOLEM_SITTING, CopperGolemStatueBlock.Pose.STAR, ModelLayers.COPPER_GOLEM_STAR, CopperGolemStatueBlock.Pose.RUNNING, ModelLayers.COPPER_GOLEM_RUNNING);
|
|
|
|
public CopperGolemStatueSpecialRenderer(CopperGolemStatueModel model, Identifier texture) {
|
|
this.model = model;
|
|
this.texture = texture;
|
|
}
|
|
|
|
@Override
|
|
public void submit(ItemDisplayContext type, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, int overlayCoords, boolean hasFoil, int outlineColor) {
|
|
this.positionModel(poseStack);
|
|
submitNodeCollector.submitModel(this.model, Direction.SOUTH, poseStack, RenderTypes.entityCutoutNoCull(this.texture), lightCoords, overlayCoords, -1, null, outlineColor, null);
|
|
}
|
|
|
|
@Override
|
|
public void getExtents(Set<Vector3f> result) {
|
|
PoseStack poseStack = new PoseStack();
|
|
this.positionModel(poseStack);
|
|
this.model.root().getExtentsForGui(poseStack, result);
|
|
}
|
|
|
|
private void positionModel(PoseStack poseStack) {
|
|
poseStack.translate(0.5f, 1.5f, 0.5f);
|
|
poseStack.scale(-1.0f, -1.0f, 1.0f);
|
|
}
|
|
|
|
public record Unbaked(Identifier texture, CopperGolemStatueBlock.Pose pose) implements SpecialModelRenderer.Unbaked
|
|
{
|
|
public static final MapCodec<Unbaked> MAP_CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)Identifier.CODEC.fieldOf("texture").forGetter(Unbaked::texture), (App)CopperGolemStatueBlock.Pose.CODEC.fieldOf("pose").forGetter(Unbaked::pose)).apply((Applicative)i, Unbaked::new));
|
|
|
|
public Unbaked(WeatheringCopper.WeatherState state, CopperGolemStatueBlock.Pose pose) {
|
|
this(CopperGolemOxidationLevels.getOxidationLevel(state).texture(), pose);
|
|
}
|
|
|
|
public MapCodec<Unbaked> type() {
|
|
return MAP_CODEC;
|
|
}
|
|
|
|
@Override
|
|
public SpecialModelRenderer<?> bake(SpecialModelRenderer.BakingContext context) {
|
|
CopperGolemStatueModel model = new CopperGolemStatueModel(context.entityModelSet().bakeLayer(MODELS.get(this.pose)));
|
|
return new CopperGolemStatueSpecialRenderer(model, this.texture);
|
|
}
|
|
}
|
|
}
|
|
|