58 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.client.model;
 | |
| 
 | |
| import net.fabricmc.api.EnvType;
 | |
| import net.fabricmc.api.Environment;
 | |
| import net.minecraft.client.model.geom.ModelPart;
 | |
| import net.minecraft.client.model.geom.PartPose;
 | |
| import net.minecraft.client.model.geom.builders.CubeListBuilder;
 | |
| import net.minecraft.client.model.geom.builders.LayerDefinition;
 | |
| import net.minecraft.client.model.geom.builders.MeshDefinition;
 | |
| import net.minecraft.client.model.geom.builders.PartDefinition;
 | |
| import net.minecraft.client.renderer.RenderType;
 | |
| import net.minecraft.core.Direction;
 | |
| import net.minecraft.util.Mth;
 | |
| import net.minecraft.world.level.block.entity.BellBlockEntity;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public class BellModel extends Model {
 | |
| 	private static final String BELL_BODY = "bell_body";
 | |
| 	private final ModelPart bellBody;
 | |
| 
 | |
| 	public BellModel(ModelPart root) {
 | |
| 		super(root, RenderType::entitySolid);
 | |
| 		this.bellBody = root.getChild("bell_body");
 | |
| 	}
 | |
| 
 | |
| 	public static LayerDefinition createBodyLayer() {
 | |
| 		MeshDefinition meshDefinition = new MeshDefinition();
 | |
| 		PartDefinition partDefinition = meshDefinition.getRoot();
 | |
| 		PartDefinition partDefinition2 = partDefinition.addOrReplaceChild(
 | |
| 			"bell_body", CubeListBuilder.create().texOffs(0, 0).addBox(-3.0F, -6.0F, -3.0F, 6.0F, 7.0F, 6.0F), PartPose.offset(8.0F, 12.0F, 8.0F)
 | |
| 		);
 | |
| 		partDefinition2.addOrReplaceChild(
 | |
| 			"bell_base", CubeListBuilder.create().texOffs(0, 13).addBox(4.0F, 4.0F, 4.0F, 8.0F, 2.0F, 8.0F), PartPose.offset(-8.0F, -12.0F, -8.0F)
 | |
| 		);
 | |
| 		return LayerDefinition.create(meshDefinition, 32, 32);
 | |
| 	}
 | |
| 
 | |
| 	public void setupAnim(BellBlockEntity bell, float partialTick) {
 | |
| 		float f = bell.ticks + partialTick;
 | |
| 		float g = 0.0F;
 | |
| 		float h = 0.0F;
 | |
| 		if (bell.shaking) {
 | |
| 			float i = Mth.sin(f / (float) Math.PI) / (4.0F + f / 3.0F);
 | |
| 			if (bell.clickDirection == Direction.NORTH) {
 | |
| 				g = -i;
 | |
| 			} else if (bell.clickDirection == Direction.SOUTH) {
 | |
| 				g = i;
 | |
| 			} else if (bell.clickDirection == Direction.EAST) {
 | |
| 				h = -i;
 | |
| 			} else if (bell.clickDirection == Direction.WEST) {
 | |
| 				h = i;
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		this.bellBody.xRot = g;
 | |
| 		this.bellBody.zRot = h;
 | |
| 	}
 | |
| }
 |