Skip to content

Commit

Permalink
add equals & hashcode to statetype
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Dec 27, 2023
1 parent df6d7fa commit 7ff8c40
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import com.github.retrooper.packetevents.protocol.world.MaterialType;
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;

import java.util.Objects;

public class StateType {
private final String name;
private final float blastResistance;
Expand Down Expand Up @@ -112,4 +114,25 @@ public MaterialType getMaterialType() {
public String toString() {
return name;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StateType stateType = (StateType) o;
return Float.compare(blastResistance, stateType.blastResistance) == 0
&& Float.compare(hardness, stateType.hardness) == 0
&& isSolid == stateType.isSolid
&& isBlocking == stateType.isBlocking
&& isAir == stateType.isAir
&& requiresCorrectTool == stateType.requiresCorrectTool
&& exceedsCube == stateType.exceedsCube
&& Objects.equals(name, stateType.name)
&& materialType == stateType.materialType;
}

@Override
public int hashCode() {
return Objects.hash(name, blastResistance, hardness, isSolid, isBlocking, isAir, requiresCorrectTool, exceedsCube, materialType);
}
}

0 comments on commit 7ff8c40

Please sign in to comment.