Skip to content

Commit

Permalink
move some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
notTamion committed Jan 13, 2025
1 parent 68581da commit c4b3d2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

public class PositionedRayTraceConfigurationBuilderImpl implements PositionedRayTraceConfigurationBuilder {

private World world;
private Location start;
private Vector direction;
private double maxDistance;
Expand All @@ -24,18 +23,13 @@ public class PositionedRayTraceConfigurationBuilderImpl implements PositionedRay
private java.util.function.Predicate<? super org.bukkit.block.Block> blockFilter;
private List<RayTraceTarget> targets;

public PositionedRayTraceConfigurationBuilderImpl(World world) {
this.world = world;
}


@Override
public @NotNull Location start() {
return this.start;
}

@Override
public PositionedRayTraceConfigurationBuilder start(final @NotNull Location start) {
public @NotNull PositionedRayTraceConfigurationBuilder start(final @NotNull Location start) {
this.start = start;
return this;
}
Expand Down Expand Up @@ -123,19 +117,10 @@ public double raySize() {
}

@Override
public @NotNull PositionedRayTraceConfigurationBuilder targets(final @NotNull RayTraceTarget first, final @NotNull RayTraceTarget... others) {
public @NotNull PositionedRayTraceConfigurationBuilder targets(final @NotNull RayTraceTarget first, final RayTraceTarget @NotNull ... others) {
List<RayTraceTarget> targets = new ArrayList<>(List.of(others));
targets.add(first);
this.targets = targets;
return this;
}

public RayTraceResult cast() {
if (targets.contains(RayTraceTarget.ENTITIES)) {
if(targets.contains(RayTraceTarget.BLOCKS))
return world.rayTrace(this.start(), this.direction(), this.maxDistance(), this.fluidCollisionMode(), this.ignorePassableBlocks(), this.raySize(), this.entityFilter(), this.blockFilter());
return world.rayTraceEntities(this.start(), this.direction(), this.maxDistance(), this.raySize(), this.entityFilter());
}
return world.rayTraceBlocks(this.start(), this.direction(), this.maxDistance(), this.fluidCollisionMode(), this.ignorePassableBlocks(), this.blockFilter());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.util.Pair;
import io.papermc.paper.FeatureHooks;
import io.papermc.paper.raytracing.RayTraceTarget;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.raytracing.RayTraceConfiguration;
import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilder;
import io.papermc.paper.raytracing.PositionedRayTraceConfigurationBuilderImpl;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
Expand Down Expand Up @@ -1253,11 +1253,16 @@ public RayTraceResult rayTrace(io.papermc.paper.math.Position start, Vector dire

@Override
public @org.jetbrains.annotations.Nullable RayTraceResult rayTrace(Consumer<PositionedRayTraceConfigurationBuilder> builderConsumer) {
PositionedRayTraceConfigurationBuilderImpl builder = new PositionedRayTraceConfigurationBuilderImpl(this);
PositionedRayTraceConfigurationBuilderImpl builder = new PositionedRayTraceConfigurationBuilderImpl();

builderConsumer.accept(builder);

return builder.cast();
if (builder.targets().contains(RayTraceTarget.ENTITIES)) {
if(builder.targets().contains(RayTraceTarget.BLOCKS))
return this.rayTrace(builder.start(), builder.direction(), builder.maxDistance(), builder.fluidCollisionMode(), builder.ignorePassableBlocks(), builder.raySize(), builder.entityFilter(), builder.blockFilter());
return this.rayTraceEntities(builder.start(), builder.direction(), builder.maxDistance(), builder.raySize(), builder.entityFilter());
}
return this.rayTraceBlocks(builder.start(), builder.direction(), builder.maxDistance(), builder.fluidCollisionMode(), builder.ignorePassableBlocks(), builder.blockFilter());
}

@Override
Expand Down

0 comments on commit c4b3d2e

Please sign in to comment.