mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-07 17:08:30 +01:00
Comments improvement
This commit is contained in:
parent
6758cadf7d
commit
db90b5e22d
@ -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 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 final Instance instance;
|
||||||
protected Biome[] biomes;
|
protected Biome[] biomes;
|
||||||
@ -58,7 +58,7 @@ public abstract class Chunk implements Viewable, DataContainer {
|
|||||||
// Key is still chunk coord
|
// Key is still chunk coord
|
||||||
protected Int2ObjectMap<Data> blocksData = new Int2ObjectOpenHashMap<>(16 * 16); // Start with the size of a single row
|
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();
|
protected IntSet updatableBlocks = new IntOpenHashSet();
|
||||||
// (block index)/(last update in ms)
|
// (block index)/(last update in ms)
|
||||||
protected Int2LongMap updatableBlocksLastUpdate = new Int2LongOpenHashMap();
|
protected Int2LongMap updatableBlocksLastUpdate = new Int2LongOpenHashMap();
|
||||||
@ -182,9 +182,9 @@ public abstract class Chunk implements Viewable, DataContainer {
|
|||||||
* @param y the block Y
|
* @param y the block Y
|
||||||
* @param z the block Z
|
* @param z the block Z
|
||||||
* @param blockStateId the new block state id
|
* @param blockStateId the new block state id
|
||||||
* @param customId the new custom block 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)
|
* 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
|
* 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();
|
public abstract byte[] getSerializedData();
|
||||||
|
|
||||||
|
@ -111,14 +111,14 @@ public class DynamicChunk extends Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
final int blockIndex = getBlockIndex(x, y, z);
|
||||||
if (!MathUtils.isBetween(blockIndex, 0, blocksStateId.length)) {
|
if (!MathUtils.isBetween(blockIndex, 0, blocksStateId.length)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.blocksStateId[blockIndex] = blockStateId;
|
this.blocksStateId[blockIndex] = blockStateId;
|
||||||
this.customBlocksId[blockIndex] = customId;
|
this.customBlocksId[blockIndex] = customBlockId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -161,6 +161,7 @@ public class DynamicChunk extends Chunk {
|
|||||||
binaryWriter.writeByte(id);
|
binaryWriter.writeByte(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loop all blocks
|
||||||
for (byte x = 0; x < CHUNK_SIZE_X; x++) {
|
for (byte x = 0; x < CHUNK_SIZE_X; x++) {
|
||||||
for (short y = 0; y < CHUNK_SIZE_Y; y++) {
|
for (short y = 0; y < CHUNK_SIZE_Y; y++) {
|
||||||
for (byte z = 0; z < CHUNK_SIZE_Z; z++) {
|
for (byte z = 0; z < CHUNK_SIZE_Z; z++) {
|
||||||
@ -230,11 +231,13 @@ public class DynamicChunk extends Chunk {
|
|||||||
serializableData.readSerializedData(reader, typeToIndexMap);
|
serializableData.readSerializedData(reader, typeToIndexMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Biomes
|
||||||
for (int i = 0; i < BIOME_COUNT; i++) {
|
for (int i = 0; i < BIOME_COUNT; i++) {
|
||||||
final byte id = reader.readByte();
|
final byte id = reader.readByte();
|
||||||
this.biomes[i] = BIOME_MANAGER.getById(id);
|
this.biomes[i] = BIOME_MANAGER.getById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loop for all blocks in the chunk
|
||||||
while (true) {
|
while (true) {
|
||||||
// Position
|
// Position
|
||||||
final short index = reader.readShort();
|
final short index = reader.readShort();
|
||||||
|
@ -964,17 +964,16 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
|||||||
* Creates an explosion at the given position with the given strength.
|
* Creates an explosion at the given position with the given strength.
|
||||||
* The algorithm used to compute damages is provided by {@link #getExplosionSupplier()}.
|
* The algorithm used to compute damages is provided by {@link #getExplosionSupplier()}.
|
||||||
*
|
*
|
||||||
* @param centerX
|
* @param centerX center X of the explosion
|
||||||
* @param centerY
|
* @param centerY center Y of the explosion
|
||||||
* @param centerZ
|
* @param centerZ center Z of the explosion
|
||||||
* @param strength
|
* @param strength the strength of the explosion
|
||||||
* @param additionalData data to pass to the explosion supplier
|
* @param additionalData data to pass to the explosion supplier
|
||||||
* @throws IllegalStateException If no {@link ExplosionSupplier} was supplied
|
* @throws IllegalStateException If no {@link ExplosionSupplier} was supplied
|
||||||
*/
|
*/
|
||||||
public void explode(float centerX, float centerY, float centerZ, float strength, Data additionalData) {
|
public void explode(float centerX, float centerY, float centerZ, float strength, Data additionalData) {
|
||||||
final ExplosionSupplier explosionSupplier = getExplosionSupplier();
|
final ExplosionSupplier explosionSupplier = getExplosionSupplier();
|
||||||
if (explosionSupplier == null)
|
Check.stateCondition(explosionSupplier == null, "Tried to create an explosion with no explosion supplier");
|
||||||
throw new IllegalStateException("Tried to create an explosion with no explosion supplier");
|
|
||||||
final Explosion explosion = explosionSupplier.createExplosion(centerX, centerY, centerZ, strength, additionalData);
|
final Explosion explosion = explosionSupplier.createExplosion(centerX, centerY, centerZ, strength, additionalData);
|
||||||
explosion.apply(this);
|
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
|
* @param supplier the explosion supplier
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user