Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.ryanhcode.sable.neoforge.mixin.entity.entity_collisions;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.ryanhcode.sable.Sable;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(Entity.class)
public class EntityMixin {

// Projects the target delta out of a sublevel when looking up solid entity collisions. This fixes teleporting to sublevels causing insane amounts of lag.
@WrapOperation(method = "collide", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;expandTowards(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/AABB;"))
public AABB sublevelEntityCollisionFix(final AABB instance, final Vec3 vector, final Operation<AABB> original) {
final var entity = (Entity)(Object) this;
return original.call(instance, Sable.HELPER.projectOutOfSubLevel(entity.level(), entity.position().add(vector)));
}
}
1 change: 1 addition & 0 deletions neoforge/src/main/resources/sable-neoforge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"compatibility.pmweather.AnemometerBlockMixin",
"compatibility.pmweather.PMWeatherMixin",
"entities_stick_sublevels.effects.LivingEntityMixin",
"entity.entity_collisions.EntityMixin",
"entity.entity_swimming.EntityMixin"
],
"injectors": {
Expand Down