Skip to content

Commit e2f275e

Browse files
committed
1.7.0
1 parent 4920246 commit e2f275e

35 files changed

+310
-277
lines changed

README.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
- Async particle ticking/rendering(buffer filling).
99
- Async client block entity ticking.
1010
- Valkyrien Skies + Pretty Rain/Particle Rain
11-
- Weather particles no longer pass through ships.
12-
- Pretty Rain/Particle Rain
13-
- Async particle gen.
14-
- Effectual
15-
- Async particle gen.
16-
- Particular
11+
- Weather particles now collide with ships.
12+
- Create + Pretty Rain/Particle Rain
13+
- Weather particles now collide with contraptions.
14+
- Pretty Rain/Particle Rain/Effectual/Particular
1715
- Async particle gen.
1816

1917
## Mods Recommended
@@ -41,12 +39,12 @@
4139
✅ Brute force Rendering Culling (Fabric/Forge)
4240
✅ Iris/Oculus (Fabric/Forge)
4341
✅ Startlight (Fabric/Forge)
44-
Create (Fabric/Forge)
42+
⚠️ Create (Fabric/Forge)
4543
✅ Valkyrien Skies (Fabric/Forge)
4644
✅ Particle Rain/Pretty Rain (Fabric/Forge)
47-
Effectual (Fabric)
48-
Effective/Effecticularity (Fabric/Forge)
49-
Particular (Fabric/Forge)
45+
Effectual (Fabric)
46+
Effective/Effecticularity (Fabric/Forge)
47+
Particular (Fabric/Forge)
5048
✅ MmmMmmMmmMmm (Target Dummy) (Fabric/Forge)
5149
✅ Hex Casting (Fabric/Forge)
5250
❌ MadParticle (Forge)

