Skip to content

Commit

Permalink
feat: Add lithium$trackBlockStateChange method to `BlockCountingSec…
Browse files Browse the repository at this point in the history
…tion` (#508)

This allows other mods such as Noisium and Big Globe to call this function using the `BlockCountingSection` interface to track blockstates (increment/decrement the blockstate counter) during world generation, for example.
  • Loading branch information
Steveplays28 authored Apr 9, 2024
1 parent e2bf990 commit 9b14a53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package me.jellysquid.mods.lithium.common.block;

import net.minecraft.block.BlockState;

public interface BlockCountingSection {
boolean lithium$mayContainAny(TrackedBlockStatePredicate trackedBlockStatePredicate);

void lithium$trackBlockStateChange(BlockState newState, BlockState oldState);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public abstract class ChunkSectionMixin implements BlockCountingSection, BlockLi
@Shadow
@Final
private PalettedContainer<BlockState> blockStateContainer;

@Unique
private short[] countsByFlag = null;
@Unique
Expand Down Expand Up @@ -107,6 +108,11 @@ private void resetData(PacketByteBuf buf, CallbackInfo ci) {
locals = LocalCapture.CAPTURE_FAILHARD
)
private void updateFlagCounters(int x, int y, int z, BlockState newState, boolean lock, CallbackInfoReturnable<BlockState> cir, BlockState oldState) {
this.lithium$trackBlockStateChange(newState, oldState);
}

@Override
public void lithium$trackBlockStateChange(BlockState newState, BlockState oldState) {
short[] countsByFlag = this.countsByFlag;
if (countsByFlag == null) {
return;
Expand Down

0 comments on commit 9b14a53

Please sign in to comment.