-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for tinted glass light blocking
- Loading branch information
1 parent
21c8ffa
commit cbfd52e
Showing
2 changed files
with
162 additions
and
0 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
161 changes: 161 additions & 0 deletions
161
src/main/java/net/wurstclient/glass/test/TintedGlassLightBlockingTest.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,161 @@ | ||
/* | ||
* Copyright (c) 2019-2025 Wurst-Imperium and contributors. | ||
* | ||
* This source code is subject to the terms of the GNU General Public | ||
* License, version 3. If a copy of the GPL was not distributed with this | ||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt | ||
*/ | ||
package net.wurstclient.glass.test; | ||
|
||
import static net.wurstclient.glass.test.WiModsTestHelper.*; | ||
|
||
public enum TintedGlassLightBlockingTest | ||
{ | ||
; | ||
|
||
public static void testTintedGlassBlocksLightCorrectly() | ||
{ | ||
System.out.println("Testing tinted glass light blocking..."); | ||
String top = "~ ~1 ~4"; | ||
String front = "~ ~ ~3"; | ||
|
||
// Slab on top - should always block light | ||
testSlab(top, "bottom", 0); | ||
testSlab(top, "top", 0); | ||
testSlab(top, "double", 0); | ||
|
||
// Slab in front - should only block light if type is double | ||
testSlab(front, "bottom", 13); | ||
testSlab(front, "top", 13); | ||
testSlab(front, "double", 0); | ||
|
||
// Stairs on top - should always block light | ||
testStairs(top, "south", "bottom", "straight", 0); | ||
testStairs(top, "east", "bottom", "straight", 0); | ||
testStairs(top, "north", "bottom", "straight", 0); | ||
testStairs(top, "west", "bottom", "straight", 0); | ||
testStairs(top, "south", "top", "straight", 0); | ||
testStairs(top, "east", "top", "straight", 0); | ||
testStairs(top, "north", "top", "straight", 0); | ||
testStairs(top, "west", "top", "straight", 0); | ||
testStairs(top, "south", "bottom", "outer_left", 0); | ||
testStairs(top, "east", "bottom", "outer_left", 0); | ||
testStairs(top, "north", "bottom", "outer_left", 0); | ||
testStairs(top, "west", "bottom", "outer_left", 0); | ||
testStairs(top, "south", "top", "outer_left", 0); | ||
testStairs(top, "east", "top", "outer_left", 0); | ||
testStairs(top, "north", "top", "outer_left", 0); | ||
testStairs(top, "west", "top", "outer_left", 0); | ||
testStairs(top, "south", "bottom", "outer_right", 0); | ||
testStairs(top, "east", "bottom", "outer_right", 0); | ||
testStairs(top, "north", "bottom", "outer_right", 0); | ||
testStairs(top, "west", "bottom", "outer_right", 0); | ||
testStairs(top, "south", "top", "outer_right", 0); | ||
testStairs(top, "east", "top", "outer_right", 0); | ||
testStairs(top, "north", "top", "outer_right", 0); | ||
testStairs(top, "west", "top", "outer_right", 0); | ||
testStairs(top, "south", "bottom", "inner_left", 0); | ||
testStairs(top, "east", "bottom", "inner_left", 0); | ||
testStairs(top, "north", "bottom", "inner_left", 0); | ||
testStairs(top, "west", "bottom", "inner_left", 0); | ||
testStairs(top, "south", "top", "inner_left", 0); | ||
testStairs(top, "east", "top", "inner_left", 0); | ||
testStairs(top, "north", "top", "inner_left", 0); | ||
testStairs(top, "west", "top", "inner_left", 0); | ||
testStairs(top, "south", "bottom", "inner_right", 0); | ||
testStairs(top, "east", "bottom", "inner_right", 0); | ||
testStairs(top, "north", "bottom", "inner_right", 0); | ||
testStairs(top, "west", "bottom", "inner_right", 0); | ||
testStairs(top, "south", "top", "inner_right", 0); | ||
testStairs(top, "east", "top", "inner_right", 0); | ||
testStairs(top, "north", "top", "inner_right", 0); | ||
testStairs(top, "west", "top", "inner_right", 0); | ||
|
||
// Straight stairs in front - depends on facing | ||
testStairs(front, "south", "bottom", "straight", 0); | ||
testStairs(front, "east", "bottom", "straight", 13); | ||
testStairs(front, "north", "bottom", "straight", 0); | ||
testStairs(front, "west", "bottom", "straight", 13); | ||
testStairs(front, "south", "top", "straight", 0); | ||
testStairs(front, "east", "top", "straight", 13); | ||
testStairs(front, "north", "top", "straight", 0); | ||
testStairs(front, "west", "top", "straight", 13); | ||
|
||
// Outer stairs in front - should always let light through | ||
testStairs(front, "south", "bottom", "outer_left", 13); | ||
testStairs(front, "east", "bottom", "outer_left", 13); | ||
testStairs(front, "north", "bottom", "outer_left", 13); | ||
testStairs(front, "west", "bottom", "outer_left", 13); | ||
testStairs(front, "south", "top", "outer_left", 13); | ||
testStairs(front, "east", "top", "outer_left", 13); | ||
testStairs(front, "north", "top", "outer_left", 13); | ||
testStairs(front, "west", "top", "outer_left", 13); | ||
testStairs(front, "south", "bottom", "outer_right", 13); | ||
testStairs(front, "east", "bottom", "outer_right", 13); | ||
testStairs(front, "north", "bottom", "outer_right", 13); | ||
testStairs(front, "west", "bottom", "outer_right", 13); | ||
testStairs(front, "south", "top", "outer_right", 13); | ||
testStairs(front, "east", "top", "outer_right", 13); | ||
testStairs(front, "north", "top", "outer_right", 13); | ||
testStairs(front, "west", "top", "outer_right", 13); | ||
|
||
// Inner stairs in front - should always block light | ||
testStairs(front, "south", "bottom", "inner_left", 0); | ||
testStairs(front, "east", "bottom", "inner_left", 0); | ||
testStairs(front, "north", "bottom", "inner_left", 0); | ||
testStairs(front, "west", "bottom", "inner_left", 0); | ||
testStairs(front, "south", "top", "inner_left", 0); | ||
testStairs(front, "east", "top", "inner_left", 0); | ||
testStairs(front, "north", "top", "inner_left", 0); | ||
testStairs(front, "west", "top", "inner_left", 0); | ||
testStairs(front, "south", "bottom", "inner_right", 0); | ||
testStairs(front, "east", "bottom", "inner_right", 0); | ||
testStairs(front, "north", "bottom", "inner_right", 0); | ||
testStairs(front, "west", "bottom", "inner_right", 0); | ||
testStairs(front, "south", "top", "inner_right", 0); | ||
testStairs(front, "east", "top", "inner_right", 0); | ||
testStairs(front, "north", "top", "inner_right", 0); | ||
testStairs(front, "west", "top", "inner_right", 0); | ||
|
||
// Clean up | ||
runChatCommand("fill ~-1 ~ ~3 ~1 ~1 ~5 air"); | ||
clearChat(); | ||
} | ||
|
||
private static void testSlab(String position, String type, int light) | ||
{ | ||
testConfiguration(position, "tinted_glass_slab[type=" + type + "]", | ||
light); | ||
} | ||
|
||
private static void testStairs(String position, String facing, String half, | ||
String shape, int light) | ||
{ | ||
testConfiguration(position, "tinted_glass_stairs[facing=" + facing | ||
+ ",half=" + half + ",shape=" + shape + "]", light); | ||
} | ||
|
||
private static void testConfiguration(String position, String block, | ||
int expectedLightLevel) | ||
{ | ||
runChatCommand("fill ~-1 ~ ~3 ~1 ~1 ~5 tinted_glass"); | ||
runChatCommand("setblock ~ ~ ~4 air"); | ||
runChatCommand("setblock " + position + " mo_glass:" + block); | ||
clearChat(); | ||
assertLightLevel(0, 0, 4, expectedLightLevel); | ||
} | ||
|
||
private static void assertLightLevel(int x, int y, int z, int expected) | ||
{ | ||
int lightLevel = submitAndGet( | ||
mc -> mc.world.getLightLevel(mc.player.getBlockPos().add(x, y, z))); | ||
|
||
if(lightLevel == expected) | ||
return; | ||
|
||
takeScreenshot("FAILED_TEST_expected_light_level_" + expected + "_got_" | ||
+ lightLevel); | ||
throw new RuntimeException("Wrong light level at ~" + x + " ~" + y | ||
+ " ~" + z + ": Expected " + expected + ", got " + lightLevel); | ||
} | ||
} |