Sit/src/main/java/one/oth3r/sit/file/SittingBlock.java

45 lines
1.3 KiB
Java
Raw Normal View History

package one.oth3r.sit.file;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
2025-05-04 13:39:34 -05:00
import java.util.Objects;
public class SittingBlock extends CustomBlock {
@SerializedName("sitting-height")
private Double sittingHeight = 0.5;
2024-09-21 20:09:14 -05:00
/**
2024-11-15 13:35:13 -06:00
* gets the sitting height of a block, limiting the size from 0 - 1
2024-09-21 20:09:14 -05:00
* @return the sitting height, clamped
*/
public Double getSittingHeight() {
2024-11-15 13:35:13 -06:00
return Math.max(0f, Math.min(1f, sittingHeight));
}
public SittingBlock() {}
public SittingBlock(ArrayList<String> blockIds, ArrayList<String> blockTags, ArrayList<String> blockStates, Double sittingHeight) {
super(blockIds, blockTags, blockStates);
this.sittingHeight = sittingHeight;
}
2025-02-11 14:51:06 -06:00
public SittingBlock(SittingBlock sittingBlock) {
super(sittingBlock);
this.sittingHeight = sittingBlock.sittingHeight;
}
2025-05-04 13:39:34 -05:00
@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
SittingBlock that = (SittingBlock) o;
return Objects.equals(sittingHeight, that.sittingHeight);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), sittingHeight);
}
}