60 lines
2.8 KiB
Java
60 lines
2.8 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* org.jspecify.annotations.Nullable
|
|
*/
|
|
package net.minecraft.client.renderer.blockentity;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import net.minecraft.client.model.BellModel;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.client.renderer.Sheets;
|
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
|
import net.minecraft.client.renderer.blockentity.state.BellRenderState;
|
|
import net.minecraft.client.renderer.feature.ModelFeatureRenderer;
|
|
import net.minecraft.client.renderer.rendertype.RenderType;
|
|
import net.minecraft.client.renderer.rendertype.RenderTypes;
|
|
import net.minecraft.client.renderer.state.CameraRenderState;
|
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
|
import net.minecraft.client.resources.model.Material;
|
|
import net.minecraft.client.resources.model.MaterialSet;
|
|
import net.minecraft.world.level.block.entity.BellBlockEntity;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import org.jspecify.annotations.Nullable;
|
|
|
|
public class BellRenderer
|
|
implements BlockEntityRenderer<BellBlockEntity, BellRenderState> {
|
|
public static final Material BELL_RESOURCE_LOCATION = Sheets.BLOCK_ENTITIES_MAPPER.defaultNamespaceApply("bell/bell_body");
|
|
private final MaterialSet materials;
|
|
private final BellModel model;
|
|
|
|
public BellRenderer(BlockEntityRendererProvider.Context context) {
|
|
this.materials = context.materials();
|
|
this.model = new BellModel(context.bakeLayer(ModelLayers.BELL));
|
|
}
|
|
|
|
@Override
|
|
public BellRenderState createRenderState() {
|
|
return new BellRenderState();
|
|
}
|
|
|
|
@Override
|
|
public void extractRenderState(BellBlockEntity blockEntity, BellRenderState state, float partialTicks, Vec3 cameraPosition, @Nullable ModelFeatureRenderer.CrumblingOverlay breakProgress) {
|
|
BlockEntityRenderer.super.extractRenderState(blockEntity, state, partialTicks, cameraPosition, breakProgress);
|
|
state.ticks = (float)blockEntity.ticks + partialTicks;
|
|
state.shakeDirection = blockEntity.shaking ? blockEntity.clickDirection : null;
|
|
}
|
|
|
|
@Override
|
|
public void submit(BellRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) {
|
|
BellModel.State modelState = new BellModel.State(state.ticks, state.shakeDirection);
|
|
this.model.setupAnim(modelState);
|
|
RenderType renderType = BELL_RESOURCE_LOCATION.renderType(RenderTypes::entitySolid);
|
|
submitNodeCollector.submitModel(this.model, modelState, poseStack, renderType, state.lightCoords, OverlayTexture.NO_OVERLAY, -1, this.materials.get(BELL_RESOURCE_LOCATION), 0, state.breakProgress);
|
|
}
|
|
}
|
|
|