Comments improvement

This commit is contained in:
themode 2020-10-03 19:07:23 +02:00
parent 6758cadf7d
commit db90b5e22d
3 changed files with 20 additions and 18 deletions

View File

@ -48,7 +48,7 @@ public abstract class Chunk implements Viewable, DataContainer {
public static final int CHUNK_SECTION_COUNT = CHUNK_SIZE_Y / CHUNK_SECTION_SIZE;
public static final int BIOME_COUNT = 1024; // 4x4x4 blocks
public static final int BIOME_COUNT = 1024; // 4x4x4 blocks group
protected final Instance instance;
protected Biome[] biomes;
@ -58,7 +58,7 @@ public abstract class Chunk implements Viewable, DataContainer {
// Key is still chunk coord
protected Int2ObjectMap<Data> blocksData = new Int2ObjectOpenHashMap<>(16 * 16); // Start with the size of a single row
// Contains CustomBlocks' index which are updatable
// Contains CustomBlocks' block index which are updatable
protected IntSet updatableBlocks = new IntOpenHashSet();
// (block index)/(last update in ms)
protected Int2LongMap updatableBlocksLastUpdate = new Int2LongOpenHashMap();
@ -178,13 +178,13 @@ public abstract class Chunk implements Viewable, DataContainer {
/**
* Change the block state id and the custom block id at a position
*
* @param x the block X
* @param y the block Y
* @param z the block Z
* @param blockStateId the new block state id
* @param customId the new custom block id
* @param x the block X
* @param y the block Y
* @param z the block Z
* @param blockStateId the new block state id
* @param customBlockId the new custom block id
*/
protected abstract void refreshBlockValue(int x, int y, int z, short blockStateId, short customId);
protected abstract void refreshBlockValue(int x, int y, int z, short blockStateId, short customBlockId);
/**
* Change the block state id at a position (the custom block id stays the same)
@ -339,7 +339,7 @@ public abstract class Chunk implements Viewable, DataContainer {
/**
* Serialize the chunk into bytes
*
* @return the serialized chunk, can potentially be null if this chunk cannot be serialized
* @return the serialized chunk, can be null if this chunk cannot be serialized
*/
public abstract byte[] getSerializedData();

View File

@ -111,14 +111,14 @@ public class DynamicChunk extends Chunk {
}
@Override
protected void refreshBlockValue(int x, int y, int z, short blockStateId, short customId) {
protected void refreshBlockValue(int x, int y, int z, short blockStateId, short customBlockId) {
final int blockIndex = getBlockIndex(x, y, z);
if (!MathUtils.isBetween(blockIndex, 0, blocksStateId.length)) {
return;
}
this.blocksStateId[blockIndex] = blockStateId;
this.customBlocksId[blockIndex] = customId;
this.customBlocksId[blockIndex] = customBlockId;
}
@Override
@ -161,6 +161,7 @@ public class DynamicChunk extends Chunk {
binaryWriter.writeByte(id);
}
// Loop all blocks
for (byte x = 0; x < CHUNK_SIZE_X; x++) {
for (short y = 0; y < CHUNK_SIZE_Y; y++) {
for (byte z = 0; z < CHUNK_SIZE_Z; z++) {
@ -230,11 +231,13 @@ public class DynamicChunk extends Chunk {
serializableData.readSerializedData(reader, typeToIndexMap);
}
// Biomes
for (int i = 0; i < BIOME_COUNT; i++) {
final byte id = reader.readByte();
this.biomes[i] = BIOME_MANAGER.getById(id);
}
// Loop for all blocks in the chunk
while (true) {
// Position
final short index = reader.readShort();

View File

@ -964,17 +964,16 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
* Creates an explosion at the given position with the given strength.
* The algorithm used to compute damages is provided by {@link #getExplosionSupplier()}.
*
* @param centerX
* @param centerY
* @param centerZ
* @param strength
* @param centerX center X of the explosion
* @param centerY center Y of the explosion
* @param centerZ center Z of the explosion
* @param strength the strength of the explosion
* @param additionalData data to pass to the explosion supplier
* @throws IllegalStateException If no {@link ExplosionSupplier} was supplied
*/
public void explode(float centerX, float centerY, float centerZ, float strength, Data additionalData) {
final ExplosionSupplier explosionSupplier = getExplosionSupplier();
if (explosionSupplier == null)
throw new IllegalStateException("Tried to create an explosion with no explosion supplier");
Check.stateCondition(explosionSupplier == null, "Tried to create an explosion with no explosion supplier");
final Explosion explosion = explosionSupplier.createExplosion(centerX, centerY, centerZ, strength, additionalData);
explosion.apply(this);
}
@ -989,7 +988,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
}
/**
* Registers the explosion supplier to use in this instance
* Registers the {@link ExplosionSupplier} to use in this instance
*
* @param supplier the explosion supplier
*/