Skip to content

Commit

Permalink
chores: add @language annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
IWareQ committed Jun 16, 2024
1 parent 894b077 commit b041974
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 61 deletions.
1 change: 1 addition & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Allay-API/src/main/java/org/allaymc/api/world/Dimension.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,12 @@ default void breakBlock(Vector3ic pos, ItemStack usedItem, EntityPlayer player)

/**
* Break a block at the specified position
* @param x The x coordinate of the block
* @param y The y coordinate of the block
* @param z The z coordinate of the block
*
* @param x The x coordinate of the block
* @param y The y coordinate of the block
* @param z The z coordinate of the block
* @param usedItem The item used to break the block, can be null
* @param player The player who breaks the block, can be null
* @param player The player who breaks the block, can be null
*/
void breakBlock(int x, int y, int z, ItemStack usedItem, EntityPlayer player);
}
24 changes: 23 additions & 1 deletion Allay-API/src/main/java/org/allaymc/api/world/WorldData.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.allaymc.api.world.gamerule.GameRule;
import org.allaymc.api.world.gamerule.GameRules;
import org.cloudburstmc.protocol.bedrock.data.GameType;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.ApiStatus;
import org.joml.Vector3i;
import org.joml.Vector3ic;
Expand All @@ -21,6 +22,7 @@ public class WorldData {
public static final long TIME_MIDNIGHT = 18000;
public static final long TIME_SUNRISE = 23000;
public static final long TIME_FULL = 24000;

@Builder.Default
String biomeOverride = "";
@Builder.Default
Expand All @@ -30,8 +32,28 @@ public class WorldData {
@Builder.Default
Difficulty difficulty = Difficulty.from(1);
@Builder.Default
@Language("JSON")
String flatWorldLayers = """
{"biome_id":1,"block_layers":[{"block_name":"minecraft:bedrock","count":1},{"block_name":"minecraft:dirt","count":2},{"block_name":"minecraft:grass","count":1}],"encoding_version":6,"structure_options":null,"world_version":"version.post_1_18"}
{
"biome_id": 1,
"block_layers": [
{
"block_name": "minecraft:bedrock",
"count": 1
},
{
"block_name": "minecraft:dirt",
"count": 2
},
{
"block_name": "minecraft:grass",
"count": 1
}
],
"encoding_version": 6,
"structure_options": null,
"world_version": "version.post_1_18"
}
""";
@Builder.Default
boolean forceGameType = false;
Expand Down
2 changes: 1 addition & 1 deletion Allay-Server/src/main/java/org/allaymc/server/Allay.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static boolean isHeadless() {
Class<?> graphicsEnv = Class.forName("java.awt.GraphicsEnvironment");
Method isHeadless = graphicsEnv.getDeclaredMethod("isHeadless");
return (boolean) isHeadless.invoke(null);
} catch (Exception ignore) { }
} catch (Exception ignore) {}

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.allaymc.api.world.DimensionInfo;
import org.allaymc.api.world.World;
import org.allaymc.api.world.generator.WorldGenerator;
import org.allaymc.server.world.generator.AllayWorldGenerator;
import org.allaymc.api.world.service.BlockUpdateService;
import org.allaymc.api.world.service.ChunkService;
import org.allaymc.api.world.service.EntityPhysicsService;
Expand Down Expand Up @@ -114,7 +113,7 @@ public void breakBlock(int x, int y, int z, ItemStack usedItem, EntityPlayer pla
pk.setType(LevelEvent.PARTICLE_DESTROY_BLOCK);
pk.setPosition(Vector3f.from(x + 0.5f, y + 0.5f, z + 0.5f));
pk.setData(block.blockStateHash());
getChunkService().getChunkByLevelPos(x ,z).addChunkPacket(pk);
getChunkService().getChunkByLevelPos(x, z).addChunkPacket(pk);
block.getBehavior().onBreak(
new BlockStateWithPos(block, new Position3i(x, y, z, this), 0),
usedItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void loadWorlds() {

@Override
public void close() {
worlds.values().forEach(org.allaymc.api.world.World::close);
worlds.values().forEach(World::close);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
import org.allaymc.api.block.type.BlockType;
import org.allaymc.api.data.VanillaBlockId;
import org.allaymc.testutils.AllayTestExtension;
import org.intellij.lang.annotations.Language;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.awt.*;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

/**
* Allay Project 2023/3/25
Expand All @@ -25,54 +23,54 @@
@ExtendWith(AllayTestExtension.class)
@Slf4j
class BlockAttributesTest {
@Language("JSON")
private static final String json = """
{
"aabbCollision": "0.0005,0.0005,0.0005,0.9995,0.1825,0.9995",
"burnAbility": 0,
"burnChance": 0,
"canContainLiquid": true,
"color": {
"a": 255,
"b": 178,
"g": 76,
"hexString": "#ff334cb2",
"nearestColorCode": "§9",
"r": 51
},
"explosionResistance": 15,
"friction": 0.6,
"hardness": 3,
"hasBlockEntity": false,
"hasComparatorSignal": false,
"hasCollision": true,
"name": "minecraft:trapdoor",
"isAlwaysDestroyable": true,
"isContainerBlock": false,
"isLiquid": false,
"isMotionBlockingBlock": false,
"isPowerSource": false,
"isSolid": false,
"isUnbreakable": false,
"isWaterBlocking": true,
"isLavaFlammable": true,
"lightDampening": 0,
"lightEmission": 0,
"pushesUpFallingBlocks": false,
"superHot": false,
"thickness": 0,
"translucency": 0,
"isAir": true,
"isBounceBlock": true,
"isButtonBlock": true,
"isCropBlock": true,
"isDoorBlock": true,
"isFallingBlock": true,
"isFenceBlock": true,
"isFenceGateBlock": true,
"isLavaFlammable": true,
"isSlabBlock": true,
"isStemBlock": true,
"isThinFenceBlock": true
"aabbCollision": "0.0005,0.0005,0.0005,0.9995,0.1825,0.9995",
"burnAbility": 0,
"burnChance": 0,
"canContainLiquid": true,
"color": {
"a": 255,
"b": 178,
"g": 76,
"hexString": "#ff334cb2",
"nearestColorCode": "§9",
"r": 51
},
"explosionResistance": 15,
"friction": 0.6,
"hardness": 3,
"hasBlockEntity": false,
"hasComparatorSignal": false,
"hasCollision": true,
"name": "minecraft:trapdoor",
"isAlwaysDestroyable": true,
"isContainerBlock": false,
"isLiquid": false,
"isMotionBlockingBlock": false,
"isPowerSource": false,
"isSolid": false,
"isUnbreakable": false,
"isWaterBlocking": true,
"lightDampening": 0,
"lightEmission": 0,
"pushesUpFallingBlocks": false,
"superHot": false,
"thickness": 0,
"translucency": 0,
"isAir": true,
"isBounceBlock": true,
"isButtonBlock": true,
"isCropBlock": true,
"isDoorBlock": true,
"isFallingBlock": true,
"isFenceBlock": true,
"isFenceGateBlock": true,
"isLavaFlammable": true,
"isSlabBlock": true,
"isStemBlock": true,
"isThinFenceBlock": true
}
""";

Expand Down Expand Up @@ -115,8 +113,8 @@ void testVanillaBlockAttributes() {
for (var state : type.getBlockStateHashMap().values()) {
var expected = attributeMap.get(state.blockStateHash());
if (expected == null) {
log.error("Missing block attributes for state: " + state + ", Block: " + type.getIdentifier());
log.info("expected blockhash: " + state.blockStateHash());
log.error("Missing block attributes for state: {}, Block: {}", state, type.getIdentifier());
log.info("expected blockhash: {}", state.blockStateHash());
error++;
}
}
Expand Down

0 comments on commit b041974

Please sign in to comment.