Skip to content

Commit

Permalink
feat: Овверайды для отмены попадания проджектайла
Browse files Browse the repository at this point in the history
- Используется новая реализация Nukkit-MOT вместо овверайдов, по умолчанию сервер не перезапускается при ошибках тика.
  • Loading branch information
MaXFeeD committed Feb 24, 2024
1 parent 44a416e commit ae13a7f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ display-ticking-errors-to-players: true

# Если серверный тик прерывается слишком часто, сервер будет остановлен;
# в противном случае тик будет пытаться продолжать перезапуски.
stop-on-critical-ticking-error: true
stop-on-critical-ticking-error: false
```
## Консольные команды
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/com/reider745/event/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
public class EventListener implements Listener {
public static final Object DEALING_LOCK = new Object();
public static Object dealingEvent = null;
private static long projectileHitEntity = -1;

public static final int FORM_REJOIN_EXCEPTION = 2560;

Expand Down Expand Up @@ -140,15 +139,6 @@ public void onProjectileHit(ProjectileHitEvent event) {
mop != null && mop.entityHit != null ? mop.entityHit.getId() : 0, mop != null ? mop.blockX : 0,
mop != null ? mop.blockY : 0, mop != null ? mop.blockZ : 0, mop != null ? mop.sideHit : -1,
item.getId(), item.count, item.getDamage(), extra));

if (event.isCancelled()) {
// It actually cannot prevent projectile remove, but cancelling
// damage is most common requirement
if (mop != null && mop.entityHit != null) {
projectileHitEntity = mop.entityHit.getId();
}
entity.isCollided = entity.isCollidedHorizontally = entity.isCollidedVertically = entity.hadCollision = false;
}
}

@EventHandler(priority = EventPriority.HIGHEST)
Expand Down Expand Up @@ -259,10 +249,6 @@ public static DamageCause convertEnumToDamageCause(int cause) {

@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageEvent event) {
if (event.getEntity().getId() == projectileHitEntity && event.getCause() == DamageCause.PROJECTILE) {
projectileHitEntity = -1;
return;
}
if (event.equals(dealingEvent) || Boolean.TRUE.equals(dealingEvent)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/zotecore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ pack-version-code: 152

# If ticking callback interrupts too often, server will be stopped;
# otherwise it will continue trying restart itself continiously.
# stop-on-critical-ticking-error: false
# stop-on-critical-ticking-error: true

0 comments on commit ae13a7f

Please sign in to comment.