Skip to content

Commit

Permalink
Merge pull request #5 from Gensokyo-Reimagined/1_21
Browse files Browse the repository at this point in the history
1.21 update
  • Loading branch information
Taiyou06 authored Aug 9, 2024
2 parents fd09c9a + 2971510 commit 346acf5
Show file tree
Hide file tree
Showing 40 changed files with 2,022 additions and 1,879 deletions.
3 changes: 1 addition & 2 deletions gradle.properties
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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mixinExtras = "0.3.5"
paperweight = "1.7.1"
shadow = "8.1.2"
spotless = "6.25.0"
paper = "1.20.6-R0.1-SNAPSHOT"
paper = "1.21-R0.1-SNAPSHOT"

[libraries]
jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "jetbrains" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package net.gensokyoreimagined.nitori.access;

import com.destroystokyo.paper.util.maplist.EntityList;
import ca.spottedleaf.moonrise.common.list.EntityList;

public interface IMixinChunkEntitySlicesAccess {
@SuppressWarnings("EmptyMethod")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package net.gensokyoreimagined.nitori.access;

public interface IMixinChunkMapAccess {
void gensouHacks$runOnTrackerMainThread(final Runnable runnable);
}
//public interface IMixinChunkMapAccess {
// void gensouHacks$runOnTrackerMainThread(final Runnable runnable);
//}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package net.gensokyoreimagined.nitori.access;

import com.destroystokyo.paper.util.misc.PooledLinkedHashSets;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;

public interface IMixinChunkMap_TrackedEntityAccess {
@SuppressWarnings("EmptyMethod")
Entity getEntity();

@SuppressWarnings("EmptyMethod")
void callUpdatePlayers(PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> newTrackerCandidates);
}
//import net.minecraft.server.level.ServerPlayer;
//import net.minecraft.world.entity.Entity;
//
//import java.util.List;
//
//public interface IMixinChunkMap_TrackedEntityAccess {
// @SuppressWarnings("EmptyMethod")
// Entity getEntity();
//
// @SuppressWarnings("EmptyMethod")
// void callUpdatePlayers(List<ServerPlayer> players);
//}
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;

/**
* Provides the ability for mods to allow Lithium's hopper optimizations to access their inventories' for item transfers.
* This exists because Lithium's optimized hopper logic will only interact with inventories more efficiently than
* vanilla if the stack list can be directly accessed and replaced with Lithium's custom stack list.
* It is not required to implement this interface, but doing so will allow the mod's inventories to benefit from
* Lithium's optimizations.
* <p>
* This interface should be implemented by your {@link net.minecraft.inventory.Inventory} or
* {@link net.minecraft.inventory.SidedInventory} type to access the stack list.
* <p>
* An inventory must not extend {@link net.minecraft.block.entity.BlockEntity} if it has a supporting block that
* implements {@link net.minecraft.block.InventoryProvider}.
* <p>
* The hopper interaction behavior of a LithiumInventory should only change if the content of the inventory
* stack list also changes. For example, an inventory which only accepts an item if it already contains an item of the
* same type would work fine (changing the acceptance condition only happens when changing the inventory contents here).
* However, an inventory which accepts an item only if a certain block is near its position will need to signal this
* change to hoppers by calling {@link LithiumNonNullList#changedInteractionConditions()}.
*
* @author 2No2Name
*/

public interface LithiumInventory extends ContainerEntity {

/**
Expand Down
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);
//}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public boolean test(BlockState operand) {
OVERSIZED_SHAPE = new TrackedBlockStatePredicate(countingFlags.size()) {
@Override
public boolean test(BlockState operand) {
return operand.shapeExceedsCube();
return operand.hasLargeCollisionShape();
}
};
countingFlags.add(OVERSIZED_SHAPE);
Expand Down
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;
// }
//}
Loading

0 comments on commit 346acf5

Please sign in to comment.