-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature
featureBreakingRestriction
- Refactor cache solution - Refactor renderer util
- Loading branch information
1 parent
a83a3b2
commit b8a4ff5
Showing
22 changed files
with
731 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
src/main/java/top/hendrixshen/tweakmyclient/helper/AreaBox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package top.hendrixshen.tweakmyclient.helper; | ||
|
||
import fi.dy.masa.malilib.util.IntBoundingBox; | ||
import net.minecraft.core.BlockPos; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class AreaBox { | ||
private final int minX; | ||
private final int minY; | ||
private final int minZ; | ||
private final int maxX; | ||
private final int maxY; | ||
private final int maxZ; | ||
|
||
public AreaBox(int x1, int y1, int z1, int x2, int y2, int z2) { | ||
this.minX = Math.min(x1, x2); | ||
this.minY = Math.min(y1, y2); | ||
this.minZ = Math.min(z1, z2); | ||
this.maxX = Math.max(x1, x2); | ||
this.maxY = Math.max(y1, y2); | ||
this.maxZ = Math.max(z1, z2); | ||
} | ||
|
||
public AreaBox(@NotNull BlockPos blockPos1, @NotNull BlockPos blockPos2) { | ||
this(blockPos1.getX(), blockPos1.getY(), blockPos1.getZ(), blockPos2.getX(), blockPos2.getY(), blockPos2.getZ()); | ||
} | ||
|
||
public int getMinX() { | ||
return this.minX; | ||
} | ||
|
||
public int getMinY() { | ||
return this.minY; | ||
} | ||
|
||
public int getMinZ() { | ||
return this.minZ; | ||
} | ||
|
||
public int getMaxX() { | ||
return this.maxX; | ||
} | ||
|
||
public int getMaxY() { | ||
return this.maxY; | ||
} | ||
|
||
public int getMaxZ() { | ||
return this.maxZ; | ||
} | ||
|
||
public boolean contains(int x, int y, int z) { | ||
return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY && z >= this.minZ && z <= this.maxZ; | ||
} | ||
|
||
public boolean contains(@NotNull BlockPos blockPos) { | ||
return this.contains(blockPos.getX(), blockPos.getY(), blockPos.getZ()); | ||
} | ||
|
||
public boolean intersects(@NotNull AreaBox areaBox) { | ||
return this.maxX >= areaBox.minX | ||
&& this.minX <= areaBox.maxX | ||
&& this.maxZ >= areaBox.minZ | ||
&& this.minZ <= areaBox.maxZ | ||
&& this.maxY >= areaBox.minY | ||
&& this.minY <= areaBox.maxY; | ||
} | ||
|
||
public int getXSize() { | ||
return this.maxX - this.minX; | ||
} | ||
|
||
public int getYSize() { | ||
return this.maxY - this.minY; | ||
} | ||
|
||
public int getZSize() { | ||
return this.maxZ - this.minZ; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int prime = 31; | ||
int result = 1; | ||
result = prime * result + this.maxX; | ||
result = prime * result + this.maxY; | ||
result = prime * result + this.maxZ; | ||
result = prime * result + this.minX; | ||
result = prime * result + this.minY; | ||
return prime * result + this.minZ; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} else if (obj instanceof AreaBox) { | ||
AreaBox areaBox = (AreaBox) obj; | ||
if (areaBox.minX != this.minX) { | ||
return false; | ||
} else if (areaBox.minY != this.minY) { | ||
return false; | ||
} else if (areaBox.minZ != this.minZ) { | ||
return false; | ||
} else if (areaBox.maxX != this.maxX) { | ||
return false; | ||
} else if (areaBox.maxY != this.maxY) { | ||
return false; | ||
} else { | ||
return areaBox.maxZ == this.maxZ; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AreaBox[" + this.minX + ", " + this.minY + ", " + this.minZ + "] -> [" + this.maxX + ", " + this.maxY + ", " + this.maxZ + "]"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/top/hendrixshen/tweakmyclient/helper/BreakingRestrictionBoxType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package top.hendrixshen.tweakmyclient.helper; | ||
|
||
import top.hendrixshen.tweakmyclient.util.StringUtil; | ||
|
||
public enum BreakingRestrictionBoxType implements ConfigOptionListEntryApi { | ||
BLACKLIST("blackList"), | ||
WHITELIST("whiteList"); | ||
|
||
private final String name; | ||
|
||
BreakingRestrictionBoxType(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String getStringValue() { | ||
return this.name; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return StringUtil.tr(String.format("label.misc.%s", this.name)); | ||
} | ||
|
||
@Override | ||
public ConfigOptionListEntryApi cycle(boolean forward) { | ||
return ConfigOptionListEntryHelper.cycle(forward, this.ordinal(), BreakingRestrictionBoxType.values()); | ||
} | ||
|
||
@Override | ||
public ConfigOptionListEntryApi fromString(String value) { | ||
return ConfigOptionListEntryHelper.fromString(value, BreakingRestrictionBoxType.WHITELIST, BreakingRestrictionBoxType.values()); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.name; | ||
} | ||
} |
Oops, something went wrong.