-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Gensokyo-Reimagined/1_21
1.21 update
- Loading branch information
Showing
40 changed files
with
2,022 additions
and
1,879 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
group=net.gensokyoreimagined.nitori | ||
version=1.4-SNAPSHOT | ||
version=1.5-SNAPSHOT | ||
description=Converting patches into mixins, for the Ignite Framework | ||
|
||
org.gradle.parallel=true | ||
org.gradle.caching=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions
24
src/main/java/net/gensokyoreimagined/nitori/common/block/BlockListeningSection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
package net.gensokyoreimagined.nitori.common.block; | ||
|
||
import net.gensokyoreimagined.nitori.common.entity.block_tracking.SectionedBlockChangeTracker; | ||
import net.minecraft.core.SectionPos; | ||
import net.minecraft.world.level.Level; | ||
|
||
public interface BlockListeningSection { | ||
|
||
void lithium$addToCallback(ListeningBlockStatePredicate blockGroup, SectionedBlockChangeTracker tracker, long sectionPos, Level world); | ||
|
||
void lithium$removeFromCallback(ListeningBlockStatePredicate blockGroup, SectionedBlockChangeTracker tracker); | ||
|
||
void lithium$invalidateListeningSection(SectionPos sectionPos); | ||
} | ||
//import net.gensokyoreimagined.nitori.common.entity.block_tracking.SectionedBlockChangeTracker; | ||
//import net.minecraft.core.SectionPos; | ||
//import net.minecraft.world.level.Level; | ||
// | ||
//public interface BlockListeningSection { | ||
// | ||
// void lithium$addToCallback(ListeningBlockStatePredicate blockGroup, SectionedBlockChangeTracker tracker, long sectionPos, Level world); | ||
// | ||
// void lithium$removeFromCallback(ListeningBlockStatePredicate blockGroup, SectionedBlockChangeTracker tracker); | ||
// | ||
// void lithium$invalidateListeningSection(SectionPos sectionPos); | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 changes: 102 additions & 102 deletions
204
...et/gensokyoreimagined/nitori/common/entity/block_tracking/ChunkSectionChangeCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,104 @@ | ||
package net.gensokyoreimagined.nitori.common.entity.block_tracking; | ||
|
||
import it.unimi.dsi.fastutil.longs.Long2ReferenceOpenHashMap; | ||
import net.gensokyoreimagined.nitori.common.block.BlockListeningSection; | ||
import net.gensokyoreimagined.nitori.common.block.BlockStateFlags; | ||
import net.gensokyoreimagined.nitori.common.block.ListeningBlockStatePredicate; | ||
import net.gensokyoreimagined.nitori.common.util.Pos; | ||
import net.gensokyoreimagined.nitori.common.world.LithiumData; | ||
import net.gensokyoreimagined.nitori.common.world.chunk.ChunkStatusTracker; | ||
import net.minecraft.core.SectionPos; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.chunk.LevelChunkSection; | ||
|
||
import java.util.ArrayList; | ||
|
||
public final class ChunkSectionChangeCallback { | ||
private final ArrayList<SectionedBlockChangeTracker>[] trackers; | ||
private short listeningMask; | ||
|
||
static { | ||
if (BlockListeningSection.class.isAssignableFrom(LevelChunkSection.class)) { | ||
ChunkStatusTracker.registerUnloadCallback((serverWorld, chunkPos) -> { | ||
Long2ReferenceOpenHashMap<ChunkSectionChangeCallback> changeCallbacks = ((LithiumData) serverWorld).lithium$getData().chunkSectionChangeCallbacks(); | ||
int x = chunkPos.x; | ||
int z = chunkPos.z; | ||
for (int y = Pos.SectionYCoord.getMinYSection(serverWorld); y <= Pos.SectionYCoord.getMaxYSectionInclusive(serverWorld); y++) { | ||
SectionPos chunkSectionPos = SectionPos.of(x, y, z); | ||
ChunkSectionChangeCallback chunkSectionChangeCallback = changeCallbacks.remove(chunkSectionPos.asLong()); | ||
if (chunkSectionChangeCallback != null) { | ||
chunkSectionChangeCallback.onChunkSectionInvalidated(chunkSectionPos); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
public ChunkSectionChangeCallback() { | ||
//noinspection unchecked | ||
this.trackers = new ArrayList[BlockStateFlags.NUM_LISTENING_FLAGS]; | ||
this.listeningMask = 0; | ||
} | ||
|
||
public static ChunkSectionChangeCallback create(long sectionPos, Level world) { | ||
ChunkSectionChangeCallback chunkSectionChangeCallback = new ChunkSectionChangeCallback(); | ||
Long2ReferenceOpenHashMap<ChunkSectionChangeCallback> changeCallbacks = ((LithiumData) world).lithium$getData().chunkSectionChangeCallbacks(); | ||
ChunkSectionChangeCallback previous = changeCallbacks.put(sectionPos, chunkSectionChangeCallback); | ||
if (previous != null) { | ||
previous.onChunkSectionInvalidated(SectionPos.of(sectionPos)); | ||
} | ||
return chunkSectionChangeCallback; | ||
} | ||
|
||
public short onBlockChange(int blockGroupIndex, BlockListeningSection section) { | ||
ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[blockGroupIndex]; | ||
this.trackers[blockGroupIndex] = null; | ||
if (sectionedBlockChangeTrackers != null) { | ||
//noinspection ForLoopReplaceableByForEach | ||
for (int i = 0; i < sectionedBlockChangeTrackers.size(); i++) { | ||
sectionedBlockChangeTrackers.get(i).setChanged(section); | ||
} | ||
} | ||
this.listeningMask &= (short) ~(1 << blockGroupIndex); | ||
|
||
return this.listeningMask; | ||
} | ||
|
||
public short addTracker(SectionedBlockChangeTracker tracker, ListeningBlockStatePredicate blockGroup) { | ||
int blockGroupIndex = blockGroup.getIndex(); | ||
ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[blockGroupIndex]; | ||
if (sectionedBlockChangeTrackers == null) { | ||
this.trackers[blockGroupIndex] = (sectionedBlockChangeTrackers = new ArrayList<>()); | ||
} | ||
sectionedBlockChangeTrackers.add(tracker); | ||
|
||
this.listeningMask |= (short) (1 << blockGroupIndex); | ||
return this.listeningMask; | ||
} | ||
|
||
public short removeTracker(SectionedBlockChangeTracker tracker, ListeningBlockStatePredicate blockGroup) { | ||
int blockGroupIndex = blockGroup.getIndex(); | ||
ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[blockGroupIndex]; | ||
if (sectionedBlockChangeTrackers != null) { | ||
sectionedBlockChangeTrackers.remove(tracker); | ||
if (sectionedBlockChangeTrackers.isEmpty()) { | ||
this.listeningMask &= (short) ~(1 << blockGroup.getIndex()); | ||
} | ||
} | ||
return this.listeningMask; | ||
} | ||
|
||
public void onChunkSectionInvalidated(SectionPos sectionPos) { | ||
for (int flagIndex = 0; flagIndex < this.trackers.length; flagIndex++) { | ||
ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[flagIndex]; | ||
this.trackers[flagIndex] = null; | ||
if (sectionedBlockChangeTrackers != null) { | ||
//noinspection ForLoopReplaceableByForEach | ||
for (int i = 0; i < sectionedBlockChangeTrackers.size(); i++) { | ||
sectionedBlockChangeTrackers.get(i).onChunkSectionInvalidated(sectionPos); | ||
} | ||
} | ||
} | ||
this.listeningMask = 0; | ||
} | ||
} | ||
//import it.unimi.dsi.fastutil.longs.Long2ReferenceOpenHashMap; | ||
//import net.gensokyoreimagined.nitori.common.block.BlockListeningSection; | ||
//import net.gensokyoreimagined.nitori.common.block.BlockStateFlags; | ||
//import net.gensokyoreimagined.nitori.common.block.ListeningBlockStatePredicate; | ||
//import net.gensokyoreimagined.nitori.common.util.Pos; | ||
//import net.gensokyoreimagined.nitori.common.world.LithiumData; | ||
//import net.gensokyoreimagined.nitori.common.world.chunk.ChunkStatusTracker; | ||
//import net.minecraft.core.SectionPos; | ||
//import net.minecraft.world.level.Level; | ||
//import net.minecraft.world.level.chunk.LevelChunkSection; | ||
// | ||
//import java.util.ArrayList; | ||
// | ||
//public final class ChunkSectionChangeCallback { | ||
// private final ArrayList<SectionedBlockChangeTracker>[] trackers; | ||
// private short listeningMask; | ||
// | ||
// static { | ||
// if (BlockListeningSection.class.isAssignableFrom(LevelChunkSection.class)) { | ||
// ChunkStatusTracker.registerUnloadCallback((serverWorld, chunkPos) -> { | ||
// Long2ReferenceOpenHashMap<ChunkSectionChangeCallback> changeCallbacks = ((LithiumData) serverWorld).lithium$getData().chunkSectionChangeCallbacks(); | ||
// int x = chunkPos.x; | ||
// int z = chunkPos.z; | ||
// for (int y = Pos.SectionYCoord.getMinYSection(serverWorld); y <= Pos.SectionYCoord.getMaxYSectionInclusive(serverWorld); y++) { | ||
// SectionPos chunkSectionPos = SectionPos.of(x, y, z); | ||
// ChunkSectionChangeCallback chunkSectionChangeCallback = changeCallbacks.remove(chunkSectionPos.asLong()); | ||
// if (chunkSectionChangeCallback != null) { | ||
// chunkSectionChangeCallback.onChunkSectionInvalidated(chunkSectionPos); | ||
// } | ||
// } | ||
// }); | ||
// } | ||
// } | ||
// | ||
// public ChunkSectionChangeCallback() { | ||
// //noinspection unchecked | ||
// this.trackers = new ArrayList[BlockStateFlags.NUM_LISTENING_FLAGS]; | ||
// this.listeningMask = 0; | ||
// } | ||
// | ||
// public static ChunkSectionChangeCallback create(long sectionPos, Level world) { | ||
// ChunkSectionChangeCallback chunkSectionChangeCallback = new ChunkSectionChangeCallback(); | ||
// Long2ReferenceOpenHashMap<ChunkSectionChangeCallback> changeCallbacks = ((LithiumData) world).lithium$getData().chunkSectionChangeCallbacks(); | ||
// ChunkSectionChangeCallback previous = changeCallbacks.put(sectionPos, chunkSectionChangeCallback); | ||
// if (previous != null) { | ||
// previous.onChunkSectionInvalidated(SectionPos.of(sectionPos)); | ||
// } | ||
// return chunkSectionChangeCallback; | ||
// } | ||
// | ||
// public short onBlockChange(int blockGroupIndex, BlockListeningSection section) { | ||
// ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[blockGroupIndex]; | ||
// this.trackers[blockGroupIndex] = null; | ||
// if (sectionedBlockChangeTrackers != null) { | ||
// //noinspection ForLoopReplaceableByForEach | ||
// for (int i = 0; i < sectionedBlockChangeTrackers.size(); i++) { | ||
// sectionedBlockChangeTrackers.get(i).setChanged(section); | ||
// } | ||
// } | ||
// this.listeningMask &= (short) ~(1 << blockGroupIndex); | ||
// | ||
// return this.listeningMask; | ||
// } | ||
// | ||
// public short addTracker(SectionedBlockChangeTracker tracker, ListeningBlockStatePredicate blockGroup) { | ||
// int blockGroupIndex = blockGroup.getIndex(); | ||
// ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[blockGroupIndex]; | ||
// if (sectionedBlockChangeTrackers == null) { | ||
// this.trackers[blockGroupIndex] = (sectionedBlockChangeTrackers = new ArrayList<>()); | ||
// } | ||
// sectionedBlockChangeTrackers.add(tracker); | ||
// | ||
// this.listeningMask |= (short) (1 << blockGroupIndex); | ||
// return this.listeningMask; | ||
// } | ||
// | ||
// public short removeTracker(SectionedBlockChangeTracker tracker, ListeningBlockStatePredicate blockGroup) { | ||
// int blockGroupIndex = blockGroup.getIndex(); | ||
// ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[blockGroupIndex]; | ||
// if (sectionedBlockChangeTrackers != null) { | ||
// sectionedBlockChangeTrackers.remove(tracker); | ||
// if (sectionedBlockChangeTrackers.isEmpty()) { | ||
// this.listeningMask &= (short) ~(1 << blockGroup.getIndex()); | ||
// } | ||
// } | ||
// return this.listeningMask; | ||
// } | ||
// | ||
// public void onChunkSectionInvalidated(SectionPos sectionPos) { | ||
// for (int flagIndex = 0; flagIndex < this.trackers.length; flagIndex++) { | ||
// ArrayList<SectionedBlockChangeTracker> sectionedBlockChangeTrackers = this.trackers[flagIndex]; | ||
// this.trackers[flagIndex] = null; | ||
// if (sectionedBlockChangeTrackers != null) { | ||
// //noinspection ForLoopReplaceableByForEach | ||
// for (int i = 0; i < sectionedBlockChangeTrackers.size(); i++) { | ||
// sectionedBlockChangeTrackers.get(i).onChunkSectionInvalidated(sectionPos); | ||
// } | ||
// } | ||
// } | ||
// this.listeningMask = 0; | ||
// } | ||
//} |
Oops, something went wrong.