-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65aa4bc
commit 394e3be
Showing
21 changed files
with
439 additions
and
200 deletions.
There are no files selected for viewing
File renamed without changes.
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
71 changes: 71 additions & 0 deletions
71
loader-common/src/main/java/org/cyclops/cyclopscore/block/multi/DetectionResult.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,71 @@ | ||
package org.cyclops.cyclopscore.block.multi; | ||
|
||
import net.minecraft.core.Vec3i; | ||
import net.minecraft.network.chat.Component; | ||
import org.cyclops.cyclopscore.helper.IModHelpers; | ||
|
||
/** | ||
* Multiblock detection result. | ||
* The `error` field is only available when the size is null, so if the structure was invalid. | ||
* | ||
* @author rubensworks | ||
*/ | ||
public class DetectionResult { | ||
|
||
private final Vec3i size; | ||
private final Component error; | ||
|
||
public DetectionResult(Vec3i size) { | ||
this.size = size; | ||
this.error = null; | ||
} | ||
|
||
public DetectionResult(Component error) { | ||
this.size = IModHelpers.get().getLocationHelpers().copyLocation(Vec3i.ZERO); | ||
this.error = error; | ||
} | ||
|
||
public DetectionResult(String error) { | ||
this(Component.literal(error)); | ||
} | ||
|
||
public Vec3i getSize() { | ||
return this.size; | ||
} | ||
|
||
public Component getError() { | ||
return this.error; | ||
} | ||
|
||
public boolean equals(final Object o) { | ||
if (o == this) return true; | ||
if (!(o instanceof DetectionResult)) return false; | ||
final DetectionResult other = (DetectionResult) o; | ||
if (!other.canEqual((Object) this)) return false; | ||
final Object this$size = this.getSize(); | ||
final Object other$size = other.getSize(); | ||
if (this$size == null ? other$size != null : !this$size.equals(other$size)) return false; | ||
final Object this$error = this.getError(); | ||
final Object other$error = other.getError(); | ||
if (this$error == null ? other$error != null : !this$error.equals(other$error)) return false; | ||
return true; | ||
} | ||
|
||
protected boolean canEqual(final Object other) { | ||
return other instanceof DetectionResult; | ||
} | ||
|
||
public int hashCode() { | ||
final int PRIME = 59; | ||
int result = 1; | ||
final Object $size = this.getSize(); | ||
result = result * PRIME + ($size == null ? 43 : $size.hashCode()); | ||
final Object $error = this.getError(); | ||
result = result * PRIME + ($error == null ? 43 : $error.hashCode()); | ||
return result; | ||
} | ||
|
||
public String toString() { | ||
return "DetectionResult(size=" + this.getSize() + ", error=" + this.getError() + ")"; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...er-common/src/main/java/org/cyclops/cyclopscore/block/multi/ExactBlockCountValidator.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,55 @@ | ||
package org.cyclops.cyclopscore.block.multi; | ||
|
||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.level.block.Block; | ||
|
||
/** | ||
* An exact block count validator. | ||
* | ||
* @author rubensworks | ||
*/ | ||
public class ExactBlockCountValidator implements IBlockCountValidator { | ||
|
||
private final int exactCount; | ||
|
||
public ExactBlockCountValidator(int exactCount) { | ||
this.exactCount = exactCount; | ||
} | ||
|
||
@Override | ||
public Component isValid(int count, boolean structureComplete, Block block) { | ||
if (!structureComplete || count == getExactCount()) { | ||
return null; | ||
} | ||
return Component.translatable("multiblock.cyclopscore.error.blockCount.exact", | ||
getExactCount(), Component.translatable(block.getDescriptionId()), count); | ||
} | ||
|
||
public int getExactCount() { | ||
return this.exactCount; | ||
} | ||
|
||
public boolean equals(final Object o) { | ||
if (o == this) return true; | ||
if (!(o instanceof ExactBlockCountValidator)) return false; | ||
final ExactBlockCountValidator other = (ExactBlockCountValidator) o; | ||
if (!other.canEqual((Object) this)) return false; | ||
if (this.getExactCount() != other.getExactCount()) return false; | ||
return true; | ||
} | ||
|
||
protected boolean canEqual(final Object other) { | ||
return other instanceof ExactBlockCountValidator; | ||
} | ||
|
||
public int hashCode() { | ||
final int PRIME = 59; | ||
int result = 1; | ||
result = result * PRIME + this.getExactCount(); | ||
return result; | ||
} | ||
|
||
public String toString() { | ||
return "ExactBlockCountValidator(exactCount=" + this.getExactCount() + ")"; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
loader-common/src/main/java/org/cyclops/cyclopscore/block/multi/ExactSizeValidator.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,59 @@ | ||
package org.cyclops.cyclopscore.block.multi; | ||
|
||
import net.minecraft.core.Vec3i; | ||
import net.minecraft.network.chat.Component; | ||
import org.cyclops.cyclopscore.helper.IModHelpers; | ||
|
||
/** | ||
* An exact size validator. | ||
* | ||
* @author rubensworks | ||
*/ | ||
public class ExactSizeValidator implements ISizeValidator { | ||
|
||
private final Vec3i exactSize; | ||
|
||
public ExactSizeValidator(Vec3i exactSize) { | ||
this.exactSize = exactSize; | ||
} | ||
|
||
@Override | ||
public Component isSizeValid(Vec3i size) { | ||
if (SizeValidators.compareVec3i(size, getExactSize()) == 0) { | ||
return null; | ||
} | ||
return Component.translatable("multiblock.cyclopscore.error.size.exact", | ||
IModHelpers.get().getLocationHelpers().toCompactString(size.offset(1, 1, 1)), IModHelpers.get().getLocationHelpers().toCompactString(getExactSize().offset(1, 1, 1))); | ||
} | ||
|
||
public Vec3i getExactSize() { | ||
return this.exactSize; | ||
} | ||
|
||
public boolean equals(final Object o) { | ||
if (o == this) return true; | ||
if (!(o instanceof ExactSizeValidator)) return false; | ||
final ExactSizeValidator other = (ExactSizeValidator) o; | ||
if (!other.canEqual((Object) this)) return false; | ||
final Object this$exactSize = this.getExactSize(); | ||
final Object other$exactSize = other.getExactSize(); | ||
if (this$exactSize == null ? other$exactSize != null : !this$exactSize.equals(other$exactSize)) return false; | ||
return true; | ||
} | ||
|
||
protected boolean canEqual(final Object other) { | ||
return other instanceof ExactSizeValidator; | ||
} | ||
|
||
public int hashCode() { | ||
final int PRIME = 59; | ||
int result = 1; | ||
final Object $exactSize = this.getExactSize(); | ||
result = result * PRIME + ($exactSize == null ? 43 : $exactSize.hashCode()); | ||
return result; | ||
} | ||
|
||
public String toString() { | ||
return "ExactSizeValidator(exactSize=" + this.getExactSize() + ")"; | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions
55
...-common/src/main/java/org/cyclops/cyclopscore/block/multi/MaximumBlockCountValidator.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,55 @@ | ||
package org.cyclops.cyclopscore.block.multi; | ||
|
||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.level.block.Block; | ||
|
||
/** | ||
* A maximum block count validator. | ||
* | ||
* @author rubensworks | ||
*/ | ||
public class MaximumBlockCountValidator implements IBlockCountValidator { | ||
|
||
private final int maximumCount; | ||
|
||
public MaximumBlockCountValidator(int maximumCount) { | ||
this.maximumCount = maximumCount; | ||
} | ||
|
||
@Override | ||
public Component isValid(int count, boolean structureComplete, Block block) { | ||
if (count <= getMaximumCount()) { | ||
return null; | ||
} | ||
return Component.translatable("multiblock.cyclopscore.error.blockCount.max", | ||
getMaximumCount(), Component.translatable(block.getDescriptionId()), count); | ||
} | ||
|
||
public int getMaximumCount() { | ||
return this.maximumCount; | ||
} | ||
|
||
public boolean equals(final Object o) { | ||
if (o == this) return true; | ||
if (!(o instanceof MaximumBlockCountValidator)) return false; | ||
final MaximumBlockCountValidator other = (MaximumBlockCountValidator) o; | ||
if (!other.canEqual((Object) this)) return false; | ||
if (this.getMaximumCount() != other.getMaximumCount()) return false; | ||
return true; | ||
} | ||
|
||
protected boolean canEqual(final Object other) { | ||
return other instanceof MaximumBlockCountValidator; | ||
} | ||
|
||
public int hashCode() { | ||
final int PRIME = 59; | ||
int result = 1; | ||
result = result * PRIME + this.getMaximumCount(); | ||
return result; | ||
} | ||
|
||
public String toString() { | ||
return "MaximumBlockCountValidator(maximumCount=" + this.getMaximumCount() + ")"; | ||
} | ||
} |
Oops, something went wrong.