common/src/main/java/fun/qu_an/minecraft/asyncparticles/client/APMixinPlugin.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
4343
}
4444
return switch (split[0]) {
4545
case "fabric" -> {
46-
if (split.length <= 2) {
46+
if (split.length == 2) {
4747
yield !ModListHelper.IS_FORGE;
4848
}
4949
yield switch (split[1]) {
5050
case "particlerain_vs" -> ModListHelper.FABRIC_PARTICLERAIN_LOADED && ModListHelper.FABRIC_VS_LOADED;
51-
case "particlerain_create" -> ModListHelper.FABRIC_PARTICLERAIN_LOADED && ModListHelper.FABRIC_CREATE_LOADED;
5251
case "particlerain" -> ModListHelper.FABRIC_PARTICLERAIN_LOADED;
5352
case "create_5" -> ModListHelper.FABRIC_CREATE_LOADED && ModListHelper.CREATE_MAJOR_VERSION < 6;
5453
case "create_6" -> ModListHelper.FABRIC_CREATE_LOADED && ModListHelper.CREATE_MAJOR_VERSION == 6;
@@ -58,14 +57,23 @@ yield switch (split[1]) {
5857
default -> throw new IllegalArgumentException("Unknown fabric mixin: " + mixinClassName);
5958
};
6059
}
60+
case "legacy" -> {
61+
if (split.length == 2) {
62+
yield true;
63+
}
64+
yield switch (split[1]) {
65+
case "flywheel" -> ModListHelper.FLYWHEEL_LOADED && ModListHelper.FLYWHEEL_MAJOR_VERSION < 1;
66+
default -> throw new IllegalArgumentException("Unknown legacy mod mixin: " + mixinClassName);
67+
};
68+
}
6169
case "fake_renders" -> true;
6270
case "vs2" -> ModListHelper.VS_LOADED;
6371
case "create" -> ModListHelper.CREATE_LOADED;
6472
case "iris" -> ModListHelper.IRIS_LOADED;
6573
case "sodium_like" -> ModListHelper.SODIUM_LIKE_LOADED;
6674
case "lodestone" -> ModListHelper.LODESTONE_LOADED;
6775
case "hexcasting" -> ModListHelper.HEXCASTING_LOADED;
68-
case "flywheel" -> ModListHelper.FLYWHEEL_LOADED;
76+
case "flywheel" -> ModListHelper.FLYWHEEL_LOADED && ModListHelper.FLYWHEEL_MAJOR_VERSION == 1;
6977
case "particle_core" -> ModListHelper.PARTICLE_CORE_LOADED;
7078
case "physicsmod" -> ModListHelper.PHYSICSMOD_LOADED;
7179
// case "enhancedblockentities" -> ModListHelper.ENHANCEDBLOCKENTITIES_LOADED;

common/src/main/java/fun/qu_an/minecraft/asyncparticles/client/AsyncparticlesClient.java

+39
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package fun.qu_an.minecraft.asyncparticles.client;
22

3+
import fun.qu_an.minecraft.asyncparticles.client.compat.create.CreateUtils;
4+
import fun.qu_an.minecraft.asyncparticles.client.compat.particlerain.ParticleRainUtils;
5+
import fun.qu_an.minecraft.asyncparticles.client.compat.particlerain.WeatherParticleAddon;
6+
import fun.qu_an.minecraft.asyncparticles.client.compat.vs2.VSClientUtils;
37
import fun.qu_an.minecraft.asyncparticles.client.config.SimplePropertiesConfig;
8+
import net.minecraft.world.phys.Vec3;
49

510
import java.io.IOException;
611

@@ -13,5 +18,39 @@ public static void init() {
1318
} catch (IOException e) {
1419
throw new RuntimeException(e);
1520
}
21+
if (ModListHelper.PARTICLERAIN_LOADED) {
22+
if (ModListHelper.VS_LOADED) {
23+
WeatherParticleAddon.Type.RAIN.register((level, location, v, aabb) -> {
24+
Vec3 shipMovement = VSClientUtils.entityMovColShipOnly(null, v, aabb, level);
25+
if (shipMovement == null) {
26+
return v;
27+
}
28+
ParticleRainUtils.onShipCollision(level, location, shipMovement, aabb);
29+
return shipMovement;
30+
});
31+
WeatherParticleAddon.CollisionFunction function = (level, location, v, aabb) -> {
32+
Vec3 shipMovement = VSClientUtils.entityMovColShipOnly(null, v, aabb, level);
33+
return shipMovement == null ? v : shipMovement;
34+
};
35+
WeatherParticleAddon.Type.SNOW.register(function);
36+
WeatherParticleAddon.Type.OTHER.register(function);
37+
}
38+
if (ModListHelper.CREATE_LOADED) {
39+
WeatherParticleAddon.Type.RAIN.register((level, position, motion, aabb) -> {
40+
Vec3 collide = CreateUtils.collideMotionWithContraptions(level, position, motion, aabb);
41+
if (collide == null) {
42+
return motion;
43+
}
44+
ParticleRainUtils.onCreateCollision(level, motion, collide, aabb);
45+
return collide;
46+
});
47+
WeatherParticleAddon.CollisionFunction function = (level, position, motion, aabb) -> {
48+
Vec3 collide = CreateUtils.collideMotionWithContraptions(level, position, motion, aabb);
49+
return collide == null ? motion : collide;
50+
};
51+
WeatherParticleAddon.Type.SNOW.register(function);
52+
WeatherParticleAddon.Type.OTHER.register(function);
53+
}
54+
}
1655
}
1756
}

common/src/main/java/fun/qu_an/minecraft/asyncparticles/client/ModListHelper.java

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class ModListHelper {
3333
public static final boolean FORGE_PARTICLERAIN_LOADED = isForgeModLoaded("particlerain");
3434
/* Flywheel */
3535
public static final boolean FLYWHEEL_LOADED = isModLoaded("flywheel");
36+
public static final int FLYWHEEL_MAJOR_VERSION = versionMajor("flywheel");
3637
/* Create */
3738
public static final boolean CREATE_LOADED = isModLoaded("create");
3839
public static final int CREATE_MAJOR_VERSION = versionMajor("create");
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
package fun.qu_an.minecraft.asyncparticles.client.compat.create;
22

3+
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
4+
import com.simibubi.create.content.contraptions.ContraptionHandler;
35
import com.simibubi.create.foundation.utility.VecHelper;
6+
import net.minecraft.client.multiplayer.ClientLevel;
47
import net.minecraft.core.BlockPos;
58
import net.minecraft.core.Direction;
69
import net.minecraft.core.Vec3i;
710
import net.minecraft.world.phys.Vec3;
811

12+
import java.lang.ref.WeakReference;
13+
import java.util.Map;
14+
915
public class Create5Utils {
1016
static Vec3 rotate(Vec3 collisionLocation, float yawOffset, Direction.Axis axis) {
1117
return VecHelper.rotate(collisionLocation, yawOffset, axis);
1218
}
1319

14-
static Vec3 getCenterOf(BlockPos blockPos) {
15-
if (blockPos.equals(Vec3i.ZERO))
16-
return VecHelper.CENTER_OF_ORIGIN;
17-
return Vec3.atLowerCornerWithOffset(blockPos, 0.5, 0.5, 0.5);
20+
static Vec3 getCenterOf(BlockPos blockPos) {
21+
if (blockPos.equals(Vec3i.ZERO))
22+
return VecHelper.CENTER_OF_ORIGIN;
23+
return Vec3.atLowerCornerWithOffset(blockPos, 0.5, 0.5, 0.5);
24+
}
25+
26+
static Map<Integer, WeakReference<AbstractContraptionEntity>> loadedContraptions(ClientLevel level) {
27+
return ContraptionHandler.loadedContraptions.get(level);
1828
}
1929
}

common/src/main/java/fun/qu_an/minecraft/asyncparticles/client/compat/create/Create6Utils.java

+11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package fun.qu_an.minecraft.asyncparticles.client.compat.create;
22

3+
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
4+
import dev.architectury.injectables.annotations.ExpectPlatform;
35
import net.createmod.catnip.math.VecHelper;
6+
import net.minecraft.client.multiplayer.ClientLevel;
47
import net.minecraft.core.BlockPos;
58
import net.minecraft.core.Direction;
69
import net.minecraft.core.Vec3i;
710
import net.minecraft.world.phys.Vec3;
811

12+
import java.lang.ref.WeakReference;
13+
import java.util.Map;
14+
915
public class Create6Utils {
1016
static Vec3 rotate(Vec3 collisionLocation, float yawOffset, Direction.Axis axis) {
1117
return VecHelper.rotate(collisionLocation, yawOffset, axis);
@@ -16,4 +22,9 @@ static Vec3 getCenterOf(BlockPos blockPos) {
1622
return VecHelper.CENTER_OF_ORIGIN;
1723
return Vec3.atLowerCornerWithOffset(blockPos, 0.5, 0.5, 0.5);
1824
}
25+
26+
@ExpectPlatform
27+
public static Map<Integer, WeakReference<AbstractContraptionEntity>> loadedContraptions(ClientLevel level) {
28+
throw new AssertionError();
29+
}
1930
}

common/src/main/java/fun/qu_an/minecraft/asyncparticles/client/compat/create/CreateUtils.java

+25-19
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,17 @@
2020
import org.jetbrains.annotations.Nullable;
2121
import org.joml.Vector3d;
2222

23-
import java.lang.ref.Reference;
24-
import java.util.ArrayList;
25-
import java.util.List;
26-
import java.util.stream.Stream;
23+
import java.lang.ref.WeakReference;
24+
import java.util.*;
2725

2826
/**
2927
* See {@link ContraptionCollider}
3028
*/
3129
public class CreateUtils {
3230
public static final boolean[] trueAndFalse = {true, false};
3331

34-
public static Stream<AbstractContraptionEntity> contraptions(ClientLevel level) {
35-
return ContraptionHandler.loadedContraptions.get(level)
36-
.values()
37-
.stream()
38-
.map(Reference::get);
32+
public static Collection<WeakReference<AbstractContraptionEntity>> contraptions(ClientLevel level) {
33+
return loadedContraptions(level).values();
3934
}
4035

4136
/**
@@ -114,18 +109,23 @@ public static boolean collideWithContraption(ClientLevel level, Vec3 originalPos
114109
@Nullable
115110
public static Vec3 collideMotionWithContraptions(ClientLevel level, Vec3 position, Vec3 motion, AABB bounds) {
116111
AABB bounds1 = bounds.inflate(0.1).move(motion);
117-
Vector3d collect = contraptions(level)
118-
.filter(c -> c.getBoundingBox().intersects(bounds1))
119-
.map(c -> {
120-
Vec3 vec3 = collideMotionWithContraption(level, position, motion, bounds1, c);
121-
return new Vector3d(vec3.x, vec3.y, vec3.z);
122-
})
123-
.reduce(new Vector3d(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE), Vector3d::min);
124-
if (collect.x == Double.MAX_VALUE
125-
|| (motion.x == collect.x && motion.y == collect.y && motion.z == collect.z)) {
112+
Vector3d result = new Vector3d(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
113+
for (WeakReference<AbstractContraptionEntity> r : contraptions(level)) {
114+
AbstractContraptionEntity contraptionEntity = r.get();
115+
if (contraptionEntity == null || !contraptionEntity.isAliveOrStale()) {
116+
continue;
117+
}
118+
if (!contraptionEntity.getBoundingBox().intersects(bounds1)) {
119+
continue;
120+
}
121+
Vec3 vec3 = collideMotionWithContraption(level, position, motion, bounds1, contraptionEntity);
122+
result.set(Math.min(result.x, vec3.x), Math.min(result.y, vec3.y), Math.min(result.z, vec3.z));
123+
}
124+
if (result.x == Double.MAX_VALUE
125+
|| (motion.x == result.x && motion.y == result.y && motion.z == result.z)) {
126126
return null;
127127
}
128-
return new Vec3(collect.x, collect.y, collect.z);
128+
return new Vec3(result.x, result.y, result.z);
129129
}
130130

131131
private static Vec3 getWorldToLocalTranslation(Vec3 entityPosition,
@@ -358,4 +358,10 @@ public static Vec3 getCenterOf(BlockPos blockPos) {
358358
? Create5Utils.getCenterOf(blockPos)
359359
: Create6Utils.getCenterOf(blockPos);
360360
}
361+
362+
public static Map<Integer, WeakReference<AbstractContraptionEntity>> loadedContraptions(ClientLevel level) {
363+
return ModListHelper.CREATE_MAJOR_VERSION < 6
364+
? Create5Utils.loadedContraptions(level)
365+
: Create6Utils.loadedContraptions(level);
366+
}
361367
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package fun.qu_an.minecraft.asyncparticles.client.compat.create.fabric;
2+
3+
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
4+
import net.minecraft.client.multiplayer.ClientLevel;
5+
6+
import java.lang.ref.WeakReference;
7+
import java.util.Map;
8+
9+
@SuppressWarnings("unused")
10+
public class Create6UtilsImpl {
11+
public static Map<Integer, WeakReference<AbstractContraptionEntity>> loadedContraptions(ClientLevel level) {
12+
throw new UnsupportedOperationException("Create 6 is not supported");
13+
}
14+
}

common/src/main/java/fun/qu_an/minecraft/asyncparticles/client/compat/particlerain/WeatherParticleAddon.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ interface CollisionFunction {
3737
/**
3838
* @return null if the particle should be removed, otherwise the motion vector
3939
*/
40-
@Nullable Vec3 apply(@NotNull ClientLevel level, @NotNull Vec3 location, @NotNull Vec3 v, @NotNull AABB aabb);
40+
@Nullable Vec3 apply(@NotNull ClientLevel level, @NotNull Vec3 location, @NotNull Vec3 motion, @NotNull AABB aabb);
4141

4242
default CollisionFunction andThen(CollisionFunction function) {
4343
return (level, location, v, aabb) -> {
@@ -59,7 +59,7 @@ enum Type {
5959
/**
6060
* @return null if the particle should be removed, otherwise the motion vector
6161
*/
62-
public @Nullable Vec3 apply(@NotNull ClientLevel level, @NotNull Vec3 position, @NotNull Vec3 motion, @NotNull AABB aabb) {
62+
public @Nullable Vec3 collide(@NotNull ClientLevel level, @NotNull Vec3 position, @NotNull Vec3 motion, @NotNull AABB aabb) {
6363
return function == null ? motion : function.apply(level, position, motion, aabb);
6464
}
6565

common/src/main/java/fun/qu_an/minecraft/asyncparticles/client/compat/particlerain/fabric/ParticleRainUtilsImpl.java

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fun.qu_an.minecraft.asyncparticles.client.compat.particlerain.fabric;
22

3+
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
34
import fun.qu_an.minecraft.asyncparticles.client.compat.create.CreateUtils;
45
import fun.qu_an.minecraft.asyncparticles.client.compat.particlerain.RippleParticleAddon;
56
import fun.qu_an.minecraft.asyncparticles.client.compat.vs2.ShipHitResult;
@@ -20,13 +21,15 @@
2021
import org.spongepowered.asm.mixin.Unique;
2122
import pigcart.particlerain.ParticleRainClient;
2223

24+
import java.lang.ref.WeakReference;
25+
2326
import static pigcart.particlerain.ParticleRainClient.config;
2427

2528
@SuppressWarnings("unused")
2629
public class ParticleRainUtilsImpl {
2730
@Unique
2831
public static void onShipCollision(ClientLevel level, Vec3 location, Vec3 movement, AABB aabb) {
29-
if (!config.doRippleParticles) {
32+
if (!config.doRippleParticles && !config.doSplashParticles) {
3033
return;
3134
}
3235
Minecraft mc = Minecraft.getInstance();
@@ -64,19 +67,26 @@ public static void onShipCollision(ClientLevel level, Vec3 location, Vec3 moveme
6467
}
6568

6669
public static void onCreateCollision(@NotNull ClientLevel level, Vec3 originalMotion, @NotNull Vec3 clipMotion, @NotNull AABB aabb) {
67-
if (!config.doRippleParticles || Math.abs(clipMotion.y) > 0.001) {
70+
if (!config.doSplashParticles || Math.abs(clipMotion.y) > 0.001) {
6871
return;
6972
}
7073
Vec3 center = aabb.getCenter();
7174
AABB aabb1 = new AABB(center.x, aabb.minY - 1, center.z, center.x, aabb.minY, center.z);
7275
Vec3 spawnPos = new Vec3(center.x, aabb.minY, center.z);
7376
Vec3 motion1 = originalMotion.scale(2);
74-
boolean b = CreateUtils.contraptions(level).filter(contraption -> contraption.getBoundingBox().intersects(aabb1))
75-
.anyMatch(contraptionEntity ->
76-
CreateUtils.collideWithContraption(level, spawnPos, motion1, aabb1, contraptionEntity));
77-
if (b) {
78-
Minecraft.getInstance().particleEngine
79-
.createParticle(ParticleTypes.RAIN, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0);
77+
for (WeakReference<AbstractContraptionEntity> r : CreateUtils.contraptions(level)) {
78+
AbstractContraptionEntity contraptionEntity = r.get();
79+
if (contraptionEntity == null || !contraptionEntity.isAliveOrStale()) {
80+
continue;
81+
}
82+
if (!contraptionEntity.getBoundingBox().intersects(aabb1)) {
83+
continue;
84+
}
85+
if (CreateUtils.collideWithContraption(level, spawnPos, motion1, aabb1, contraptionEntity)) {
86+
Minecraft.getInstance().particleEngine
87+
.createParticle(ParticleTypes.RAIN, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0);
88+
return;
89+
}
8090
}
8191
}
8292
}

common/src/main/java/fun/qu_an/minecraft/asyncparticles/client/compat/vs2/VSClientUtils.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ public static Vec3 entityMovColShipOnly(
143143
@Nullable Entity entity,
144144
Vec3 movement,
145145
AABB entityBoundingBox,
146-
ClientLevel world) {
146+
ClientLevel world,
147+
double inflation) {
147148
// Inflate the bounding box more for players than other entities, to give players a better collision result.
148149
// Note that this increases the cost of doing collision, so we only do it for the players
149-
double inflation = (entity instanceof Player) ? 0.5 : 0.1;
150150
double stepHeight = (entity != null) ? entity.maxUpStep() : 0.0;
151151
// Add [max(stepHeight - inflation, 0.0)] to search for polygons we might collide with while stepping
152152
double yMovement = movement.y() + Math.max(stepHeight - inflation, 0.0);
@@ -173,6 +173,19 @@ entity, new Vec3(movement.x(), yMovement, movement.z()),
173173
return null;
174174
}
175175

176+
/**
177+
* No vanilla collision check.
178+
*/
179+
@Nullable
180+
public static Vec3 entityMovColShipOnly(
181+
@Nullable Entity entity,
182+
Vec3 movement,
183+
AABB entityBoundingBox,
184+
ClientLevel world) {
185+
double inflation = (entity instanceof Player) ? 0.5 : 0.1;
186+
return entityMovColShipOnly(entity, movement, entityBoundingBox, world, inflation);
187+
}
188+
176189
/**
177190
* include matrices in hit result.
178191
* No vanilla hit result.

0 commit comments

Comments
 (0)