Skip to content

Commit

Permalink
Update to 24w18a
Browse files Browse the repository at this point in the history
  • Loading branch information
DrexHD committed May 16, 2024
1 parent 9a89b2a commit 48de79a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 40 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
org.gradle.jvmargs=-Xmx3G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10
minecraft_version=24w18a
yarn_mappings=24w18a+build.1
loader_version=0.15.11

#Fabric api
fabric_version=0.97.8+1.20.6
Expand Down
2 changes: 1 addition & 1 deletion lithium-mixin-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Requirements:

### `mixin.entity.collisions.movement`
(default: `true`)
Entity movement uses optimized block access and optimized and delayed entity access
Entity movement uses optimized block/entity access
Requirements:
- `mixin.util.chunk_access=true`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public RaiderEntityMixin(EntityType<?> type, World world) {
}

@Redirect(
method = "onDeath(Lnet/minecraft/entity/damage/DamageSource;)V",
method = "isCaptain",
at = @At(value = "INVOKE", target = "Lnet/minecraft/village/raid/Raid;getOminousBanner(Lnet/minecraft/registry/RegistryEntryLookup;)Lnet/minecraft/item/ItemStack;")
)
private ItemStack getOminousBanner(RegistryEntryLookup<BannerPattern> bannerPatternLookup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class EntityMixin {
target = "Lnet/minecraft/world/World;getEntityCollisions(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;)Ljava/util/List;"
)
)
private List<VoxelShape> getEntitiesLater(World world, Entity entity, Box box) {
return List.of();
private List<VoxelShape> getEntitiesOptimized(World world, Entity entity, Box movementSpace) {
return LithiumEntityCollisions.getEntityWorldBorderCollisions(world, entity, movementSpace, entity != null);
}


Expand All @@ -35,11 +35,10 @@ private List<VoxelShape> getEntitiesLater(World world, Entity entity, Box box) {
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/Entity;adjustMovementForCollisions(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Box;Lnet/minecraft/world/World;Ljava/util/List;)Lnet/minecraft/util/math/Vec3d;"
),
require = 5
)
)
private Vec3d adjustMovementForCollisionsGetEntitiesLater(@Nullable Entity entity, Vec3d movement, Box entityBoundingBox, World world, List<VoxelShape> collisions) {
return lithiumCollideMultiAxisMovement(entity, movement, entityBoundingBox, world, true, collisions);
private Vec3d adjustMovementForCollisionsOptimized(@Nullable Entity entity, Vec3d movement, Box entityBoundingBox, World world, List<VoxelShape> collisions) {
return lithiumCollideMultiAxisMovement(entity, movement, entityBoundingBox, world, collisions);
}

/**
Expand All @@ -48,10 +47,10 @@ private Vec3d adjustMovementForCollisionsGetEntitiesLater(@Nullable Entity entit
*/
@Overwrite
public static Vec3d adjustMovementForCollisions(@Nullable Entity entity, Vec3d movement, Box entityBoundingBox, World world, List<VoxelShape> collisions) {
return lithiumCollideMultiAxisMovement(entity, movement, entityBoundingBox, world, false, collisions);
return lithiumCollideMultiAxisMovement(entity, movement, entityBoundingBox, world, collisions);
}

private static Vec3d lithiumCollideMultiAxisMovement(@Nullable Entity entity, Vec3d movement, Box entityBoundingBox, World world, boolean getEntityCollisions, List<VoxelShape> otherCollisions) {
private static Vec3d lithiumCollideMultiAxisMovement(@Nullable Entity entity, Vec3d movement, Box entityBoundingBox, World world, List<VoxelShape> otherCollisions) {
//vanilla order: entities, worldborder, blocks. It is unknown whether changing this order changes the result regarding the confusing 1e-7 VoxelShape margin behavior. Not yet investigated
double velX = movement.x;
double velY = movement.y;
Expand All @@ -78,18 +77,13 @@ private static Vec3d lithiumCollideMultiAxisMovement(@Nullable Entity entity, Ve
}

List<VoxelShape> blockCollisions = LithiumEntityCollisions.getBlockCollisions(world, entity, movementSpace);
List<VoxelShape> entityWorldBorderCollisions = null;

if (velY != 0.0) {
velY = VoxelShapes.calculateMaxOffset(Direction.Axis.Y, entityBoundingBox, blockCollisions, velY);
if (velY != 0.0) {
if (!otherCollisions.isEmpty()) {
velY = VoxelShapes.calculateMaxOffset(Direction.Axis.Y, entityBoundingBox, otherCollisions, velY);
}
if (velY != 0.0 && getEntityCollisions) {
entityWorldBorderCollisions = LithiumEntityCollisions.getEntityWorldBorderCollisions(world, entity, movementSpace, entity != null);
velY = VoxelShapes.calculateMaxOffset(Direction.Axis.Y, entityBoundingBox, entityWorldBorderCollisions, velY);
}
if (velY != 0.0) {
entityBoundingBox = entityBoundingBox.offset(0.0, velY, 0.0);
}
Expand All @@ -102,13 +96,6 @@ private static Vec3d lithiumCollideMultiAxisMovement(@Nullable Entity entity, Ve
if (!otherCollisions.isEmpty()) {
velZ = VoxelShapes.calculateMaxOffset(Direction.Axis.Z, entityBoundingBox, otherCollisions, velZ);
}
if (velZ != 0.0 && getEntityCollisions) {
if (entityWorldBorderCollisions == null) {
entityWorldBorderCollisions = LithiumEntityCollisions.getEntityWorldBorderCollisions(world, entity, movementSpace, entity != null);
}

velZ = VoxelShapes.calculateMaxOffset(Direction.Axis.Z, entityBoundingBox, entityWorldBorderCollisions, velZ);
}
if (velZ != 0.0) {
entityBoundingBox = entityBoundingBox.offset(0.0, 0.0, velZ);
}
Expand All @@ -120,13 +107,6 @@ private static Vec3d lithiumCollideMultiAxisMovement(@Nullable Entity entity, Ve
if (!otherCollisions.isEmpty()) {
velX = VoxelShapes.calculateMaxOffset(Direction.Axis.X, entityBoundingBox, otherCollisions, velX);
}
if (velX != 0.0 && getEntityCollisions) {
if (entityWorldBorderCollisions == null) {
entityWorldBorderCollisions = LithiumEntityCollisions.getEntityWorldBorderCollisions(world, entity, movementSpace, entity != null);
}

velX = VoxelShapes.calculateMaxOffset(Direction.Axis.X, entityBoundingBox, entityWorldBorderCollisions, velX);
}
if (velX != 0.0) {
entityBoundingBox = entityBoundingBox.offset(velX, 0.0, 0.0);
}
Expand All @@ -138,13 +118,6 @@ private static Vec3d lithiumCollideMultiAxisMovement(@Nullable Entity entity, Ve
if (!otherCollisions.isEmpty()) {
velZ = VoxelShapes.calculateMaxOffset(Direction.Axis.Z, entityBoundingBox, otherCollisions, velZ);
}
if (velZ != 0.0 && getEntityCollisions) {
if (entityWorldBorderCollisions == null) {
entityWorldBorderCollisions = LithiumEntityCollisions.getEntityWorldBorderCollisions(world, entity, movementSpace, entity != null);
}

velZ = VoxelShapes.calculateMaxOffset(Direction.Axis.Z, entityBoundingBox, entityWorldBorderCollisions, velZ);
}
}
}
return new Vec3d(velX, velY, velZ);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@MixinConfigOption(
description = "Entity movement uses optimized block access and optimized and delayed entity access",
description = "Entity movement uses optimized block/entity access",
depends = @MixinConfigDependency(dependencyPath = "mixin.util.chunk_access")
)
package me.jellysquid.mods.lithium.mixin.entity.collisions.movement;
Expand Down

0 comments on commit 48de79a

Please sign in to comment.