Skip to content

Commit

Permalink
Block-related updates
Browse files Browse the repository at this point in the history
- Fix block breaking animation
- Fix block breaking particles
- Don't initialize Geyser's chunk cache if using Spigot
  • Loading branch information
Camotoy committed Jul 7, 2020
1 parent 24f9651 commit f68632f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.github.steveice10.mc.protocol.data.game.chunk.Column;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
import lombok.Getter;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.world.chunk.ChunkPosition;
Expand All @@ -38,15 +39,17 @@

public class ChunkCache {

private boolean cache;
private final GeyserSession session;
private final boolean cache;

@Getter
private Map<ChunkPosition, Column> chunks = new HashMap<>();

public ChunkCache(GeyserSession session) {
this.session = session;
this.cache = session.getConnector().getConfig().isCacheChunks();
if (session.getConnector().getWorldManager().getClass() == GeyserBootstrap.DEFAULT_CHUNK_MANAGER.getClass()) {
this.cache = session.getConnector().getConfig().isCacheChunks();
} else {
this.cache = false; // To prevent Spigot from initializing
}
}

public void addToCache(Column chunk) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void translate(PlayerActionPacket packet, GeyserSession session) {
break;
case CONTINUE_BREAK:
LevelEventPacket continueBreakPacket = new LevelEventPacket();
continueBreakPacket.setType(LevelEventType.BLOCK_UPDATE_BREAK); //TODO: There are now level event types for all breaks. Important?
continueBreakPacket.setType(LevelEventType.PARTICLE_CRACK_BLOCK);
continueBreakPacket.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
continueBreakPacket.setPosition(packet.getBlockPosition().toFloat());
session.sendUpstreamPacket(continueBreakPacket);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void translate(InventoryTransactionPacket packet, GeyserSession session)
session.setLastBlockPlacePosition(null);

LevelEventPacket blockBreakPacket = new LevelEventPacket();
blockBreakPacket.setType(LevelEventType.BLOCK_STOP_BREAK); //TODO: Make sure this is the right new enum
blockBreakPacket.setType(LevelEventType.PARTICLE_DESTROY_BLOCK);
blockBreakPacket.setPosition(packet.getBlockPosition().toFloat());
blockBreakPacket.setData(BlockTranslator.getBedrockBlockId(blockState));
session.sendUpstreamPacket(blockBreakPacket);
Expand Down

0 comments on commit f68632f

Please sign in to comment.