You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Class for grouping Entity classes by some property for use in TypeFilterableList
22
+
* Class for grouping Entity classes and Entity types by some property for use in TypeFilterableList
19
23
* It is intended that an EntityClassGroup acts as if it was immutable, however we cannot predict which subclasses of
20
-
* Entity might appear. Therefore we evaluate whether a class belongs to the class group when it is first seen.
24
+
* Entity might appear. Therefore, we evaluate whether a class belongs to the class group when it is first seen.
21
25
* Once a class was evaluated the result of it is cached and cannot be changed.
22
26
*
23
27
* @author 2No2Name
24
28
*/
25
29
publicclassEntityClassGroup {
30
+
31
+
privatestaticfinalbyteABSENT_VALUE = (byte) 3;
32
+
26
33
publicstaticfinalEntityClassGroupCUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE; //aka entities that will attempt to collide with all other entities when moving
//sanity check: in case intermediary mappings changed, we fail
34
-
if ((!CUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE.contains(Minecart.class))) {
41
+
if ((!CUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE.contains(Minecart.class, EntityType.MINECART))) {
35
42
thrownewAssertionError();
36
43
}
37
-
if ((!CUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE.contains(WindCharge.class)) || (!CUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE.contains(BreezeWindCharge.class))) {
44
+
if ((!CUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE.contains(WindCharge.class, EntityType.WIND_CHARGE)) || (!CUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE.contains(BreezeWindCharge.class, EntityType.BREEZE_WIND_CHARGE))) {
38
45
thrownewAssertionError();
39
46
}
40
-
if ((CUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE.contains(Shulker.class))) {
41
-
//should not throw an Error here, because another mod *could* add the method to ShulkerEntity. Wwarning when this sanity check fails.
47
+
if ((CUSTOM_COLLIDE_LIKE_MINECART_BOAT_WINDCHARGE.contains(Shulker.class, EntityType.SHULKER))) {
48
+
//should not throw an Error here, because another mod *could* add the method to ShulkerEntity. Warning when this sanity check fails.
42
49
Logger.getLogger("Lithium EntityClassGroup").warning("Either Lithium EntityClassGroup is broken or something else gave Shulkers the minecart-like collision behavior.");
privatevolatileReference2ByteOpenHashMap<Class<?>> class2GroupContains; // 0: Not contained (decision based on class only), 1: Contained (decision based on class only), 2: Check containedClassAndTypePairs (decision based on entity type)
56
+
privatevolatile@NullableObjectOpenHashSet<ReferenceReferenceImmutablePair<Class<?>, EntityType<?>>> containedClassAndTypePairs; //only used if decision is based on entity type
if (previousContainsInfo != ABSENT_VALUE && previousContainsInfo != containsInfo) {
125
+
thrownewIllegalStateException("Entity class group class fit evaluator must be a pure function! Class fit for " + entityClass + " changed from " + previousContainsInfo + " to " + containsInfo + " when evaluating for " + entityType + "!");
126
+
}
127
+
128
+
//publish the new map in a volatile field, so that all threads reading after this write can also see all changes to the map done beforehand
if (classAndTypeFitEvaluator.test(EnderDragon.class, () -> {
151
+
thrownewIllegalArgumentException("EntityClassGroup.NoDragonClassGroup cannot be initialized: Must exclude EnderDragonEntity without checking entity type!");
152
+
})) {
107
153
thrownewIllegalArgumentException("EntityClassGroup.NoDragonClassGroup cannot be initialized: Must exclude EnderDragonEntity!");
* Projectiles that do not override {@link net.minecraft.world.entity.projectile.Projectile#canHitEntity(Entity)} or only do so to restrict the set of hittable entities
* Projectiles that override {@link Entity#canBeHitByProjectile()} or override {@link Entity#isPickable()} in a way that makes them hittable by projectiles.
0 commit comments