mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-27 07:05:39 +00:00
add 2 more
This commit is contained in:
parent
32ba851514
commit
bf02d9cb8c
19
patches/server/0014-Fix-negative-death-times.patch
Normal file
19
patches/server/0014-Fix-negative-death-times.patch
Normal file
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Wed, 8 May 2024 12:48:19 -0500
|
||||
Subject: [PATCH] Fix negative death times
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 6e043457a29a890bcefd27fc5bb07c1a7e4e30f7..8ff815b1bb77eab735c65fa9c6bf469dca8562c4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -650,7 +650,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
- if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
|
||||
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level().isClientSide() && !this.isRemoved()) { // Scissors
|
||||
this.level().broadcastEntityEvent(this, (byte) 60);
|
||||
this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Wed, 8 May 2024 13:00:39 -0500
|
||||
Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
|
||||
vehicles if they collide with more than 15 other entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
index 4d7454e5a64fc18e63793a221daa94617f17c666..0ebc9b469d684251ba73989b3f7483522faf48d7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
@@ -8,6 +8,7 @@ import com.mojang.datafixers.util.Pair;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.Util;
|
||||
@@ -101,6 +102,7 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
private double flyingX = 0.95;
|
||||
private double flyingY = 0.95;
|
||||
private double flyingZ = 0.95;
|
||||
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
|
||||
public double maxSpeed = 0.4D;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -381,8 +383,8 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
|
||||
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
||||
|
||||
- if (!list.isEmpty()) {
|
||||
- Iterator iterator = list.iterator();
|
||||
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability
|
||||
+ Iterator iterator = list.size() <= 15 ? list.iterator() : list.subList(0, 15).iterator(); // Scissors
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
@@ -411,6 +413,13 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
entity.push(this);
|
||||
}
|
||||
}
|
||||
+ // Scissors start - Add a collision debounce
|
||||
+ if (list.size() > 15) {
|
||||
+ this.discard(null);
|
||||
+ } else if (list.size() > 3) {
|
||||
+ lastLargeCollision = System.currentTimeMillis();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
} else {
|
||||
Iterator iterator1 = this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index b068cff9b5aa457d65b679529956e8210296d799..9efea76afdbe653d8071936d553aea3b31d4f8e3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.IntFunction;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.BlockUtil;
|
||||
@@ -107,6 +108,8 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||
public boolean landBoats = false;
|
||||
// CraftBukkit end
|
||||
|
||||
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
|
||||
+
|
||||
public Boat(EntityType<? extends Boat> type, Level world) {
|
||||
super(type, world);
|
||||
this.paddlePositions = new float[2];
|
||||
@@ -401,9 +404,9 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||
this.checkInsideBlocks();
|
||||
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
||||
|
||||
- if (!list.isEmpty()) {
|
||||
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability
|
||||
boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player);
|
||||
- Iterator iterator = list.iterator();
|
||||
+ Iterator iterator = list.size() <= 15 ? list.iterator() : list.subList(0, 15).iterator(); // Scissors
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
@@ -416,6 +419,13 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // Scissors start - Add collision debounce
|
||||
+ if (list.size() > 15) {
|
||||
+ this.discard();
|
||||
+ } else if (list.size() > 3) {
|
||||
+ lastLargeCollision = System.currentTimeMillis();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user