style: fix checkstyle findings (#4781)

develop
jdrueckert 2021-06-20 19:50:09 +02:00 committed by GitHub
parent 6f5bf08201
commit e11c4f7cb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
202 changed files with 1248 additions and 660 deletions

View File

@ -18,7 +18,8 @@ public class FieldMetadataTest {
@Test
public void testOwnsAnnotationProcessed() throws NoSuchMethodException {
ComponentMetadata<OwnerComponent> classMetadata = new ComponentMetadata<>(new ResourceUrn("unittest:owner"), OwnerComponent.class, factory, copyStrategyLibrary);
ComponentMetadata<OwnerComponent> classMetadata = new ComponentMetadata<>(new ResourceUrn("unittest:owner"),
OwnerComponent.class, factory, copyStrategyLibrary);
ComponentFieldMetadata metadata = classMetadata.getField("child");
assertTrue(metadata.isOwnedReference());
}

View File

@ -26,13 +26,15 @@ public class MetadataBuilderTest {
@Test
public void testDetectsLackOfDefaultConstructor() throws Exception {
DefaultClassMetadata<NoDefaultConstructor> metadata = new DefaultClassMetadata<>("engine:empty", NoDefaultConstructor.class, factory, copyStrategyLibrary);
DefaultClassMetadata<NoDefaultConstructor> metadata = new DefaultClassMetadata<>("engine:empty",
NoDefaultConstructor.class, factory, copyStrategyLibrary);
assertFalse(metadata.isConstructable());
}
@Test
public void testTrivialMetadata() throws Exception {
DefaultClassMetadata<Trivial> metadata = new DefaultClassMetadata<>("engine:empty", Trivial.class, factory, copyStrategyLibrary);
DefaultClassMetadata<Trivial> metadata = new DefaultClassMetadata<>("engine:empty",
Trivial.class, factory, copyStrategyLibrary);
assertNotNull(metadata);
assertEquals(0, metadata.getFieldCount());
assertTrue(metadata.isConstructable());
@ -40,7 +42,8 @@ public class MetadataBuilderTest {
@Test
public void testPrivateField() throws Exception {
DefaultClassMetadata<PrivateField> metadata = new DefaultClassMetadata<>("engine:empty", PrivateField.class, factory, copyStrategyLibrary);
DefaultClassMetadata<PrivateField> metadata = new DefaultClassMetadata<>("engine:empty",
PrivateField.class, factory, copyStrategyLibrary);
assertNotNull(metadata);
assertEquals(1, metadata.getFieldCount());
FieldMetadata fieldMetadata = metadata.getField("name");
@ -52,7 +55,8 @@ public class MetadataBuilderTest {
@Test
public void testInheritsFields() throws Exception {
DefaultClassMetadata<Inheriting> metadata = new DefaultClassMetadata<>("engine:empty", Inheriting.class, factory, copyStrategyLibrary);
DefaultClassMetadata<Inheriting> metadata = new DefaultClassMetadata<>("engine:empty",
Inheriting.class, factory, copyStrategyLibrary);
assertNotNull(metadata);
assertEquals(2, metadata.getFieldCount());
assertNotNull(metadata.getField("name"));

View File

@ -23,15 +23,23 @@ public class CounterTest {
assertRun("{ sequence:[ { print:{msg:A} }, { print:{msg:B} } ] }", 1, "[A][B]");
assertRun("{ sequence:[ { print:{msg:A} }, failure, { print:{msg:B} } ] }", 1, "[A]");
assertRun("{ sequence:[ { counter:{ count=1, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }", 1, "[A][B]");
assertRun("{ sequence:[ { counter:{ count=2, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }", 1, "[A]");
assertRun("{ sequence:[ { counter:{ count=2, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }", 2, "[A][A][B]");
assertRun("{ sequence:[ { counter:{ count=2, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }", 4, "[A][A][B][A][A][B]");
assertRun("{ sequence:[ { counter:{ count=1, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }",
1, "[A][B]");
assertRun("{ sequence:[ { counter:{ count=2, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }",
1, "[A]");
assertRun("{ sequence:[ { counter:{ count=2, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }",
2, "[A][A][B]");
assertRun("{ sequence:[ { counter:{ count=2, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }",
4, "[A][A][B][A][A][B]");
assertRun("{ sequence:[ { counter:{ count=2, child:{ counter:{ count=2, child:{ print:{msg:A} } } } } },{ print:{msg:B} } ] }", 4, "[A][A][A][A][B]");
assertRun("{ sequence:[ { timeout:{ time=1, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }", 2, "[A][B][A][B]");
assertRun("{ sequence:[ { timeout:{ time=2, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }", 4, "[A][B][A][B][A][B][A][B]");
assertRun("{ sequence:[ { timeout:{ time=1, child:{ timeout:{ time=2, child:{ print:{msg:A} } } } } },{ print:{msg:B} } ] }", 2, "[A][B][A][B]");
assertRun("{ sequence:[ { counter:{ count=2, child:{ counter:{ count=2, child:{ print:{msg:A} } } } } },{ print:{msg:B} } ] }",
4, "[A][A][A][A][B]");
assertRun("{ sequence:[ { timeout:{ time=1, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }",
2, "[A][B][A][B]");
assertRun("{ sequence:[ { timeout:{ time=2, child:{ print:{msg:A} } } },{ print:{msg:B} } ] }",
4, "[A][B][A][B][A][B][A][B]");
assertRun("{ sequence:[ { timeout:{ time=1, child:{ timeout:{ time=2, child:{ print:{msg:A} } } } } },{ print:{msg:B} } ] }",
2, "[A][B][A][B]");
}
@BeforeEach

View File

@ -11,44 +11,51 @@ public class DynamicSelectorTest extends CountCallsTest {
@Test
public void testAllSuccess() {
assertBT("{ dynamic:[success, success, success]}",
Arrays.asList(BehaviorState.SUCCESS, BehaviorState.SUCCESS, BehaviorState.SUCCESS), Arrays.asList(4, 1, 4, 1, 4, 1));
Arrays.asList(BehaviorState.SUCCESS, BehaviorState.SUCCESS, BehaviorState.SUCCESS),
Arrays.asList(4, 1, 4, 1, 4, 1));
}
@Test
public void testAllFail() {
assertBT("{ dynamic:[failure, failure, failure]}",
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE), Arrays.asList(4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3));
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE),
Arrays.asList(4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3));
}
@Test
public void testAllRunning() {
assertBT("{ dynamic:[running, running, running]}",
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING), Arrays.asList(4, 1, 4, 1, 4, 1));
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING),
Arrays.asList(4, 1, 4, 1, 4, 1));
}
@Test
public void testFailSuccess() {
assertBT("{ dynamic:[failure, success, success]}",
Arrays.asList(BehaviorState.SUCCESS, BehaviorState.SUCCESS, BehaviorState.SUCCESS), Arrays.asList(4, 1, 2, 4, 1, 2, 4, 1, 2));
Arrays.asList(BehaviorState.SUCCESS, BehaviorState.SUCCESS, BehaviorState.SUCCESS),
Arrays.asList(4, 1, 2, 4, 1, 2, 4, 1, 2));
}
@Test
public void testSuccessFail() {
assertBT("{ dynamic:[success, failure, failure]}",
Arrays.asList(BehaviorState.SUCCESS, BehaviorState.SUCCESS, BehaviorState.SUCCESS), Arrays.asList(4, 1, 4, 1, 4, 1));
Arrays.asList(BehaviorState.SUCCESS, BehaviorState.SUCCESS, BehaviorState.SUCCESS),
Arrays.asList(4, 1, 4, 1, 4, 1));
}
@Test
public void testRunningFail() {
assertBT("{ dynamic:[running, failure, failure]}",
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING), Arrays.asList(4, 1, 4, 1, 4, 1));
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING),
Arrays.asList(4, 1, 4, 1, 4, 1));
}
@Test
public void testRunningSuccess() {
assertBT("{ dynamic:[running, success, success]}",
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING), Arrays.asList(4, 1, 4, 1, 4, 1));
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING),
Arrays.asList(4, 1, 4, 1, 4, 1));
}
}

View File

@ -31,7 +31,8 @@ public final class Example {
treeBuilder.registerAction("delay", Delay.class);
Actor actor = new Actor(null);
actor.setDelta(0.1f);
node = treeBuilder.fromJson("{ sequence:[ success, { delay:{duration:1}}, { print:{msg:Hello} }, { delay:{duration:1}}, { print:{msg:World} } ] }");
node = treeBuilder.fromJson("{ sequence:[ success, { delay:{duration:1}}, { print:{msg:Hello} }, " +
"{ delay:{duration:1}}, { print:{msg:World} } ] }");
DefaultBehaviorTreeRunner tree = new DefaultBehaviorTreeRunner(node, actor);
for (int i = 0; i < 100; i++) {
tree.step();
@ -42,7 +43,8 @@ public final class Example {
actor.setDelta(0.1f);
node = treeBuilder.fromJson(
"{ sequence:[ "
+ "{repeat :{ count:5, child:{print:{msg:x}}}}, success, { delay:{duration:1}}, { print:{msg:Hello} }, { delay:{duration:1}}, { print:{msg:World} } "
+ "{repeat :{ count:5, child:{print:{msg:x}}}}, success, { delay:{duration:1}}, " +
"{ print:{msg:Hello} }, { delay:{duration:1}}, { print:{msg:World} } "
+ "] }");
tree = new DefaultBehaviorTreeRunner(node, actor);
for (int i = 0; i < 100; i++) {

View File

@ -14,49 +14,56 @@ public class ParallelTest extends CountCallsTest {
@Test
public void testAllSuccess() {
assertBT("{ parallel:[success, success, success]}",
Arrays.asList(BehaviorState.SUCCESS, BehaviorState.SUCCESS, BehaviorState.SUCCESS), Arrays.asList(4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3));
Arrays.asList(BehaviorState.SUCCESS, BehaviorState.SUCCESS, BehaviorState.SUCCESS),
Arrays.asList(4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3));
}
@Disabled("Ignored for the moment")
@Test
public void testAllFail() {
assertBT("{ parallel:[failure, failure, failure]}",
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE), Arrays.asList(4, 1, 4, 1, 4, 1));
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE),
Arrays.asList(4, 1, 4, 1, 4, 1));
}
@Disabled("Ignored for the moment")
@Test
public void testAllRunning() {
assertBT("{ parallel:[running, running, running]}",
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING), Arrays.asList(4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3));
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING),
Arrays.asList(4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3));
}
@Disabled("Ignored for the moment")
@Test
public void testFailSuccess() {
assertBT("{ parallel:[failure, success, success]}",
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE), Arrays.asList(4, 1, 4, 1, 4, 1));
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE),
Arrays.asList(4, 1, 4, 1, 4, 1));
}
@Disabled("Ignored for the moment")
@Test
public void testSuccessFail() {
assertBT("{ parallel:[success, failure, failure]}",
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE), Arrays.asList(4, 1, 2, 4, 1, 2, 4, 1, 2));
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE),
Arrays.asList(4, 1, 2, 4, 1, 2, 4, 1, 2));
}
@Disabled("Ignored for the moment")
@Test
public void testRunningFail() {
assertBT("{ parallel:[running, failure, failure]}",
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE), Arrays.asList(4, 1, 2, 4, 1, 2, 4, 1, 2));
Arrays.asList(BehaviorState.FAILURE, BehaviorState.FAILURE, BehaviorState.FAILURE),
Arrays.asList(4, 1, 2, 4, 1, 2, 4, 1, 2));
}
@Disabled("Ignored for the moment")
@Test
public void testRunningSuccess() {
assertBT("{ parallel:[running, success, success]}",
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING), Arrays.asList(4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3));
Arrays.asList(BehaviorState.RUNNING, BehaviorState.RUNNING, BehaviorState.RUNNING),
Arrays.asList(4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3));
}
}

View File

@ -130,7 +130,8 @@ public class VisualCharacterSystemTest {
List<Event> laterJoiningCharacterEntityEvents = new ArrayList<>();
recordEntityEventsToList(laterJoiningCharacterEntity, laterJoiningCharacterEntityEvents);
VisualCharacterComponent visualComponentOfLaterJoiningCharacter = new VisualCharacterComponent();
Mockito.when(laterJoiningCharacterEntity.getComponent(VisualCharacterComponent.class)).thenReturn(visualComponentOfLaterJoiningCharacter);
Mockito.when(laterJoiningCharacterEntity.getComponent(VisualCharacterComponent.class))
.thenReturn(visualComponentOfLaterJoiningCharacter);
// Joined player is not properly linked but it should not matter:
Mockito.when(laterJoiningCharacterEntity.getOwner()).thenReturn(EntityRef.NULL);
@ -163,7 +164,8 @@ public class VisualCharacterSystemTest {
clientEntityReturnedByLocalPlayer = clientEntity;
Mockito.when(ownCharacterEntity.getOwner()).thenReturn(clientEntity);
Mockito.when(otherCharacterEntity.getOwner()).thenReturn(otherClientEntity);
Mockito.when(entityManager.getEntitiesWith(VisualCharacterComponent.class)).thenReturn(Arrays.asList(otherCharacterEntity, ownCharacterEntity));
Mockito.when(entityManager.getEntitiesWith(VisualCharacterComponent.class))
.thenReturn(Arrays.asList(otherCharacterEntity, ownCharacterEntity));
}

View File

@ -112,8 +112,10 @@ public class ComponentSerializerTest {
@Test
public void testComponentTypeIdDeserializes() throws Exception {
componentSerializer.setIdMapping(ImmutableMap.<Class<? extends Component>, Integer>builder().put(StringComponent.class, 1).build());
EntityData.Component compData = EntityData.Component.newBuilder().setTypeIndex(1)
.addField(EntityData.NameValue.newBuilder().setName("value").setValue(EntityData.Value.newBuilder().addString("item"))).build();
EntityData.Component compData = EntityData.Component.newBuilder()
.setTypeIndex(1)
.addField(EntityData.NameValue.newBuilder().setName("value").setValue(EntityData.Value.newBuilder().addString("item")))
.build();
Component comp = componentSerializer.deserialize(compData);
assertTrue(comp instanceof StringComponent);
assertEquals("item", ((StringComponent) comp).value);
@ -122,8 +124,10 @@ public class ComponentSerializerTest {
@Test
public void testDeltaComponentTypeIdDeserializesWithValue() throws Exception {
componentSerializer.setIdMapping(ImmutableMap.<Class<? extends Component>, Integer>builder().put(StringComponent.class, 1).build());
EntityData.Component compData = EntityData.Component.newBuilder().setTypeIndex(1)
.addField(EntityData.NameValue.newBuilder().setName("value").setValue(EntityData.Value.newBuilder().addString("item"))).build();
EntityData.Component compData = EntityData.Component.newBuilder()
.setTypeIndex(1)
.addField(EntityData.NameValue.newBuilder().setName("value").setValue(EntityData.Value.newBuilder().addString("item")))
.build();
StringComponent original = new StringComponent("test");
componentSerializer.deserializeOnto(original, compData);
assertEquals("item", original.value);
@ -132,7 +136,10 @@ public class ComponentSerializerTest {
@Test
public void testDeltaComponentTypeIdDeserializesWithoutValue() throws Exception {
componentSerializer.setIdMapping(ImmutableMap.<Class<? extends Component>, Integer>builder().put(StringComponent.class, 1).build());
EntityData.Component compData = EntityData.Component.newBuilder().setTypeIndex(1).addField(EntityData.NameValue.newBuilder().setName("value")).build();
EntityData.Component compData = EntityData.Component.newBuilder()
.setTypeIndex(1)
.addField(EntityData.NameValue.newBuilder().setName("value"))
.build();
StringComponent original = new StringComponent("test");
componentSerializer.deserializeOnto(original, compData);
assertEquals(null, original.value);

View File

@ -150,7 +150,10 @@ public class EntitySerializerTest {
assertEquals(0, entityData.getRemovedComponentCount());
EntityData.Component componentData = entityData.getComponent(0);
assertEquals("test:string", componentData.getType());
assertEquals(Lists.newArrayList(EntityData.NameValue.newBuilder().setName("value").setValue(EntityData.Value.newBuilder().addString("Delta").build()).build()),
assertEquals(Lists.newArrayList(EntityData.NameValue.newBuilder()
.setName("value")
.setValue(EntityData.Value.newBuilder().addString("Delta").build())
.build()),
componentData.getFieldList());
}

View File

@ -95,20 +95,30 @@ public class ColumnLayoutTest {
columnLayout.onDraw(canvas);
// Gets half of entire area
verify(canvas).drawWidget(itemAt1x1, RectUtility.createFromMinAndSize(0, ((CANVAS_HEIGHT - 20) / 2), CANVAS_WIDTH / 2, 10));
verify(canvas).drawWidget(itemAt1x1,
RectUtility.createFromMinAndSize(0, ((CANVAS_HEIGHT - 20) / 2),
CANVAS_WIDTH / 2, 10));
// Gets one-fifth of entire area
verify(canvas).drawWidget(itemAt2x1, RectUtility.createFromMinAndSize(CANVAS_WIDTH / 2, ((CANVAS_HEIGHT - 20) / 2), CANVAS_WIDTH * 2 / 10, 10));
verify(canvas).drawWidget(itemAt2x1,
RectUtility.createFromMinAndSize(CANVAS_WIDTH / 2, ((CANVAS_HEIGHT - 20) / 2),
CANVAS_WIDTH * 2 / 10, 10));
// Gets three-tens of entire area
verify(canvas).drawWidget(itemAt3x1, RectUtility.createFromMinAndSize(CANVAS_WIDTH / 2 + CANVAS_WIDTH * 2 / 10,
((CANVAS_HEIGHT - 20) / 2), CANVAS_WIDTH * 3 / 10, 10));
verify(canvas).drawWidget(itemAt3x1,
RectUtility.createFromMinAndSize(CANVAS_WIDTH / 2 + CANVAS_WIDTH * 2 / 10, ((CANVAS_HEIGHT - 20) / 2),
CANVAS_WIDTH * 3 / 10, 10));
// Gets half of entire area
verify(canvas).drawWidget(itemAt1x2, RectUtility.createFromMinAndSize(0, ((CANVAS_HEIGHT - 20) / 2) + 10, CANVAS_WIDTH / 2, 10));
verify(canvas).drawWidget(itemAt1x2,
RectUtility.createFromMinAndSize(0, ((CANVAS_HEIGHT - 20) / 2) + 10,
CANVAS_WIDTH / 2, 10));
// Gets one-fifth of entire area
verify(canvas).drawWidget(itemAt2x2, RectUtility.createFromMinAndSize(CANVAS_WIDTH / 2, ((CANVAS_HEIGHT - 20) / 2) + 10, CANVAS_WIDTH * 2 / 10, 10));
verify(canvas).drawWidget(itemAt2x2,
RectUtility.createFromMinAndSize(CANVAS_WIDTH / 2, ((CANVAS_HEIGHT - 20) / 2) + 10,
CANVAS_WIDTH * 2 / 10, 10));
// Gets three-tens of entire area
verify(canvas).drawWidget(itemAt3x2, RectUtility.createFromMinAndSize(CANVAS_WIDTH / 2 + CANVAS_WIDTH * 2 / 10,
((CANVAS_HEIGHT - 20) / 2) + 10, CANVAS_WIDTH * 3 / 10, 10));
verify(canvas).drawWidget(itemAt3x2,
RectUtility.createFromMinAndSize(CANVAS_WIDTH / 2 + CANVAS_WIDTH * 2 / 10, ((CANVAS_HEIGHT - 20) / 2) + 10,
CANVAS_WIDTH * 3 / 10, 10));
}
@Test
@ -123,13 +133,25 @@ public class ColumnLayoutTest {
columnLayout.onDraw(canvas);
verify(canvas).drawWidget(itemAt1x1, RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2), ((CANVAS_HEIGHT - 20) / 2), 50, 10));
verify(canvas).drawWidget(itemAt2x1, RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2) + 50, ((CANVAS_HEIGHT - 20) / 2), 5, 10));
verify(canvas).drawWidget(itemAt3x1, RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2) + 50 + 5, ((CANVAS_HEIGHT - 20) / 2), 20, 10));
verify(canvas).drawWidget(itemAt1x1,
RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2), ((CANVAS_HEIGHT - 20) / 2),
50, 10));
verify(canvas).drawWidget(itemAt2x1,
RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2) + 50, ((CANVAS_HEIGHT - 20) / 2),
5, 10));
verify(canvas).drawWidget(itemAt3x1,
RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2) + 50 + 5, ((CANVAS_HEIGHT - 20) / 2),
20, 10));
verify(canvas).drawWidget(itemAt1x2, RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2), ((CANVAS_HEIGHT - 20) / 2) + 10, 50, 10));
verify(canvas).drawWidget(itemAt2x2, RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2) + 50, ((CANVAS_HEIGHT - 20) / 2) + 10, 5, 10));
verify(canvas).drawWidget(itemAt3x2, RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2) + 50 + 5, ((CANVAS_HEIGHT - 20) / 2) + 10, 20, 10));
verify(canvas).drawWidget(itemAt1x2,
RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2), ((CANVAS_HEIGHT - 20) / 2) + 10,
50, 10));
verify(canvas).drawWidget(itemAt2x2,
RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2) + 50, ((CANVAS_HEIGHT - 20) / 2) + 10,
5, 10));
verify(canvas).drawWidget(itemAt3x2,
RectUtility.createFromMinAndSize(((CANVAS_WIDTH - 75) / 2) + 50 + 5, ((CANVAS_HEIGHT - 20) / 2) + 10,
20, 10));
}
}

