generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from boholder/1.20.x-camera-look-straight-up-…
…down [1.20] Camera look straight up down FINISH
- Loading branch information
Showing
14 changed files
with
290 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,11 @@ jobs: | |
- name: Validate Gradle wrapper | ||
uses: gradle/wrapper-validation-action@064a97fb0b4cef86a65f09898c572382f3af10e0 | ||
|
||
- name: Run unit test suite | ||
uses: gradle/[email protected] | ||
with: | ||
arguments: :common:test | ||
|
||
- name: Build Fabric with Gradle | ||
uses: gradle/[email protected] | ||
with: | ||
|
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 |
---|---|---|
|
@@ -38,3 +38,6 @@ run/ | |
|
||
# Ignore Gradle build output directory | ||
build | ||
|
||
# Ignore Gragle test report logs | ||
/common/logs/ |
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
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
24 changes: 22 additions & 2 deletions
24
...rc/main/java/com/github/khanshoaib3/minecraft_access/utils/condition/KeystrokeTiming.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
69 changes: 69 additions & 0 deletions
69
...rc/test/java/com/github/khanshoaib3/minecraft_access/utils/condition/DoubleClickTest.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,69 @@ | ||
package com.github.khanshoaib3.minecraft_access.utils.condition; | ||
|
||
import com.github.khanshoaib3.minecraft_access.MainClass; | ||
import com.github.khanshoaib3.minecraft_access.config.Config; | ||
import com.github.khanshoaib3.minecraft_access.config.ConfigMap; | ||
import com.github.khanshoaib3.minecraft_access.config.config_maps.OtherConfigsMap; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class DoubleClickTest { | ||
@BeforeAll | ||
static void beforeAll() { | ||
ConfigMap mockConfigMap = mock(ConfigMap.class); | ||
when(mockConfigMap.getOtherConfigsMap()).thenReturn(OtherConfigsMap.getDefaultOtherConfigsMap()); | ||
Config mockConfig = mock(Config.class); | ||
when(mockConfig.getConfigMap()).thenReturn(mockConfigMap); | ||
MainClass.config = mockConfig; | ||
} | ||
|
||
@Test | ||
void testCanCountTrigger() { | ||
MockKeystrokeAction m = new MockKeystrokeAction(true); | ||
DoubleClick k = new DoubleClick(m.supplier, Keystroke.TriggeredAt.PRESSING); | ||
|
||
k.updateStateForNextTick(); | ||
assertThat(k.canBeTriggered()).as("there should be one valid count").isTrue(); | ||
|
||
k.updateStateForNextTick(); | ||
assertThat(k.canBeTriggered()).as("once reaches triggered condition, the counter will be cleaned after update").isFalse(); | ||
} | ||
|
||
@Test | ||
void testCanCleanStaleCountIfTimeOut() throws InterruptedException { | ||
MockKeystrokeAction m = new MockKeystrokeAction(true); | ||
MockInterval i = new MockInterval(0, 0); | ||
DoubleClick k = new DoubleClick(m.supplier, Keystroke.TriggeredAt.PRESSING, i); | ||
|
||
// record first keystroke | ||
k.updateStateForNextTick(); | ||
// simulate time passing through the interval | ||
i.setReady(true); | ||
k.updateStateForNextTick(); | ||
|
||
assertThat(k.canBeTriggered()).as("first count should be cleaned").isFalse(); | ||
} | ||
|
||
@Test | ||
void testCanTriggerIfProperlyTriggerAgain() { | ||
MockKeystrokeAction m = new MockKeystrokeAction(true); | ||
MockInterval i = new MockInterval(0, 0); | ||
DoubleClick k = new DoubleClick(m.supplier, Keystroke.TriggeredAt.PRESSING, i); | ||
|
||
// record first keystroke | ||
k.updateStateForNextTick(); | ||
// simulate time passing through the interval | ||
i.setReady(true); | ||
k.updateStateForNextTick(); | ||
assertThat(k.canBeTriggered()).as("first count should be cleaned").isFalse(); | ||
|
||
// third keystroke | ||
i.setReady(false); | ||
k.updateStateForNextTick(); | ||
assertThat(k.canBeTriggered()).as("third keystroke should be regarded as first valid keystroke").isTrue(); | ||
} | ||
} |
Oops, something went wrong.