Skip to content

Commit

Permalink
Avoid Shapes.or in calculateCrossPortalCollisionShape
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jul 21, 2023
1 parent 7091eb8 commit 0446159
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/fusionflux/portalcubed/entity/Portal.java
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ private VoxelShape calculateCrossPortalCollisionShape(Vec3 normal, Vec3 origin,
result.forAllBoxes((x1, y1, z1, x2, y2, z2) -> {
final Vec3 minT = transform.rotate(new Vec3(x1, y1, z1), false);
final Vec3 maxT = transform.rotate(new Vec3(x2, y2, z2), false);
rotatedShape.setValue(Shapes.or(
rotatedShape.setValue(Shapes.joinUnoptimized(
rotatedShape.getValue(),
Shapes.box(
Math.min(minT.x, maxT.x),
Expand All @@ -616,7 +616,8 @@ private VoxelShape calculateCrossPortalCollisionShape(Vec3 normal, Vec3 origin,
Math.max(minT.x, maxT.x),
Math.max(minT.y, maxT.y),
Math.max(minT.z, maxT.z)
)
),
BooleanOp.OR
));
});
result = rotatedShape.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
Expand Down Expand Up @@ -161,6 +162,7 @@ public void setMaxFallSpeed(double maxFallSpeed) {

@Shadow public abstract Level level();

@Shadow private Level level;
@Unique
private final Map<BlockState, BlockPos> collidingBlocks = new HashMap<>();
@Unique
Expand All @@ -184,6 +186,8 @@ public void setMaxFallSpeed(double maxFallSpeed) {

@Inject(method = "tick", at = @At("HEAD"))
public void tick(CallbackInfo ci) {
final ProfilerFiller profiler = level.getProfiler();
profiler.push("portalcubed_entity");

Entity thiz = (Entity) (Object) this;

Expand Down Expand Up @@ -237,6 +241,8 @@ public void tick(CallbackInfo ci) {
}

prevGravDirec = GravityChangerAPI.getGravityDirection(((Entity) (Object) this));

profiler.pop();
}

@Inject(method = "tick", at = @At("TAIL"))
Expand Down

0 comments on commit 0446159

Please sign in to comment.