Entity Activation Range
This feature gives 3 new configurable ranges that if an entity of the matching type is outside of this radius of any player, will tick at 5% of its normal rate. This will drastically cut down on tick timings for entities that are not in range of a user to actually be "used". This change can have dramatic impact on gameplay if configured too low. Balance according to your servers desired gameplay. By: Aikar <aikar@aikar.co>
This commit is contained in:
@@ -19,7 +19,26 @@
|
||||
|
||||
public abstract class AbstractArrow extends Projectile {
|
||||
|
||||
@@ -88,23 +93,30 @@
|
||||
@@ -78,6 +83,18 @@
|
||||
@Nullable
|
||||
public ItemStack firedFromWeapon;
|
||||
|
||||
+ // Spigot Start
|
||||
+ @Override
|
||||
+ public void inactiveTick()
|
||||
+ {
|
||||
+ if ( this.isInGround() )
|
||||
+ {
|
||||
+ this.life += 1;
|
||||
+ }
|
||||
+ super.inactiveTick();
|
||||
+ }
|
||||
+ // Spigot End
|
||||
+
|
||||
protected AbstractArrow(EntityType<? extends AbstractArrow> type, Level world) {
|
||||
super(type, world);
|
||||
this.pickup = AbstractArrow.Pickup.DISALLOWED;
|
||||
@@ -88,23 +105,30 @@
|
||||
}
|
||||
|
||||
protected AbstractArrow(EntityType<? extends AbstractArrow> type, double x, double y, double z, Level world, ItemStack stack, @Nullable ItemStack weapon) {
|
||||
@@ -30,7 +49,7 @@
|
||||
+ // CraftBukkit start - handle the owner before the rest of things
|
||||
+ this(type, x, y, z, world, stack, weapon, null);
|
||||
+ }
|
||||
|
||||
+
|
||||
+ protected AbstractArrow(EntityType<? extends AbstractArrow> entitytypes, double d0, double d1, double d2, Level world, ItemStack itemstack, @Nullable ItemStack itemstack1, @Nullable LivingEntity ownerEntity) {
|
||||
+ this(entitytypes, world);
|
||||
+ this.setOwner(ownerEntity);
|
||||
@@ -38,7 +57,7 @@
|
||||
+ this.pickupItemStack = itemstack.copy();
|
||||
+ this.setCustomName((Component) itemstack.get(DataComponents.CUSTOM_NAME));
|
||||
+ Unit unit = (Unit) itemstack.remove(DataComponents.INTANGIBLE_PROJECTILE);
|
||||
+
|
||||
|
||||
if (unit != null) {
|
||||
this.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
|
||||
}
|
||||
@@ -59,7 +78,7 @@
|
||||
|
||||
if (i > 0) {
|
||||
this.setPierceLevel((byte) i);
|
||||
@@ -114,8 +126,8 @@
|
||||
@@ -114,8 +138,8 @@
|
||||
}
|
||||
|
||||
protected AbstractArrow(EntityType<? extends AbstractArrow> type, LivingEntity owner, Level world, ItemStack stack, @Nullable ItemStack shotFrom) {
|
||||
@@ -70,7 +89,7 @@
|
||||
}
|
||||
|
||||
public void setSoundEvent(SoundEvent sound) {
|
||||
@@ -282,7 +294,7 @@
|
||||
@@ -282,7 +306,7 @@
|
||||
|
||||
if (movingobjectpositionentity == null) {
|
||||
if (this.isAlive() && blockHitResult.getType() != HitResult.Type.MISS) {
|
||||
@@ -79,7 +98,7 @@
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
} else {
|
||||
@@ -290,7 +302,7 @@
|
||||
@@ -290,7 +314,7 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -88,7 +107,7 @@
|
||||
|
||||
this.hasImpulse = true;
|
||||
if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) {
|
||||
@@ -357,7 +369,7 @@
|
||||
@@ -357,7 +381,7 @@
|
||||
protected void tickDespawn() {
|
||||
++this.life;
|
||||
if (this.life >= 1200) {
|
||||
@@ -97,7 +116,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -423,7 +435,7 @@
|
||||
@@ -423,7 +447,7 @@
|
||||
}
|
||||
|
||||
if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) {
|
||||
@@ -106,7 +125,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -444,7 +456,13 @@
|
||||
@@ -444,7 +468,13 @@
|
||||
int k = entity.getRemainingFireTicks();
|
||||
|
||||
if (this.isOnFire() && !flag) {
|
||||
@@ -121,7 +140,7 @@
|
||||
}
|
||||
|
||||
if (entity.hurtOrSimulate(damagesource, (float) i)) {
|
||||
@@ -490,7 +508,7 @@
|
||||
@@ -490,7 +520,7 @@
|
||||
|
||||
this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
|
||||
if (this.getPierceLevel() <= 0) {
|
||||
@@ -130,7 +149,7 @@
|
||||
}
|
||||
} else {
|
||||
entity.setRemainingFireTicks(k);
|
||||
@@ -506,7 +524,7 @@
|
||||
@@ -506,7 +536,7 @@
|
||||
this.spawnAtLocation(worldserver2, this.getPickupItem(), 0.1F);
|
||||
}
|
||||
|
||||
@@ -139,7 +158,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -675,7 +693,7 @@
|
||||
@@ -675,7 +705,7 @@
|
||||
}
|
||||
|
||||
if (nbt.contains("weapon", 10)) {
|
||||
@@ -148,7 +167,7 @@
|
||||
} else {
|
||||
this.firedFromWeapon = null;
|
||||
}
|
||||
@@ -688,34 +706,31 @@
|
||||
@@ -688,34 +718,31 @@
|
||||
Entity entity1 = entity;
|
||||
byte b0 = 0;
|
||||
|
||||
@@ -195,7 +214,7 @@
|
||||
}
|
||||
|
||||
this.pickup = entityarrow_pickupstatus;
|
||||
@@ -724,9 +739,24 @@
|
||||
@@ -724,9 +751,24 @@
|
||||
@Override
|
||||
public void playerTouch(Player player) {
|
||||
if (!this.level().isClientSide && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) {
|
||||
|
||||
@@ -10,7 +10,37 @@
|
||||
|
||||
public class FireworkRocketEntity extends Projectile implements ItemSupplier {
|
||||
|
||||
@@ -152,7 +155,7 @@
|
||||
@@ -84,7 +87,29 @@
|
||||
this.setOwner(entity);
|
||||
}
|
||||
|
||||
+ // Spigot Start - copied from tick
|
||||
@Override
|
||||
+ public void inactiveTick() {
|
||||
+ this.life += 1;
|
||||
+
|
||||
+ if (this.life > this.lifetime) {
|
||||
+ Level world = this.level();
|
||||
+
|
||||
+ if (world instanceof ServerLevel) {
|
||||
+ ServerLevel worldserver = (ServerLevel) world;
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
|
||||
+ this.explode(worldserver);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+ }
|
||||
+ super.inactiveTick();
|
||||
+ }
|
||||
+ // Spigot End
|
||||
+
|
||||
+ @Override
|
||||
protected void defineSynchedData(SynchedEntityData.Builder builder) {
|
||||
builder.define(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM, FireworkRocketEntity.getDefaultItem());
|
||||
builder.define(FireworkRocketEntity.DATA_ATTACHED_TO_TARGET, OptionalInt.empty());
|
||||
@@ -152,7 +177,7 @@
|
||||
}
|
||||
|
||||
if (!this.noPhysics && this.isAlive() && movingobjectposition.getType() != HitResult.Type.MISS) {
|
||||
@@ -19,7 +49,7 @@
|
||||
this.hasImpulse = true;
|
||||
}
|
||||
|
||||
@@ -172,7 +175,11 @@
|
||||
@@ -172,7 +197,11 @@
|
||||
if (world instanceof ServerLevel) {
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
@@ -32,7 +62,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +189,7 @@
|
||||
@@ -182,7 +211,7 @@
|
||||
world.broadcastEntityEvent(this, (byte) 17);
|
||||
this.gameEvent(GameEvent.EXPLODE, this.getOwner());
|
||||
this.dealExplosionDamage(world);
|
||||
@@ -41,7 +71,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,7 +198,11 @@
|
||||
@@ -191,7 +220,11 @@
|
||||
Level world = this.level();
|
||||
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
@@ -54,7 +84,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -205,7 +216,11 @@
|
||||
@@ -205,7 +238,11 @@
|
||||
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
if (this.hasExplosion()) {
|
||||
|
||||
Reference in New Issue
Block a user