Spaces:
Build error
Build error
File size: 2,424 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
package net.minecraft.client.model;
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BellModel extends Model {
private static final String BELL_BODY = "bell_body";
private final ModelPart bellBody;
public BellModel(ModelPart p_363820_) {
super(p_363820_, RenderType::entitySolid);
this.bellBody = p_363820_.getChild("bell_body");
}
public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
PartDefinition partdefinition1 = 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)
);
partdefinition1.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 p_368573_, float p_361141_) {
float f = (float)p_368573_.ticks + p_361141_;
float f1 = 0.0F;
float f2 = 0.0F;
if (p_368573_.shaking) {
float f3 = Mth.sin(f / (float) Math.PI) / (4.0F + f / 3.0F);
if (p_368573_.clickDirection == Direction.NORTH) {
f1 = -f3;
} else if (p_368573_.clickDirection == Direction.SOUTH) {
f1 = f3;
} else if (p_368573_.clickDirection == Direction.EAST) {
f2 = -f3;
} else if (p_368573_.clickDirection == Direction.WEST) {
f2 = f3;
}
}
this.bellBody.xRot = f1;
this.bellBody.zRot = f2;
}
} |