Skip to content

Commit 0c0eb0c

Browse files
committed
rename DetectionType.ENTITIES -> DetectionType.ENTITY
1 parent 1a08c6a commit 0c0eb0c

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/DistanceDetectorPeripheral.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public final void setDetectionMode(IArguments args) throws LuaException {
5454
} else if (mode instanceof String modeStr) {
5555
detectionType = switch (modeStr.toUpperCase()) {
5656
case "BLOCK" -> DetectionType.BLOCK;
57-
case "ENTITIES" -> DetectionType.ENTITIES;
57+
case "ENTITY" -> DetectionType.ENTITY;
5858
case "BOTH" -> DetectionType.BOTH;
5959
default -> throw new LuaException("Unknown detection mode '" + mode + "'");
6060
};
@@ -67,13 +67,13 @@ public final void setDetectionMode(IArguments args) throws LuaException {
6767
@LuaFunction
6868
public final boolean detectsEntities() {
6969
DetectionType detectionType = getPeripheralOwner().tileEntity.getDetectionType();
70-
return detectionType == DetectionType.ENTITIES || detectionType == DetectionType.BOTH;
70+
return detectionType.detectEntity();
7171
}
7272

7373
@LuaFunction
7474
public final boolean detectsBlocks() {
7575
DetectionType detectionType = getPeripheralOwner().tileEntity.getDetectionType();
76-
return detectionType == DetectionType.BLOCK || detectionType == DetectionType.BOTH;
76+
return detectionType.detectBlock();
7777
}
7878

7979
@LuaFunction
@@ -113,9 +113,24 @@ public final double getMaxRange() {
113113
}
114114

115115
public enum DetectionType {
116-
BLOCK,
117-
ENTITIES,
118-
BOTH
116+
BLOCK(true, false),
117+
ENTITY(false, true),
118+
BOTH(true, true);
119+
120+
private final boolean block, entity;
121+
122+
private DetectionType(boolean block, boolean entity) {
123+
this.block = block;
124+
this.entity = entity;
125+
}
126+
127+
public boolean detectBlock() {
128+
return this.block;
129+
}
130+
131+
public boolean detectEntity() {
132+
return this.entity;
133+
}
119134
}
120135

121136
}

src/main/java/de/srendi/advancedperipherals/common/blocks/blockentities/DistanceDetectorEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public double calculateAndUpdateDistance() {
196196
private HitResult getHitResult(Vec3 to, Vec3 from) {
197197
Level level = this.getLevel();
198198
return switch (this.detectionType) {
199-
case ENTITIES -> HitResultUtil.getEntityHitResult(to, from, level);
199+
case ENTITY -> HitResultUtil.getEntityHitResult(to, from, level);
200200
case BLOCK -> HitResultUtil.getBlockHitResult(to, from, level, this.ignoreTransparent);
201201
default -> HitResultUtil.getHitResult(to, from, level, this.ignoreTransparent);
202202
};

0 commit comments

Comments
 (0)