Skip to content

Commit

Permalink
Close #280
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Feb 1, 2025
1 parent 77364db commit ffdd28d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mods.railcraft.util.EntitySearcher;
import mods.railcraft.util.ModEntitySelector;
import mods.railcraft.world.level.block.RailcraftBlocks;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySelector;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -16,6 +17,7 @@
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.IMinecartCollisionHandler;
Expand All @@ -41,6 +43,7 @@ public void onEntityCollision(AbstractMinecart cart, Entity other) {
|| !other.isAlive() || !cart.isAlive()) {
return;
}
var serverLevel = (ServerLevel) level;

var rollingStock = RollingStock.getOrThrow(cart);

Expand Down Expand Up @@ -84,7 +87,8 @@ public void onEntityCollision(AbstractMinecart cart, Entity other) {
.around(cart)
.and(EntitySelector.ENTITY_STILL_ALIVE, ModEntitySelector.NON_MECHANICAL)
.list(level);
if (carts.size() >= 12) {
var maxEntityCramming = serverLevel.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
if (carts.size() >= maxEntityCramming) {
rollingStock.primeExplosion();
}
}
Expand Down

0 comments on commit ffdd28d

Please sign in to comment.