View File

@ -83,9 +83,12 @@ public class RowLayoutTest {
// Gets 1/10 of the entire area
final int width3 = CANVAS_WIDTH / 10;
verify(canvas).drawWidget(itemAt1x1, RectUtility.createFromMinAndSize(0, 0, width1, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x2, RectUtility.createFromMinAndSize(width1, 0, width2, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x3, RectUtility.createFromMinAndSize(width1 + width2, 0, width3, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x1,
RectUtility.createFromMinAndSize(0, 0, width1, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x2,
RectUtility.createFromMinAndSize(width1, 0, width2, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x3,
RectUtility.createFromMinAndSize(width1 + width2, 0, width3, CANVAS_HEIGHT));
}
@Test
@ -103,9 +106,12 @@ public class RowLayoutTest {
rowLayout.onDraw(canvas);
//Width split equally among 3 widgets as they have no relative widths
verify(canvas).drawWidget(itemAt1x1, RectUtility.createFromMinAndSize(0, 0, CANVAS_WIDTH / 3, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x2, RectUtility.createFromMinAndSize(CANVAS_WIDTH / 3, 0, CANVAS_WIDTH / 3, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x3, RectUtility.createFromMinAndSize(CANVAS_WIDTH / 3 + CANVAS_WIDTH / 3, 0, CANVAS_WIDTH / 3, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x1,
RectUtility.createFromMinAndSize(0, 0, CANVAS_WIDTH / 3, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x2,
RectUtility.createFromMinAndSize(CANVAS_WIDTH / 3, 0, CANVAS_WIDTH / 3, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x3,
RectUtility.createFromMinAndSize(CANVAS_WIDTH / 3 + CANVAS_WIDTH / 3, 0, CANVAS_WIDTH / 3, CANVAS_HEIGHT));
}
@Test
@ -129,8 +135,11 @@ public class RowLayoutTest {
final int width2 = (CANVAS_WIDTH - width1) / 2;
final int width3 = (CANVAS_WIDTH - width1) / 2;
verify(canvas).drawWidget(itemAt1x1, RectUtility.createFromMinAndSize(0, 0, width1, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x2, RectUtility.createFromMinAndSize(width1, 0, width2, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x3, RectUtility.createFromMinAndSize(width1 + width2, 0, width3, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x1,
RectUtility.createFromMinAndSize(0, 0, width1, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x2,
RectUtility.createFromMinAndSize(width1, 0, width2, CANVAS_HEIGHT));
verify(canvas).drawWidget(itemAt1x3,
RectUtility.createFromMinAndSize(width1 + width2, 0, width3, CANVAS_HEIGHT));
}
}

View File

@ -103,7 +103,8 @@ public class GenericTreeTest {
@Test
public void testDepthFirstIteratorIterateExpandedOnly() {
List<GenericTree<Integer>> expected = Arrays.asList(nodes.get(0), nodes.get(1), nodes.get(2), nodes.get(4), nodes.get(5), nodes.get(6), nodes.get(9));
List<GenericTree<Integer>> expected = Arrays.asList(nodes.get(0), nodes.get(1), nodes.get(2),
nodes.get(4), nodes.get(5), nodes.get(6), nodes.get(9));
List<GenericTree<Integer>> actual = Lists.newArrayList();
Iterator i = nodes.get(0).getDepthFirstIterator(true);

View File

@ -65,7 +65,8 @@ public class ChunkTest extends TerasologyTestingEnvironment {
public void testGetAabb() {
AABBfc aabb = chunk.getAABB();
assertEquals(new Vector3f(-.5f, -.5f, -.5f), new Vector3f(aabb.minX(), aabb.minY(), aabb.minZ()));
assertEquals(new Vector3f(Chunks.SIZE_X - .5f, Chunks.SIZE_Y - .5f, Chunks.SIZE_Z - .5f), new Vector3f(aabb.maxX(), aabb.maxY(), aabb.maxZ()));
assertEquals(new Vector3f(Chunks.SIZE_X - .5f, Chunks.SIZE_Y - .5f, Chunks.SIZE_Z - .5f),
new Vector3f(aabb.maxX(), aabb.maxY(), aabb.maxZ()));
}
}

View File

@ -90,7 +90,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
blockWithString = createBlockWithPrefab("test:blockWithString", prefabWithString, false, assetManager, blockManager);
keepActiveBlock = createBlockWithPrefab("test:keepActiveBlock", prefabWithString, true, assetManager, blockManager);
Prefab prefabWithDifferentString = createPrefabWithString("test:prefabWithDifferentString", "Test2", assetManager);
blockWithDifferentString = createBlockWithPrefab("test:prefabWithDifferentString", prefabWithDifferentString, false, assetManager, blockManager);
blockWithDifferentString = createBlockWithPrefab("test:prefabWithDifferentString", prefabWithDifferentString,
false, assetManager, blockManager);
BlockFamily blockFamily = createBlockFamily("test:blockFamily", prefabWithString, assetManager, blockManager);
Iterator<Block> iterator = blockFamily.getBlocks().iterator();
@ -101,7 +102,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
retainedPrefabData.addComponent(new RetainedOnBlockChangeComponent(3));
Prefab retainedPrefab = assetManager.loadAsset(new ResourceUrn("test:retainedPrefab"), retainedPrefabData, Prefab.class);
blockWithRetainedComponent = createBlockWithPrefab("test:blockWithRetainedComponent", retainedPrefab, false, assetManager, blockManager);
blockWithRetainedComponent = createBlockWithPrefab("test:blockWithRetainedComponent", retainedPrefab,
false, assetManager, blockManager);
worldProvider.initialise();
}
@ -189,8 +191,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i());
assertTrue(blockEntity.exists());
assertEquals(Lists.newArrayList(new EventInfo(OnAddedComponent.newInstance(), blockEntity), new EventInfo(OnActivatedComponent.newInstance(), blockEntity)),
checker.receivedEvents);
assertEquals(Lists.newArrayList(new EventInfo(OnAddedComponent.newInstance(), blockEntity),
new EventInfo(OnActivatedComponent.newInstance(), blockEntity)), checker.receivedEvents);
}
@Disabled("Failing due to #2625. TODO: fix to match new behaviour")
@ -204,8 +206,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i());
assertTrue(blockEntity.exists());
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), blockEntity), new EventInfo(BeforeRemoveComponent.newInstance(), blockEntity)),
checker.receivedEvents);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), blockEntity),
new EventInfo(BeforeRemoveComponent.newInstance(), blockEntity)), checker.receivedEvents);
}
@Disabled("Failing due to #2625. TODO: fix to match new behaviour")
@ -227,7 +229,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
worldProvider.setBlock(new Vector3i(), blockWithString);
assertEquals(blockWithString.getPrefab().get().getName(), worldProvider.getBlockEntityAt(new Vector3i()).getParentPrefab().getName());
worldProvider.setBlock(new Vector3i(), blockWithDifferentString);
assertEquals(blockWithDifferentString.getPrefab().get().getName(), worldProvider.getBlockEntityAt(new Vector3i()).getParentPrefab().getName());
assertEquals(blockWithDifferentString.getPrefab().get().getName(),
worldProvider.getBlockEntityAt(new Vector3i()).getParentPrefab().getName());
}
@Test
@ -287,8 +290,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity), new EventInfo(BeforeRemoveComponent.newInstance(), entity)),
checker.receivedEvents);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity),
new EventInfo(BeforeRemoveComponent.newInstance(), entity)), checker.receivedEvents);
}
@Test
@ -300,8 +303,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), IntegerComponent.class);
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity), new EventInfo(BeforeRemoveComponent.newInstance(), entity)),
checker.receivedEvents);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity),
new EventInfo(BeforeRemoveComponent.newInstance(), entity)), checker.receivedEvents);
}
@Test
@ -313,8 +316,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(OnAddedComponent.newInstance(), entity), new EventInfo(OnActivatedComponent.newInstance(), entity)),
checker.receivedEvents);
assertEquals(Lists.newArrayList(new EventInfo(OnAddedComponent.newInstance(), entity),
new EventInfo(OnActivatedComponent.newInstance(), entity)), checker.receivedEvents);
}
@Test
@ -360,8 +363,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new RetainedOnBlockChangeComponent(2));
assertEquals(Lists.newArrayList(new EventInfo(OnAddedComponent.newInstance(), entity), new EventInfo(OnActivatedComponent.newInstance(), entity)),
checker.receivedEvents);
assertEquals(Lists.newArrayList(new EventInfo(OnAddedComponent.newInstance(), entity),
new EventInfo(OnActivatedComponent.newInstance(), entity)), checker.receivedEvents);
assertTrue(entity.hasComponent(NetworkComponent.class));
}
@ -375,8 +378,8 @@ public class EntityAwareWorldProviderTest extends TerasologyTestingEnvironment {
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity), new EventInfo(BeforeRemoveComponent.newInstance(), entity)),
checker.receivedEvents);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity),
new EventInfo(BeforeRemoveComponent.newInstance(), entity)), checker.receivedEvents);
}
@Test

View File

