Skip to content

Commit

Permalink
Rename mixins to match target class name
Browse files Browse the repository at this point in the history
  • Loading branch information
2No2Name committed Oct 3, 2024
1 parent c8f6ed9 commit 833a83a
Show file tree
Hide file tree
Showing 166 changed files with 558 additions and 574 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.caffeinemc.mods.lithium.common.util.Pos;
import net.caffeinemc.mods.lithium.common.world.ChunkView;
import net.caffeinemc.mods.lithium.common.world.WorldHelper;
import net.caffeinemc.mods.lithium.mixin.ai.pathing.PathContextAccessor;
import net.caffeinemc.mods.lithium.mixin.ai.pathing.PathfindingContextAccessor;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockBehaviour;
Expand Down Expand Up @@ -103,7 +103,7 @@ public static PathType getNodeTypeFromNeighbors(PathfindingContext context, int
if (section != null) {
state = section.getBlockState(adjX & 15, adjY & 15, adjZ & 15);
} else {
BlockPos.MutableBlockPos pos = ((PathContextAccessor) context).getLastNodePos().set(adjX, adjY, adjZ);
BlockPos.MutableBlockPos pos = ((PathfindingContextAccessor) context).getLastNodePos().set(adjX, adjY, adjZ);
state = world.getBlockState(pos);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import net.caffeinemc.mods.lithium.common.util.tuples.WorldSectionBox;
import net.caffeinemc.mods.lithium.common.world.LithiumData;
import net.caffeinemc.mods.lithium.mixin.util.entity_movement_tracking.ServerEntityManagerAccessor;
import net.caffeinemc.mods.lithium.mixin.util.entity_movement_tracking.ServerWorldAccessor;
import net.caffeinemc.mods.lithium.mixin.util.entity_movement_tracking.PersistentEntitySectionManagerAccessor;
import net.caffeinemc.mods.lithium.mixin.util.entity_movement_tracking.ServerLevelAccessor;
import net.minecraft.core.SectionPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.entity.EntityAccess;
import net.minecraft.world.level.entity.EntitySection;
import net.minecraft.world.level.entity.EntitySectionStorage;

import java.util.ArrayList;

public abstract class SectionedEntityMovementTracker<E extends EntityAccess, S> {
Expand Down Expand Up @@ -81,7 +82,7 @@ public void register(ServerLevel world) {

if (this.timesRegistered == 0) {
//noinspection unchecked
EntitySectionStorage<E> cache = ((ServerEntityManagerAccessor<E>) ((ServerWorldAccessor) world).getEntityManager()).getCache();
EntitySectionStorage<E> cache = ((PersistentEntitySectionManagerAccessor<E>) ((ServerLevelAccessor) world).getEntityManager()).getCache();

WorldSectionBox trackedSections = this.trackedWorldSections;
int size = trackedSections.numSections();
Expand Down Expand Up @@ -114,7 +115,7 @@ public void unRegister(ServerLevel world) {
}
assert this.timesRegistered == 0;
//noinspection unchecked
EntitySectionStorage<E> cache = ((ServerEntityManagerAccessor<E>) ((ServerWorldAccessor) world).getEntityManager()).getCache();
EntitySectionStorage<E> cache = ((PersistentEntitySectionManagerAccessor<E>) ((ServerLevelAccessor) world).getEntityManager()).getCache();
((LithiumData) world).lithium$getData().entityMovementTrackers().deleteCanonical(this);

ArrayList<EntitySection<E>> sections = this.sortedSections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import net.caffeinemc.mods.lithium.common.util.tuples.WorldSectionBox;
import net.caffeinemc.mods.lithium.common.world.LithiumData;
import net.caffeinemc.mods.lithium.mixin.block.hopper.EntityTrackingSectionAccessor;
import net.caffeinemc.mods.lithium.mixin.block.hopper.EntitySectionAccessor;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.ClassInstanceMultiMap;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.AABB;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -30,7 +31,7 @@ public List<S> getEntities(AABB box) {
for (int i = 0; i < this.sortedSections.size(); i++) {
if (this.sectionVisible[i]) {
//noinspection unchecked
ClassInstanceMultiMap<S> collection = ((EntityTrackingSectionAccessor<S>) this.sortedSections.get(i)).getCollection();
ClassInstanceMultiMap<S> collection = ((EntitySectionAccessor<S>) this.sortedSections.get(i)).getCollection();

for (S entity : collection.find(this.clazz)) {
Entity inventoryEntity = (Entity) entity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import net.caffeinemc.mods.lithium.common.util.tuples.WorldSectionBox;
import net.caffeinemc.mods.lithium.common.world.LithiumData;
import net.caffeinemc.mods.lithium.mixin.block.hopper.EntityTrackingSectionAccessor;
import net.caffeinemc.mods.lithium.mixin.block.hopper.EntitySectionAccessor;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.ClassInstanceMultiMap;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.AABB;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -30,7 +31,7 @@ public List<S> getEntities(AABB interactionArea) {
for (int sectionIndex = 0; sectionIndex < this.sortedSections.size(); sectionIndex++) {
if (this.sectionVisible[sectionIndex]) {
//noinspection unchecked
ClassInstanceMultiMap<S> collection = ((EntityTrackingSectionAccessor<S>) this.sortedSections.get(sectionIndex)).getCollection();
ClassInstanceMultiMap<S> collection = ((EntitySectionAccessor<S>) this.sortedSections.get(sectionIndex)).getCollection();

for (S entity : collection.find(this.clazz)) {
if (entity.isAlive()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.caffeinemc.mods.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker;
import net.caffeinemc.mods.lithium.common.util.change_tracking.ChangePublisher;
import net.caffeinemc.mods.lithium.common.util.change_tracking.ChangeSubscriber;
import net.caffeinemc.mods.lithium.mixin.block.hopper.DefaultedListAccessor;
import net.caffeinemc.mods.lithium.mixin.block.hopper.NonNullListAccessor;
import net.minecraft.core.NonNullList;
import net.minecraft.util.Mth;
import net.minecraft.world.Container;
Expand All @@ -31,7 +31,7 @@ public class LithiumStackList extends NonNullList<ItemStack> implements LithiumD

public LithiumStackList(NonNullList<ItemStack> original, int maxCountPerStack) {
//noinspection unchecked
super(((DefaultedListAccessor<ItemStack>) original).getDelegate(), ItemStack.EMPTY);
super(((NonNullListAccessor<ItemStack>) original).getDelegate(), ItemStack.EMPTY);
this.maxCountPerStack = maxCountPerStack;

this.cachedSignalStrength = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import it.unimi.dsi.fastutil.doubles.*;
import net.caffeinemc.mods.lithium.mixin.minimal_nonvanilla.collisions.empty_space.ArrayVoxelShapeInvoker;
import net.caffeinemc.mods.lithium.mixin.minimal_nonvanilla.collisions.empty_space.BitSetVoxelSetAccessor;
import net.caffeinemc.mods.lithium.mixin.minimal_nonvanilla.collisions.empty_space.BitSetDiscreteVoxelShapeAccessor;
import net.minecraft.core.Direction;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.BitSetDiscreteVoxelShape;
import net.minecraft.world.phys.shapes.VoxelShape;

import java.util.BitSet;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -103,7 +104,7 @@ public static Optional<Vec3> getClosestPointTo(Vec3 target, VoxelShape colliding
bitSetVoxelSet.fill(xSize, ySize, zSize);
//Clear the values have just written, but without updating min/max x, y, z values. The voxelSet is empty
// but has the correct min/max values after this
BitSet bitSet = ((BitSetVoxelSetAccessor) (Object) bitSetVoxelSet).getStorage();
BitSet bitSet = ((BitSetDiscreteVoxelShapeAccessor) (Object) bitSetVoxelSet).getStorage();
bitSet.clear();

//Add all points inside the collidingShape, remove all points in other boxes afterward
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import net.caffeinemc.mods.lithium.common.entity.EntityClassGroup;
import net.caffeinemc.mods.lithium.common.entity.pushable.EntityPushablePredicate;
import net.caffeinemc.mods.lithium.common.world.chunk.ClassGroupFilterableList;
import net.caffeinemc.mods.lithium.mixin.util.accessors.ClientEntityManagerAccessor;
import net.caffeinemc.mods.lithium.mixin.util.accessors.EntityTrackingSectionAccessor;
import net.caffeinemc.mods.lithium.mixin.util.accessors.ServerEntityManagerAccessor;
import net.caffeinemc.mods.lithium.mixin.util.accessors.ServerWorldAccessor;
import net.caffeinemc.mods.lithium.mixin.util.accessors.EntitySectionAccessor;
import net.caffeinemc.mods.lithium.mixin.util.accessors.PersistentEntitySectionManagerAccessor;
import net.caffeinemc.mods.lithium.mixin.util.accessors.ServerLevelAccessor;
import net.caffeinemc.mods.lithium.mixin.util.accessors.TransientEntitySectionManagerAccessor;
import net.minecraft.core.BlockPos;
import net.minecraft.util.AbortableIterationConsumer;
import net.minecraft.util.ClassInstanceMultiMap;
Expand Down Expand Up @@ -72,10 +72,10 @@ public static List<Entity> getOtherEntitiesForCollision(EntityGetter entityView,
public static EntitySectionStorage<Entity> getEntityCacheOrNull(Level world) {
if (world instanceof ClientWorldAccessor) {
//noinspection unchecked
return ((ClientEntityManagerAccessor<Entity>) ((ClientWorldAccessor) world).lithium$getEntityManager()).getCache();
} else if (world instanceof ServerWorldAccessor) {
return ((TransientEntitySectionManagerAccessor<Entity>) ((ClientWorldAccessor) world).lithium$getEntityManager()).getCache();
} else if (world instanceof ServerLevelAccessor) {
//noinspection unchecked
return ((ServerEntityManagerAccessor<Entity>) ((ServerWorldAccessor) world).getEntityManager()).getCache();
return ((PersistentEntitySectionManagerAccessor<Entity>) ((ServerLevelAccessor) world).getEntityManager()).getCache();
}
return null;
}
Expand All @@ -84,7 +84,7 @@ public static List<Entity> getEntitiesOfClassGroup(EntitySectionStorage<Entity>
ArrayList<Entity> entities = new ArrayList<>();
cache.forEachAccessibleNonEmptySection(box, section -> {
//noinspection unchecked
ClassInstanceMultiMap<Entity> allEntities = ((EntityTrackingSectionAccessor<Entity>) section).getCollection();
ClassInstanceMultiMap<Entity> allEntities = ((EntitySectionAccessor<Entity>) section).getCollection();
//noinspection unchecked
Collection<Entity> entitiesOfType = ((ClassGroupFilterableList<Entity>) allEntities).lithium$getAllOfGroupType(entityClassGroup);
if (!entitiesOfType.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.spongepowered.asm.mixin.Shadow;

@Mixin(BlockBehaviour.BlockStateBase.class)
public abstract class AbstractBlockStateMixin implements BlockStatePathingCache {
public abstract class BlockStateBaseMixin implements BlockStatePathingCache {
private PathType pathNodeType = null;
private PathType pathNodeTypeNeighbor = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(FlyNodeEvaluator.class)
public class BirdPathNodeMakerMixin {
public class FlyNodeEvaluatorMixin {

/**
* @reason Use optimized implementation which avoids scanning blocks for dangers where possible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* code.
*/
@Mixin(PathNavigationRegion.class)
public abstract class ChunkCacheMixin implements BlockGetter {
public abstract class PathNavigationRegionMixin implements BlockGetter {
private static final BlockState DEFAULT_BLOCK = Blocks.AIR.defaultBlockState();

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(PathfindingContext.class)
public interface PathContextAccessor {
public interface PathfindingContextAccessor {

@Accessor("mutablePos")
BlockPos.MutableBlockPos getLastNodePos();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.spongepowered.asm.mixin.injection.At;

@Mixin(PathfindingContext.class)
public class PathContextMixin {
public class PathfindingContextMixin {

@WrapOperation(
method = "<init>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* code and should be relatively safe.
*/
@Mixin(value = WalkNodeEvaluator.class, priority = 990)
public abstract class LandPathNodeMakerMixin {
public abstract class WalkNodeEvaluatorMixin {
/**
* This mixin requires a priority < 1000 due to fabric api using 1000 and us needing to inject before them.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
import java.util.stream.StreamSupport;

@Mixin(PoiManager.class)
public abstract class PointOfInterestStorageMixin extends SectionStorage<PoiSection>
implements PointOfInterestStorageExtended {
public abstract class PoiManagerMixin extends SectionStorage<PoiSection> implements PointOfInterestStorageExtended {


public PointOfInterestStorageMixin(SimpleRegionStorage storageAccess, Function<Runnable, Codec<PoiSection>> codecFactory, Function<Runnable, PoiSection> factory, RegistryAccess registryManager, ChunkIOErrorReporter errorHandler, LevelHeightAccessor world) {
public PoiManagerMixin(SimpleRegionStorage storageAccess, Function<Runnable, Codec<PoiSection>> codecFactory, Function<Runnable, PoiSection> factory, RegistryAccess registryManager, ChunkIOErrorReporter errorHandler, LevelHeightAccessor world) {
super(storageAccess, codecFactory, factory, registryManager, errorHandler, world);
}

Expand All @@ -52,7 +51,7 @@ public PointOfInterestStorageMixin(SimpleRegionStorage storageAccess, Function<R
@SuppressWarnings("unchecked")
@Overwrite
public Stream<PoiRecord> getInChunk(Predicate<Holder<PoiType>> predicate, ChunkPos pos,
PoiManager.Occupancy status) {
PoiManager.Occupancy status) {
return ((RegionBasedStorageSectionExtended<PoiSection>) this)
.lithium$getWithinChunkColumn(pos.x, pos.z)
.flatMap(set -> set.getRecords(predicate, status));
Expand All @@ -66,8 +65,8 @@ public Stream<PoiRecord> getInChunk(Predicate<Holder<PoiType>> predicate, ChunkP
*/
@Overwrite
public Optional<BlockPos> getRandom(Predicate<Holder<PoiType>> typePredicate, Predicate<BlockPos> posPredicate,
PoiManager.Occupancy status, BlockPos pos, int radius,
RandomSource rand) {
PoiManager.Occupancy status, BlockPos pos, int radius,
RandomSource rand) {
ArrayList<PoiRecord> list = this.withinSphereChunkSectionSorted(typePredicate, pos, radius, status);

for (int i = list.size() - 1; i >= 0; i--) {
Expand All @@ -92,7 +91,7 @@ public Optional<BlockPos> getRandom(Predicate<Holder<PoiType>> typePredicate, Pr
*/
@Overwrite
public Optional<BlockPos> findClosest(Predicate<Holder<PoiType>> predicate, BlockPos pos, int radius,
PoiManager.Occupancy status) {
PoiManager.Occupancy status) {
return this.findClosest(predicate, null, pos, radius, status);
}

Expand All @@ -105,8 +104,8 @@ public Optional<BlockPos> findClosest(Predicate<Holder<PoiType>> predicate, Bloc
*/
@Overwrite
public Optional<BlockPos> findClosest(Predicate<Holder<PoiType>> predicate,
Predicate<BlockPos> posPredicate, BlockPos pos, int radius,
PoiManager.Occupancy status) {
Predicate<BlockPos> posPredicate, BlockPos pos, int radius,
PoiManager.Occupancy status) {
Stream<PoiRecord> pointOfInterestStream = this.streamOutwards(pos, radius, status, true, false, predicate, posPredicate == null ? null : poi -> posPredicate.test(poi.getPos()));
return pointOfInterestStream.map(PoiRecord::getPos).findFirst();
}
Expand All @@ -119,7 +118,7 @@ public Optional<BlockPos> findClosest(Predicate<Holder<PoiType>> predicate,
*/
@Overwrite
public long getCountInRange(Predicate<Holder<PoiType>> predicate, BlockPos pos, int radius,
PoiManager.Occupancy status) {
PoiManager.Occupancy status) {
return this.withinSphereChunkSectionSorted(predicate, pos, radius, status).size();
}

Expand All @@ -134,14 +133,14 @@ public long getCountInRange(Predicate<Holder<PoiType>> predicate, BlockPos pos,
*/
@Overwrite
public Stream<PoiRecord> getInRange(Predicate<Holder<PoiType>> predicate, BlockPos sphereOrigin, int radius,
PoiManager.Occupancy status) {
PoiManager.Occupancy status) {
return this.withinSphereChunkSectionSortedStream(predicate, sphereOrigin, radius, status);
}

@Override
public Optional<PoiRecord> lithium$findNearestForPortalLogic(BlockPos origin, int radius, Holder<PoiType> type,
PoiManager.Occupancy status,
Predicate<PoiRecord> afterSortPredicate, WorldBorder worldBorder) {
PoiManager.Occupancy status,
Predicate<PoiRecord> afterSortPredicate, WorldBorder worldBorder) {
// Order of the POI:
// return closest accepted POI (L2 distance). If several exist:
// return the one with most negative Y. If several exist:
Expand All @@ -159,7 +158,7 @@ public Stream<PoiRecord> getInRange(Predicate<Holder<PoiType>> predicate, BlockP
}

private Stream<PoiRecord> withinSphereChunkSectionSortedStream(Predicate<Holder<PoiType>> predicate, BlockPos origin,
int radius, PoiManager.Occupancy status) {
int radius, PoiManager.Occupancy status) {
double radiusSq = radius * radius;


Expand All @@ -176,7 +175,7 @@ private Stream<PoiRecord> withinSphereChunkSectionSortedStream(Predicate<Holder<
}

private ArrayList<PoiRecord> withinSphereChunkSectionSorted(Predicate<Holder<PoiType>> predicate, BlockPos origin,
int radius, PoiManager.Occupancy status) {
int radius, PoiManager.Occupancy status) {
double radiusSq = radius * radius;

int minChunkX = origin.getX() - radius - 1 >> 4;
Expand Down Expand Up @@ -207,11 +206,11 @@ private ArrayList<PoiRecord> withinSphereChunkSectionSorted(Predicate<Holder<Poi
}

private Stream<PoiRecord> streamOutwards(BlockPos origin, int radius,
PoiManager.Occupancy status,
@SuppressWarnings("SameParameterValue") boolean useSquareDistanceLimit,
boolean preferNegativeY,
Predicate<Holder<PoiType>> typePredicate,
@Nullable Predicate<PoiRecord> afterSortingPredicate) {
PoiManager.Occupancy status,
@SuppressWarnings("SameParameterValue") boolean useSquareDistanceLimit,
boolean preferNegativeY,
Predicate<Holder<PoiType>> typePredicate,
@Nullable Predicate<PoiRecord> afterSortingPredicate) {
// noinspection unchecked
RegionBasedStorageSectionExtended<PoiSection> storage = (RegionBasedStorageSectionExtended<PoiSection>) this;

Expand Down
Loading

0 comments on commit 833a83a

Please sign in to comment.