Merge branch '1.18.2' of https://github.com/DimensionalDevelopment/Dimdoors into 1.18.2
This commit is contained in:
commit
a91c5c5471
17 changed files with 545 additions and 529 deletions
28
build.gradle
28
build.gradle
|
@ -151,8 +151,8 @@ dependencies {
|
||||||
|
|
||||||
modCompileOnly "curse.maven:worldedit-225608:3559499"
|
modCompileOnly "curse.maven:worldedit-225608:3559499"
|
||||||
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
// testImplementation("junit:junit:4.13.2")
|
||||||
testImplementation("net.devtech:PotatoUnit:1.0.2")
|
// testImplementation("net.devtech:PotatoUnit:1.0.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
version = computeVersion(project.mod_version)
|
version = computeVersion(project.mod_version)
|
||||||
|
@ -213,15 +213,15 @@ curseforge {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
//test {
|
||||||
workingDir = file("test")
|
// workingDir = file("test")
|
||||||
|
//
|
||||||
systemProperty("fabric.dli.config", file(".gradle/loom-cache/launch.cfg").getAbsolutePath())
|
// systemProperty("fabric.dli.config", file(".gradle/loom-cache/launch.cfg").getAbsolutePath())
|
||||||
//useJUnitPlatform()
|
// //useJUnitPlatform()
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
tasks.test.doFirst {test ->
|
//tasks.test.doFirst {test ->
|
||||||
if (!test.workingDir.exists()) {
|
// if (!test.workingDir.exists()) {
|
||||||
test.workingDir.mkdirs();
|
// test.workingDir.mkdirs();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -3,6 +3,11 @@ package org.dimdev.dimdoors.client;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.flowpowered.math.TrigMath;
|
import com.flowpowered.math.TrigMath;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.render.LightmapTextureManager;
|
||||||
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||||
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
|
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
|
||||||
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
|
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
|
||||||
|
@ -17,6 +22,8 @@ import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import org.dimdev.dimdoors.item.ModItems;
|
||||||
|
import org.dimdev.dimdoors.rift.targets.IdMarker;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class DetachedRiftBlockEntityRenderer implements BlockEntityRenderer<DetachedRiftBlockEntity> {
|
public class DetachedRiftBlockEntityRenderer implements BlockEntityRenderer<DetachedRiftBlockEntity> {
|
||||||
|
@ -28,6 +35,15 @@ public class DetachedRiftBlockEntityRenderer implements BlockEntityRenderer<Deta
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(DetachedRiftBlockEntity rift, float tickDelta, MatrixStack matrices, VertexConsumerProvider vcs, int breakProgress, int alpha) {
|
public void render(DetachedRiftBlockEntity rift, float tickDelta, MatrixStack matrices, VertexConsumerProvider vcs, int breakProgress, int alpha) {
|
||||||
|
if(MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().player.getStackInHand(Hand.MAIN_HAND).isOf(ModItems.RIFT_CONFIGURATION_TOOL) && rift.getData().getDestination() instanceof IdMarker idMarker) {
|
||||||
|
matrices.push();
|
||||||
|
matrices.translate(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
|
MinecraftClient.getInstance().textRenderer.draw(Text.of(String.valueOf(idMarker.getId())), 0f,0f, 0xffffffff, false, matrices.peek().getPositionMatrix(), vcs, true, 0x000000, LightmapTextureManager.MAX_LIGHT_COORDINATE);
|
||||||
|
|
||||||
|
matrices.pop();
|
||||||
|
}
|
||||||
|
|
||||||
if (DimensionalDoorsInitializer.getConfig().getGraphicsConfig().showRiftCore) {
|
if (DimensionalDoorsInitializer.getConfig().getGraphicsConfig().showRiftCore) {
|
||||||
this.renderTesseract(vcs.getBuffer(MyRenderLayer.TESSERACT), rift, matrices, tickDelta);
|
this.renderTesseract(vcs.getBuffer(MyRenderLayer.TESSERACT), rift, matrices, tickDelta);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package org.dimdev.dimdoors.client;
|
package org.dimdev.dimdoors.client;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.render.LightmapTextureManager;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
import org.dimdev.dimdoors.api.client.DimensionalPortalRenderer;
|
import org.dimdev.dimdoors.api.client.DimensionalPortalRenderer;
|
||||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||||
|
|
||||||
|
@ -9,11 +13,24 @@ import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import org.dimdev.dimdoors.item.ModItems;
|
||||||
|
import org.dimdev.dimdoors.rift.targets.IdMarker;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class EntranceRiftBlockEntityRenderer implements BlockEntityRenderer<EntranceRiftBlockEntity> {
|
public class EntranceRiftBlockEntityRenderer implements BlockEntityRenderer<EntranceRiftBlockEntity> {
|
||||||
@Override
|
@Override
|
||||||
public void render(EntranceRiftBlockEntity blockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, int overlay) {
|
public void render(EntranceRiftBlockEntity blockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, int overlay) {
|
||||||
|
if (MinecraftClient.getInstance().player != null)
|
||||||
|
if (MinecraftClient.getInstance().player.getStackInHand(Hand.MAIN_HAND).isOf(ModItems.RIFT_CONFIGURATION_TOOL))
|
||||||
|
if (blockEntity.getData().getDestination() instanceof IdMarker idMarker) {
|
||||||
|
matrixStack.push();
|
||||||
|
matrixStack.translate(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
|
MinecraftClient.getInstance().textRenderer.draw(Text.of(String.valueOf(idMarker.getId())), 0f, 0f, 0xffffffff, false, matrixStack.peek().getPositionMatrix(), vertexConsumerProvider, true, 0x000000, LightmapTextureManager.MAX_LIGHT_COORDINATE);
|
||||||
|
|
||||||
|
matrixStack.pop();
|
||||||
|
}
|
||||||
|
|
||||||
DimensionalPortalRenderer.renderDimensionalPortal(matrixStack, vertexConsumerProvider, blockEntity.getTransformer(), tickDelta, light, overlay, blockEntity.isTall());
|
DimensionalPortalRenderer.renderDimensionalPortal(matrixStack, vertexConsumerProvider, blockEntity.getTransformer(), tickDelta, light, overlay, blockEntity.isTall());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
{
|
{
|
||||||
"type": {
|
"type": "dimdoors:limbo",
|
||||||
"ultrawarm": false,
|
|
||||||
"natural": false,
|
|
||||||
"piglin_safe": false,
|
|
||||||
"respawn_anchor_works": false,
|
|
||||||
"bed_works": false,
|
|
||||||
"has_raids": false,
|
|
||||||
"has_skylight": false,
|
|
||||||
"has_ceiling": false,
|
|
||||||
"coordinate_scale": 1,
|
|
||||||
"ambient_light": 0,
|
|
||||||
"logical_height": 256,
|
|
||||||
"infiniburn": "#minecraft:infiniburn_overworld",
|
|
||||||
"effects":"dimdoor:limbo",
|
|
||||||
"min_y": 0,
|
|
||||||
"height": 256
|
|
||||||
},
|
|
||||||
"generator": {
|
"generator": {
|
||||||
"type": "minecraft:noise",
|
"type": "minecraft:noise",
|
||||||
"seed": 42,
|
"seed": 0,
|
||||||
"settings": "dimdoors:limbo",
|
"settings": "dimdoors:limbo",
|
||||||
"biome_source": {
|
"biome_source": {
|
||||||
"type": "minecraft:fixed",
|
"type": "minecraft:fixed",
|
||||||
|
|
|
@ -5,7 +5,6 @@ accessible class net/minecraft/client/render/RenderLayer$MultiPhase
|
||||||
accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters
|
accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters
|
||||||
accessible class net/minecraft/client/render/RenderPhase$Shader
|
accessible class net/minecraft/client/render/RenderPhase$Shader
|
||||||
accessible class net/minecraft/client/render/RenderPhase$Textures
|
accessible class net/minecraft/client/render/RenderPhase$Textures
|
||||||
accessible class net/minecraft/world/gen/feature/ConfiguredFeatures$Decorators
|
|
||||||
accessible method net/minecraft/entity/Entity setRotation (FF)V
|
accessible method net/minecraft/entity/Entity setRotation (FF)V
|
||||||
|
|
||||||
# for MutableBlockEntityType
|
# for MutableBlockEntityType
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
"door_type": "dimdoors:quartz_dimensional_door",
|
"door_type": "dimdoors:quartz_dimensional_door",
|
||||||
"x": "width/2",
|
"x": "width/2",
|
||||||
"facing": "north",
|
"facing": "north",
|
||||||
"y": "5",
|
"y": "0",
|
||||||
"z": "4",
|
"z": "-1",
|
||||||
"type": "dimdoors:door",
|
"type": "dimdoors:door",
|
||||||
"rift_data": {
|
"rift_data": {
|
||||||
"destination": {
|
"destination": {
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
"door_type": "dimdoors:iron_dimensional_door",
|
"door_type": "dimdoors:iron_dimensional_door",
|
||||||
"x": "width/2",
|
"x": "width/2",
|
||||||
"facing": "north",
|
"facing": "north",
|
||||||
"y": "5",
|
"y": "0",
|
||||||
"z": "4",
|
"z": "-1",
|
||||||
"type": "dimdoors:door",
|
"type": "dimdoors:door",
|
||||||
"rift_data": {
|
"rift_data": {
|
||||||
"destination": {
|
"destination": {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package org.dimdev.dimdoors;
|
//package org.dimdev.dimdoors;
|
||||||
|
//
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
|
//
|
||||||
public class MiscellaneousTest {
|
//public class MiscellaneousTest {
|
||||||
@Test
|
// @Test
|
||||||
public void runSomeTestStuff() {
|
// public void runSomeTestStuff() {
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
package org.dimdev.dimdoors.api;
|
//package org.dimdev.dimdoors.api;
|
||||||
|
//
|
||||||
import net.fabricmc.api.ModInitializer;
|
//import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
//import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.Bootstrap;
|
//import net.minecraft.Bootstrap;
|
||||||
import net.minecraft.SharedConstants;
|
//import net.minecraft.SharedConstants;
|
||||||
import net.minecraft.util.registry.Registry;
|
//import net.minecraft.util.registry.Registry;
|
||||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
//import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||||
import org.dimdev.dimdoors.block.door.data.condition.Condition;
|
//import org.dimdev.dimdoors.block.door.data.condition.Condition;
|
||||||
import org.dimdev.dimdoors.pockets.generator.PocketGenerator;
|
//import org.dimdev.dimdoors.pockets.generator.PocketGenerator;
|
||||||
import org.dimdev.dimdoors.pockets.modifier.Modifier;
|
//import org.dimdev.dimdoors.pockets.modifier.Modifier;
|
||||||
import org.dimdev.dimdoors.pockets.virtual.ImplementedVirtualPocket;
|
//import org.dimdev.dimdoors.pockets.virtual.ImplementedVirtualPocket;
|
||||||
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
|
//import org.dimdev.dimdoors.rift.targets.VirtualTarget;
|
||||||
import org.dimdev.dimdoors.world.pocket.type.AbstractPocket;
|
//import org.dimdev.dimdoors.world.pocket.type.AbstractPocket;
|
||||||
import org.dimdev.dimdoors.world.pocket.type.addon.PocketAddon;
|
//import org.dimdev.dimdoors.world.pocket.type.addon.PocketAddon;
|
||||||
import org.dimdev.test.ServerTestRunner;
|
//import org.dimdev.test.ServerTestRunner;
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
//import org.junit.runner.RunWith;
|
||||||
|
//
|
||||||
import static org.junit.Assert.*;
|
//import static org.junit.Assert.*;
|
||||||
|
//
|
||||||
@RunWith(ServerTestRunner.class)
|
//@RunWith(ServerTestRunner.class)
|
||||||
public class DimensionalDoorsApiTest {
|
//public class DimensionalDoorsApiTest {
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void apiTest() {
|
// public void apiTest() {
|
||||||
SharedConstants.createGameVersion();
|
// SharedConstants.createGameVersion();
|
||||||
Bootstrap.initialize();
|
// Bootstrap.initialize();
|
||||||
FabricLoader.getInstance().getEntrypoints("main", ModInitializer.class).stream()
|
// FabricLoader.getInstance().getEntrypoints("main", ModInitializer.class).stream()
|
||||||
.filter(DimensionalDoorsInitializer.class::isInstance)
|
// .filter(DimensionalDoorsInitializer.class::isInstance)
|
||||||
.map(DimensionalDoorsInitializer.class::cast)
|
// .map(DimensionalDoorsInitializer.class::cast)
|
||||||
.forEach(DimensionalDoorsInitializer::onInitialize);
|
// .forEach(DimensionalDoorsInitializer::onInitialize);
|
||||||
|
//
|
||||||
DimDoorsTestApi apiTest = FabricLoader.getInstance().getEntrypoints("dimdoors:api", DimensionalDoorsApi.class).stream()
|
// DimDoorsTestApi apiTest = FabricLoader.getInstance().getEntrypoints("dimdoors:api", DimensionalDoorsApi.class).stream()
|
||||||
.filter(DimDoorsTestApi.class::isInstance)
|
// .filter(DimDoorsTestApi.class::isInstance)
|
||||||
.map(DimDoorsTestApi.class::cast)
|
// .map(DimDoorsTestApi.class::cast)
|
||||||
.findFirst()
|
// .findFirst()
|
||||||
.orElseThrow(RuntimeException::new);
|
// .orElseThrow(RuntimeException::new);
|
||||||
|
//
|
||||||
assertTrue(apiTest.hasCalledRegisterVirtualTargetTypes);
|
// assertTrue(apiTest.hasCalledRegisterVirtualTargetTypes);
|
||||||
assertTrue(apiTest.hasCalledRegisterVirtualSingularPocketTypes);
|
// assertTrue(apiTest.hasCalledRegisterVirtualSingularPocketTypes);
|
||||||
assertTrue(apiTest.hasCalledRegisterModifierTypes);
|
// assertTrue(apiTest.hasCalledRegisterModifierTypes);
|
||||||
assertTrue(apiTest.hasCalledRegisterPocketGeneratorTypes);
|
// assertTrue(apiTest.hasCalledRegisterPocketGeneratorTypes);
|
||||||
assertTrue(apiTest.hasCalledRegisterAbstractPocketTypes);
|
// assertTrue(apiTest.hasCalledRegisterAbstractPocketTypes);
|
||||||
assertTrue(apiTest.hasCalledRegisterPocketAddonTypes);
|
// assertTrue(apiTest.hasCalledRegisterPocketAddonTypes);
|
||||||
assertTrue(apiTest.hasCalledRegisterConditionTypes);
|
// assertTrue(apiTest.hasCalledRegisterConditionTypes);
|
||||||
assertTrue(apiTest.hasCalledPostInitialize);
|
// assertTrue(apiTest.hasCalledPostInitialize);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static class DimDoorsTestApi implements DimensionalDoorsApi {
|
// public static class DimDoorsTestApi implements DimensionalDoorsApi {
|
||||||
private boolean hasCalledRegisterVirtualTargetTypes = false;
|
// private boolean hasCalledRegisterVirtualTargetTypes = false;
|
||||||
private boolean hasCalledRegisterVirtualSingularPocketTypes = false;
|
// private boolean hasCalledRegisterVirtualSingularPocketTypes = false;
|
||||||
private boolean hasCalledRegisterModifierTypes = false;
|
// private boolean hasCalledRegisterModifierTypes = false;
|
||||||
private boolean hasCalledRegisterPocketGeneratorTypes = false;
|
// private boolean hasCalledRegisterPocketGeneratorTypes = false;
|
||||||
private boolean hasCalledRegisterAbstractPocketTypes = false;
|
// private boolean hasCalledRegisterAbstractPocketTypes = false;
|
||||||
private boolean hasCalledRegisterPocketAddonTypes = false;
|
// private boolean hasCalledRegisterPocketAddonTypes = false;
|
||||||
private boolean hasCalledRegisterConditionTypes = false;
|
// private boolean hasCalledRegisterConditionTypes = false;
|
||||||
private boolean hasCalledPostInitialize = false;
|
// private boolean hasCalledPostInitialize = false;
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerVirtualTargetTypes(Registry<VirtualTarget.VirtualTargetType<?>> registry) {
|
// public void registerVirtualTargetTypes(Registry<VirtualTarget.VirtualTargetType<?>> registry) {
|
||||||
hasCalledRegisterVirtualTargetTypes = true;
|
// hasCalledRegisterVirtualTargetTypes = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerVirtualSingularPocketTypes(Registry<ImplementedVirtualPocket.VirtualPocketType<?>> registry) {
|
// public void registerVirtualSingularPocketTypes(Registry<ImplementedVirtualPocket.VirtualPocketType<?>> registry) {
|
||||||
hasCalledRegisterVirtualSingularPocketTypes = true;
|
// hasCalledRegisterVirtualSingularPocketTypes = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerModifierTypes(Registry<Modifier.ModifierType<?>> registry) {
|
// public void registerModifierTypes(Registry<Modifier.ModifierType<?>> registry) {
|
||||||
hasCalledRegisterModifierTypes = true;
|
// hasCalledRegisterModifierTypes = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerPocketGeneratorTypes(Registry<PocketGenerator.PocketGeneratorType<?>> registry) {
|
// public void registerPocketGeneratorTypes(Registry<PocketGenerator.PocketGeneratorType<?>> registry) {
|
||||||
hasCalledRegisterPocketGeneratorTypes = true;
|
// hasCalledRegisterPocketGeneratorTypes = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerAbstractPocketTypes(Registry<AbstractPocket.AbstractPocketType<?>> registry) {
|
// public void registerAbstractPocketTypes(Registry<AbstractPocket.AbstractPocketType<?>> registry) {
|
||||||
hasCalledRegisterAbstractPocketTypes = true;
|
// hasCalledRegisterAbstractPocketTypes = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerPocketAddonTypes(Registry<PocketAddon.PocketAddonType<?>> registry) {
|
// public void registerPocketAddonTypes(Registry<PocketAddon.PocketAddonType<?>> registry) {
|
||||||
hasCalledRegisterPocketAddonTypes = true;
|
// hasCalledRegisterPocketAddonTypes = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void registerConditionTypes(Registry<Condition.ConditionType<?>> registry) {
|
// public void registerConditionTypes(Registry<Condition.ConditionType<?>> registry) {
|
||||||
hasCalledRegisterConditionTypes= true;
|
// hasCalledRegisterConditionTypes= true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void postInitialize() {
|
// public void postInitialize() {
|
||||||
hasCalledPostInitialize = true;
|
// hasCalledPostInitialize = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,52 +1,52 @@
|
||||||
package org.dimdev.dimdoors.api.util.math;
|
//package org.dimdev.dimdoors.api.util.math;
|
||||||
|
//
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
|
//
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
import static org.junit.Assert.*;
|
//import static org.junit.Assert.*;
|
||||||
|
//
|
||||||
public class EquationTest {
|
//public class EquationTest {
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void parseAndApply() throws Equation.EquationParseException {
|
// public void parseAndApply() throws Equation.EquationParseException {
|
||||||
Map<String, Double> empty = new HashMap<>();
|
// Map<String, Double> empty = new HashMap<>();
|
||||||
double expected;
|
// double expected;
|
||||||
String equation;
|
// String equation;
|
||||||
|
//
|
||||||
assertThrows(Equation.EquationParseException.class, () -> Equation.parse("."));
|
// assertThrows(Equation.EquationParseException.class, () -> Equation.parse("."));
|
||||||
|
//
|
||||||
expected = 15d;
|
// expected = 15d;
|
||||||
equation = Double.toString(expected);
|
// equation = Double.toString(expected);
|
||||||
assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
// assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
||||||
|
//
|
||||||
|
//
|
||||||
expected = 4d;
|
// expected = 4d;
|
||||||
equation = "2 + 2";
|
// equation = "2 + 2";
|
||||||
assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
// assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
||||||
|
//
|
||||||
|
//
|
||||||
expected = 1;
|
// expected = 1;
|
||||||
equation = "1 ? 1 : 0";
|
// equation = "1 ? 1 : 0";
|
||||||
assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
// assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
||||||
|
//
|
||||||
expected = 0;
|
// expected = 0;
|
||||||
equation = "0 ? 1 : 0";
|
// equation = "0 ? 1 : 0";
|
||||||
assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
// assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
||||||
|
//
|
||||||
expected = 1;
|
// expected = 1;
|
||||||
equation = (Math.random() + 1d) + "? 1 : 0";
|
// equation = (Math.random() + 1d) + "? 1 : 0";
|
||||||
assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
// assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
||||||
|
//
|
||||||
expected = 1;
|
// expected = 1;
|
||||||
equation = (Math.random() - 1d) + "? 1 : 0";
|
// equation = (Math.random() - 1d) + "? 1 : 0";
|
||||||
assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
// assertEquals(expected, Equation.parse(equation).apply(empty), 0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void parseAndAsBoolean() throws Equation.EquationParseException {
|
// public void parseAndAsBoolean() throws Equation.EquationParseException {
|
||||||
Map<String, Double> empty = new HashMap<>();
|
// Map<String, Double> empty = new HashMap<>();
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
package org.dimdev.dimdoors.api.util.math;
|
//package org.dimdev.dimdoors.api.util.math;
|
||||||
|
//
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
|
//
|
||||||
import static org.junit.Assert.*;
|
//import static org.junit.Assert.*;
|
||||||
|
//
|
||||||
public class GridUtilTest {
|
//public class GridUtilTest {
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void idToGridPos() {
|
// public void idToGridPos() {
|
||||||
GridUtil.GridPos pos;
|
// GridUtil.GridPos pos;
|
||||||
// I scribbled the grid down so I could figure out these tests, lmao
|
// // I scribbled the grid down so I could figure out these tests, lmao
|
||||||
pos = GridUtil.idToGridPos(86);
|
// pos = GridUtil.idToGridPos(86);
|
||||||
assertEquals(new GridUtil.GridPos(8, 1), pos);
|
// assertEquals(new GridUtil.GridPos(8, 1), pos);
|
||||||
pos = GridUtil.idToGridPos(90);
|
// pos = GridUtil.idToGridPos(90);
|
||||||
assertEquals(new GridUtil.GridPos(12, 0), pos);
|
// assertEquals(new GridUtil.GridPos(12, 0), pos);
|
||||||
pos = GridUtil.idToGridPos(100);
|
// pos = GridUtil.idToGridPos(100);
|
||||||
assertEquals(new GridUtil.GridPos(7, 0), pos);
|
// assertEquals(new GridUtil.GridPos(7, 0), pos);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void conversionConsistencyTest() {
|
// public void conversionConsistencyTest() {
|
||||||
for (int i = 0; i < 1000; i++) {
|
// for (int i = 0; i < 1000; i++) {
|
||||||
assertEquals(i, GridUtil.gridPosToID(GridUtil.idToGridPos(i)));
|
// assertEquals(i, GridUtil.gridPosToID(GridUtil.idToGridPos(i)));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,46 +1,46 @@
|
||||||
package org.dimdev.dimdoors.api.util.math;
|
//package org.dimdev.dimdoors.api.util.math;
|
||||||
|
//
|
||||||
import net.minecraft.util.math.Direction;
|
//import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.EulerAngle;
|
//import net.minecraft.util.math.EulerAngle;
|
||||||
import net.minecraft.util.math.Vec3d;
|
//import net.minecraft.util.math.Vec3d;
|
||||||
|
//
|
||||||
import org.dimdev.test.TestUtil;
|
//import org.dimdev.test.TestUtil;
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
|
//
|
||||||
import static org.junit.Assert.*;
|
//import static org.junit.Assert.*;
|
||||||
|
//
|
||||||
public class MathUtilTest {
|
//public class MathUtilTest {
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void eulerAngle() {
|
// public void eulerAngle() {
|
||||||
EulerAngle expected = new EulerAngle(0, 0, 0);
|
// EulerAngle expected = new EulerAngle(0, 0, 0);
|
||||||
|
//
|
||||||
Vec3d direction = new Vec3d(0, 0, 1);
|
// Vec3d direction = new Vec3d(0, 0, 1);
|
||||||
Vec3d upwards = new Vec3d(0, 1, 0);
|
// Vec3d upwards = new Vec3d(0, 1, 0);
|
||||||
EulerAngle angle = MathUtil.eulerAngle(direction, upwards);
|
// EulerAngle angle = MathUtil.eulerAngle(direction, upwards);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
expected = new EulerAngle(-90, 0, 0);
|
// expected = new EulerAngle(-90, 0, 0);
|
||||||
direction = new Vec3d(0, 1, 0);
|
// direction = new Vec3d(0, 1, 0);
|
||||||
upwards = new Vec3d(0, 0, -1);
|
// upwards = new Vec3d(0, 0, -1);
|
||||||
angle = MathUtil.eulerAngle(direction, upwards);
|
// angle = MathUtil.eulerAngle(direction, upwards);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
expected = new EulerAngle(0, -45, 0);
|
// expected = new EulerAngle(0, -45, 0);
|
||||||
direction = new Vec3d(Math.cos(Math.PI / 2), 0, Math.cos(Math.PI / 2));
|
// direction = new Vec3d(Math.cos(Math.PI / 2), 0, Math.cos(Math.PI / 2));
|
||||||
upwards = new Vec3d(0, 1, 0);
|
// upwards = new Vec3d(0, 1, 0);
|
||||||
angle = MathUtil.eulerAngle(direction, upwards);
|
// angle = MathUtil.eulerAngle(direction, upwards);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void directionEulerAngle() {
|
// public void directionEulerAngle() {
|
||||||
for (Direction direction : Direction.values()) {
|
// for (Direction direction : Direction.values()) {
|
||||||
EulerAngle expected = MathUtil.directionEulerAngle(direction);
|
// EulerAngle expected = MathUtil.directionEulerAngle(direction);
|
||||||
Vec3d dir = Vec3d.of(direction.getVector());
|
// Vec3d dir = Vec3d.of(direction.getVector());
|
||||||
EulerAngle angle = new EulerAngle(MathUtil.pitch(dir), MathUtil.yaw(dir), 0);
|
// EulerAngle angle = new EulerAngle(MathUtil.pitch(dir), MathUtil.yaw(dir), 0);
|
||||||
|
//
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,130 +1,130 @@
|
||||||
package org.dimdev.dimdoors.api.util.math;
|
//package org.dimdev.dimdoors.api.util.math;
|
||||||
|
//
|
||||||
import net.minecraft.util.math.EulerAngle;
|
//import net.minecraft.util.math.EulerAngle;
|
||||||
import net.minecraft.util.math.Vec3d;
|
//import net.minecraft.util.math.Vec3d;
|
||||||
|
//
|
||||||
import org.dimdev.test.TestUtil;
|
//import org.dimdev.test.TestUtil;
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
|
//
|
||||||
import static org.junit.Assert.*;
|
//import static org.junit.Assert.*;
|
||||||
|
//
|
||||||
public class TransformationMatrix3dTest {
|
//public class TransformationMatrix3dTest {
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void identity() {
|
// public void identity() {
|
||||||
double[][] matrix = new double[4][4];
|
// double[][] matrix = new double[4][4];
|
||||||
matrix[0] = new double[]{1, 0, 0, 0};
|
// matrix[0] = new double[]{1, 0, 0, 0};
|
||||||
matrix[1] = new double[]{0, 1, 0, 0};
|
// matrix[1] = new double[]{0, 1, 0, 0};
|
||||||
matrix[2] = new double[]{0, 0, 1, 0};
|
// matrix[2] = new double[]{0, 0, 1, 0};
|
||||||
matrix[3] = new double[]{0, 0, 0, 1};
|
// matrix[3] = new double[]{0, 0, 0, 1};
|
||||||
TransformationMatrix3d identity = new TransformationMatrix3d(matrix);
|
// TransformationMatrix3d identity = new TransformationMatrix3d(matrix);
|
||||||
assertEquals(identity, TransformationMatrix3d.identity());
|
// assertEquals(identity, TransformationMatrix3d.identity());
|
||||||
|
//
|
||||||
matrix[3] = new double[]{1, 0, 0, 1};
|
// matrix[3] = new double[]{1, 0, 0, 1};
|
||||||
TransformationMatrix3d matrix3d = new TransformationMatrix3d(matrix);
|
// TransformationMatrix3d matrix3d = new TransformationMatrix3d(matrix);
|
||||||
assertNotEquals(matrix3d, TransformationMatrix3d.identity());
|
// assertNotEquals(matrix3d, TransformationMatrix3d.identity());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void transformVec3d() {
|
// public void transformVec3d() {
|
||||||
// rotate around
|
// // rotate around
|
||||||
Vec3d vector = new Vec3d(1, 0, 0);
|
// Vec3d vector = new Vec3d(1, 0, 0);
|
||||||
Vec3d expected;
|
// Vec3d expected;
|
||||||
TransformationMatrix3d rotate90DegreesY = TransformationMatrix3d.builder().rotateY(Math.PI / 2).build();
|
// TransformationMatrix3d rotate90DegreesY = TransformationMatrix3d.builder().rotateY(Math.PI / 2).build();
|
||||||
|
//
|
||||||
vector = rotate90DegreesY.transform(vector);
|
// vector = rotate90DegreesY.transform(vector);
|
||||||
expected = new Vec3d(0, 0, -1);
|
// expected = new Vec3d(0, 0, -1);
|
||||||
assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
// assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
||||||
|
//
|
||||||
vector = rotate90DegreesY.transform(vector);
|
// vector = rotate90DegreesY.transform(vector);
|
||||||
expected = new Vec3d(-1, 0, 0);
|
// expected = new Vec3d(-1, 0, 0);
|
||||||
assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
// assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
||||||
|
//
|
||||||
vector = rotate90DegreesY.transform(vector);
|
// vector = rotate90DegreesY.transform(vector);
|
||||||
expected = new Vec3d(0, 0, 1);
|
// expected = new Vec3d(0, 0, 1);
|
||||||
assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
// assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
||||||
|
//
|
||||||
vector = rotate90DegreesY.transform(vector);
|
// vector = rotate90DegreesY.transform(vector);
|
||||||
expected = new Vec3d(1, 0, 0);
|
// expected = new Vec3d(1, 0, 0);
|
||||||
assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
// assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
||||||
|
//
|
||||||
TransformationMatrix3d rotate45DegreesY = TransformationMatrix3d.builder().rotateY(Math.PI / 4).build();
|
// TransformationMatrix3d rotate45DegreesY = TransformationMatrix3d.builder().rotateY(Math.PI / 4).build();
|
||||||
|
//
|
||||||
vector = rotate45DegreesY.transform(vector);
|
// vector = rotate45DegreesY.transform(vector);
|
||||||
expected = new Vec3d(Math.cos(Math.PI/4), 0, -Math.sin(Math.PI/4));
|
// expected = new Vec3d(Math.cos(Math.PI/4), 0, -Math.sin(Math.PI/4));
|
||||||
assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
// assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
||||||
|
//
|
||||||
double random = Math.random()*2*Math.PI;
|
// double random = Math.random()*2*Math.PI;
|
||||||
expected = new Vec3d(Math.cos(random), 0, -Math.sin(random));
|
// expected = new Vec3d(Math.cos(random), 0, -Math.sin(random));
|
||||||
TransformationMatrix3d.TransformationMatrix3dBuilder builder = TransformationMatrix3d.builder()
|
// TransformationMatrix3d.TransformationMatrix3dBuilder builder = TransformationMatrix3d.builder()
|
||||||
.rotate(new EulerAngle((((float) Math.random()) - 0.5F) * 180, (((float) Math.random()) - 0.5F) * 360, (((float) Math.random()) - 0.5F) * 360))
|
// .rotate(new EulerAngle((((float) Math.random()) - 0.5F) * 180, (((float) Math.random()) - 0.5F) * 360, (((float) Math.random()) - 0.5F) * 360))
|
||||||
.translate(new Vec3d(Math.random()*100, Math.random()*100, Math.random()*100))
|
// .translate(new Vec3d(Math.random()*100, Math.random()*100, Math.random()*100))
|
||||||
.rotate(new EulerAngle((((float) Math.random()) - 0.5F) * 180, (((float) Math.random()) - 0.5F) * 360, (((float) Math.random()) - 0.5F) * 360))
|
// .rotate(new EulerAngle((((float) Math.random()) - 0.5F) * 180, (((float) Math.random()) - 0.5F) * 360, (((float) Math.random()) - 0.5F) * 360))
|
||||||
.translate(new Vec3d(Math.random()*100, Math.random()*100, Math.random()*100));
|
// .translate(new Vec3d(Math.random()*100, Math.random()*100, Math.random()*100));
|
||||||
|
//
|
||||||
vector = builder.buildReverse().transform(builder.build().transform(expected));
|
// vector = builder.buildReverse().transform(builder.build().transform(expected));
|
||||||
assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
// assertTrue(TestUtil.expectedActual(expected, vector), TestUtil.closeEnough(expected, vector));
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void transformEulerAngle() {
|
// public void transformEulerAngle() {
|
||||||
EulerAngle expected;
|
// EulerAngle expected;
|
||||||
EulerAngle angle;
|
// EulerAngle angle;
|
||||||
|
//
|
||||||
TransformationMatrix3d identity = TransformationMatrix3d.identity();
|
// TransformationMatrix3d identity = TransformationMatrix3d.identity();
|
||||||
|
//
|
||||||
expected = new EulerAngle(0, 0, 0);
|
// expected = new EulerAngle(0, 0, 0);
|
||||||
angle = identity.transform(expected);
|
// angle = identity.transform(expected);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
expected = new EulerAngle(90, 0, 0);
|
// expected = new EulerAngle(90, 0, 0);
|
||||||
angle = identity.transform(expected);
|
// angle = identity.transform(expected);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
expected = new EulerAngle(0, 90, 0);
|
// expected = new EulerAngle(0, 90, 0);
|
||||||
angle = identity.transform(expected);
|
// angle = identity.transform(expected);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
expected = new EulerAngle(0, 0, 90);
|
// expected = new EulerAngle(0, 0, 90);
|
||||||
angle = identity.transform(expected);
|
// angle = identity.transform(expected);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
expected = new EulerAngle(90, 90, 90);
|
// expected = new EulerAngle(90, 90, 90);
|
||||||
angle = identity.transform(expected);
|
// angle = identity.transform(expected);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
// randomize EulerAngle
|
// // randomize EulerAngle
|
||||||
expected = new EulerAngle((((float) Math.random()) - 0.5F) * 180, (((float) Math.random()) - 0.5F) * 360, (((float) Math.random()) - 0.5F) * 360);
|
// expected = new EulerAngle((((float) Math.random()) - 0.5F) * 180, (((float) Math.random()) - 0.5F) * 360, (((float) Math.random()) - 0.5F) * 360);
|
||||||
|
//
|
||||||
angle = identity.transform(expected);
|
// angle = identity.transform(expected);
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
angle = expected;
|
// angle = expected;
|
||||||
TransformationMatrix3d rotate90DegreesY = TransformationMatrix3d.builder().rotateY(Math.PI / 2).build();
|
// TransformationMatrix3d rotate90DegreesY = TransformationMatrix3d.builder().rotateY(Math.PI / 2).build();
|
||||||
for (int i = 0; i < 4; i++) {
|
// for (int i = 0; i < 4; i++) {
|
||||||
angle = rotate90DegreesY.transform(angle);
|
// angle = rotate90DegreesY.transform(angle);
|
||||||
}
|
// }
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
angle = expected;
|
// angle = expected;
|
||||||
TransformationMatrix3d rotate90DegreesX = TransformationMatrix3d.builder().rotateX(Math.PI / 2).build();
|
// TransformationMatrix3d rotate90DegreesX = TransformationMatrix3d.builder().rotateX(Math.PI / 2).build();
|
||||||
for (int i = 0; i < 4; i++) {
|
// for (int i = 0; i < 4; i++) {
|
||||||
angle = rotate90DegreesX.transform(angle);
|
// angle = rotate90DegreesX.transform(angle);
|
||||||
}
|
// }
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
|
//
|
||||||
angle = expected;
|
// angle = expected;
|
||||||
TransformationMatrix3d rotate90DegreesZ = TransformationMatrix3d.builder().rotateZ(Math.PI / 2).build();
|
// TransformationMatrix3d rotate90DegreesZ = TransformationMatrix3d.builder().rotateZ(Math.PI / 2).build();
|
||||||
for (int i = 0; i < 4; i++) {
|
// for (int i = 0; i < 4; i++) {
|
||||||
angle = rotate90DegreesZ.transform(angle);
|
// angle = rotate90DegreesZ.transform(angle);
|
||||||
}
|
// }
|
||||||
assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
// assertTrue(TestUtil.expectedActual(TestUtil.toString(expected), TestUtil.toString(angle)), TestUtil.closeEnough(expected, angle));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void product() {
|
// public void product() {
|
||||||
// compare I and I^2
|
// // compare I and I^2
|
||||||
assertEquals(TransformationMatrix3d.identity(), TransformationMatrix3d.identity().product(TransformationMatrix3d.identity()));
|
// assertEquals(TransformationMatrix3d.identity(), TransformationMatrix3d.identity().product(TransformationMatrix3d.identity()));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
package org.dimdev.dimdoors.world.pocket;
|
//package org.dimdev.dimdoors.world.pocket;
|
||||||
|
//
|
||||||
import net.minecraft.util.math.Vec3i;
|
//import net.minecraft.util.math.Vec3i;
|
||||||
import org.dimdev.dimdoors.world.ModDimensions;
|
//import org.dimdev.dimdoors.world.ModDimensions;
|
||||||
import org.dimdev.dimdoors.world.pocket.type.Pocket;
|
//import org.dimdev.dimdoors.world.pocket.type.Pocket;
|
||||||
import org.dimdev.test.ServerTestRunner;
|
//import org.dimdev.test.ServerTestRunner;
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
//import org.junit.runner.RunWith;
|
||||||
|
//
|
||||||
import static org.junit.Assert.*;
|
//import static org.junit.Assert.*;
|
||||||
|
//
|
||||||
//@RunWith(ServerTestRunner.class)
|
////@RunWith(ServerTestRunner.class)
|
||||||
public class PocketDirectoryTest {
|
//public class PocketDirectoryTest {
|
||||||
|
//
|
||||||
//@Test
|
// //@Test
|
||||||
public void newPocket() {
|
// public void newPocket() {
|
||||||
PocketDirectory directory = new PocketDirectory(ModDimensions.DUNGEON, 13);//
|
// PocketDirectory directory = new PocketDirectory(ModDimensions.DUNGEON, 13);//
|
||||||
|
//
|
||||||
Pocket.PocketBuilder<?, ?> builder = Pocket.builder().expand(new Vec3i(16 * directory.getGridSize(), 1, 1));
|
// Pocket.PocketBuilder<?, ?> builder = Pocket.builder().expand(new Vec3i(16 * directory.getGridSize(), 1, 1));
|
||||||
|
//
|
||||||
assertEquals(0, directory.newPocket(builder).getId()); // from 0 to 0
|
// assertEquals(0, directory.newPocket(builder).getId()); // from 0 to 0
|
||||||
assertEquals(1, directory.newPocket(builder).getId()); // from 1 to 1
|
// assertEquals(1, directory.newPocket(builder).getId()); // from 1 to 1
|
||||||
assertEquals(2, directory.newPocket(builder).getId()); // from 2 to 2
|
// assertEquals(2, directory.newPocket(builder).getId()); // from 2 to 2
|
||||||
assertEquals(3, directory.newPocket(builder).getId()); // from 3 to 3
|
// assertEquals(3, directory.newPocket(builder).getId()); // from 3 to 3
|
||||||
assertEquals(4, directory.newPocket(builder).getId()); // from 4 to 4
|
// assertEquals(4, directory.newPocket(builder).getId()); // from 4 to 4
|
||||||
assertEquals(5, directory.newPocket(builder).getId()); // from 5 to 5
|
// assertEquals(5, directory.newPocket(builder).getId()); // from 5 to 5
|
||||||
assertEquals(6, directory.newPocket(builder).getId()); // from 6 to 6
|
// assertEquals(6, directory.newPocket(builder).getId()); // from 6 to 6
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
builder = Pocket.builder().expand(new Vec3i(16 * directory.getGridSize() + 1, 16 * directory.getGridSize() + 1, 16 * directory.getGridSize() + 1));
|
// builder = Pocket.builder().expand(new Vec3i(16 * directory.getGridSize() + 1, 16 * directory.getGridSize() + 1, 16 * directory.getGridSize() + 1));
|
||||||
assertEquals(17, directory.newPocket(builder).getId()); // from 9 to 17
|
// assertEquals(17, directory.newPocket(builder).getId()); // from 9 to 17
|
||||||
assertEquals(26, directory.newPocket(builder).getId()); // from 18 to 26
|
// assertEquals(26, directory.newPocket(builder).getId()); // from 18 to 26
|
||||||
|
//
|
||||||
builder = Pocket.builder().expand(new Vec3i(3 * 16 * directory.getGridSize() + 1, 3 * 16 * directory.getGridSize() + 1, 3 * 16 * directory.getGridSize() + 1));
|
// builder = Pocket.builder().expand(new Vec3i(3 * 16 * directory.getGridSize() + 1, 3 * 16 * directory.getGridSize() + 1, 3 * 16 * directory.getGridSize() + 1));
|
||||||
assertEquals(161, directory.newPocket(builder).getId()); // from 81 to 161
|
// assertEquals(161, directory.newPocket(builder).getId()); // from 81 to 161
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
builder = Pocket.builder().expand(new Vec3i(16 * directory.getGridSize() + 1, 16 * directory.getGridSize() + 1, 16 * directory.getGridSize() + 1));
|
// builder = Pocket.builder().expand(new Vec3i(16 * directory.getGridSize() + 1, 16 * directory.getGridSize() + 1, 16 * directory.getGridSize() + 1));
|
||||||
assertEquals(35, directory.newPocket(builder).getId()); // from 27 to 35
|
// assertEquals(35, directory.newPocket(builder).getId()); // from 27 to 35
|
||||||
|
//
|
||||||
builder = Pocket.builder().expand(new Vec3i(1, 1, 1));
|
// builder = Pocket.builder().expand(new Vec3i(1, 1, 1));
|
||||||
assertEquals(7, directory.newPocket(builder).getId()); // from 7 to 7
|
// assertEquals(7, directory.newPocket(builder).getId()); // from 7 to 7
|
||||||
assertEquals(8, directory.newPocket(builder).getId()); // from 8 to 8
|
// assertEquals(8, directory.newPocket(builder).getId()); // from 8 to 8
|
||||||
assertEquals(36, directory.newPocket(builder).getId()); // from 36 to 36
|
// assertEquals(36, directory.newPocket(builder).getId()); // from 36 to 36
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package org.dimdev.test;
|
//package org.dimdev.test;
|
||||||
|
//
|
||||||
import net.devtech.potatounit.TestRunner;
|
//import net.devtech.potatounit.TestRunner;
|
||||||
import net.fabricmc.api.EnvType;
|
//import net.fabricmc.api.EnvType;
|
||||||
import org.junit.runners.model.InitializationError;
|
//import org.junit.runners.model.InitializationError;
|
||||||
|
//
|
||||||
public class ClientTestRunner extends TestRunner {
|
//public class ClientTestRunner extends TestRunner {
|
||||||
public ClientTestRunner(Class<?> testClass) throws InitializationError, ReflectiveOperationException {
|
// public ClientTestRunner(Class<?> testClass) throws InitializationError, ReflectiveOperationException {
|
||||||
super(hackyOrderMethod(testClass), EnvType.CLIENT);
|
// super(hackyOrderMethod(testClass), EnvType.CLIENT);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static Class<?> hackyOrderMethod(Class<?> testClass) {
|
// private static Class<?> hackyOrderMethod(Class<?> testClass) {
|
||||||
System.setProperty("fabric.dli.main", "net.fabricmc.loader.launch.knot.KnotClient");
|
// System.setProperty("fabric.dli.main", "net.fabricmc.loader.launch.knot.KnotClient");
|
||||||
return testClass;
|
// return testClass;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package org.dimdev.test;
|
//package org.dimdev.test;
|
||||||
|
//
|
||||||
import net.devtech.potatounit.TestRunner;
|
//import net.devtech.potatounit.TestRunner;
|
||||||
import net.fabricmc.api.EnvType;
|
//import net.fabricmc.api.EnvType;
|
||||||
import org.junit.runners.model.InitializationError;
|
//import org.junit.runners.model.InitializationError;
|
||||||
|
//
|
||||||
public class ServerTestRunner extends TestRunner {
|
//public class ServerTestRunner extends TestRunner {
|
||||||
public ServerTestRunner(Class<?> testClass) throws InitializationError, ReflectiveOperationException {
|
// public ServerTestRunner(Class<?> testClass) throws InitializationError, ReflectiveOperationException {
|
||||||
super(hackyOrderMethod(testClass), EnvType.SERVER);
|
// super(hackyOrderMethod(testClass), EnvType.SERVER);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static Class<?> hackyOrderMethod(Class<?> testClass) {
|
// private static Class<?> hackyOrderMethod(Class<?> testClass) {
|
||||||
System.setProperty("fabric.dli.main", "net.fabricmc.loader.launch.knot.KnotServer");
|
// System.setProperty("fabric.dli.main", "net.fabricmc.loader.launch.knot.KnotServer");
|
||||||
return testClass;
|
// return testClass;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
package org.dimdev.test;
|
//package org.dimdev.test;
|
||||||
|
//
|
||||||
import net.minecraft.util.math.EulerAngle;
|
//import net.minecraft.util.math.EulerAngle;
|
||||||
import net.minecraft.util.math.Vec3d;
|
//import net.minecraft.util.math.Vec3d;
|
||||||
import org.dimdev.dimdoors.api.util.math.AbstractMatrixd;
|
//import org.dimdev.dimdoors.api.util.math.AbstractMatrixd;
|
||||||
|
//
|
||||||
import java.util.function.Supplier;
|
//import java.util.function.Supplier;
|
||||||
|
//
|
||||||
public class TestUtil {
|
//public class TestUtil {
|
||||||
public static String expectedActual(Object expected,Object actual) {
|
// public static String expectedActual(Object expected,Object actual) {
|
||||||
return "\nexpected:\n" + expected + "\nactual:\n" + actual + "\n";
|
// return "\nexpected:\n" + expected + "\nactual:\n" + actual + "\n";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static boolean closeEnough(Vec3d expected, Vec3d actual) {
|
// public static boolean closeEnough(Vec3d expected, Vec3d actual) {
|
||||||
return expected.squaredDistanceTo(actual) <= expected.lengthSquared() * 1E-10;
|
// return expected.squaredDistanceTo(actual) <= expected.lengthSquared() * 1E-10;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static boolean closeEnough(AbstractMatrixd<?> expected, AbstractMatrixd<?> actual) {
|
// public static boolean closeEnough(AbstractMatrixd<?> expected, AbstractMatrixd<?> actual) {
|
||||||
if (expected.getDimensionX() != actual.getDimensionX() || expected.getDimensionY() != actual.getDimensionY()) return false;
|
// if (expected.getDimensionX() != actual.getDimensionX() || expected.getDimensionY() != actual.getDimensionY()) return false;
|
||||||
|
//
|
||||||
for (int i = 0; i < expected.getDimensionX(); i++) {
|
// for (int i = 0; i < expected.getDimensionX(); i++) {
|
||||||
for (int j = 0; j < expected.getDimensionY(); j++) {
|
// for (int j = 0; j < expected.getDimensionY(); j++) {
|
||||||
double entry1 = expected.get(i, j);
|
// double entry1 = expected.get(i, j);
|
||||||
double entry2 = actual.get(i, j);
|
// double entry2 = actual.get(i, j);
|
||||||
if (entry1 == entry2) continue;
|
// if (entry1 == entry2) continue;
|
||||||
if (entry1 != 0 && entry2 != 0) {
|
// if (entry1 != 0 && entry2 != 0) {
|
||||||
double div = entry1/entry2;
|
// double div = entry1/entry2;
|
||||||
if (0.991 <= div && div <= 0.001) continue;
|
// if (0.991 <= div && div <= 0.001) continue;
|
||||||
}
|
// }
|
||||||
if (Math.abs(entry1 - entry2) <= 1E-10) continue;
|
// if (Math.abs(entry1 - entry2) <= 1E-10) continue;
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static boolean closeEnough(EulerAngle expected, EulerAngle actual) {
|
// public static boolean closeEnough(EulerAngle expected, EulerAngle actual) {
|
||||||
float yawDiff = Math.abs(expected.getYaw() - actual.getYaw());
|
// float yawDiff = Math.abs(expected.getYaw() - actual.getYaw());
|
||||||
float pitchDiff = Math.abs(expected.getPitch() - actual.getPitch());
|
// float pitchDiff = Math.abs(expected.getPitch() - actual.getPitch());
|
||||||
float rollDiff = Math.abs(expected.getRoll() - actual.getRoll());
|
// float rollDiff = Math.abs(expected.getRoll() - actual.getRoll());
|
||||||
|
//
|
||||||
return yawDiff <= 1 && pitchDiff <= 1 && rollDiff <= 1;
|
// return yawDiff <= 1 && pitchDiff <= 1 && rollDiff <= 1;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static String toString(EulerAngle angle) {
|
// public static String toString(EulerAngle angle) {
|
||||||
return "{yaw: " + angle.getYaw() + "; pitch: " + angle.getPitch() + "; roll: " + angle.getRoll() + "}";
|
// return "{yaw: " + angle.getYaw() + "; pitch: " + angle.getPitch() + "; roll: " + angle.getRoll() + "}";
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
Loading…
Reference in a new issue