Merge branch 'master' into 1.17
# Conflicts: # src/main/java/carpet/mixins/ServerWorld_scarpetMixin.java # src/main/java/carpet/script/api/WorldAccess.java
This commit is contained in:
commit
388a3de577
15 files changed
+326
-19
No files matched your search
@@ -10,13 +10,10 @@ import java.util.List;
|
||||
import carpet.logging.logHelpers.ExplosionLogHelper;
|
||||
import carpet.mixins.ExplosionAccessor;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.mixins.ExplosionMixin;
|
||||
import carpet.utils.Messenger;
|
||||
import com.google.common.collect.Lists;
|
||||
import it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -48,6 +45,8 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.EXPLOSION_OUTCOME;
|
||||
|
||||
public class OptimizedExplosion
|
||||
{
|
||||
private static List<Entity> entitylist;
|
||||
@@ -68,9 +67,14 @@ public class OptimizedExplosion
|
||||
private static ArrayList<Float> chances = new ArrayList<>();
|
||||
private static BlockPos blastChanceLocation;
|
||||
|
||||
// Creating entity list for scarpet event
|
||||
private static List<Entity> entityList = new ArrayList<>();
|
||||
|
||||
public static void doExplosionA(Explosion e, ExplosionLogHelper eLogger) {
|
||||
ExplosionAccessor eAccess = (ExplosionAccessor) e;
|
||||
|
||||
entityList.clear();
|
||||
boolean eventNeeded = EXPLOSION_OUTCOME.isNeeded() && !eAccess.getWorld().isClient();
|
||||
blastCalc(e);
|
||||
|
||||
if (!CarpetSettings.explosionNoBlockDamage) {
|
||||
@@ -156,6 +160,11 @@ public class OptimizedExplosion
|
||||
densityCache.put(pair, density);
|
||||
}
|
||||
|
||||
// If it is needed, it saves the entity
|
||||
if (eventNeeded) {
|
||||
entityList.add(entity);
|
||||
}
|
||||
|
||||
double d10 = (1.0D - d12) * density;
|
||||
entity.damage(e.getDamageSource(),
|
||||
(float) ((int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f3 + 1.0D)));
|
||||
@@ -195,6 +204,11 @@ public class OptimizedExplosion
|
||||
double posY = eAccess.getY();
|
||||
double posZ = eAccess.getZ();
|
||||
|
||||
// If it is needed, calls scarpet event
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClient()) {
|
||||
EXPLOSION_OUTCOME.onExplosion((ServerWorld) world, eAccess.getEntity(), e::getCausingEntity, eAccess.getX(), eAccess.getY(), eAccess.getZ(), eAccess.getPower(), eAccess.isCreateFire(), e.getAffectedBlocks(), entityList, eAccess.getDestructionType());
|
||||
}
|
||||
|
||||
boolean damagesTerrain = eAccess.getDestructionType() != Explosion.DestructionType.NONE;
|
||||
|
||||
// explosionSound incremented till disabling the explosion particles and sound
|
||||
@@ -598,4 +612,4 @@ public class OptimizedExplosion
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user