Skip to content

Commit

Permalink
chore: resolve checkstyle problems (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: Josephine Rueckert <jd.rueckert@googlemail.com>
  • Loading branch information
pollend and jdrueckert committed Dec 7, 2021
1 parent 3e90dc4 commit 7bde71b
Show file tree
Hide file tree
Showing 47 changed files with 266 additions and 781 deletions.
@@ -1,18 +1,5 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.display.system.client;

import org.terasology.engine.rendering.assets.material.Material;
Expand Down Expand Up @@ -50,7 +37,8 @@ public Material renderMaterial(String mode, List<String> data) {

ByteBuffer resultBuffer = TextureUtil.convertToByteBuffer(image);

Texture texture = Assets.generateAsset(new TextureData(width, height, new ByteBuffer[]{resultBuffer}, Texture.WrapMode.REPEAT, Texture.FilterMode.NEAREST), Texture.class);
Texture texture = Assets.generateAsset(new TextureData(width, height, new ByteBuffer[]{resultBuffer},
Texture.WrapMode.REPEAT, Texture.FilterMode.NEAREST), Texture.class);

MaterialData terrainMatData = new MaterialData(Assets.getShader("engine:genericMeshMaterial").get());
terrainMatData.setParam("diffuse", texture);
Expand Down
Expand Up @@ -57,7 +57,8 @@ public void onMonitorAdded(OnAddedComponent event, EntityRef monitorEntity, Disp
DisplayRenderComponent computerRenderComponent = new DisplayRenderComponent();

computerRenderComponent.monitorChassis = createChassisRenderingEntity(worldPosition, monitorSize, front);
computerRenderComponent.screen = createScreenRenderingEntity(worldPosition, monitorSize, front, monitor.getMode(), monitor.getData());
computerRenderComponent.screen = createScreenRenderingEntity(worldPosition, monitorSize, front, monitor.getMode(),
monitor.getData());
monitorEntity.addComponent(computerRenderComponent);
}

Expand Down Expand Up @@ -148,7 +149,7 @@ private void addMeshForSide(MeshBuilder meshBuilder, Side side, Vector3i monitor
getTopRight(monitorSize, meshPart),
getBottomRight(monitorSize, meshPart),
getBottomLeft(monitorSize, meshPart));
meshBuilder.addColor(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK);
meshBuilder.addColor(Color.black, Color.black, Color.black, Color.black);
meshBuilder.addTexCoord((float) 0, (float) 0);
meshBuilder.addTexCoord((float) 0, 0.0625f);
meshBuilder.addTexCoord(0.0625f, 0.0625f);
Expand All @@ -159,19 +160,19 @@ private void addNormalizedMeshForSide(MeshBuilder meshBuilder, Side side, Vector
BlockShape blockShape = Assets.get("engine:cube", BlockShape.class).get();
BlockMeshPart meshPart = blockShape.getMeshPart(BlockPart.fromSide(side));

Vector3f[] sideVectors =new Vector3f[] {
Vector3f[] sideVectors = new Vector3f[]{
getTopLeft(monitorSize, meshPart),
getTopRight(monitorSize, meshPart),
getBottomRight(monitorSize, meshPart),
getBottomLeft(monitorSize, meshPart) };
getBottomLeft(monitorSize, meshPart)};

int startIndex = findIndexOfTopLeft(sideVectors);

meshBuilder.addPoly(
sideVectors[startIndex],
sideVectors[(startIndex+1)%4],
sideVectors[(startIndex+2)%4],
sideVectors[(startIndex+3)%4]);
sideVectors[(startIndex + 1) % 4],
sideVectors[(startIndex + 2) % 4],
sideVectors[(startIndex + 3) % 4]);
meshBuilder.addColor(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK);
meshBuilder.addTexCoord(0, 0);
meshBuilder.addTexCoord(1, 0);
Expand All @@ -186,15 +187,15 @@ private int findIndexOfTopLeft(Vector3f[] sideVectors) {
}

boolean[] indicesWithValue = new boolean[4];
for (int i=0; i<sideVectors.length; i++) {
for (int i = 0; i < sideVectors.length; i++) {
indicesWithValue[i] = (sideVectors[i].y == maxY);
}

if (indicesWithValue[3] && indicesWithValue[0]) {
return 3;
}

for (int i=0; i<3; i++) {
for (int i = 0; i < 3; i++) {
if (indicesWithValue[i]) {
return i;
}
Expand Down
@@ -1,18 +1,5 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.display.system.client;

public interface DisplayRenderModeRegistry {
Expand Down
@@ -1,18 +1,5 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.display.system.client;

import org.terasology.engine.rendering.assets.material.Material;
Expand Down
Expand Up @@ -93,7 +93,8 @@ protected RegionMultiBlockDefinition createMultiBlockDefinition(BlockRegionc mul
}
}

return new RegionMultiBlockDefinition(MONITOR_MULTI_BLOCK_TYPE, mainBlock, memberLocations, new BlockRegion(multiBlockRegion), frontSide);
return new RegionMultiBlockDefinition(MONITOR_MULTI_BLOCK_TYPE, mainBlock, memberLocations,
new BlockRegion(multiBlockRegion), frontSide);
}
});
}
Expand Down
@@ -1,23 +1,10 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.monitor.module;

import com.gempukku.lang.ExecutionException;

public class ColorUtils {
public final class ColorUtils {
private ColorUtils() {
}

Expand Down
@@ -1,18 +1,5 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.monitor.module;

import com.gempukku.lang.ExecutionException;
Expand Down
@@ -1,28 +1,15 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.monitor.module;

import com.gempukku.lang.ExecutionException;

import java.util.List;

public interface RenderCommandSink {
public List<String> getExistingData(int line) throws ExecutionException;
List<String> getExistingData(int line) throws ExecutionException;

public void setData(int line, List<String> data) throws ExecutionException;
void setData(int line, List<String> data) throws ExecutionException;

public boolean isInstantRendering();
boolean isInstantRendering();
}
@@ -1,18 +1,5 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.monitor.module.graphics;

import com.gempukku.lang.CustomObject;
Expand Down Expand Up @@ -55,15 +42,16 @@ public int getCpuCycleDuration() {
}

@Override
public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Variable> parameters, Object onFunctionStartResult) throws ExecutionException {
public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Variable> parameters, Object onFunctionStartResult)
throws ExecutionException {
String hex = FunctionParamValidationUtil.validateStringParameter(line, parameters, "hex", methodName);

int[] c = ColorUtils.parseColor(line, hex);

return new ColorCustomObject(c[0], c[1], c[2], c[3]);
}

private static class ColorCustomObject implements CustomObject, PaintCustomObject {
private static final class ColorCustomObject implements CustomObject, PaintCustomObject {
private int r;
private int g;
private int b;
Expand Down
@@ -1,18 +1,5 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.monitor.module.graphics;

import com.gempukku.lang.CustomObject;
Expand Down Expand Up @@ -63,7 +50,8 @@ public int getCpuCycleDuration() {
}

@Override
public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Variable> parameters, Object onFunctionStartResult) throws ExecutionException {
public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Variable> parameters, Object onFunctionStartResult)
throws ExecutionException {
String hex1 = FunctionParamValidationUtil.validateStringParameter(line, parameters, "hex1", methodName);
String hex2 = FunctionParamValidationUtil.validateStringParameter(line, parameters, "hex2", methodName);

Expand All @@ -81,7 +69,7 @@ public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Var
return new GradientCustomObject(c1, x1, y1, c2, x2, y2, cyclic);
}

private static class GradientCustomObject implements CustomObject, PaintCustomObject {
private static final class GradientCustomObject implements CustomObject, PaintCustomObject {
private final int[] c1;
private final int x1;
private final int y1;
Expand Down
@@ -1,18 +1,5 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.monitor.module.graphics;

import com.gempukku.lang.ExecutionException;
Expand Down Expand Up @@ -61,13 +48,16 @@ public int getCpuCycleDuration() {

@Override
public int getMinimumExecutionTime(int line, ComputerCallback computer, Map<String, Variable> parameters) throws ExecutionException {
GraphicsRenderCommandSink renderCommandSink = GraphicsRenderBindingValidator.validateGraphicsRenderBinding(line, computer, parameters, "renderBinding", methodName);
GraphicsRenderCommandSink renderCommandSink = GraphicsRenderBindingValidator.validateGraphicsRenderBinding(
line, computer, parameters, "renderBinding", methodName);
return renderCommandSink.isInstantRendering() ? 0 : 100;
}

@Override
public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Variable> parameters, Object onFunctionStartResult) throws ExecutionException {
GraphicsRenderCommandSink renderCommandSink = GraphicsRenderBindingValidator.validateGraphicsRenderBinding(line, computer, parameters, "renderBinding", methodName);
public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Variable> parameters, Object onFunctionStartResult)
throws ExecutionException {
GraphicsRenderCommandSink renderCommandSink = GraphicsRenderBindingValidator.validateGraphicsRenderBinding(
line, computer, parameters, "renderBinding", methodName);
int x1 = FunctionParamValidationUtil.validateIntParameter(line, parameters, "x1", methodName);
int y1 = FunctionParamValidationUtil.validateIntParameter(line, parameters, "y1", methodName);
int x2 = FunctionParamValidationUtil.validateIntParameter(line, parameters, "x2", methodName);
Expand Down
@@ -1,18 +1,5 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.computer.monitor.module.graphics;

import com.gempukku.lang.ExecutionException;
Expand Down Expand Up @@ -60,13 +47,16 @@ public int getCpuCycleDuration() {

@Override
public int getMinimumExecutionTime(int line, ComputerCallback computer, Map<String, Variable> parameters) throws ExecutionException {
GraphicsRenderCommandSink renderCommandSink = GraphicsRenderBindingValidator.validateGraphicsRenderBinding(line, computer, parameters, "renderBinding", methodName);
GraphicsRenderCommandSink renderCommandSink = GraphicsRenderBindingValidator.validateGraphicsRenderBinding(line, computer,
parameters, "renderBinding", methodName);
return renderCommandSink.isInstantRendering() ? 0 : 100;
}

@Override
public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Variable> parameters, Object onFunctionStartResult) throws ExecutionException {
GraphicsRenderCommandSink renderCommandSink = GraphicsRenderBindingValidator.validateGraphicsRenderBinding(line, computer, parameters, "renderBinding", methodName);
public Object onFunctionEnd(int line, ComputerCallback computer, Map<String, Variable> parameters, Object onFunctionStartResult)
throws ExecutionException {
GraphicsRenderCommandSink renderCommandSink = GraphicsRenderBindingValidator.validateGraphicsRenderBinding(line, computer,
parameters, "renderBinding", methodName);
int x = FunctionParamValidationUtil.validateIntParameter(line, parameters, "x", methodName);
int y = FunctionParamValidationUtil.validateIntParameter(line, parameters, "y", methodName);
int width = FunctionParamValidationUtil.validateIntParameter(line, parameters, "width", methodName);
Expand Down

0 comments on commit 7bde71b

Please sign in to comment.