@ -171,7 +171,8 @@ class ChunkProcessingPipelineTest extends TerasologyTestingEnvironment {
pipeline = new ChunkProcessingPipeline(chunkCache::get, (o1, o2) -> {
if (position.get() != null) {
Vector3ic entityPos = position.get();
return (int) (entityPos.distance(((PositionFuture<?>) o1).getPosition()) - entityPos.distance(((PositionFuture<?>) o2).getPosition()));
return (int) (entityPos.distance(((PositionFuture<?>) o1).getPosition())
- entityPos.distance(((PositionFuture<?>) o2).getPosition()));
}
return 0;
});

View File

@ -4,12 +4,12 @@ package org.terasology.reflection.reflect;
import org.joml.Vector3f;
import org.junit.jupiter.api.Test;
import org.terasology.engine.logic.characters.events.AttackRequest;
import org.terasology.engine.logic.location.LocationComponent;
import org.terasology.engine.reflection.reflect.ByteCodeReflectFactory;
import org.terasology.unittest.stubs.GetterSetterComponent;
import org.terasology.unittest.stubs.IntegerComponent;
import org.terasology.unittest.stubs.StringComponent;
import org.terasology.engine.reflection.reflect.ByteCodeReflectFactory;
import org.terasology.engine.logic.characters.events.AttackRequest;
import org.terasology.engine.logic.location.LocationComponent;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -36,8 +36,8 @@ public class ByteCodeReflectFactoryTest {
@Test
public void testCreateFieldAccessorWithGetterSetter() throws Exception {
ReflectFactory reflectFactory = new ByteCodeReflectFactory();
FieldAccessor<GetterSetterComponent, Vector3f> fieldAccessor
= reflectFactory.createFieldAccessor(GetterSetterComponent.class, GetterSetterComponent.class.getDeclaredField("value"), Vector3f.class);
FieldAccessor<GetterSetterComponent, Vector3f> fieldAccessor = reflectFactory.createFieldAccessor(GetterSetterComponent.class,
GetterSetterComponent.class.getDeclaredField("value"), Vector3f.class);
GetterSetterComponent comp = new GetterSetterComponent();
Vector3f newVal = new Vector3f(1, 2, 3);
fieldAccessor.setValue(comp, newVal);

View File

@ -21,93 +21,109 @@ public class MersenneRandomTest {
*/
private static final long[] FIRST_1000_VALS = {
1067595299L, 955945823L, 477289528L, 4107218783L, 4228976476L, 3344332714L, 3355579695L, 227628506L, 810200273L, 2591290167L, 2560260675L, 3242736208L, 646746669L,
1479517882L, 4245472273L, 1143372638L, 3863670494L, 3221021970L, 1773610557L, 1138697238L, 1421897700L, 1269916527L, 2859934041L, 1764463362L, 3874892047L,
3965319921L, 72549643L, 2383988930L, 2600218693L, 3237492380L, 2792901476L, 725331109L, 605841842L, 271258942L, 715137098L, 3297999536L, 1322965544L, 4229579109L,
1395091102L, 3735697720L, 2101727825L, 3730287744L, 2950434330L, 1661921839L, 2895579582L, 2370511479L, 1004092106L, 2247096681L, 2111242379L, 3237345263L,
4082424759L, 219785033L, 2454039889L, 3709582971L, 835606218L, 2411949883L, 2735205030L, 756421180L, 2175209704L, 1873865952L, 2762534237L, 4161807854L,
3351099340L, 181129879L, 3269891896L, 776029799L, 2218161979L, 3001745796L, 1866825872L, 2133627728L, 34862734L, 1191934573L, 3102311354L, 2916517763L,
1012402762L, 2184831317L, 4257399449L, 2899497138L, 3818095062L, 3030756734L, 1282161629L, 420003642L, 2326421477L, 2741455717L, 1278020671L, 3744179621L,
271777016L, 2626330018L, 2560563991L, 3055977700L, 4233527566L, 1228397661L, 3595579322L, 1077915006L, 2395931898L, 1851927286L, 3013683506L, 1999971931L,
3006888962L, 1049781534L, 1488758959L, 3491776230L, 104418065L, 2448267297L, 3075614115L, 3872332600L, 891912190L, 3936547759L, 2269180963L, 2633455084L,
1047636807L, 2604612377L, 2709305729L, 1952216715L, 207593580L, 2849898034L, 670771757L, 2210471108L, 467711165L, 263046873L, 3569667915L, 1042291111L,
3863517079L, 1464270005L, 2758321352L, 3790799816L, 2301278724L, 3106281430L, 7974801L, 2792461636L, 555991332L, 621766759L, 1322453093L, 853629228L, 686962251L,
1455120532L, 957753161L, 1802033300L, 1021534190L, 3486047311L, 1902128914L, 3701138056L, 4176424663L, 1795608698L, 560858864L, 3737752754L, 3141170998L,
1553553385L, 3367807274L, 711546358L, 2475125503L, 262969859L, 251416325L, 2980076994L, 1806565895L, 969527843L, 3529327173L, 2736343040L, 2987196734L,
1649016367L, 2206175811L, 3048174801L, 3662503553L, 3138851612L, 2660143804L, 1663017612L, 1816683231L, 411916003L, 3887461314L, 2347044079L, 1015311755L,
1203592432L, 2170947766L, 2569420716L, 813872093L, 1105387678L, 1431142475L, 220570551L, 4243632715L, 4179591855L, 2607469131L, 3090613241L, 282341803L,
1734241730L, 1391822177L, 1001254810L, 827927915L, 1886687171L, 3935097347L, 2631788714L, 3905163266L, 110554195L, 2447955646L, 3717202975L, 3304793075L,
3739614479L, 3059127468L, 953919171L, 2590123714L, 1132511021L, 3795593679L, 2788030429L, 982155079L, 3472349556L, 859942552L, 2681007391L, 2299624053L,
647443547L, 233600422L, 608168955L, 3689327453L, 1849778220L, 1608438222L, 3968158357L, 2692977776L, 2851872572L, 246750393L, 3582818628L, 3329652309L,
4036366910L, 1012970930L, 950780808L, 3959768744L, 2538550045L, 191422718L, 2658142375L, 3276369011L, 2927737484L, 1234200027L, 1920815603L, 3536074689L,
1535612501L, 2184142071L, 3276955054L, 428488088L, 2378411984L, 4059769550L, 3913744741L, 2732139246L, 64369859L, 3755670074L, 842839565L, 2819894466L,
2414718973L, 1010060670L, 1839715346L, 2410311136L, 152774329L, 3485009480L, 4102101512L, 2852724304L, 879944024L, 1785007662L, 2748284463L, 1354768064L,
3267784736L, 2269127717L, 3001240761L, 3179796763L, 895723219L, 865924942L, 4291570937L, 89355264L, 1471026971L, 4114180745L, 3201939751L, 2867476999L,
2460866060L, 3603874571L, 2238880432L, 3308416168L, 2072246611L, 2755653839L, 3773737248L, 1709066580L, 4282731467L, 2746170170L, 2832568330L, 433439009L,
3175778732L, 26248366L, 2551382801L, 183214346L, 3893339516L, 1928168445L, 1337157619L, 3429096554L, 3275170900L, 1782047316L, 4264403756L, 1876594403L,
4289659572L, 3223834894L, 1728705513L, 4068244734L, 2867840287L, 1147798696L, 302879820L, 1730407747L, 1923824407L, 1180597908L, 1569786639L, 198796327L,
560793173L, 2107345620L, 2705990316L, 3448772106L, 3678374155L, 758635715L, 884524671L, 486356516L, 1774865603L, 3881226226L, 2635213607L, 1181121587L,
1508809820L, 3178988241L, 1594193633L, 1235154121L, 326117244L, 2304031425L, 937054774L, 2687415945L, 3192389340L, 2003740439L, 1823766188L, 2759543402L,
10067710L, 1533252662L, 4132494984L, 82378136L, 420615890L, 3467563163L, 541562091L, 3535949864L, 2277319197L, 3330822853L, 3215654174L, 4113831979L, 4204996991L,
2162248333L, 3255093522L, 2219088909L, 2978279037L, 255818579L, 2859348628L, 3097280311L, 2569721123L, 1861951120L, 2907080079L, 2719467166L, 998319094L,
2521935127L, 2404125338L, 259456032L, 2086860995L, 1839848496L, 1893547357L, 2527997525L, 1489393124L, 2860855349L, 76448234L, 2264934035L, 744914583L,
2586791259L, 1385380501L, 66529922L, 1819103258L, 1899300332L, 2098173828L, 1793831094L, 276463159L, 360132945L, 4178212058L, 595015228L, 177071838L, 2800080290L,
1573557746L, 1548998935L, 378454223L, 1460534296L, 1116274283L, 3112385063L, 3709761796L, 827999348L, 3580042847L, 1913901014L, 614021289L, 4278528023L,
1905177404L, 45407939L, 3298183234L, 1184848810L, 3644926330L, 3923635459L, 1627046213L, 3677876759L, 969772772L, 1160524753L, 1522441192L, 452369933L,
1527502551L, 832490847L, 1003299676L, 1071381111L, 2891255476L, 973747308L, 4086897108L, 1847554542L, 3895651598L, 2227820339L, 1621250941L, 2881344691L,
3583565821L, 3510404498L, 849362119L, 862871471L, 797858058L, 2867774932L, 2821282612L, 3272403146L, 3997979905L, 209178708L, 1805135652L, 6783381L, 2823361423L,
792580494L, 4263749770L, 776439581L, 3798193823L, 2853444094L, 2729507474L, 1071873341L, 1329010206L, 1289336450L, 3327680758L, 2011491779L, 80157208L,
922428856L, 1158943220L, 1667230961L, 2461022820L, 2608845159L, 387516115L, 3345351910L, 1495629111L, 4098154157L, 3156649613L, 3525698599L, 4134908037L,
446713264L, 2137537399L, 3617403512L, 813966752L, 1157943946L, 3734692965L, 1680301658L, 3180398473L, 3509854711L, 2228114612L, 1008102291L, 486805123L,
863791847L, 3189125290L, 1050308116L, 3777341526L, 4291726501L, 844061465L, 1347461791L, 2826481581L, 745465012L, 2055805750L, 4260209475L, 2386693097L,
2980646741L, 447229436L, 2077782664L, 1232942813L, 4023002732L, 1399011509L, 3140569849L, 2579909222L, 3794857471L, 900758066L, 2887199683L, 1720257997L,
3367494931L, 2668921229L, 955539029L, 3818726432L, 1105704962L, 3889207255L, 2277369307L, 2746484505L, 1761846513L, 2413916784L, 2685127085L, 4240257943L,
1166726899L, 4215215715L, 3082092067L, 3960461946L, 1663304043L, 2087473241L, 4162589986L, 2507310778L, 1579665506L, 767234210L, 970676017L, 492207530L,
1441679602L, 1314785090L, 3262202570L, 3417091742L, 1561989210L, 3011406780L, 1146609202L, 3262321040L, 1374872171L, 1634688712L, 1280458888L, 2230023982L,
419323804L, 3262899800L, 39783310L, 1641619040L, 1700368658L, 2207946628L, 2571300939L, 2424079766L, 780290914L, 2715195096L, 3390957695L, 163151474L,
2309534542L, 1860018424L, 555755123L, 280320104L, 1604831083L, 2713022383L, 1728987441L, 3639955502L, 623065489L, 3828630947L, 4275479050L, 3516347383L,
2343951195L, 2430677756L, 635534992L, 3868699749L, 808442435L, 3070644069L, 4282166003L, 2093181383L, 2023555632L, 1568662086L, 3422372620L, 4134522350L,
3016979543L, 3259320234L, 2888030729L, 3185253876L, 4258779643L, 1267304371L, 1022517473L, 815943045L, 929020012L, 2995251018L, 3371283296L, 3608029049L,
2018485115L, 122123397L, 2810669150L, 1411365618L, 1238391329L, 1186786476L, 3155969091L, 2242941310L, 1765554882L, 279121160L, 4279838515L, 1641578514L,
3796324015L, 13351065L, 103516986L, 1609694427L, 551411743L, 2493771609L, 1316337047L, 3932650856L, 4189700203L, 463397996L, 2937735066L, 1855616529L,
2626847990L, 55091862L, 3823351211L, 753448970L, 4045045500L, 1274127772L, 1124182256L, 92039808L, 2126345552L, 425973257L, 386287896L, 2589870191L, 1987762798L,
4084826973L, 2172456685L, 3366583455L, 3602966653L, 2378803535L, 2901764433L, 3716929006L, 3710159000L, 2653449155L, 3469742630L, 3096444476L, 3932564653L,
2595257433L, 318974657L, 3146202484L, 853571438L, 144400272L, 3768408841L, 782634401L, 2161109003L, 570039522L, 1886241521L, 14249488L, 2230804228L, 1604941699L,
3928713335L, 3921942509L, 2155806892L, 134366254L, 430507376L, 1924011722L, 276713377L, 196481886L, 3614810992L, 1610021185L, 1785757066L, 851346168L,
3761148643L, 2918835642L, 3364422385L, 3012284466L, 3735958851L, 2643153892L, 3778608231L, 1164289832L, 205853021L, 2876112231L, 3503398282L, 3078397001L,
3472037921L, 1748894853L, 2740861475L, 316056182L, 1660426908L, 168885906L, 956005527L, 3984354789L, 566521563L, 1001109523L, 1216710575L, 2952284757L,
3834433081L, 3842608301L, 2467352408L, 3974441264L, 3256601745L, 1409353924L, 1329904859L, 2307560293L, 3125217879L, 3622920184L, 3832785684L, 3882365951L,
2308537115L, 2659155028L, 1450441945L, 3532257603L, 3186324194L, 1225603425L, 1124246549L, 175808705L, 3009142319L, 2796710159L, 3651990107L, 160762750L,
1902254979L, 1698648476L, 1134980669L, 497144426L, 3302689335L, 4057485630L, 3603530763L, 4087252587L, 427812652L, 286876201L, 823134128L, 1627554964L,
3745564327L, 2589226092L, 4202024494L, 62878473L, 3275585894L, 3987124064L, 2791777159L, 1916869511L, 2585861905L, 1375038919L, 1403421920L, 60249114L,
3811870450L, 3021498009L, 2612993202L, 528933105L, 2757361321L, 3341402964L, 2621861700L, 273128190L, 4015252178L, 3094781002L, 1621621288L, 2337611177L,
1796718448L, 1258965619L, 4241913140L, 2138560392L, 3022190223L, 4174180924L, 450094611L, 3274724580L, 617150026L, 2704660665L, 1469700689L, 1341616587L,
356715071L, 1188789960L, 2278869135L, 1766569160L, 2795896635L, 57824704L, 2893496380L, 1235723989L, 1630694347L, 3927960522L, 428891364L, 1814070806L,
2287999787L, 4125941184L, 3968103889L, 3548724050L, 1025597707L, 1404281500L, 2002212197L, 92429143L, 2313943944L, 2403086080L, 3006180634L, 3561981764L,
1671860914L, 1768520622L, 1803542985L, 844848113L, 3006139921L, 1410888995L, 1157749833L, 2125704913L, 1789979528L, 1799263423L, 741157179L, 2405862309L,
767040434L, 2655241390L, 3663420179L, 2172009096L, 2511931187L, 1680542666L, 231857466L, 1154981000L, 157168255L, 1454112128L, 3505872099L, 1929775046L,
2309422350L, 2143329496L, 2960716902L, 407610648L, 2938108129L, 2581749599L, 538837155L, 2342628867L, 430543915L, 740188568L, 1937713272L, 3315215132L,
2085587024L, 4030765687L, 766054429L, 3517641839L, 689721775L, 1294158986L, 1753287754L, 4202601348L, 1974852792L, 33459103L, 3568087535L, 3144677435L,
1686130825L, 4134943013L, 3005738435L, 3599293386L, 426570142L, 754104406L, 3660892564L, 1964545167L, 829466833L, 821587464L, 1746693036L, 1006492428L,
1595312919L, 1256599985L, 1024482560L, 1897312280L, 2902903201L, 691790057L, 1037515867L, 3176831208L, 1968401055L, 2173506824L, 1089055278L, 1748401123L,
2941380082L, 968412354L, 1818753861L, 2973200866L, 3875951774L, 1119354008L, 3988604139L, 1647155589L, 2232450826L, 3486058011L, 3655784043L, 3759258462L,
847163678L, 1082052057L, 989516446L, 2871541755L, 3196311070L, 3929963078L, 658187585L, 3664944641L, 2175149170L, 2203709147L, 2756014689L, 2456473919L,
3890267390L, 1293787864L, 2830347984L, 3059280931L, 4158802520L, 1561677400L, 2586570938L, 783570352L, 1355506163L, 31495586L, 3789437343L, 3340549429L,
2092501630L, 896419368L, 671715824L, 3530450081L, 3603554138L, 1055991716L, 3442308219L, 1499434728L, 3130288473L, 3639507000L, 17769680L, 2259741420L,
487032199L, 4227143402L, 3693771256L, 1880482820L, 3924810796L, 381462353L, 4017855991L, 2452034943L, 2736680833L, 2209866385L, 2128986379L, 437874044L,
595759426L, 641721026L, 1636065708L, 3899136933L, 629879088L, 3591174506L, 351984326L, 2638783544L, 2348444281L, 2341604660L, 2123933692L, 143443325L,
1525942256L, 364660499L, 599149312L, 939093251L, 1523003209L, 106601097L, 376589484L, 1346282236L, 1297387043L, 764598052L, 3741218111L, 933457002L, 1886424424L,
3219631016L, 525405256L, 3014235619L, 323149677L, 2038881721L, 4100129043L, 2851715101L, 2984028078L, 1888574695L, 2014194741L, 3515193880L, 4180573530L,
3461824363L, 2641995497L, 3179230245L, 2902294983L, 2217320456L, 4040852155L, 1784656905L, 3311906931L, 87498458L, 2752971818L, 2635474297L, 2831215366L,
3682231106L, 2920043893L, 3772929704L, 2816374944L, 309949752L, 2383758854L, 154870719L, 385111597L, 1191604312L, 1840700563L, 872191186L, 2925548701L,
1310412747L, 2102066999L, 1504727249L, 3574298750L, 1191230036L, 3330575266L, 3180292097L, 3539347721L, 681369118L, 3305125752L, 3648233597L, 950049240L,
4173257693L, 1760124957L, 512151405L, 681175196L, 580563018L, 1169662867L, 4015033554L, 2687781101L, 699691603L, 2673494188L, 1137221356L, 123599888L, 472658308L,
1053598179L, 1012713758L, 3481064843L, 3759461013L, 3981457956L, 3830587662L, 1877191791L, 3650996736L, 988064871L, 3515461600L, 4089077232L, 2225147448L,
1249609188L, 2643151863L, 3896204135L, 2416995901L, 1397735321L, 3460025646L};
1067595299L, 955945823L, 477289528L, 4107218783L, 4228976476L, 3344332714L, 3355579695L, 227628506L, 810200273L, 2591290167L,
2560260675L, 3242736208L, 646746669L, 1479517882L, 4245472273L, 1143372638L, 3863670494L, 3221021970L, 1773610557L, 1138697238L,
1421897700L, 1269916527L, 2859934041L, 1764463362L, 3874892047L, 3965319921L, 72549643L, 2383988930L, 2600218693L, 3237492380L,
2792901476L, 725331109L, 605841842L, 271258942L, 715137098L, 3297999536L, 1322965544L, 4229579109L, 1395091102L, 3735697720L,
2101727825L, 3730287744L, 2950434330L, 1661921839L, 2895579582L, 2370511479L, 1004092106L, 2247096681L, 2111242379L, 3237345263L,
4082424759L, 219785033L, 2454039889L, 3709582971L, 835606218L, 2411949883L, 2735205030L, 756421180L, 2175209704L, 1873865952L,
2762534237L, 4161807854L, 3351099340L, 181129879L, 3269891896L, 776029799L, 2218161979L, 3001745796L, 1866825872L, 2133627728L,
34862734L, 1191934573L, 3102311354L, 2916517763L, 1012402762L, 2184831317L, 4257399449L, 2899497138L, 3818095062L, 3030756734L,
1282161629L, 420003642L, 2326421477L, 2741455717L, 1278020671L, 3744179621L, 271777016L, 2626330018L, 2560563991L, 3055977700L,
4233527566L, 1228397661L, 3595579322L, 1077915006L, 2395931898L, 1851927286L, 3013683506L, 1999971931L, 3006888962L, 1049781534L,
1488758959L, 3491776230L, 104418065L, 2448267297L, 3075614115L, 3872332600L, 891912190L, 3936547759L, 2269180963L, 2633455084L,
1047636807L, 2604612377L, 2709305729L, 1952216715L, 207593580L, 2849898034L, 670771757L, 2210471108L, 467711165L, 263046873L,
3569667915L, 1042291111L, 3863517079L, 1464270005L, 2758321352L, 3790799816L, 2301278724L, 3106281430L, 7974801L, 2792461636L,
555991332L, 621766759L, 1322453093L, 853629228L, 686962251L, 1455120532L, 957753161L, 1802033300L, 1021534190L, 3486047311L,
1902128914L, 3701138056L, 4176424663L, 1795608698L, 560858864L, 3737752754L, 3141170998L, 1553553385L, 3367807274L, 711546358L,
2475125503L, 262969859L, 251416325L, 2980076994L, 1806565895L, 969527843L, 3529327173L, 2736343040L, 2987196734L, 1649016367L,
2206175811L, 3048174801L, 3662503553L, 3138851612L, 2660143804L, 1663017612L, 1816683231L, 411916003L, 3887461314L, 2347044079L,
1015311755L, 1203592432L, 2170947766L, 2569420716L, 813872093L, 1105387678L, 1431142475L, 220570551L, 4243632715L, 4179591855L,
2607469131L, 3090613241L, 282341803L, 1734241730L, 1391822177L, 1001254810L, 827927915L, 1886687171L, 3935097347L, 2631788714L,
3905163266L, 110554195L, 2447955646L, 3717202975L, 3304793075L, 3739614479L, 3059127468L, 953919171L, 2590123714L, 1132511021L,
3795593679L, 2788030429L, 982155079L, 3472349556L, 859942552L, 2681007391L, 2299624053L, 647443547L, 233600422L, 608168955L,
3689327453L, 1849778220L, 1608438222L, 3968158357L, 2692977776L, 2851872572L, 246750393L, 3582818628L, 3329652309L, 4036366910L,
1012970930L, 950780808L, 3959768744L, 2538550045L, 191422718L, 2658142375L, 3276369011L, 2927737484L, 1234200027L, 1920815603L,
3536074689L, 1535612501L, 2184142071L, 3276955054L, 428488088L, 2378411984L, 4059769550L, 3913744741L, 2732139246L, 64369859L,
3755670074L, 842839565L, 2819894466L, 2414718973L, 1010060670L, 1839715346L, 2410311136L, 152774329L, 3485009480L, 4102101512L,
2852724304L, 879944024L, 1785007662L, 2748284463L, 1354768064L, 3267784736L, 2269127717L, 3001240761L, 3179796763L, 895723219L,
865924942L, 4291570937L, 89355264L, 1471026971L, 4114180745L, 3201939751L, 2867476999L, 2460866060L, 3603874571L, 2238880432L,
3308416168L, 2072246611L, 2755653839L, 3773737248L, 1709066580L, 4282731467L, 2746170170L, 2832568330L, 433439009L, 3175778732L,
26248366L, 2551382801L, 183214346L, 3893339516L, 1928168445L, 1337157619L, 3429096554L, 3275170900L, 1782047316L, 4264403756L,
1876594403L, 4289659572L, 3223834894L, 1728705513L, 4068244734L, 2867840287L, 1147798696L, 302879820L, 1730407747L, 1923824407L,
1180597908L, 1569786639L, 198796327L, 560793173L, 2107345620L, 2705990316L, 3448772106L, 3678374155L, 758635715L, 884524671L,
486356516L, 1774865603L, 3881226226L, 2635213607L, 1181121587L, 1508809820L, 3178988241L, 1594193633L, 1235154121L, 326117244L,
2304031425L, 937054774L, 2687415945L, 3192389340L, 2003740439L, 1823766188L, 2759543402L, 10067710L, 1533252662L, 4132494984L,
82378136L, 420615890L, 3467563163L, 541562091L, 3535949864L, 2277319197L, 3330822853L, 3215654174L, 4113831979L, 4204996991L,
2162248333L, 3255093522L, 2219088909L, 2978279037L, 255818579L, 2859348628L, 3097280311L, 2569721123L, 1861951120L, 2907080079L,
2719467166L, 998319094L, 2521935127L, 2404125338L, 259456032L, 2086860995L, 1839848496L, 1893547357L, 2527997525L, 1489393124L,
2860855349L, 76448234L, 2264934035L, 744914583L, 2586791259L, 1385380501L, 66529922L, 1819103258L, 1899300332L, 2098173828L,
1793831094L, 276463159L, 360132945L, 4178212058L, 595015228L, 177071838L, 2800080290L, 1573557746L, 1548998935L, 378454223L,
1460534296L, 1116274283L, 3112385063L, 3709761796L, 827999348L, 3580042847L, 1913901014L, 614021289L, 4278528023L, 1905177404L,
45407939L, 3298183234L, 1184848810L, 3644926330L, 3923635459L, 1627046213L, 3677876759L, 969772772L, 1160524753L, 1522441192L,
452369933L, 1527502551L, 832490847L, 1003299676L, 1071381111L, 2891255476L, 973747308L, 4086897108L, 1847554542L, 3895651598L,
2227820339L, 1621250941L, 2881344691L, 3583565821L, 3510404498L, 849362119L, 862871471L, 797858058L, 2867774932L, 2821282612L,
3272403146L, 3997979905L, 209178708L, 1805135652L, 6783381L, 2823361423L, 792580494L, 4263749770L, 776439581L, 3798193823L,
2853444094L, 2729507474L, 1071873341L, 1329010206L, 1289336450L, 3327680758L, 2011491779L, 80157208L, 922428856L, 1158943220L,
1667230961L, 2461022820L, 2608845159L, 387516115L, 3345351910L, 1495629111L, 4098154157L, 3156649613L, 3525698599L, 4134908037L,
446713264L, 2137537399L, 3617403512L, 813966752L, 1157943946L, 3734692965L, 1680301658L, 3180398473L, 3509854711L, 2228114612L,
1008102291L, 486805123L, 863791847L, 3189125290L, 1050308116L, 3777341526L, 4291726501L, 844061465L, 1347461791L, 2826481581L,
745465012L, 2055805750L, 4260209475L, 2386693097L, 2980646741L, 447229436L, 2077782664L, 1232942813L, 4023002732L, 1399011509L,
3140569849L, 2579909222L, 3794857471L, 900758066L, 2887199683L, 1720257997L, 3367494931L, 2668921229L, 955539029L, 3818726432L,
1105704962L, 3889207255L, 2277369307L, 2746484505L, 1761846513L, 2413916784L, 2685127085L, 4240257943L, 1166726899L, 4215215715L,
3082092067L, 3960461946L, 1663304043L, 2087473241L, 4162589986L, 2507310778L, 1579665506L, 767234210L, 970676017L, 492207530L,
1441679602L, 1314785090L, 3262202570L, 3417091742L, 1561989210L, 3011406780L, 1146609202L, 3262321040L, 1374872171L, 1634688712L,
1280458888L, 2230023982L, 419323804L, 3262899800L, 39783310L, 1641619040L, 1700368658L, 2207946628L, 2571300939L, 2424079766L,
780290914L, 2715195096L, 3390957695L, 163151474L, 2309534542L, 1860018424L, 555755123L, 280320104L, 1604831083L, 2713022383L,
1728987441L, 3639955502L, 623065489L, 3828630947L, 4275479050L, 3516347383L, 2343951195L, 2430677756L, 635534992L, 3868699749L,
808442435L, 3070644069L, 4282166003L, 2093181383L, 2023555632L, 1568662086L, 3422372620L, 4134522350L, 3016979543L, 3259320234L,
2888030729L, 3185253876L, 4258779643L, 1267304371L, 1022517473L, 815943045L, 929020012L, 2995251018L, 3371283296L, 3608029049L,
2018485115L, 122123397L, 2810669150L, 1411365618L, 1238391329L, 1186786476L, 3155969091L, 2242941310L, 1765554882L, 279121160L,
4279838515L, 1641578514L, 3796324015L, 13351065L, 103516986L, 1609694427L, 551411743L, 2493771609L, 1316337047L, 3932650856L,
4189700203L, 463397996L, 2937735066L, 1855616529L, 2626847990L, 55091862L, 3823351211L, 753448970L, 4045045500L, 1274127772L,
1124182256L, 92039808L, 2126345552L, 425973257L, 386287896L, 2589870191L, 1987762798L, 4084826973L, 2172456685L, 3366583455L,
3602966653L, 2378803535L, 2901764433L, 3716929006L, 3710159000L, 2653449155L, 3469742630L, 3096444476L, 3932564653L, 2595257433L,
318974657L, 3146202484L, 853571438L, 144400272L, 3768408841L, 782634401L, 2161109003L, 570039522L, 1886241521L, 14249488L,
2230804228L, 1604941699L, 3928713335L, 3921942509L, 2155806892L, 134366254L, 430507376L, 1924011722L, 276713377L, 196481886L,
3614810992L, 1610021185L, 1785757066L, 851346168L, 3761148643L, 2918835642L, 3364422385L, 3012284466L, 3735958851L, 2643153892L,
3778608231L, 1164289832L, 205853021L, 2876112231L, 3503398282L, 3078397001L, 3472037921L, 1748894853L, 2740861475L, 316056182L,
1660426908L, 168885906L, 956005527L, 3984354789L, 566521563L, 1001109523L, 1216710575L, 2952284757L, 3834433081L, 3842608301L,
2467352408L, 3974441264L, 3256601745L, 1409353924L, 1329904859L, 2307560293L, 3125217879L, 3622920184L, 3832785684L, 3882365951L,
2308537115L, 2659155028L, 1450441945L, 3532257603L, 3186324194L, 1225603425L, 1124246549L, 175808705L, 3009142319L, 2796710159L,
3651990107L, 160762750L, 1902254979L, 1698648476L, 1134980669L, 497144426L, 3302689335L, 4057485630L, 3603530763L, 4087252587L,
427812652L, 286876201L, 823134128L, 1627554964L, 3745564327L, 2589226092L, 4202024494L, 62878473L, 3275585894L, 3987124064L,
2791777159L, 1916869511L, 2585861905L, 1375038919L, 1403421920L, 60249114L, 3811870450L, 3021498009L, 2612993202L, 528933105L,
2757361321L, 3341402964L, 2621861700L, 273128190L, 4015252178L, 3094781002L, 1621621288L, 2337611177L, 1796718448L, 1258965619L,
4241913140L, 2138560392L, 3022190223L, 4174180924L, 450094611L, 3274724580L, 617150026L, 2704660665L, 1469700689L, 1341616587L,
356715071L, 1188789960L, 2278869135L, 1766569160L, 2795896635L, 57824704L, 2893496380L, 1235723989L, 1630694347L, 3927960522L,
428891364L, 1814070806L, 2287999787L, 4125941184L, 3968103889L, 3548724050L, 1025597707L, 1404281500L, 2002212197L, 92429143L,
2313943944L, 2403086080L, 3006180634L, 3561981764L, 1671860914L, 1768520622L, 1803542985L, 844848113L, 3006139921L, 1410888995L,
1157749833L, 2125704913L, 1789979528L, 1799263423L, 741157179L, 2405862309L, 767040434L, 2655241390L, 3663420179L, 2172009096L,
2511931187L, 1680542666L, 231857466L, 1154981000L, 157168255L, 1454112128L, 3505872099L, 1929775046L, 2309422350L, 2143329496L,
2960716902L, 407610648L, 2938108129L, 2581749599L, 538837155L, 2342628867L, 430543915L, 740188568L, 1937713272L, 3315215132L,
2085587024L, 4030765687L, 766054429L, 3517641839L, 689721775L, 1294158986L, 1753287754L, 4202601348L, 1974852792L, 33459103L,
3568087535L, 3144677435L, 1686130825L, 4134943013L, 3005738435L, 3599293386L, 426570142L, 754104406L, 3660892564L, 1964545167L,
829466833L, 821587464L, 1746693036L, 1006492428L, 1595312919L, 1256599985L, 1024482560L, 1897312280L, 2902903201L, 691790057L,
1037515867L, 3176831208L, 1968401055L, 2173506824L, 1089055278L, 1748401123L, 2941380082L, 968412354L, 1818753861L, 2973200866L,
3875951774L, 1119354008L, 3988604139L, 1647155589L, 2232450826L, 3486058011L, 3655784043L, 3759258462L, 847163678L, 1082052057L,
989516446L, 2871541755L, 3196311070L, 3929963078L, 658187585L, 3664944641L, 2175149170L, 2203709147L, 2756014689L, 2456473919L,
3890267390L, 1293787864L, 2830347984L, 3059280931L, 4158802520L, 1561677400L, 2586570938L, 783570352L, 1355506163L, 31495586L,
3789437343L, 3340549429L, 2092501630L, 896419368L, 671715824L, 3530450081L, 3603554138L, 1055991716L, 3442308219L, 1499434728L,
3130288473L, 3639507000L, 17769680L, 2259741420L, 487032199L, 4227143402L, 3693771256L, 1880482820L, 3924810796L, 381462353L,
4017855991L, 2452034943L, 2736680833L, 2209866385L, 2128986379L, 437874044L, 595759426L, 641721026L, 1636065708L, 3899136933L,
629879088L, 3591174506L, 351984326L, 2638783544L, 2348444281L, 2341604660L, 2123933692L, 143443325L, 1525942256L, 364660499L,
599149312L, 939093251L, 1523003209L, 106601097L, 376589484L, 1346282236L, 1297387043L, 764598052L, 3741218111L, 933457002L,
1886424424L, 3219631016L, 525405256L, 3014235619L, 323149677L, 2038881721L, 4100129043L, 2851715101L, 2984028078L, 1888574695L,
2014194741L, 3515193880L, 4180573530L, 3461824363L, 2641995497L, 3179230245L, 2902294983L, 2217320456L, 4040852155L, 1784656905L,
3311906931L, 87498458L, 2752971818L, 2635474297L, 2831215366L, 3682231106L, 2920043893L, 3772929704L, 2816374944L, 309949752L,
2383758854L, 154870719L, 385111597L, 1191604312L, 1840700563L, 872191186L, 2925548701L, 1310412747L, 2102066999L, 1504727249L,
3574298750L, 1191230036L, 3330575266L, 3180292097L, 3539347721L, 681369118L, 3305125752L, 3648233597L, 950049240L, 4173257693L,
1760124957L, 512151405L, 681175196L, 580563018L, 1169662867L, 4015033554L, 2687781101L, 699691603L, 2673494188L, 1137221356L,
123599888L, 472658308L, 1053598179L, 1012713758L, 3481064843L, 3759461013L, 3981457956L, 3830587662L, 1877191791L, 3650996736L,
988064871L, 3515461600L, 4089077232L, 2225147448L, 1249609188L, 2643151863L, 3896204135L, 2416995901L, 1397735321L, 3460025646L};
/**
* Compare results with
* http://www.math.keio.ac.jp/matumoto/CODES/MT2002/mt19937ar.out
* Compare results with http://www.math.keio.ac.jp/matumoto/CODES/MT2002/mt19937ar.out
*/
@Test
public void testCorrectness() {

View File

@ -22,13 +22,16 @@ public class DateTimeHelperTest {
assertEquals("01h 00m 00s", DateTimeHelper.getDeltaBetweenTimestamps(0, 60 * 1000 * 60));
assertEquals("12h 34m 56s", DateTimeHelper.getDeltaBetweenTimestamps(0, 60 * 1000 * 60 * 12 + 60 * 1000 * 34 + 56 * 1000));
assertEquals("1 Days 01h 00m 00s", DateTimeHelper.getDeltaBetweenTimestamps(0, 60 * 1000 * 60 * 25));
assertEquals("1 Days 01h 20m 40s", DateTimeHelper.getDeltaBetweenTimestamps(0, 60 * 1000 * 60 * 24 + 60 * 1000 * 60 + 60 * 1000 * 20 + 40 * 1000));
assertEquals("1 Days 01h 00m 00s",
DateTimeHelper.getDeltaBetweenTimestamps(0, 60 * 1000 * 60 * 25));
assertEquals("1 Days 01h 20m 40s",
DateTimeHelper.getDeltaBetweenTimestamps(0, 60 * 1000 * 60 * 24 + 60 * 1000 * 60 + 60 * 1000 * 20 + 40 * 1000));
assertEquals("00h 00m 00s", DateTimeHelper.getDeltaBetweenTimestamps(1000, 1000));
assertEquals("00h 00m 00s", DateTimeHelper.getDeltaBetweenTimestamps(50000, 50000));
assertEquals("11h 01m 01s", DateTimeHelper.getDeltaBetweenTimestamps(1000 * 60 * 25, 1000 * 60 * 25 + 60 * 1000 * 60 * 11 + 60 * 1000 + 1000));
assertEquals("11h 01m 01s",
DateTimeHelper.getDeltaBetweenTimestamps(1000 * 60 * 25, 1000 * 60 * 25 + 60 * 1000 * 60 * 11 + 60 * 1000 + 1000));
}
@Test

View File

@ -15,7 +15,8 @@ import org.terasology.gestalt.assets.ResourceUrn;
public abstract class Sound<T extends AssetData> extends Asset<T> implements org.terasology.nui.asset.Sound {
/**
* The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
* The constructor for an asset.
* It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
*
* @param urn The urn identifying the asset.
* @param assetType The asset type this asset belongs to.
@ -25,7 +26,8 @@ public abstract class Sound<T extends AssetData> extends Asset<T> implements org
}
/**
* The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
* The constructor for an asset.
* It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
*
* @param urn The urn identifying the asset.
* @param assetType The asset type this asset belongs to.

View File

@ -13,7 +13,8 @@ import org.terasology.gestalt.assets.ResourceUrn;
public abstract class StaticSound extends Sound<StaticSoundData> {
/**
* The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
* The constructor for an asset.
* It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
*
* @param urn The urn identifying the asset.
* @param assetType The asset type this asset belongs to.
@ -23,7 +24,8 @@ public abstract class StaticSound extends Sound<StaticSoundData> {
}
/**
* The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
* The constructor for an asset.
* It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
*
* @param urn The urn identifying the asset.
* @param assetType The asset type this asset belongs to.

View File

@ -13,7 +13,8 @@ import org.terasology.gestalt.assets.ResourceUrn;
public abstract class StreamingSound extends Sound<StreamingSoundData> {
/**
* The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
* The constructor for an asset.
* It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
*
* @param urn The urn identifying the asset.
* @param assetType The asset type this asset belongs to.
@ -23,7 +24,8 @@ public abstract class StreamingSound extends Sound<StreamingSoundData> {
}
/**
* The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
* The constructor for an asset.
* It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
*
* @param urn The urn identifying the asset.
* @param assetType The asset type this asset belongs to.

View File

@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
/**
* This package provides a low-level system for describing classes and fields, with support for construction and field access. Essentially it is a simplified reflection
* This package provides a low-level system for describing classes and fields, with support for construction and field access.
* Essentially it is a simplified reflection
* framework.
* <br><br>
* To support this functionality, a copy-strategy library is used to provide copying support for types. This is used instead of cloning because

View File

@ -276,12 +276,14 @@ public class OpenALManager implements AudioManager {
@Override
public AssetFactory<StaticSound, StaticSoundData> getStaticSoundFactory() {
return (urn, assetType, data) -> new OpenALSound(urn, assetType, data, OpenALManager.this, new OpenALSound.DisposalAction(urn));
return (urn, assetType, data) -> new OpenALSound(urn, assetType, data,
OpenALManager.this, new OpenALSound.DisposalAction(urn));
}
@Override
public AssetFactory<StreamingSound, StreamingSoundData> getStreamingSoundFactory() {
return (urn, assetType, data) -> new OpenALStreamingSound(urn, assetType, data, OpenALManager.this, new OpenALStreamingSound.DisposalAction(urn));
return (urn, assetType, data) -> new OpenALStreamingSound(urn, assetType, data,
OpenALManager.this, new OpenALStreamingSound.DisposalAction(urn));
}
public void purgeSound(Sound<?> sound) {

View File

@ -35,7 +35,8 @@ public final class OpenALSound extends StaticSound {
// TODO: Do we have proper support for unloading sounds (as mods are changed?)
private int bufferId;
public OpenALSound(ResourceUrn urn, AssetType<?, StaticSoundData> assetType, StaticSoundData data, OpenALManager audioManager, OpenALSound.DisposalAction disposalAction) {
public OpenALSound(ResourceUrn urn, AssetType<?, StaticSoundData> assetType, StaticSoundData data,
OpenALManager audioManager, OpenALSound.DisposalAction disposalAction) {
super(urn, assetType, disposalAction);
disposalAction.setAsset(this);
this.audioManager = audioManager;
@ -92,7 +93,8 @@ public final class OpenALSound extends StaticSound {
audioManager.purgeSound(this);
}
AL10.alBufferData(bufferId, newData.getChannels() == 1 ? AL10.AL_FORMAT_MONO16 : AL10.AL_FORMAT_STEREO16, newData.getData(), newData.getSampleRate());
AL10.alBufferData(bufferId, newData.getChannels() == 1 ? AL10.AL_FORMAT_MONO16 : AL10.AL_FORMAT_STEREO16,
newData.getData(), newData.getSampleRate());
OpenALException.checkState("Allocating sound buffer");
int bits = newData.getBufferBits();

View File

@ -23,8 +23,10 @@ import java.util.Map;
public class SecurityConfig {
public static final SecurityPermission PRIVATE_CERTIFICATE_ACCESS_PERMISSION = new SecurityPermission("PRIVATE_CERTIFICATE_ACCESS_PERMISSION");
public static final SecurityPermission CERTIFICATE_WRITE_PERMISSION = new SecurityPermission("CERTIFICATE_WRITE_PERMISSION");
public static final SecurityPermission PRIVATE_CERTIFICATE_ACCESS_PERMISSION =
new SecurityPermission("PRIVATE_CERTIFICATE_ACCESS_PERMISSION");
public static final SecurityPermission CERTIFICATE_WRITE_PERMISSION =
new SecurityPermission("CERTIFICATE_WRITE_PERMISSION");
private PublicIdentityCertificate serverPublicCertificate;
private PrivateIdentityCertificate serverPrivateCertificate;
@ -76,14 +78,17 @@ public class SecurityConfig {
public static final String CLIENT_IDENTITIES = "clientIdentities";
@Override
public SecurityConfig deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
public SecurityConfig deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
SecurityConfig result = new SecurityConfig();
JsonObject jsonObject = json.getAsJsonObject();
if (jsonObject.has(SERVER_PUBLIC_CERTIFICATE)) {
result.serverPublicCertificate = context.deserialize(jsonObject.getAsJsonObject(SERVER_PUBLIC_CERTIFICATE), PublicIdentityCertificate.class);
result.serverPublicCertificate = context.deserialize(jsonObject.getAsJsonObject(SERVER_PUBLIC_CERTIFICATE),
PublicIdentityCertificate.class);
}
if (jsonObject.has(SERVER_PRIVATE_CERTIFICATE)) {
result.serverPrivateCertificate = context.deserialize(jsonObject.getAsJsonObject(SERVER_PRIVATE_CERTIFICATE), PrivateIdentityCertificate.class);
result.serverPrivateCertificate = context.deserialize(jsonObject.getAsJsonObject(SERVER_PRIVATE_CERTIFICATE),
PrivateIdentityCertificate.class);
}
if (jsonObject.has(CLIENT_IDENTITIES)) {
JsonArray clientArray = jsonObject.getAsJsonArray(CLIENT_IDENTITIES);

View File

@ -16,7 +16,9 @@ public class TelemetryConfig {
private boolean telemetryEnabled;
private String telemetryDestination = TelemetryEmitter.getDefaultCollectorURL(DEFAULT_COLLECTOR_PROTOCOL, DEFAULT_COLLECTOR_HOST, DEFAULT_COLLECTOR_PORT).toString();
private String telemetryDestination = TelemetryEmitter
.getDefaultCollectorURL(DEFAULT_COLLECTOR_PROTOCOL, DEFAULT_COLLECTOR_HOST, DEFAULT_COLLECTOR_PORT)
.toString();
private String telemetryServerName = TelemetryEmitter.DEFAULT_COLLECTOR_NAME;
@ -24,7 +26,8 @@ public class TelemetryConfig {
private boolean errorReportingEnabled;
private String errorReportingDestination = TelemetryLogstashAppender.DEFAULT_LOGSTASH_HOST + ":" + TelemetryLogstashAppender.DEFAULT_LOGSTASH_PORT;
private String errorReportingDestination = TelemetryLogstashAppender.DEFAULT_LOGSTASH_HOST
+ ":" + TelemetryLogstashAppender.DEFAULT_LOGSTASH_PORT;
private String errorReportingServerName = TelemetryLogstashAppender.DEFAULT_LOGSTASH_NAME;

View File

@ -11,7 +11,8 @@ import java.util.Optional;
/**
* Creates {@link UIWidget}s by {@link Setting} and used {@link SettingConstraint}
* <p>
* You should to implement {@link ConstraintWidgetFactory} if you what use custom type in your {@link org.terasology.engine.config.flexible.AutoConfig}
* You should to implement {@link ConstraintWidgetFactory} if you what use custom type
* in your {@link org.terasology.engine.config.flexible.AutoConfig}
*
* @param <T> type of setting
* @param <C> concrete type of {@link SettingConstraint}

View File

@ -3,8 +3,8 @@
package org.terasology.engine.core;
/**
* Engine Status provides the current status of the engine - what it is doing, at a higher granularity than just running. This can be used by external and internal observers
* to report on the state of the engine, such as splash screens/loading screens.
* Engine Status provides the current status of the engine - what it is doing, at a higher granularity than just running.
* This can be used by external and internal observers to report on the state of the engine, such as splash screens/loading screens.
*/
public interface EngineStatus {

View File

@ -146,9 +146,13 @@ public final class EntitySystemSetupUtil {
registerEvents(entityManager.getEventSystem(), environment);
}
private static EventSystem createEventSystem(NetworkSystem networkSystem, PojoEntityManager entityManager, EntitySystemLibrary library,
RecordedEventStore recordedEventStore, RecordAndReplaySerializer recordAndReplaySerializer,
RecordAndReplayUtils recordAndReplayUtils, RecordAndReplayCurrentStatus recordAndReplayCurrentStatus) {
private static EventSystem createEventSystem(NetworkSystem networkSystem,
PojoEntityManager entityManager,
EntitySystemLibrary library,
RecordedEventStore recordedEventStore,
RecordAndReplaySerializer recordAndReplaySerializer,
RecordAndReplayUtils recordAndReplayUtils,
RecordAndReplayCurrentStatus recordAndReplayCurrentStatus) {
EventSystem eventSystem;
List<Class<?>> selectedClassesToRecord = createSelectedClassesToRecordList();
if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.PREPARING_REPLAY) {
@ -167,7 +171,8 @@ public final class EntitySystemSetupUtil {
for (Class<? extends Component> componentType : environment.getSubtypesOf(Component.class)) {
if (componentType.getAnnotation(DoNotAutoRegister.class) == null) {
String componentName = MetadataUtil.getComponentClassName(componentType);
Name componentModuleName = verifyNotNull(environment.getModuleProviding(componentType), "Could not find module for %s %s", componentName, componentType);
Name componentModuleName = verifyNotNull(environment.getModuleProviding(componentType),
"Could not find module for %s %s", componentName, componentType);
library.register(new ResourceUrn(componentModuleName.toString(), componentName), componentType);
}
}

View File

@ -184,7 +184,6 @@ public final class EnvironmentSwitchHandler {
}
}
@SuppressWarnings({"rawtypes", "unchecked"})
private static void registerTypeHandlers(Context context, TypeHandlerLibrary library, ModuleEnvironment environment) {
for (Class<? extends TypeHandler> handler : environment.getSubtypesOf(TypeHandler.class)) {

View File

@ -8,8 +8,9 @@ import org.terasology.gestalt.module.sandbox.API;
/**
* Event which is triggered when LocalPlayer is setup with a character entity. Allows for detection of when LocalPlayer is
* completely setup for a character, in case a system needs to wait until it is setup and therefore cannot act in {@link BaseComponentSystem#postBegin()}
* Event is sent to the character entity. This only triggers at the setup of the local player(once per in game session). It is sent by
* completely setup for a character, in case a system needs to wait until it is setup and therefore cannot act
* an {@link BaseComponentSystem#postBegin()} Event is sent to the character entity.
* This only triggers at the setup of the local player(once per in game session). It is sent by
* {@link AwaitCharacterSpawn}
*
* API annotation is to allow modules to utilize this event as well.

View File

@ -16,8 +16,9 @@ public interface EngineSubsystem {
String getName();
/**
* Called on each system before initialisation. This is an opportunity to add anything into the root context that will carry across the entire rune
* of the engine, and may be used by other systems
* Called on each system before initialisation.
* This is an opportunity to add anything into the root context that will carry across the entire rune of the engine,
* and may be used by other systems
*
* @param rootContext The root context, that will survive the entire run of the engine
*/

View File

@ -227,7 +227,9 @@ public class BindsSubsystem implements EngineSubsystem, BindsManager {
bindButton.setMode(info.mode());
bindButton.setRepeating(info.repeating());
bindsConfiguration.getBinds(bindUri).stream().filter(input -> input != null).forEach(input -> linkBindButtonToInput(input, bindUri));
bindsConfiguration.getBinds(bindUri).stream()
.filter(input -> input != null)
.forEach(input -> linkBindButtonToInput(input, bindUri));
logger.debug("Registered button bind: {}", bindUri);
} catch (InstantiationException | IllegalAccessException e) {
@ -257,7 +259,8 @@ public class BindsSubsystem implements EngineSubsystem, BindsManager {
continue;
}
try {
BindableAxis bindAxis = registerBindAxis(id.toString(), (BindAxisEvent) registerBindClass.newInstance(), positiveButton, negativeButton);
BindableAxis bindAxis = registerBindAxis(id.toString(), (BindAxisEvent) registerBindClass.newInstance(),
positiveButton, negativeButton);
bindAxis.setSendEventMode(info.eventMode());
logger.debug("Registered axis bind: {}", id);
} catch (InstantiationException | IllegalAccessException e) {

View File

@ -34,7 +34,8 @@ public class HeadlessCanvasRenderer implements TerasologyCanvasRenderer {
}
@Override
public void drawMesh(Mesh mesh, Material material, Rectanglei drawRegion, Rectanglei cropRegion, Quaternionfc rotation, Vector3fc offset, float scale, float alpha) {
public void drawMesh(Mesh mesh, Material material, Rectanglei drawRegion, Rectanglei cropRegion,
Quaternionfc rotation, Vector3fc offset, float scale, float alpha) {
// Do nothing
}
@ -64,18 +65,20 @@ public class HeadlessCanvasRenderer implements TerasologyCanvasRenderer {
}
@Override
public void drawTexture(UITextureRegion texture, Colorc color, ScaleMode mode, Rectanglei absoluteRegion, float ux, float uy, float uw, float uh, float alpha) {
public void drawTexture(UITextureRegion texture, Colorc color, ScaleMode mode, Rectanglei absoluteRegion,
float ux, float uy, float uw, float uh, float alpha) {
// Do nothing
}
@Override
public void drawText(String text, Font font, HorizontalAlign hAlign, VerticalAlign vAlign, Rectanglei absoluteRegion, Colorc color, Colorc shadowColor,
float alpha, boolean underlined) {
public void drawText(String text, Font font, HorizontalAlign hAlign, VerticalAlign vAlign, Rectanglei absoluteRegion,
Colorc color, Colorc shadowColor, float alpha, boolean underlined) {
// Do nothing
}
@Override
public void drawTextureBordered(UITextureRegion texture, Rectanglei absoluteRegion, Border border, boolean tile, float ux, float uy, float uw, float uh, float alpha) {
public void drawTextureBordered(UITextureRegion texture, Rectanglei absoluteRegion, Border border, boolean tile,
float ux, float uy, float uw, float uh, float alpha) {
// Do nothing
}

View File

@ -29,7 +29,9 @@ import java.util.List;
public class HeadlessWorldRenderer implements WorldRenderer {
private static final int MAX_CHUNKS = ViewDistance.MEGA.getChunkDistance().x() * ViewDistance.MEGA.getChunkDistance().y() * ViewDistance.MEGA.getChunkDistance().z();
private static final int MAX_CHUNKS = ViewDistance.MEGA.getChunkDistance().x()
* ViewDistance.MEGA.getChunkDistance().y()
* ViewDistance.MEGA.getChunkDistance().z();
private WorldProvider worldProvider;
private ChunkProvider chunkProvider;
@ -193,20 +195,22 @@ public class HeadlessWorldRenderer implements WorldRenderer {
boolean chunksCurrentlyPending = false;
if (!newChunkPos.equals(chunkPos) || force || pendingChunks) {
Vector3ic viewingDistance = config.getRendering().getViewDistance().getChunkDistance();
BlockRegion viewRegion = new BlockRegion(newChunkPos).expand(new org.joml.Vector3i(viewingDistance.x() / 2, viewingDistance.y() / 2, viewingDistance.z() / 2));
BlockRegion viewRegion = new BlockRegion(newChunkPos)
.expand(new Vector3i(viewingDistance.x() / 2, viewingDistance.y() / 2, viewingDistance.z() / 2));
if (chunksInProximity.size() == 0 || force || pendingChunks) {
// just add all visible chunks
chunksInProximity.clear();
for (Vector3ic chunkPosition : viewRegion) {
Chunk c = chunkProvider.getChunk(chunkPosition);
if (c != null && worldProvider.getLocalView(c.getPosition(new org.joml.Vector3i())) != null) {
if (c != null && worldProvider.getLocalView(c.getPosition(new Vector3i())) != null) {
chunksInProximity.add(c);
} else {
chunksCurrentlyPending = true;
}
}
} else {
BlockRegion oldRegion = new BlockRegion(chunkPos).expand(new org.joml.Vector3i(viewingDistance.x() / 2, viewingDistance.y() / 2, viewingDistance.z() / 2));
BlockRegion oldRegion = new BlockRegion(chunkPos)
.expand(new Vector3i(viewingDistance.x() / 2, viewingDistance.y() / 2, viewingDistance.z() / 2));
// remove
for (Vector3ic candidateForRemove : viewRegion) {
@ -222,7 +226,7 @@ public class HeadlessWorldRenderer implements WorldRenderer {
// add
for (Vector3ic chunkPosition : viewRegion) {
Chunk c = chunkProvider.getChunk(chunkPosition);
if (c != null && worldProvider.getLocalView(c.getPosition(new org.joml.Vector3i())) != null) {
if (c != null && worldProvider.getLocalView(c.getPosition(new Vector3i())) != null) {
chunksInProximity.add(c);
} else {
chunksCurrentlyPending = true;

View File

@ -28,7 +28,8 @@ public interface EventSystem {
void registerEvent(ResourceUrn uri, Class<? extends Event> eventType);
/**
* Registers an object as an event handler - all methods with the {@link org.terasology.engine.entitySystem.event.ReceiveEvent} annotation will be registered
* Registers an object as an event handler - all methods with the {@link org.terasology.engine.entitySystem.event.ReceiveEvent}
* annotation will be registered
*
* @param handler
*/
@ -48,7 +49,8 @@ public interface EventSystem {
* @param componentTypes
* @param <T>
*/
<T extends Event> void registerEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass, Class<? extends Component>... componentTypes);
<T extends Event> void registerEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass,
Class<? extends Component>... componentTypes);
/**
* @param eventReceiver
@ -57,9 +59,11 @@ public interface EventSystem {
* @param componentTypes
* @param <T>
*/
<T extends Event> void registerEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass, int priority, Class<? extends Component>... componentTypes);
<T extends Event> void registerEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass,
int priority, Class<? extends Component>... componentTypes);
<T extends Event> void unregisterEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass, Class<? extends Component>... componentTypes);
<T extends Event> void unregisterEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass,
Class<? extends Component>... componentTypes);
/**
* Sends an event to all handlers for an entity's components

View File

@ -19,7 +19,8 @@ import java.util.Collection;
import java.util.Map;
/**
* Field Metadata for the fields of components. In addition to the standard and replication metadata, has information on whether the field declares ownership over an entity.
* Field Metadata for the fields of components.
* In addition to the standard and replication metadata, has information on whether the field declares ownership over an entity.
*
*/
public class ComponentFieldMetadata<T extends Component, U> extends ReplicatedFieldMetadata<T, U> {
@ -28,14 +29,16 @@ public class ComponentFieldMetadata<T extends Component, U> extends ReplicatedFi
private final CopyStrategy<U> copyWithOwnedEntitiesStrategy;
public ComponentFieldMetadata(ClassMetadata<T, ?> owner, Field field, CopyStrategyLibrary copyStrategyLibrary, ReflectFactory factory, boolean replicatedByDefault)
public ComponentFieldMetadata(ClassMetadata<T, ?> owner, Field field, CopyStrategyLibrary copyStrategyLibrary,
ReflectFactory factory, boolean replicatedByDefault)
throws InaccessibleFieldException {
super(owner, field, copyStrategyLibrary, factory, replicatedByDefault);
ownedReference = field.getAnnotation(Owns.class) != null && (EntityRef.class.isAssignableFrom(field.getType())
|| isCollectionOf(EntityRef.class, field.getGenericType()));
if (ownedReference) {
copyWithOwnedEntitiesStrategy =
(CopyStrategy<U>) copyStrategyLibrary.createCopyOfLibraryWithStrategy(EntityRef.class, EntityCopyStrategy.INSTANCE).getStrategy(field.getGenericType());
copyWithOwnedEntitiesStrategy = (CopyStrategy<U>) copyStrategyLibrary
.createCopyOfLibraryWithStrategy(EntityRef.class, EntityCopyStrategy.INSTANCE)
.getStrategy(field.getGenericType());
} else {
copyWithOwnedEntitiesStrategy = copyStrategy;
}

View File

@ -40,7 +40,8 @@ public class ComponentLibrary extends ModuleClassLibrary<Component> {
}
@Override
protected <C extends Component> ClassMetadata<C, ?> createMetadata(Class<C> type, ReflectFactory factory, CopyStrategyLibrary copyStrategies, ResourceUrn uri) {
protected <C extends Component> ClassMetadata<C, ?> createMetadata(Class<C> type, ReflectFactory factory,
CopyStrategyLibrary copyStrategies, ResourceUrn uri) {
ComponentMetadata<C> info;
try {
info = new ComponentMetadata<>(uri, type, factory, copyStrategies);

View File

@ -42,7 +42,8 @@ public class ComponentMetadata<T extends Component> extends ClassMetadata<T, Com
* @param copyStrategies A copy strategy library
* @throws NoSuchMethodException If the component has no default constructor
*/
public ComponentMetadata(ResourceUrn uri, Class<T> type, ReflectFactory factory, CopyStrategyLibrary copyStrategies) throws NoSuchMethodException {
public ComponentMetadata(ResourceUrn uri, Class<T> type, ReflectFactory factory, CopyStrategyLibrary copyStrategies)
throws NoSuchMethodException {
super(uri.toString(), type, factory, copyStrategies, Predicates.<Field>alwaysTrue());
persisted = type.getAnnotation(DoNotPersist.class) == null;
replicated = type.getAnnotation(Replicate.class) != null;
@ -69,7 +70,8 @@ public class ComponentMetadata<T extends Component> extends ClassMetadata<T, Com
}
@Override
protected ComponentFieldMetadata<T, ?> createField(Field field, CopyStrategyLibrary copyStrategyLibrary, ReflectFactory factory) throws InaccessibleFieldException {
protected ComponentFieldMetadata<T, ?> createField(Field field, CopyStrategyLibrary copyStrategyLibrary, ReflectFactory factory)
throws InaccessibleFieldException {
return new ComponentFieldMetadata<>(this, field, copyStrategyLibrary, factory, false);
}

View File

@ -25,7 +25,8 @@ public class EventLibrary extends ModuleClassLibrary<Event> {
}
@Override
protected <C extends Event> ClassMetadata<C, ?> createMetadata(Class<C> type, ReflectFactory factory, CopyStrategyLibrary copyStrategies, ResourceUrn uri) {
protected <C extends Event> ClassMetadata<C, ?> createMetadata(Class<C> type, ReflectFactory factory,
CopyStrategyLibrary copyStrategies, ResourceUrn uri) {
try {
return new EventMetadata<>(type, copyStrategies, factory, uri);
} catch (NoSuchMethodException e) {

View File

@ -25,7 +25,8 @@ public class EventMetadata<T extends Event> extends ClassMetadata<T, ReplicatedF
private boolean lagCompensated;
private boolean skipInstigator;
public EventMetadata(Class<T> simpleClass, CopyStrategyLibrary copyStrategies, ReflectFactory factory, ResourceUrn uri) throws NoSuchMethodException {
public EventMetadata(Class<T> simpleClass, CopyStrategyLibrary copyStrategies, ReflectFactory factory, ResourceUrn uri)
throws NoSuchMethodException {
super(uri.toString(), simpleClass, factory, copyStrategies, Predicates.<Field>alwaysTrue());
if (simpleClass.getAnnotation(ServerEvent.class) != null) {
networkEventType = NetworkEventType.SERVER;
@ -70,7 +71,8 @@ public class EventMetadata<T extends Event> extends ClassMetadata<T, ReplicatedF
}
@Override
protected ReplicatedFieldMetadata<T, ?> createField(Field field, CopyStrategyLibrary copyStrategyLibrary, ReflectFactory factory) throws InaccessibleFieldException {
protected ReplicatedFieldMetadata<T, ?> createField(Field field, CopyStrategyLibrary copyStrategyLibrary, ReflectFactory factory)
throws InaccessibleFieldException {
return new ReplicatedFieldMetadata<>(this, field, copyStrategyLibrary, factory, true);
}
}

View File

@ -21,7 +21,8 @@ public class ReplicatedFieldMetadata<T, U> extends FieldMetadata<T, U> {
private boolean replicated;
private Replicate replicationInfo;
public ReplicatedFieldMetadata(ClassMetadata<T, ?> owner, Field field, CopyStrategyLibrary copyStrategyLibrary, ReflectFactory factory, boolean replicatedByDefault)
public ReplicatedFieldMetadata(ClassMetadata<T, ?> owner, Field field, CopyStrategyLibrary copyStrategyLibrary,
ReflectFactory factory, boolean replicatedByDefault)
throws InaccessibleFieldException {
super(owner, field, copyStrategyLibrary, factory);
this.replicated = replicatedByDefault;

View File

@ -4,7 +4,8 @@ package org.terasology.engine.entitySystem.systems;
public interface ComponentSystem {
/**
* Called to initialise the system. This occurs after injection, but before other systems are necessarily initialised, so they should not be interacted with.
* Called to initialise the system.
* This occurs after injection, but before other systems are necessarily initialised, so they should not be interacted with.
*/
void initialise();

View File

@ -34,7 +34,8 @@ public class CertificateGenerator {
keyFactory = KeyFactory.getInstance(IdentityConstants.CERTIFICATE_ALGORITHM);
signer = Signature.getInstance(IdentityConstants.SIGNATURE_ALGORITHM);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM + "', required for identity management", e);
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM
+ "', required for identity management", e);
}
}

View File

@ -50,7 +50,8 @@ public class ClientIdentity {
}
if (obj instanceof ClientIdentity) {
ClientIdentity other = (ClientIdentity) obj;
return Objects.equals(playerPublicCertificate, other.playerPublicCertificate) && Objects.equals(playerPrivateCertificate, other.playerPrivateCertificate);
return Objects.equals(playerPublicCertificate, other.playerPublicCertificate)
&& Objects.equals(playerPrivateCertificate, other.playerPrivateCertificate);
}
return false;
}

View File

@ -77,7 +77,8 @@ public class PrivateIdentityCertificate {
cipher.init(Cipher.DECRYPT_MODE, key);
return cipher.doFinal(data);
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM + "', required for identity management", e);
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM
+ "', required for identity management", e);
} catch (InvalidKeySpecException | InvalidKeyException e) {
throw new RuntimeException("Unexpected error during encryption", e);
} catch (BadPaddingException | IllegalBlockSizeException e) {

View File

@ -108,7 +108,8 @@ public class PublicIdentityCertificate {
cipher.init(Cipher.ENCRYPT_MODE, key);
return cipher.doFinal(data);
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM + "', required for identity management", e);
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM
+ "', required for identity management", e);
} catch (InvalidKeySpecException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException e) {
throw new RuntimeException("Unexpected error during encryption", e);
}
@ -141,7 +142,8 @@ public class PublicIdentityCertificate {
signatureVerifier.update(exponent.toByteArray());
return signatureVerifier.verify(getSignatureBytes());
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM + "', required for identity management", e);
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM
+ "', required for identity management", e);
} catch (InvalidKeySpecException e) {
return false;
} catch (SignatureException e) {
@ -169,7 +171,8 @@ public class PublicIdentityCertificate {
signatureVerifier.update(data);
return signatureVerifier.verify(signedData);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM + "', required for identity management", e);
throw new RuntimeException("Insufficient support for '" + IdentityConstants.CERTIFICATE_ALGORITHM
+ "', required for identity management", e);
} catch (InvalidKeySpecException e) {
return false;
} catch (SignatureException e) {

View File

@ -29,7 +29,8 @@ final class APISession {
static APISession createFromLogin(URL hostURL, String login, String password) throws IOException, StorageServiceException {
SessionPostRequestData req = new SessionPostRequestData(login, password);
SessionPostResponseData res = ServiceApiRequest.request(new URL(hostURL, ENDPOINT_SESSION), HttpMethod.POST, null, req, SessionPostResponseData.class);
SessionPostResponseData res = ServiceApiRequest.request(new URL(hostURL, ENDPOINT_SESSION), HttpMethod.POST,
null, req, SessionPostResponseData.class);
return new APISession(hostURL, res.token);
}
@ -52,7 +53,8 @@ final class APISession {
}
Map<PublicIdentityCertificate, ClientIdentity> getAllIdentities() throws IOException, StorageServiceException {
AllIdentitiesGetResponseData res = requestEndpoint(ENDPOINT_CLIENT_IDENTITY, null, HttpMethod.GET, null, AllIdentitiesGetResponseData.class);
AllIdentitiesGetResponseData res = requestEndpoint(ENDPOINT_CLIENT_IDENTITY, null, HttpMethod.GET,
null, AllIdentitiesGetResponseData.class);
return IdentityBundle.listToMap(res.clientIdentities);
}

View File

@ -21,7 +21,8 @@ import java.net.URLDecoder;
*/
final class ServiceApiRequest {
private static final Gson GSON = new GsonBuilder().registerTypeHierarchyAdapter(BigInteger.class, BigIntegerBase64Serializer.getInstance()).create();
private static final Gson GSON =
new GsonBuilder().registerTypeHierarchyAdapter(BigInteger.class, BigIntegerBase64Serializer.getInstance()).create();
private ServiceApiRequest() {
}
@ -44,7 +45,8 @@ final class ServiceApiRequest {
}
}
public static <REQUEST, RESPONSE> RESPONSE request(HttpURLConnection firstConn, HttpMethod method, String sessionToken, REQUEST data, Class<RESPONSE> responseClass)
public static <REQUEST, RESPONSE> RESPONSE request(HttpURLConnection firstConn, HttpMethod method, String sessionToken,
REQUEST data, Class<RESPONSE> responseClass)
throws IOException, StorageServiceException {
HttpURLConnection conn = null;
int followedRedirects = 0;
@ -62,7 +64,8 @@ final class ServiceApiRequest {
//needed if the Location header specifies a relative redirect, e.g. "Location: /some/path/on/the/same/server"
URL baseUrl = conn.getURL();
//if redirectUrl is already absolute (contains authority), baseUrl will be ignored (see javadoc for the URL(URL, String) constructor for more info)
//if redirectUrl is already absolute (contains authority), baseUrl will be ignored
// (see javadoc for the URL(URL, String) constructor for more info)
URL target = new URL(baseUrl, redirectUrl);
conn = (HttpURLConnection) target.openConnection();
@ -95,7 +98,8 @@ final class ServiceApiRequest {
}
}
public static <REQUEST, RESPONSE> RESPONSE request(URL url, HttpMethod method, String sessionToken, REQUEST data, Class<RESPONSE> responseClass)
public static <REQUEST, RESPONSE> RESPONSE request(URL url, HttpMethod method, String sessionToken,
REQUEST data, Class<RESPONSE> responseClass)
throws IOException, StorageServiceException {
return request((HttpURLConnection) url.openConnection(), method, sessionToken, data, responseClass);
}

View File

@ -7,6 +7,7 @@ import org.terasology.engine.input.BindAxisEvent;
import org.terasology.engine.input.RegisterBindAxis;
import org.terasology.engine.input.SendEventMode;
@RegisterBindAxis(id = "forwardsMovement", positiveButton = "engine:forwards", negativeButton = "engine:backwards", eventMode = SendEventMode.WHEN_CHANGED)
@RegisterBindAxis(id = "forwardsMovement", positiveButton = "engine:forwards", negativeButton = "engine:backwards",
eventMode = SendEventMode.WHEN_CHANGED)
public class ForwardsMovementAxis extends BindAxisEvent {
}

View File

@ -63,7 +63,8 @@ public class PlayerTargetSystem extends BaseComponentSystem implements UpdateSub
if (charComp != null) {
Vector3f dir = player.getViewDirection(new Vector3f());
float maxDist = charComp.interactionRange;
FirstPersonHeldItemMountPointComponent heldItemMountPoint = player.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
FirstPersonHeldItemMountPointComponent heldItemMountPoint =
player.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
if (heldItemMountPoint != null && heldItemMountPoint.isTracked()) {
maxDist = heldItemMountPoint.translate.length() + 0.25f;
dir = new Vector3f(heldItemMountPoint.translate).normalize();

View File

@ -37,7 +37,8 @@ public class SimpleAISystem extends BaseComponentSystem implements UpdateSubscri
@Override
public void update(float delta) {
for (EntityRef entity : entityManager.getEntitiesWith(SimpleAIComponent.class, CharacterMovementComponent.class, LocationComponent.class)) {
for (EntityRef entity : entityManager.getEntitiesWith(SimpleAIComponent.class,
CharacterMovementComponent.class, LocationComponent.class)) {
LocationComponent location = entity.getComponent(LocationComponent.class);
Vector3f worldPos = location.getWorldPosition(new Vector3f());
@ -61,7 +62,8 @@ public class SimpleAISystem extends BaseComponentSystem implements UpdateSubscri
} else {
// Random walk
if (time.getGameTimeInMs() - ai.lastChangeOfDirectionAt > 12000 || ai.followingPlayer) {
ai.movementTarget.set(worldPos.x + random.nextFloat(-500.0f, 500.0f), worldPos.y, worldPos.z + random.nextFloat(-500.0f, 500.0f));
ai.movementTarget.set(worldPos.x + random.nextFloat(-500.0f, 500.0f), worldPos.y,
worldPos.z + random.nextFloat(-500.0f, 500.0f));
ai.lastChangeOfDirectionAt = time.getGameTimeInMs();
ai.followingPlayer = false;
entity.saveComponent(ai);
@ -77,7 +79,8 @@ public class SimpleAISystem extends BaseComponentSystem implements UpdateSubscri
location.setLocalRotation(new Quaternionf().setAngleAxis(yaw, 0, 1, 0));
entity.saveComponent(location);
}
entity.send(new CharacterMoveInputEvent(0, 0, 0, drive, false, false, false, time.getGameDeltaInMs()));
entity.send(new CharacterMoveInputEvent(0, 0, 0, drive,
false, false, false, time.getGameDeltaInMs()));
}
}

View File

@ -100,7 +100,8 @@ public class BehaviorSystem extends BaseComponentSystem implements UpdateSubscri
public BehaviorTree createTree(String name, BehaviorNode root) {
BehaviorTreeData data = new BehaviorTreeData();
data.setRoot(root);
BehaviorTree behaviorTree = assetManager.loadAsset(new ResourceUrn(BEHAVIORS, new Name(name.replaceAll("\\W+", ""))), data, BehaviorTree.class);
BehaviorTree behaviorTree = assetManager.loadAsset(
new ResourceUrn(BEHAVIORS, new Name(name.replaceAll("\\W+", ""))), data, BehaviorTree.class);
trees.add(behaviorTree);
save(behaviorTree);
return behaviorTree;

View File

@ -101,7 +101,8 @@ public class CollectiveBehaviorSystem extends BaseComponentSystem implements Upd
public BehaviorTree createTree(String name, BehaviorNode root) {
BehaviorTreeData data = new BehaviorTreeData();
data.setRoot(root);
BehaviorTree behaviorTree = assetManager.loadAsset(new ResourceUrn(BEHAVIORS, new Name(name.replaceAll("\\W+", ""))), data, BehaviorTree.class);
BehaviorTree behaviorTree = assetManager.loadAsset(new ResourceUrn(BEHAVIORS, new Name(name.replaceAll("\\W+", ""))),
data, BehaviorTree.class);
trees.add(behaviorTree);
save(behaviorTree);
return behaviorTree;

View File

@ -55,11 +55,14 @@ public class ConditionAction extends BaseAction {
}
return BehaviorState.SUCCESS;
} catch (ClassNotFoundException e) {
logger.error("Class not found. Does the Component specified exist?", e);
logger.error("Class not found. " +
"Does the Component specified exist?", e);
} catch (NoSuchFieldException e) {
logger.error("Field not found. Does the field specified in 'values' (publicly) exist in the Component specified in 'componentPresent'?", e);
logger.error("Field not found. " +
"Does the field specified in 'values' (publicly) exist in the Component specified in 'componentPresent'?", e);
} catch (IllegalAccessException e) {
logger.error("Illegal access. Do we have access to the Component in question?", e);
logger.error("Illegal access. " +
"Do we have access to the Component in question?", e);
}
return BehaviorState.FAILURE;
}

View File

@ -18,7 +18,8 @@ public class BehaviorTree extends Asset<BehaviorTreeData> {
private BehaviorTreeData data;
/**
* The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn, and an initial AssetData to load.
* The constructor for an asset. It is suggested that implementing classes provide a constructor taking both the urn,
* and an initial AssetData to load.
*
* @param urn The urn identifying the asset.
* @param assetType The asset type this asset belongs to.

View File

@ -285,7 +285,8 @@ public class BehaviorEditor extends ZoomableLayout implements DefaultBehaviorTre
public void layout(RenderableNode start) {
LayoutTree layoutTree = new LayoutTree(start);
TreeLayout<RenderableNode> layout = new TreeLayout<>(layoutTree, new FixedNodeExtentProvider<RenderableNode>(10, 5), new DefaultConfiguration<RenderableNode>(4, 2));
TreeLayout<RenderableNode> layout = new TreeLayout<>(layoutTree, new FixedNodeExtentProvider<RenderableNode>(10, 5),
new DefaultConfiguration<RenderableNode>(4, 2));
Map<RenderableNode, Rectangle2D.Double> bounds = layout.getNodeBounds();
for (Map.Entry<RenderableNode, Rectangle2D.Double> entry : bounds.entrySet()) {
RenderableNode node = entry.getKey();

View File

@ -61,7 +61,9 @@ public class RenderableNode extends CoreWidget implements ZoomableLayout.Positio
MouseInput button = event.getMouseButton();
KeyboardDevice keyboard = event.getKeyboard();
dragged = false;
copyMode = button == MouseInput.MOUSE_LEFT && (keyboard.isKeyDown(Keyboard.KeyId.LEFT_SHIFT) || keyboard.isKeyDown(Keyboard.KeyId.RIGHT_SHIFT));
copyMode = button == MouseInput.MOUSE_LEFT
&& (keyboard.isKeyDown(Keyboard.KeyId.LEFT_SHIFT)
|| keyboard.isKeyDown(Keyboard.KeyId.RIGHT_SHIFT));
if (copyMode) {
editor.copyNode(RenderableNode.this);
}

View File

@ -24,11 +24,13 @@ public class CharacterMoveInputEvent extends NetworkEvent {
}
@Deprecated
public CharacterMoveInputEvent(int sequence, float pitch, float yaw, Vector3fc movementDirection, boolean running, boolean jumping, long delta) {
public CharacterMoveInputEvent(int sequence, float pitch, float yaw, Vector3fc movementDirection,
boolean running, boolean jumping, long delta) {
this(sequence, pitch, yaw, movementDirection, running, false, jumping, delta);
}
public CharacterMoveInputEvent(int sequence, float pitch, float yaw, Vector3fc movementDirection, boolean running, boolean crouching, boolean jumping, long delta) {
public CharacterMoveInputEvent(int sequence, float pitch, float yaw, Vector3fc movementDirection,
boolean running, boolean crouching, boolean jumping, long delta) {
this.delta = delta;
this.pitch = pitch;
this.yaw = yaw;

View File

@ -56,7 +56,8 @@ import java.util.Optional;
@RegisterSystem
public class CharacterSystem extends BaseComponentSystem implements UpdateSubscriberSystem {
public static final CollisionGroup[] DEFAULTPHYSICSFILTER = {StandardCollisionGroup.DEFAULT, StandardCollisionGroup.WORLD, StandardCollisionGroup.CHARACTER};
public static final CollisionGroup[] DEFAULTPHYSICSFILTER =
{StandardCollisionGroup.DEFAULT, StandardCollisionGroup.WORLD, StandardCollisionGroup.CHARACTER};
private static final Logger logger = LoggerFactory.getLogger(CharacterSystem.class);
@In
@ -87,7 +88,8 @@ public class CharacterSystem extends BaseComponentSystem implements UpdateSubscr
private RecordAndReplayCurrentStatus recordAndReplayCurrentStatus;
@ReceiveEvent
public void beforeDestroy(BeforeDestroyEvent event, EntityRef character, CharacterComponent characterComponent, AliveCharacterComponent aliveCharacterComponent) {
public void beforeDestroy(BeforeDestroyEvent event, EntityRef character,
CharacterComponent characterComponent, AliveCharacterComponent aliveCharacterComponent) {
if (character.hasComponent(PlayerCharacterComponent.class)) {
// Consume the BeforeDestroyEvent so that the DoDestroy event is never sent for player entities
event.consume();
@ -350,7 +352,8 @@ public class CharacterSystem extends BaseComponentSystem implements UpdateSubscr
return false; // can happen if target existed on client
}
HitResult result = physics.rayTrace(originPos, direction, characterComponent.interactionRange, Sets.newHashSet(character), DEFAULTPHYSICSFILTER);
HitResult result = physics.rayTrace(originPos, direction, characterComponent.interactionRange, Sets.newHashSet(character),
DEFAULTPHYSICSFILTER);
if (!result.isHit()) {
String msg = "Denied activation attempt by {} since at the authority there was nothing to activate at that place";
logger.info(msg, getPlayerNameFromCharacter(character));

View File

@ -81,14 +81,19 @@ public class ClientCommands extends BaseComponentSystem {
* Sets the spawn location for the client to the current location
* @return String containing debug information on the entity
*/
@Command(shortDescription = "Sets the spawn location for the client to the current location", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
@Command(shortDescription = "Sets the spawn location for the client to the current location",
runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setSpawnLocation(@Sender EntityRef sender) {
EntityRef clientInfo = sender.getComponent(ClientComponent.class).clientInfo;
StaticSpawnLocationComponent staticSpawnLocationComponent = new StaticSpawnLocationComponent();
if (clientInfo.hasComponent(StaticSpawnLocationComponent.class)) {
staticSpawnLocationComponent = clientInfo.getComponent(StaticSpawnLocationComponent.class);
}
staticSpawnLocationComponent.position = sender.getComponent(ClientComponent.class).character.getComponent(LocationComponent.class).getWorldPosition(new Vector3f());
staticSpawnLocationComponent.position = sender
.getComponent(ClientComponent.class)
.character
.getComponent(LocationComponent.class)
.getWorldPosition(new Vector3f());
clientInfo.addOrSaveComponent(staticSpawnLocationComponent);
return "Set spawn location to- " + staticSpawnLocationComponent.position;
}

View File

@ -510,7 +510,8 @@ public class CoreCommands extends BaseComponentSystem {
* @param prefabName String containing prefab name
* @return String containing final message
*/
@Command(shortDescription = "Spawns an instance of a prefab in the world", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
@Command(shortDescription = "Spawns an instance of a prefab in the world", runOnServer = true,
requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String spawnPrefab(@Sender EntityRef sender, @CommandParam("prefabId") String prefabName) {
ClientComponent clientComponent = sender.getComponent(ClientComponent.class);
LocationComponent characterLocation = clientComponent.character.getComponent(LocationComponent.class);
@ -547,7 +548,8 @@ public class CoreCommands extends BaseComponentSystem {
* @return String containg final message
*/
@Command(shortDescription = "Spawns a block in front of the player", helpText = "Spawns the specified block as a " +
"item in front of the player. You can simply pick it up.", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
"item in front of the player. You can simply pick it up.", runOnServer = true,
requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String spawnBlock(@Sender EntityRef sender, @CommandParam("blockName") String blockName) {
ClientComponent clientComponent = sender.getComponent(ClientComponent.class);
LocationComponent characterLocation = clientComponent.character.getComponent(LocationComponent.class);
@ -706,27 +708,27 @@ public class CoreCommands extends BaseComponentSystem {
} else {
StringBuilder msg = new StringBuilder();
msg.append("=====================================================================================================================");
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
msg.append(cmd.getUsage());
msg.append(Console.NEW_LINE);
msg.append("=====================================================================================================================");
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
if (!cmd.getHelpText().isEmpty()) {
msg.append(cmd.getHelpText());
msg.append(Console.NEW_LINE);
msg.append("=====================================================================================================================");
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
} else if (!cmd.getDescription().isEmpty()) {
msg.append(cmd.getDescription());
msg.append(Console.NEW_LINE);
msg.append("=====================================================================================================================");
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
}
if (!cmd.getRequiredPermission().isEmpty()) {
msg.append("Required permission level - " + cmd.getRequiredPermission());
msg.append(Console.NEW_LINE);
msg.append("=====================================================================================================================");
msg.append("===========================================================================================================");
msg.append(Console.NEW_LINE);
}

View File

@ -283,7 +283,8 @@ public class MovementDebugCommands extends BaseComponentSystem {
@Command(value = "teleport", shortDescription = "Teleports you to a location", runOnServer = true,
requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String teleportCommand(@Sender EntityRef sender, @CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
public String teleportCommand(@Sender EntityRef sender,
@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
ClientComponent clientComp = sender.getComponent(ClientComponent.class);
clientComp.character.send(new CharacterTeleportEvent(new Vector3f(x, y, z)));
return "Teleporting to " + x + " " + y + " " + z;
@ -443,7 +444,9 @@ public class MovementDebugCommands extends BaseComponentSystem {
clientComp.character.send(new CharacterTeleportEvent(vPlayerLocation));
CharacterMovementComponent characterMovementComponent = clientComp.character.getComponent(CharacterMovementComponent.class);
if (characterMovementComponent != null && playerMovementMode != MovementMode.NONE && playerMovementMode != characterMovementComponent.mode) {
if (characterMovementComponent != null
&& playerMovementMode != MovementMode.NONE
&& playerMovementMode != characterMovementComponent.mode) {
clientComp.character.send(new SetMovementModeEvent(playerMovementMode));
}
}

View File

@ -97,14 +97,16 @@ public class CameraClientSystem extends BaseComponentSystem {
}
@ReceiveEvent
public void mountCameraOnActivate(OnActivatedComponent event, EntityRef entityRef, AutoMountCameraComponent autoMountCameraComponent, ClientComponent clientComponent) {
public void mountCameraOnActivate(OnActivatedComponent event, EntityRef entityRef,
AutoMountCameraComponent autoMountCameraComponent, ClientComponent clientComponent) {
if (localPlayer.getClientEntity().equals(entityRef) && clientComponent.camera.exists()) {
mountCamera();
}
}
@ReceiveEvent
public void mountCameraOnChange(OnChangedComponent event, EntityRef entityRef, AutoMountCameraComponent autoMountCameraComponent, ClientComponent clientComponent) {
public void mountCameraOnChange(OnChangedComponent event, EntityRef entityRef,
AutoMountCameraComponent autoMountCameraComponent, ClientComponent clientComponent) {
if (localPlayer.getClientEntity().equals(entityRef) && clientComponent.camera.exists()) {
mountCamera();
}

View File

@ -9,7 +9,8 @@ import org.terasology.input.InputType;
import org.terasology.input.Keyboard;
import org.terasology.engine.input.RegisterBindButton;
@RegisterBindButton(id = "decreaseViewDistance", description = "${engine:menu#binding-decrease-view-distance}", mode = ActivateMode.PRESS, category = "general")
@RegisterBindButton(id = "decreaseViewDistance", description = "${engine:menu#binding-decrease-view-distance}",
mode = ActivateMode.PRESS, category = "general")
@DefaultBinding(type = InputType.KEY, id = Keyboard.KeyId.END)
public class DecreaseViewDistanceButton extends BindButtonEvent {
}

View File

@ -91,7 +91,9 @@ public class FirstPersonClientSystem extends BaseComponentSystem implements Upda
@Command(shortDescription = "Sets the held item mount point translation for the first person view")
public void setFirstPersonheldItemMountPointTranslation(@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
FirstPersonHeldItemMountPointComponent newComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
FirstPersonHeldItemMountPointComponent newComponent = localPlayer
.getCameraEntity()
.getComponent(FirstPersonHeldItemMountPointComponent.class);
if (newComponent != null) {
newComponent.translate = new Vector3f(x, y, z);
ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent.newInstance(), localPlayer.getCameraEntity(), newComponent);
@ -100,7 +102,9 @@ public class FirstPersonClientSystem extends BaseComponentSystem implements Upda
@Command(shortDescription = "Sets the held item mount point rotation for the first person view")
public void setFirstPersonheldItemMountPointRotation(@CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
FirstPersonHeldItemMountPointComponent newComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
FirstPersonHeldItemMountPointComponent newComponent = localPlayer
.getCameraEntity()
.getComponent(FirstPersonHeldItemMountPointComponent.class);
if (newComponent != null) {
newComponent.rotateDegrees = new Vector3f(x, y, z);
ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent.newInstance(), localPlayer.getCameraEntity(), newComponent);
@ -108,7 +112,8 @@ public class FirstPersonClientSystem extends BaseComponentSystem implements Upda
}
@ReceiveEvent
public void onHeldItemActivated(OnActivatedComponent event, EntityRef character, CharacterHeldItemComponent heldItemComponent, CharacterComponent characterComponents) {
public void onHeldItemActivated(OnActivatedComponent event, EntityRef character,
CharacterHeldItemComponent heldItemComponent, CharacterComponent characterComponents) {
if (localPlayer.getCharacterEntity().equals(character)) {
EntityRef newItem = heldItemComponent.selectedItem;
linkHeldItemLocationForLocalPlayer(newItem);
@ -116,7 +121,8 @@ public class FirstPersonClientSystem extends BaseComponentSystem implements Upda
}
@ReceiveEvent
public void onHeldItemChanged(OnChangedComponent event, EntityRef character, CharacterHeldItemComponent heldItemComponent, CharacterComponent characterComponents) {
public void onHeldItemChanged(OnChangedComponent event, EntityRef character,
CharacterHeldItemComponent heldItemComponent, CharacterComponent characterComponents) {
if (localPlayer.getCharacterEntity().equals(character)) {
EntityRef newItem = heldItemComponent.selectedItem;
linkHeldItemLocationForLocalPlayer(newItem);
@ -162,7 +168,8 @@ public class FirstPersonClientSystem extends BaseComponentSystem implements Upda
currentHeldItem.addComponent(new LocationComponent());
currentHeldItem.addComponent(new ItemIsHeldComponent());
FirstPersonHeldItemTransformComponent heldItemTransformComponent = currentHeldItem.getComponent(FirstPersonHeldItemTransformComponent.class);
FirstPersonHeldItemTransformComponent heldItemTransformComponent =
currentHeldItem.getComponent(FirstPersonHeldItemTransformComponent.class);
if (heldItemTransformComponent == null) {
heldItemTransformComponent = new FirstPersonHeldItemTransformComponent();
currentHeldItem.addComponent(heldItemTransformComponent);
@ -198,8 +205,12 @@ public class FirstPersonClientSystem extends BaseComponentSystem implements Upda
}
// get the first person mount point and rotate it away from the camera
CharacterHeldItemComponent characterHeldItemComponent = localPlayer.getCharacterEntity().getComponent(CharacterHeldItemComponent.class);
FirstPersonHeldItemMountPointComponent mountPointComponent = localPlayer.getCameraEntity().getComponent(FirstPersonHeldItemMountPointComponent.class);
CharacterHeldItemComponent characterHeldItemComponent = localPlayer
.getCharacterEntity()
.getComponent(CharacterHeldItemComponent.class);
FirstPersonHeldItemMountPointComponent mountPointComponent = localPlayer
.getCameraEntity()
.getComponent(FirstPersonHeldItemMountPointComponent.class);
if (characterHeldItemComponent == null
|| mountPointComponent == null) {
return;

View File

@ -9,7 +9,8 @@ import org.terasology.input.InputType;
import org.terasology.input.Keyboard;
import org.terasology.engine.input.RegisterBindButton;
@RegisterBindButton(id = "increaseViewDistance", description = "${engine:menu#binding-increase-view-distance}", mode = ActivateMode.PRESS, category = "general")
@RegisterBindButton(id = "increaseViewDistance", description = "${engine:menu#binding-increase-view-distance}",
mode = ActivateMode.PRESS, category = "general")
@DefaultBinding(type = InputType.KEY, id = Keyboard.KeyId.HOME)
public class IncreaseViewDistanceButton extends BindButtonEvent {
}

View File

@ -5,8 +5,6 @@ package org.terasology.engine.logic.players;
import com.google.common.collect.Sets;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.logic.characters.CharacterComponent;
import org.terasology.engine.logic.characters.CharacterMovementComponent;
@ -87,7 +85,9 @@ public class LocalPlayer {
public boolean isValid() {
EntityRef characterEntity = getCharacterEntity();
return characterEntity.exists() && characterEntity.hasComponent(LocationComponent.class) && characterEntity.hasComponent(CharacterComponent.class)
return characterEntity.exists()
&& characterEntity.hasComponent(LocationComponent.class)
&& characterEntity.hasComponent(CharacterComponent.class)
&& characterEntity.hasComponent(CharacterMovementComponent.class);
}

View File

@ -54,7 +54,8 @@ public class TimeAuthoritySystem extends BaseComponentSystem implements UpdateSu
}
}
@Command(shortDescription = "Toggle automatic time dilation", requiredPermission = PermissionManager.SERVER_MANAGEMENT_PERMISSION, runOnServer = true)
@Command(shortDescription = "Toggle automatic time dilation", requiredPermission =
PermissionManager.SERVER_MANAGEMENT_PERMISSION, runOnServer = true)
public String toggleAutoTimeDilation() {
enableAutomaticTimeDilation = !enableAutomaticTimeDilation;
if (enableAutomaticTimeDilation) {

View File

@ -113,8 +113,12 @@ public class PerformanceMonitorImpl implements PerformanceMonitorInternal {
if (!activityStack.isEmpty()) {
ActivityInfo currentActivity = activityStack.peek();
currentActivity.ownTime += newActivity.startTime - ((currentActivity.resumeTime > 0) ? currentActivity.resumeTime : currentActivity.startTime);
currentActivity.ownMem += (currentActivity.startMem - newActivity.startMem > 0) ? currentActivity.startMem - newActivity.startMem : 0;
currentActivity.ownTime += newActivity.startTime - ((currentActivity.resumeTime > 0)
? currentActivity.resumeTime
: currentActivity.startTime);
currentActivity.ownMem += (currentActivity.startMem - newActivity.startMem > 0)
? currentActivity.startMem - newActivity.startMem
: 0;
}
activityStack.push(newActivity);
@ -130,11 +134,15 @@ public class PerformanceMonitorImpl implements PerformanceMonitorInternal {
ActivityInfo oldActivity = activityStack.pop();
long endTime = timer.getRealTimeInMs();
long totalTime = (oldActivity.resumeTime > 0) ? oldActivity.ownTime + endTime - oldActivity.resumeTime : endTime - oldActivity.startTime;
long totalTime = (oldActivity.resumeTime > 0)
? oldActivity.ownTime + endTime - oldActivity.resumeTime
: endTime - oldActivity.startTime;
currentExecutionData.adjustOrPutValue(oldActivity.name, totalTime, totalTime);
long endMem = Runtime.getRuntime().freeMemory();
long totalMem = (oldActivity.startMem - endMem > 0) ? oldActivity.startMem - endMem + oldActivity.ownMem : oldActivity.ownMem;
long totalMem = (oldActivity.startMem - endMem > 0)
? oldActivity.startMem - endMem + oldActivity.ownMem
: oldActivity.ownMem;
currentAllocationData.adjustOrPutValue(oldActivity.name, totalMem, totalMem);
if (!activityStack.isEmpty()) {

View File

@ -125,7 +125,8 @@ public class ClientConnectionHandler extends ChannelInboundHandlerAdapter {
}
/**
* Attempts to receive a module from the server and push it to the client. Creates a file on the target machine and begins preparation to write to it.
* Attempts to receive a module from the server and push it to the client.
* Creates a file on the target machine and begins preparation to write to it.
* @param channelHandlerContext
* @param moduleDataHeader
*/

View File

@ -75,7 +75,8 @@ public class ClientHandshakeHandler extends ChannelInboundHandlerAdapter {
}
/**
* Process the handshake verification, checking that both the server and client have attempted it. If successful marks the channel as Authenticated.
* Process the handshake verification, checking that both the server and client have attempted it.
* If successful marks the channel as Authenticated.
* @param handshakeVerification
* @param ctx Channel Handler Context.
*/
@ -88,7 +89,8 @@ public class ClientHandshakeHandler extends ChannelInboundHandlerAdapter {
return;
}
if (!serverCertificate.verify(HandshakeCommon.getSignatureData(serverHello, clientHello), handshakeVerification.getSignature().toByteArray())) {
if (!serverCertificate.verify(HandshakeCommon.getSignatureData(serverHello, clientHello),
handshakeVerification.getSignature().toByteArray())) {
logger.error("Server failed verification: cancelling authentication");
joinStatus.setErrorMessage(AUTHENTICATION_FAILURE);
ctx.channel().close();

View File

@ -26,7 +26,8 @@ public final class HandshakeCommon {
* @return
*/
public static byte[] generateMasterSecret(byte[] preMasterSecret, byte[] clientRandom, byte[] serverRandom) {
return SecretGenerator.generate(preMasterSecret, SecretGenerator.MASTER_SECRET_LABEL, Bytes.concat(clientRandom, serverRandom), SecretGenerator.MASTER_SECRET_LENGTH);
return SecretGenerator.generate(preMasterSecret, SecretGenerator.MASTER_SECRET_LABEL,
Bytes.concat(clientRandom, serverRandom), SecretGenerator.MASTER_SECRET_LENGTH);
}
/**
@ -39,7 +40,8 @@ public final class HandshakeCommon {
*/
public static SecretKeySpec generateSymmetricKey(byte[] masterSecret, byte[] clientRandom, byte[] serverRandom) {
return new SecretKeySpec(SecretGenerator.generate(masterSecret, SecretGenerator.KEY_EXPANSION,
Bytes.concat(clientRandom, serverRandom), IdentityConstants.SYMMETRIC_ENCRYPTION_KEY_LENGTH), IdentityConstants.SYMMETRIC_ENCRYPTION_ALGORITHM);
Bytes.concat(clientRandom, serverRandom), IdentityConstants.SYMMETRIC_ENCRYPTION_KEY_LENGTH),
IdentityConstants.SYMMETRIC_ENCRYPTION_ALGORITHM);
}
/**

View File

@ -441,7 +441,8 @@ public class NetClient extends AbstractClient implements WorldChangeListener {
EntityRef currentEntity = networkSystem.getEntity(updateMessage.getNetId());
if (networkSystem.getOwner(currentEntity) == this) {
entitySerializer.deserializeOnto(currentEntity, updateMessage.getEntity(), new ServerComponentFieldCheck(false, true));
entitySerializer.deserializeOnto(currentEntity, updateMessage.getEntity(),
new ServerComponentFieldCheck(false, true));
}
}
}
@ -455,7 +456,8 @@ public class NetClient extends AbstractClient implements WorldChangeListener {
logger.error("Sending non-existent entity update for netId {}", netId);
}
boolean isOwner = networkSystem.getOwner(entity) == this;
EntityData.PackedEntity entityData = entitySerializer.serialize(entity, addedComponents.get(netId), dirtyComponents.get(netId), removedComponents.get(netId),
EntityData.PackedEntity entityData = entitySerializer.serialize(entity, addedComponents.get(netId),
dirtyComponents.get(netId), removedComponents.get(netId),
new ServerComponentFieldCheck(isOwner, false));
if (entityData != null) {
message.addUpdateEntity(NetData.UpdateEntityMessage.newBuilder().setEntity(entityData).setNetId(netId));
@ -488,7 +490,8 @@ public class NetClient extends AbstractClient implements WorldChangeListener {
}
// Note: Send owner->server fields on initial create
Client owner = networkSystem.getOwner(entity);
EntityData.PackedEntity entityData = entitySerializer.serialize(entity, true, new ServerComponentFieldCheck(owner == this, true)).build();
EntityData.PackedEntity entityData = entitySerializer.serialize(entity, true,
new ServerComponentFieldCheck(owner == this, true)).build();
NetData.CreateEntityMessage.Builder createMessage = NetData.CreateEntityMessage.newBuilder().setEntity(entityData);
BlockComponent blockComponent = entity.getComponent(BlockComponent.class);
if (blockComponent != null) {

View File

@ -849,7 +849,9 @@ public class NetworkSystemImpl implements EntityChangeSubscriber, NetworkSystem
client.connected(entityManager, entitySerializer, eventSerializer, eventLibrary);
client.send(NetData.NetMessage.newBuilder().setJoinComplete(
NetData.JoinCompleteMessage.newBuilder().setClientId(client.getEntity().getComponent(NetworkComponent.class).getNetworkId())).build());
NetData.JoinCompleteMessage.newBuilder().setClientId(client.getEntity()
.getComponent(NetworkComponent.class)
.getNetworkId())).build());
clientList.add(client);
netClientList.add(client);
clientPlayerLookup.put(client.getEntity(), client);

View File

@ -66,7 +66,8 @@ public class ServerHandshakeHandler extends ChannelInboundHandlerAdapter {
}
}
private void processClientHandshake(NetData.HandshakeHello clientHello, NetData.HandshakeVerification handshakeVerification, ChannelHandlerContext ctx) {
private void processClientHandshake(NetData.HandshakeHello clientHello, NetData.HandshakeVerification handshakeVerification,
ChannelHandlerContext ctx) {
logger.info("Received client certificate");
PublicIdentityCertificate clientCert = NetMessageUtil.convert(clientHello.getCertificate());
@ -98,8 +99,11 @@ public class ServerHandshakeHandler extends ChannelInboundHandlerAdapter {
private void processNewIdentityRequest(NetData.NewIdentityRequest newIdentityRequest, ChannelHandlerContext ctx) {
logger.info("Received new identity request");
try {
byte[] preMasterSecret = config.getSecurity().getServerPrivateCertificate().decrypt(newIdentityRequest.getPreMasterSecret().toByteArray());
byte[] masterSecret = HandshakeCommon.generateMasterSecret(preMasterSecret, newIdentityRequest.getRandom().toByteArray(), serverRandom);
byte[] preMasterSecret = config.getSecurity()
.getServerPrivateCertificate()
.decrypt(newIdentityRequest.getPreMasterSecret().toByteArray());
byte[] masterSecret = HandshakeCommon.generateMasterSecret(preMasterSecret,
newIdentityRequest.getRandom().toByteArray(), serverRandom);
// Generate a certificate pair for the client
CertificatePair clientCertificates = new CertificateGenerator().generate(config.getSecurity().getServerPrivateCertificate());
@ -111,11 +115,13 @@ public class ServerHandshakeHandler extends ChannelInboundHandlerAdapter {
byte[] encryptedCert = null;
try {
SecretKeySpec key = HandshakeCommon.generateSymmetricKey(masterSecret, newIdentityRequest.getRandom().toByteArray(), serverRandom);
SecretKeySpec key = HandshakeCommon.generateSymmetricKey(masterSecret,
newIdentityRequest.getRandom().toByteArray(), serverRandom);
Cipher cipher = Cipher.getInstance(IdentityConstants.SYMMETRIC_ENCRYPTION_ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, key);
encryptedCert = cipher.doFinal(certificateData.toByteArray());
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException e) {
} catch (NoSuchAlgorithmException | NoSuchPaddingException
| InvalidKeyException | BadPaddingException | IllegalBlockSizeException e) {
logger.error("Unexpected error encrypting certificate for sending, ending connection attempt", e);
ctx.channel().close();
return;

View File

@ -9,7 +9,8 @@ import org.terasology.engine.particles.rendering.ParticleRenderingData;
import java.util.stream.Stream;
/**
* Component system responsible for keeping track of all {@link org.terasology.engine.particles.components.ParticleEmitterComponent} components and updating them.
* Component system responsible for keeping track of all {@link org.terasology.engine.particles.components.ParticleEmitterComponent}
* components and updating them.
* Also maintains a registry of generator and affector functions to be used when processing generators
* and affectors during a particle system update.
*/
@ -18,7 +19,8 @@ import java.util.stream.Stream;
public interface ParticleSystemManager {
/**
* Gets all current emitters that have a given particle data component and returns a stream of all particle pools and their associated data for rendering.
* Gets all current emitters that have a given particle data component and returns a stream of all particle pools
* and their associated data for rendering.
* A particle data component stores information used to define how the particles of the emitter it is attached to are rendered.
*
* @param particleDataComponent The particle data component to select emitters by.

View File

@ -99,8 +99,10 @@ public class ParticleSystemManagerImpl extends BaseComponentSystem implements Up
@Override
public Stream<ParticleRenderingData> getParticleEmittersByDataComponent(Class<? extends Component> particleDataComponent) {
return particleUpdater.getParticleEmitters().stream()
.filter(emitter -> emitter.ownerEntity.hasComponent(particleDataComponent)) // filter emitters, whose owning entity has a particleDataComponent
.filter(distinctByKey(emitter -> emitter.particlePool)) // filter emitters referencing a unique particle pool
// filter emitters, whose owning entity has a particleDataComponent
.filter(emitter -> emitter.ownerEntity.hasComponent(particleDataComponent))
// filter emitters referencing a unique particle pool
.filter(distinctByKey(emitter -> emitter.particlePool))
.map(emitter -> new ParticleRenderingData<>(
emitter.ownerEntity.getComponent(particleDataComponent),
emitter.particlePool

View File

@ -55,12 +55,14 @@ public class ParticleEmitterComponent implements Component {
public boolean enabled = true;
/**
* The remaining life time of this emitter in seconds, the emitter will auto-remove upon reaching 0 TODO: Implement emitter lifetime
* The remaining life time of this emitter in seconds, the emitter will auto-remove upon reaching 0
* TODO: Implement emitter lifetime
*/
public float lifeTime = INDEFINITE_EMITTER_LIFETIME;
/**
* The maximum amount of particle this emitter can emit before auto-removing, the emitter will auto-remove upon reaching 0 TODO: Implement emitter max spawns
* The maximum amount of particle this emitter can emit before auto-removing, the emitter will auto-remove upon reaching 0
* TODO: Implement emitter max spawns
*/
public int particleSpawnsLeft = INFINITE_PARTICLE_SPAWNS;

View File

@ -10,7 +10,8 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation is used to mark a {@link ParticleSystemFunction} to be registered in by the {@link org.terasology.engine.particles.updating.ParticleUpdater}.
* This annotation is used to mark a {@link ParticleSystemFunction} to be registered in
* by the {@link org.terasology.engine.particles.updating.ParticleUpdater}.
*/
@API
@Retention(RetentionPolicy.RUNTIME)

View File

@ -67,7 +67,8 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public final class ReadWriteStorageManager extends AbstractStorageManager implements EntityDestroySubscriber, EntityChangeSubscriber, DelayedEntityRefFactory {
public final class ReadWriteStorageManager extends AbstractStorageManager
implements EntityDestroySubscriber, EntityChangeSubscriber, DelayedEntityRefFactory {
private static final Logger logger = LoggerFactory.getLogger(ReadWriteStorageManager.class);
private final TaskMaster<Task> saveThreadManager;
@ -113,7 +114,8 @@ public final class ReadWriteStorageManager extends AbstractStorageManager implem
public ReadWriteStorageManager(Path savePath, ModuleEnvironment environment, EngineEntityManager entityManager, BlockManager blockManager,
ExtraBlockDataManager extraDataManager, RecordAndReplaySerializer recordAndReplaySerializer,
RecordAndReplayUtils recordAndReplayUtils, RecordAndReplayCurrentStatus recordAndReplayCurrentStatus) throws IOException {
RecordAndReplayUtils recordAndReplayUtils, RecordAndReplayCurrentStatus recordAndReplayCurrentStatus)
throws IOException {
this(savePath, environment, entityManager, blockManager, extraDataManager,
true, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus);
}

View File

@ -153,7 +153,8 @@ public class ComponentSerializer {
* @param context The module this component is being deserialized from, or null if it isn't within a module
* @return The target component.
*/
public Component deserializeOnto(Component target, EntityData.Component componentData, FieldSerializeCheck<Component> fieldCheck, Module context) {
public Component deserializeOnto(Component target, EntityData.Component componentData,
FieldSerializeCheck<Component> fieldCheck, Module context) {
ComponentMetadata<? extends Component> componentMetadata = getComponentMetadata(componentData, context);
if (componentMetadata != null) {
return deserializeOnto(target, componentData, componentMetadata, fieldCheck);

View File

@ -96,7 +96,8 @@ public final class EntityDataJSONFormat {
}
@Override
public EntityData.GlobalStore deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
public EntityData.GlobalStore deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
EntityData.GlobalStore.Builder world = EntityData.GlobalStore.newBuilder();
if (json.isJsonObject()) {
JsonObject jsonObject = json.getAsJsonObject();
@ -137,7 +138,8 @@ public final class EntityDataJSONFormat {
private static class ComponentBuilderHandler implements JsonDeserializer<EntityData.Component.Builder> {
@Override
public EntityData.Component.Builder deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
public EntityData.Component.Builder deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
EntityData.Component.Builder component = EntityData.Component.newBuilder();
JsonObject jsonObject = json.getAsJsonObject();
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
@ -183,7 +185,8 @@ public final class EntityDataJSONFormat {
}
@Override
public EntityData.Entity deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
public EntityData.Entity deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
EntityData.Entity.Builder entity = EntityData.Entity.newBuilder();
JsonObject jsonObject = json.getAsJsonObject();
@ -252,7 +255,8 @@ public final class EntityDataJSONFormat {
}
@Override
public EntityData.Prefab deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
public EntityData.Prefab deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
EntityData.Prefab.Builder prefab = EntityData.Prefab.newBuilder();
JsonObject jsonObject = json.getAsJsonObject();
@ -339,7 +343,8 @@ public final class EntityDataJSONFormat {
}
@Override
public EntityData.Value deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
public EntityData.Value deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
EntityData.Value.Builder value = EntityData.Value.newBuilder();
if (json.isJsonPrimitive()) {
extractPrimitive(value, json);

View File

@ -109,7 +109,8 @@ public class EventSerializer {
if (eventMetadata == null) {
throw new SerializationException("Unregistered event type: " + event.getClass());
} else if (!eventMetadata.isConstructable()) {
throw new SerializationException("Cannot serialize event '" + eventMetadata + "' - lacks default constructor so cannot be deserialized");
throw new SerializationException("Cannot serialize event '" + eventMetadata
+ "' - lacks default constructor so cannot be deserialized");
}
EntityData.Event.Builder eventData = EntityData.Event.newBuilder();
serializeEventType(event, eventData);
@ -118,7 +119,9 @@ public class EventSerializer {
ByteString.Output fieldIds = ByteString.newOutput();
for (ReplicatedFieldMetadata field : eventMetadata.getFields()) {
if (field.isReplicated()) {
EntityData.Value serializedValue = ((ProtobufPersistedData) eventSerializer.serialize(field, event, persistedDataSerializer)).getValue();
EntityData.Value serializedValue = ((ProtobufPersistedData) eventSerializer
.serialize(field, event, persistedDataSerializer))
.getValue();
if (serializedValue != null) {
eventData.addFieldValue(serializedValue);
fieldIds.write(field.getId());

View File

@ -116,7 +116,8 @@ public class NetworkEntitySerializer {
entity.setComponentFieldCounts(componentFieldCounts.toByteString());
for (Component prefabComponent : prefab.iterateComponents()) {
if (!presentClasses.contains(prefabComponent.getClass()) && componentSerializeCheck.serialize(componentLibrary.getMetadata(prefabComponent.getClass()))) {
if (!presentClasses.contains(prefabComponent.getClass())
&& componentSerializeCheck.serialize(componentLibrary.getMetadata(prefabComponent.getClass()))) {
entity.addRemovedComponent(idTable.get(prefabComponent.getClass()));
}
}
@ -124,7 +125,8 @@ public class NetworkEntitySerializer {
}
private void serializeComponentDelta(Component oldComponent, Component newComponent, FieldSerializeCheck<Component> fieldCheck,
EntityData.PackedEntity.Builder entityData, ByteString.Output entityFieldIds, ByteString.Output componentFieldCounts,
EntityData.PackedEntity.Builder entityData,
ByteString.Output entityFieldIds, ByteString.Output componentFieldCounts,
boolean componentInitial) {
ComponentMetadata<?> componentMetadata = componentLibrary.getMetadata(oldComponent.getClass());
if (componentMetadata == null) {
@ -158,7 +160,8 @@ public class NetworkEntitySerializer {
}
private void serializeComponentFull(Component component, boolean ignoreIfNoFields, FieldSerializeCheck<Component> fieldCheck,
EntityData.PackedEntity.Builder entityData, ByteString.Output entityFieldIds, ByteString.Output componentFieldCounts,
EntityData.PackedEntity.Builder entityData,
ByteString.Output entityFieldIds, ByteString.Output componentFieldCounts,
boolean componentInitial) {
ComponentMetadata<?> componentMetadata = componentLibrary.getMetadata(component.getClass());
if (componentMetadata == null) {
@ -264,12 +267,14 @@ public class NetworkEntitySerializer {
if (component == null) {
logger.error("Non-existent component marked as added: {}", componentType);
}
serializeComponentFull(entityRef.getComponent(componentType), false, fieldCheck, entity, fieldIds, componentFieldCounts, true);
serializeComponentFull(entityRef.getComponent(componentType), false, fieldCheck, entity, fieldIds,
componentFieldCounts, true);
}
for (Class<? extends Component> componentType : changed) {
Component comp = entityRef.getComponent(componentType);
if (comp != null) {
serializeComponentFull(comp, true, fieldCheck, entity, fieldIds, componentFieldCounts, false);
serializeComponentFull(comp, true, fieldCheck, entity, fieldIds,
componentFieldCounts, false);
} else {
logger.error("Non-existent component marked as changed: {}", componentType);
}

View File

@ -75,7 +75,8 @@ public class PrefabSerializer {
// Delta off the parent
for (Component component : prefab.iterateComponents()) {
if (prefab.getParent() != null && prefab.getParent().hasComponent(component.getClass())) {
EntityData.Component serializedComponent = componentSerializer.serialize(prefab.getParent().getComponent(component.getClass()), component);
EntityData.Component serializedComponent =
componentSerializer.serialize(prefab.getParent().getComponent(component.getClass()), component);
if (serializedComponent != null) {
prefabData.addComponent(serializedComponent);
}

View File

@ -208,7 +208,8 @@ public class ProtobufPersistedData implements PersistedData, PersistedDataArray
@Override
public boolean isNull() {
return !data.hasBytes() && data.getBooleanCount() + data.getFloatCount() + data.getDoubleCount() + data.getIntegerCount() + data.getLongCount()
return !data.hasBytes() && data.getBooleanCount() + data.getFloatCount() + data.getDoubleCount()
+ data.getIntegerCount() + data.getLongCount()
+ data.getStringCount() + data.getValueCount() + data.getNameValueCount() == 0;
}

View File

@ -552,7 +552,8 @@ public class BulletPhysics implements PhysicsEngine {
return true;
}
} else {
logger.warn("Trying to create trigger for entity without ShapeComponent or without LocationComponent or without TriggerComponent. Entity: {}", entity);
logger.warn("Trying to create trigger for entity without ShapeComponent or without LocationComponent " +
"or without TriggerComponent. Entity: {}", entity);
return false;
}
}

View File

@ -50,7 +50,8 @@ public class BulletSweepCallback extends ClosestConvexResultCallback implements
Matrix4f from = new Matrix4f().setTranslation(fromWorld);
Matrix4f to = new Matrix4f().setTranslation(toWorld);
Matrix4f targetTransform = this.getHitCollisionObject().getWorldTransform();
btDiscreteDynamicsWorld.rayTestSingle(from, to, this.getHitCollisionObject(), this.getHitCollisionObject().getCollisionShape(), targetTransform, resultCallback);
btDiscreteDynamicsWorld.rayTestSingle(from, to, this.getHitCollisionObject(), this.getHitCollisionObject().getCollisionShape(),
targetTransform, resultCallback);
if (resultCallback.hasHit()) {
foundSlope = true;
Vector3f result = new Vector3f();
@ -68,7 +69,8 @@ public class BulletSweepCallback extends ClosestConvexResultCallback implements
from = new Matrix4f().setTranslation(fromWorld);
to = new Matrix4f().setTranslation(toWorld);
targetTransform = this.getHitCollisionObject().getWorldTransform();
btDiscreteDynamicsWorld.rayTestSingle(from, to, this.getHitCollisionObject(), this.getHitCollisionObject().getCollisionShape(), targetTransform, resultCallback);
btDiscreteDynamicsWorld.rayTestSingle(from, to, this.getHitCollisionObject(), this.getHitCollisionObject().getCollisionShape(),
targetTransform, resultCallback);
if (resultCallback.hasHit()) {
foundSlope = true;
Vector3f hitNormal = new Vector3f();

View File

@ -34,8 +34,10 @@ public class BulletCompoundShape extends BulletCollisionShape implements Compoun
public void addChildShape(Vector3fc origin, Quaternionfc rotation, float scale, CollisionShape collisionShape) {
BulletCollisionShape bulletCollisionShape = (BulletCollisionShape) collisionShape;
compoundShape.addChildShape(new Matrix4f().translationRotateScale(origin, rotation, scale), ((BulletCollisionShape) collisionShape).underlyingShape);
childList.add(new BulletCompoundShapeChild(origin, rotation, scale, bulletCollisionShape, compoundShape.getChildShape(compoundShape.getNumChildShapes() - 1)));
compoundShape.addChildShape(new Matrix4f().translationRotateScale(origin, rotation, scale),
((BulletCollisionShape) collisionShape).underlyingShape);
childList.add(new BulletCompoundShapeChild(origin, rotation, scale, bulletCollisionShape,
compoundShape.getChildShape(compoundShape.getNumChildShapes() - 1)));
}
// TODO: Add removeChildShape if needed
@ -46,7 +48,8 @@ public class BulletCompoundShape extends BulletCollisionShape implements Compoun
for (BulletCompoundShapeChild child : childList) {
Matrix4f transform = new Matrix4f().rotate(rot).mul(child.transform);
shape.compoundShape.addChildShape(transform, child.childShape.underlyingShape);
shape.childList.add(new BulletCompoundShapeChild(transform, child.childShape, compoundShape.getChildShape(compoundShape.getNumChildShapes() - 1)));
shape.childList.add(new BulletCompoundShapeChild(transform, child.childShape,
compoundShape.getChildShape(compoundShape.getNumChildShapes() - 1)));
}
return shape;
}
@ -57,13 +60,15 @@ public class BulletCompoundShape extends BulletCollisionShape implements Compoun
public btCollisionShape compoundShapeChild;
private final Matrix4f transform = new Matrix4f();
private BulletCompoundShapeChild(Matrix4fc trans, BulletCollisionShape childShape, btCollisionShape compoundShapeChild) {
private BulletCompoundShapeChild(Matrix4fc trans, BulletCollisionShape childShape,
btCollisionShape compoundShapeChild) {
this.transform.set(trans);
this.childShape = childShape;
this.compoundShapeChild = compoundShapeChild;
}
private BulletCompoundShapeChild(Vector3fc origin, Quaternionfc rotation, float scale, BulletCollisionShape childShape, btCollisionShape compoundShapeChild) {
private BulletCompoundShapeChild(Vector3fc origin, Quaternionfc rotation, float scale, BulletCollisionShape childShape,
btCollisionShape compoundShapeChild) {
this.transform.translationRotateScale(origin, rotation, scale);
this.childShape = childShape;
this.compoundShapeChild = compoundShapeChild;

View File

@ -45,9 +45,12 @@ public class VoxelBlockFluidWorld implements VoxelWorld {
blockConsInf = new btRigidBody.btRigidBodyConstructionInfo(0, blockMotionState, worldShape, new Vector3f());
rigidBody = new btRigidBody(blockConsInf);
rigidBody.setCollisionFlags(btCollisionObject.CollisionFlags.CF_STATIC_OBJECT | rigidBody.getCollisionFlags()); // voxel world is added to static collision flag
short mask = (short) StandardCollisionGroup.LIQUID.getFlag(); // interacts with liquid only
discreteDynamicsWorld.addRigidBody(rigidBody, physics.combineGroups(StandardCollisionGroup.LIQUID), mask); // adds rigid body to world
// voxel world is added to static collision flag
rigidBody.setCollisionFlags(btCollisionObject.CollisionFlags.CF_STATIC_OBJECT | rigidBody.getCollisionFlags());
// interacts with liquid only
short mask = (short) StandardCollisionGroup.LIQUID.getFlag();
// adds rigid body to world
discreteDynamicsWorld.addRigidBody(rigidBody, physics.combineGroups(StandardCollisionGroup.LIQUID), mask);
}

View File

@ -45,9 +45,12 @@ public class VoxelBlockWorld implements VoxelWorld {
blockConsInf = new btRigidBody.btRigidBodyConstructionInfo(0, blockMotionState, worldShape, new Vector3f());
rigidBody = new btRigidBody(blockConsInf);
rigidBody.setCollisionFlags(btCollisionObject.CollisionFlags.CF_STATIC_OBJECT | rigidBody.getCollisionFlags()); // voxel world is added to static collision flag
short mask = (short) (~(StandardCollisionGroup.STATIC.getFlag() | StandardCollisionGroup.LIQUID.getFlag())); // interacts with anything but static and liquid
discreteDynamicsWorld.addRigidBody(rigidBody, physics.combineGroups(StandardCollisionGroup.WORLD), mask); // adds rigid body to world
// voxel world is added to static collision flag
rigidBody.setCollisionFlags(btCollisionObject.CollisionFlags.CF_STATIC_OBJECT | rigidBody.getCollisionFlags());
// interacts with anything but static and liquid
short mask = (short) (~(StandardCollisionGroup.STATIC.getFlag() | StandardCollisionGroup.LIQUID.getFlag()));
// adds rigid body to world
discreteDynamicsWorld.addRigidBody(rigidBody, physics.combineGroups(StandardCollisionGroup.WORLD), mask);
}

View File

@ -58,7 +58,8 @@ public class PhysicsSystem extends BaseComponentSystem implements UpdateSubscrib
private static final Logger logger = LoggerFactory.getLogger(PhysicsSystem.class);
private static final long TIME_BETWEEN_NETSYNCS = 500;
private static final CollisionGroup[] DEFAULT_COLLISION_GROUP = {StandardCollisionGroup.WORLD, StandardCollisionGroup.CHARACTER, StandardCollisionGroup.DEFAULT};
private static final CollisionGroup[] DEFAULT_COLLISION_GROUP =
{StandardCollisionGroup.WORLD, StandardCollisionGroup.CHARACTER, StandardCollisionGroup.DEFAULT};
private static final float COLLISION_DAMPENING_MULTIPLIER = 0.5f;
@In
private Time time;
@ -206,13 +207,16 @@ public class PhysicsSystem extends BaseComponentSystem implements UpdateSubscrib
}
if (hitBlock.isPenetrable()) {
if (!hitInfo.getEntity().hasComponent(BlockComponent.class)) {
entity.send(new EntityImpactEvent(hitInfo.getHitPoint(), hitInfo.getHitNormal(), comp.velocity, fDistanceThisFrame, hitInfo.getEntity()));
entity.send(new EntityImpactEvent(hitInfo.getHitPoint(), hitInfo.getHitNormal(), comp.velocity,
fDistanceThisFrame, hitInfo.getEntity()));
break;
}
fDistanceThisFrame = fDistanceThisFrame - fTravelledDistance; // decrease the remaining distance to check if we hit a block
// decrease the remaining distance to check if we hit a block
fDistanceThisFrame = fDistanceThisFrame - fTravelledDistance;
vLocation = hitInfo.getHitPoint();
} else {
entity.send(new BlockImpactEvent(hitInfo.getHitPoint(), hitInfo.getHitNormal(), comp.velocity, fDistanceThisFrame, hitInfo.getEntity()));
entity.send(new BlockImpactEvent(hitInfo.getHitPoint(), hitInfo.getHitNormal(), comp.velocity,
fDistanceThisFrame, hitInfo.getEntity()));
break;
}
} else {

View File

@ -9,7 +9,8 @@ import org.joml.Quaternionf;
import org.joml.Vector3f;
/**
* A rigid body is a physics object whose movement and location is controlled by the physics engine. Rigid bodies move under gravity and bounce off each other and the world.
* A rigid body is a physics object whose movement and location is controlled by the physics engine.
* Rigid bodies move under gravity and bounce off each other and the world.
* <br><br>
* After being removed from the physics engine this object is no longer valid and should not be used anymore.
* <br><br>

View File

@ -154,7 +154,8 @@ public class EventSystemReplayImpl implements EventSystem {
if (Thread.currentThread() != mainThread) {
pendingEvents.offer(new PendingEvent(entity, event, component));
} else {
SetMultimap<Class<? extends Component>, EventSystemReplayImpl.EventHandlerInfo> handlers = componentSpecificHandlers.get(event.getClass());
SetMultimap<Class<? extends Component>, EventSystemReplayImpl.EventHandlerInfo> handlers =
componentSpecificHandlers.get(event.getClass());
if (handlers != null) {
List<EventSystemReplayImpl.EventHandlerInfo> eventHandlers = Lists.newArrayList(handlers.get(component.getClass()));
eventHandlers.sort(priorityComparator);
@ -209,7 +210,8 @@ public class EventSystemReplayImpl implements EventSystem {
*/
private void finishReplay() {
recordedEventStore.popEvents();
recordAndReplayCurrentStatus.setStatus(RecordAndReplayStatus.REPLAY_FINISHED); // stops the replay if every recorded event was already replayed
// stops replay if all recorded events already replayed
recordAndReplayCurrentStatus.setStatus(RecordAndReplayStatus.REPLAY_FINISHED);
}
private void loadNextRecordedEventFile() {
@ -233,7 +235,8 @@ public class EventSystemReplayImpl implements EventSystem {
long beginTime = System.currentTimeMillis();
for (RecordedEvent re = recordedEvents.peek(); re != null; re = recordedEvents.peek()) {
long passedTime = System.currentTimeMillis() - this.replayEventsLoadTime;
//Waits until the time of reproduction is right or until 'maxDuration' miliseconds have already passed since this method was called
//Waits until the time of reproduction is right or until 'maxDuration' miliseconds have already passed
// since this method was called
while (passedTime < re.getTimestamp()) {
passedTime = System.currentTimeMillis() - this.replayEventsLoadTime;
if ((System.currentTimeMillis() - beginTime) >= maxDuration) {
@ -362,7 +365,8 @@ public class EventSystemReplayImpl implements EventSystem {
mainThread = Thread.currentThread();
}
private void addEventHandler(Class<? extends Event> type, EventSystemReplayImpl.EventHandlerInfo handler, Collection<Class<? extends Component>> components) {
private void addEventHandler(Class<? extends Event> type, EventSystemReplayImpl.EventHandlerInfo handler,
Collection<Class<? extends Component>> components) {
if (components.isEmpty()) {
generalHandlers.put(type, handler);
for (Class<? extends Event> childType : childEvents.get(type)) {
@ -378,8 +382,10 @@ public class EventSystemReplayImpl implements EventSystem {
}
}
private void addToComponentSpecificHandlers(Class<? extends Event> type, EventSystemReplayImpl.EventHandlerInfo handlerInfo, Class<? extends Component> c) {
SetMultimap<Class<? extends Component>, EventSystemReplayImpl.EventHandlerInfo> componentMap = componentSpecificHandlers.get(type);
private void addToComponentSpecificHandlers(Class<? extends Event> type, EventSystemReplayImpl.EventHandlerInfo handlerInfo,
Class<? extends Component> c) {
SetMultimap<Class<? extends Component>, EventSystemReplayImpl.EventHandlerInfo> componentMap =
componentSpecificHandlers.get(type);
if (componentMap == null) {
componentMap = HashMultimap.create();
componentSpecificHandlers.put(type, componentMap);
@ -388,21 +394,27 @@ public class EventSystemReplayImpl implements EventSystem {
}
@Override
public <T extends Event> void registerEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass, Class<? extends Component>... componentTypes) {
public <T extends Event> void registerEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass,
Class<? extends Component>... componentTypes) {
registerEventReceiver(eventReceiver, eventClass, EventPriority.PRIORITY_NORMAL, componentTypes);
}
@Override
public <T extends Event> void registerEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass, int priority, Class<? extends Component>... componentTypes) {
EventSystemReplayImpl.EventHandlerInfo info = new EventSystemReplayImpl.ReceiverEventHandlerInfo<>(eventReceiver, priority, componentTypes);
public <T extends Event> void registerEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass, int priority,
Class<? extends Component>... componentTypes) {
EventSystemReplayImpl.EventHandlerInfo info =
new EventSystemReplayImpl.ReceiverEventHandlerInfo<>(eventReceiver, priority, componentTypes);
addEventHandler(eventClass, info, Arrays.asList(componentTypes));
}
@Override
public <T extends Event> void unregisterEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass, Class<? extends Component>... componentTypes) {
SetMultimap<Class<? extends Component>, EventSystemReplayImpl.EventHandlerInfo> eventHandlerMap = componentSpecificHandlers.get(eventClass);
public <T extends Event> void unregisterEventReceiver(EventReceiver<T> eventReceiver, Class<T> eventClass,
Class<? extends Component>... componentTypes) {
SetMultimap<Class<? extends Component>, EventSystemReplayImpl.EventHandlerInfo> eventHandlerMap =
componentSpecificHandlers.get(eventClass);
if (eventHandlerMap != null) {
EventSystemReplayImpl.ReceiverEventHandlerInfo testReceiver = new EventSystemReplayImpl.ReceiverEventHandlerInfo<>(eventReceiver, 0, componentTypes);
EventSystemReplayImpl.ReceiverEventHandlerInfo testReceiver =
new EventSystemReplayImpl.ReceiverEventHandlerInfo<>(eventReceiver, 0, componentTypes);
for (Class<? extends Component> c : componentTypes) {
eventHandlerMap.remove(c, testReceiver);
for (Class<? extends Event> childType : childEvents.get(eventClass)) {

View File

@ -13,18 +13,21 @@ package org.terasology.engine.recording;
* every time an event is sent.
*
* The RECORDING status will also make the {@link DirectionAndOriginPosRecorder} and {@link CharacterStateEventPositionMap}
* record the data they are supposed to. Every time the game is saved during the recording, {@link org.terasology.engine.persistence.internal.SaveTransaction}'s
* record the data they are supposed to.
* Every time the game is saved during the recording, {@link org.terasology.engine.persistence.internal.SaveTransaction}'s
* saveRecordingData() is called and the events in the {@link RecordedEventStore} are saved in an "event file", reseting
* the store and updating {@link RecordAndReplayUtils}.
*
* When the game shutdowns with the RECORDING status, the {@link RecordAndReplayUtils}'s shutdownRequested is set to true
* and then every recorded data that was not stored yet will be serialized and stored once {@link org.terasology.engine.persistence.internal.SaveTransaction}'s
* and then every recorded data that was not stored yet will be serialized
* and stored once {@link org.terasology.engine.persistence.internal.SaveTransaction}'s
* saveRecordingData() method is called right after the game is saved. Once this is done, the {@link #status} is set to NOT_ACTIVATED.
* <p>
* <h2>Replay Workflow</h2> When the user clicks on the "Replay" button on the extras menu, the {@link #status}
* is set to PREPEARING_REPLAY. During the load process of a Replay, the {@link org.terasology.engine.core.modes.loadProcesses.InitialiseWorld}
* class gets the game path from the "recordings" folder instead of the "saves" one, and the {@link org.terasology.engine.core.bootstrap.EntitySystemSetupUtil}
* creates an {@link EventSystemReplayImpl} instead of {@link org.terasology.engine.entitySystem.event.internal.EventSystemImpl}.
* class gets the game path from the "recordings" folder instead of the "saves" one,
* and the {@link org.terasology.engine.core.bootstrap.EntitySystemSetupUtil} creates an {@link EventSystemReplayImpl}
* instead of {@link org.terasology.engine.entitySystem.event.internal.EventSystemImpl}.
*
* When the game is loading, the InitialiseRecordAndReplay load process will set the {@link #status} to REPLAYING and deserialize
* the recorded data, updating {@link RecordedEventStore},{@link RecordAndReplayUtils}, {@link CharacterStateEventPositionMap}
@ -36,7 +39,8 @@ package org.terasology.engine.recording;
* If there are, the store is updated and the event system continues to replay the events. It is important to notice that
* the REPLAYING status also makes the {@link DirectionAndOriginPosRecorderList} and {@link CharacterStateEventPositionMap}
* to replace some variables for the recorded ones. Once there is no more events to be replayed, the {@link #status} is set to
* REPLAY_FINISHED and the {@link EventSystemReplayImpl} will work exactly like {@link org.terasology.engine.entitySystem.event.internal.EventSystemImpl}.
* REPLAY_FINISHED and the {@link EventSystemReplayImpl} will work exactly
* like {@link org.terasology.engine.entitySystem.event.internal.EventSystemImpl}.
*
* When the game is shutdown during this state, {@link RecordAndReplayUtils}'s shutdownRequested variable is set to true,
* and then when {@link org.terasology.engine.persistence.internal.SaveTransaction}'s run() method is called, the {@link #status} will be

View File

@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
/**
* This package provides a low-level system for describing classes and fields, with support for construction and field access. Essentially it is a simplified reflection
* This package provides a low-level system for describing classes and fields, with support for construction and field access.
* Essentially it is a simplified reflection
* framework.
* <br><br>
* To support this functionality, a copy-strategy library is used to provide copying support for types. This is used instead of cloning because

View File

@ -59,7 +59,8 @@ public class ByteCodeReflectFactory implements ReflectFactory {
CtMethod method = CtNewMethod.make("public Object construct() { return new " + type.getName() + "();}", constructorClass);
constructorClass.addMethod(method);
return (ObjectConstructor<T>) (constructorClass.toClass(type.getClassLoader(), type.getProtectionDomain()).getConstructor().newInstance());
return (ObjectConstructor<T>) (constructorClass.toClass(type.getClassLoader(), type.getProtectionDomain())
.getConstructor().newInstance());
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | CannotCompileException e) {
logger.error("Error instantiating constructor object for '{}', falling back on reflection", type, e);
return backupFactory.createConstructor(type);
@ -118,7 +119,8 @@ public class ByteCodeReflectFactory implements ReflectFactory {
try {
fieldIndex = fieldAccess.getIndex(field.getName());
} catch (IllegalArgumentException e) {
throw new InaccessibleFieldException("Failed to create accessor for field '" + field.getName() + "' of type '" + ownerType.getName() + "'", e);
throw new InaccessibleFieldException("Failed to create accessor for field '" + field.getName()
+ "' of type '" + ownerType.getName() + "'", e);
}
}
}

View File

@ -104,7 +104,8 @@ public final class InjectionHelper {
* @param clazz The class to instantiate.
* @param context The context to use for injection.
* @return A new instance of the class to create.
* @throws NoSuchElementException if the injection failed, e.g. if no parameters were available on the context and a default constructor is missing.
* @throws NoSuchElementException if the injection failed,
* e.g. if no parameters were available on the context and a default constructor is missing.
*/
public static <E> E createWithConstructorInjection(Class<? extends E> clazz, Context context) {
return safeCreateWithConstructorInjection(clazz, context).get();

View File

@ -60,8 +60,9 @@ public final class RenderHelper {
float timeFactor = RefractiveReflectiveBlocksNodeProxy.waveSpeed;
for (int i = 0; i < OCEAN_OCTAVES; ++i) {
height += (float) (smoothTriangleWave(timeToTick(days,
timeFactor) + position.x() * OCEAN_WAVE_DIRECTIONS[i].x * waveSize + position.z() * OCEAN_WAVE_DIRECTIONS[i].y * waveSize) * 2.0 - 1.0) * waveIntensity;
height += (float) (smoothTriangleWave(timeToTick(days, timeFactor)
+ position.x() * OCEAN_WAVE_DIRECTIONS[i].x * waveSize
+ position.z() * OCEAN_WAVE_DIRECTIONS[i].y * waveSize) * 2.0 - 1.0) * waveIntensity;
waveSize *= RefractiveReflectiveBlocksNodeProxy.waveSizeFalloff;
waveIntensity *= RefractiveReflectiveBlocksNodeProxy.waveIntensityFalloff;

Some files were not shown because too many files have changed in this diff Show More