MORE WORK

This commit is contained in:
Ben Kerllenevich
2021-06-20 07:07:41 -04:00
parent 6b674805cf
commit 50f06bd4d4
12 changed files with 474 additions and 524 deletions

View File

@@ -0,0 +1,66 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: James Lyne <jim+github@not-null.co.uk>
Date: Mon, 7 Dec 2020 17:52:36 +0000
Subject: [PATCH] Spread out and optimise player list ticksSpread out and
optimise player list ticks
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index d613b5bf9d0be9b8593d4cc02b8cb77a1f49938a..7bab62ac11d31f9eb0936f8c8540ad19685b49ee 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -998,22 +998,22 @@ public abstract class PlayerList {
}
public void tick() {
- if (++this.sendAllPlayerInfoIn > 600) {
- // CraftBukkit start
- for (int i = 0; i < this.players.size(); ++i) {
- final ServerPlayer target = (ServerPlayer) this.players.get(i);
-
- target.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY, this.players.stream().filter(new Predicate<ServerPlayer>() {
- @Override
- public boolean apply(ServerPlayer input) {
- return target.getBukkitEntity().canSee(input.getBukkitEntity());
- }
- }).collect(Collectors.toList())));
+ // Purpur start
+ if (this.sendAllPlayerInfoIn < this.players.size()) {
+ final org.bukkit.craftbukkit.entity.CraftPlayer target = this.players.get(this.sendAllPlayerInfoIn).getBukkitEntity();
+ final List<ServerPlayer> list = new java.util.ArrayList<>();
+ for (ServerPlayer player : this.players) {
+ if (target.canSee(player.getUUID())) {
+ list.add(player);
+ }
}
- // CraftBukkit end
- this.sendAllPlayerInfoIn = 0;
+ target.getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_LATENCY, list));
}
+ if (++this.sendAllPlayerInfoIn > 600) {
+ this.sendAllPlayerInfoIn = 0;
+ }
+ // Purpur end
}
public void broadcastAll(Packet<?> packet) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 676d98f183d798f1ea894cd78539f9034edb3659..9388a960317b3d0bcebbbce3855db64d2dc9e97a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1503,7 +1503,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public boolean canSee(Player player) {
- return !this.hiddenPlayers.containsKey(player.getUniqueId());
+ // Purpur start
+ return canSee(player.getUniqueId());
+ }
+
+ public boolean canSee(UUID uuid) {
+ return !hiddenPlayers.containsKey(uuid);
+ // Purpur end
}
@Override

View File

@@ -0,0 +1,245 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Tue, 8 Dec 2020 17:15:15 -0500
Subject: [PATCH] Configurable chance for wolves to spawn rabid
Configurable chance to spawn a wolf that is rabid.
Rabid wolves attack all players, mobs, and animals.
diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
index ef4abaf68de01b0879f7d0b330d2d57cc6bd10f9..3e7409ebf1f94b9cf55f2d0b0fe17ca8ec44659f 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
@@ -10,22 +10,28 @@ import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
import net.minecraft.util.TimeUtil;
import net.minecraft.util.valueproviders.UniformInt;
+import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.effect.MobEffectInstance;
+import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
+import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.NeutralMob;
import net.minecraft.world.entity.Pose;
+import net.minecraft.world.entity.SpawnGroupData;
import net.minecraft.world.entity.TamableAnimal;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
@@ -34,6 +40,7 @@ import net.minecraft.world.entity.ai.goal.BegGoal;
import net.minecraft.world.entity.ai.goal.BreedGoal;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.FollowOwnerGoal;
+import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.entity.ai.goal.LeapAtTargetGoal;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
@@ -59,6 +66,7 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
+import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3;
@@ -77,6 +85,37 @@ public class Wolf extends TamableAnimal implements NeutralMob {
return entitytypes == EntityType.SHEEP || entitytypes == EntityType.RABBIT || entitytypes == EntityType.FOX;
};
+ // Purpur start - rabid wolf spawn chance
+ private boolean isRabid = false;
+ private static final Predicate<LivingEntity> RABID_PREDICATE = entity -> entity instanceof ServerPlayer || entity instanceof Mob;
+ private final Goal PATHFINDER_VANILLA = new NonTameRandomTargetGoal<>(this, Animal.class, false, PREY_SELECTOR);
+ private final Goal PATHFINDER_RABID = new NonTameRandomTargetGoal<>(this, LivingEntity.class, false, RABID_PREDICATE);
+ private static final class AvoidRabidWolfGoal extends AvoidEntityGoal<Wolf> {
+ private final Wolf wolf;
+
+ public AvoidRabidWolfGoal(Wolf wolf, float distance, double minSpeed, double maxSpeed) {
+ super(wolf, Wolf.class, distance, minSpeed, maxSpeed);
+ this.wolf = wolf;
+ }
+
+ @Override
+ public boolean canUse() {
+ return super.canUse() && !this.wolf.isRabid() && this.toAvoid != null && this.toAvoid.isRabid(); // wolves which are not rabid run away from rabid wolves
+ }
+
+ @Override
+ public void start() {
+ this.wolf.setTarget(null);
+ super.start();
+ }
+
+ @Override
+ public void tick() {
+ this.wolf.setTarget(null);
+ super.tick();
+ }
+ }
+ // Purpur end
private static final float START_HEALTH = 8.0F;
private static final float TAME_HEALTH = 20.0F;
private float interestedAngle;
@@ -118,6 +157,37 @@ public class Wolf extends TamableAnimal implements NeutralMob {
public int getPurpurBreedTime() {
return this.level.purpurConfig.wolfBreedingTicks;
}
+
+ public boolean isRabid() {
+ return this.isRabid;
+ }
+
+ public void setRabid(boolean isRabid) {
+ this.isRabid = isRabid;
+ updatePathfinders(true);
+ }
+
+ public void updatePathfinders(boolean modifyEffects) {
+ this.targetSelector.removeGoal(PATHFINDER_VANILLA);
+ this.targetSelector.removeGoal(PATHFINDER_RABID);
+ if (this.isRabid) {
+ setTame(false);
+ setOwnerUUID(null);
+ this.targetSelector.addGoal(5, PATHFINDER_RABID);
+ if (modifyEffects) this.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 1200));
+ } else {
+ this.targetSelector.addGoal(5, PATHFINDER_VANILLA);
+ this.stopBeingAngry();
+ if (modifyEffects) this.removeEffect(MobEffects.CONFUSION);
+ }
+ }
+
+ @Override
+ public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType type, @Nullable SpawnGroupData data, @Nullable CompoundTag nbt) {
+ this.isRabid = level.purpurConfig.wolfNaturalRabid > 0.0D && random.nextDouble() <= level.purpurConfig.wolfNaturalRabid;
+ this.updatePathfinders(false);
+ return super.finalizeSpawn(world, difficulty, type, data, nbt);
+ }
// Purpur end
@Override
@@ -126,6 +196,7 @@ public class Wolf extends TamableAnimal implements NeutralMob {
this.goalSelector.addGoal(1, new net.pl3x.purpur.entity.ai.HasRider(this)); // Purpur
this.goalSelector.addGoal(2, new SitWhenOrderedToGoal(this));
this.goalSelector.addGoal(3, new Wolf.WolfAvoidEntityGoal<>(this, Llama.class, 24.0F, 1.5D, 1.5D));
+ this.goalSelector.addGoal(3, new AvoidRabidWolfGoal(this, 24.0F, 1.5D, 1.5D)); // Purpur
this.goalSelector.addGoal(4, new LeapAtTargetGoal(this, 0.4F));
this.goalSelector.addGoal(5, new MeleeAttackGoal(this, 1.0D, true));
this.goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false));
@@ -139,7 +210,7 @@ public class Wolf extends TamableAnimal implements NeutralMob {
this.targetSelector.addGoal(2, new OwnerHurtTargetGoal(this));
this.targetSelector.addGoal(3, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers(new Class[0])); // CraftBukkit - decompile error
this.targetSelector.addGoal(4, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
- this.targetSelector.addGoal(5, new NonTameRandomTargetGoal<>(this, Animal.class, false, Wolf.PREY_SELECTOR));
+ // this.targetSelector.addGoal(5, new NonTameRandomTargetGoal<>(this, Animal.class, false, Wolf.PREY_SELECTOR)); // Purpur - moved to updatePathfinders()
this.targetSelector.addGoal(6, new NonTameRandomTargetGoal<>(this, Turtle.class, false, Turtle.BABY_ON_LAND_SELECTOR));
this.targetSelector.addGoal(7, new NearestAttackableTargetGoal<>(this, AbstractSkeleton.class, false));
this.targetSelector.addGoal(8, new ResetUniversalAngerTargetGoal<>(this, true));
@@ -184,6 +255,7 @@ public class Wolf extends TamableAnimal implements NeutralMob {
public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
nbt.putByte("CollarColor", (byte) this.getCollarColor().getId());
+ nbt.putBoolean("Purpur.IsRabid", this.isRabid); // Purpur
this.addPersistentAngerSaveData(nbt);
}
@@ -193,6 +265,10 @@ public class Wolf extends TamableAnimal implements NeutralMob {
if (nbt.contains("CollarColor", 99)) {
this.setCollarColor(DyeColor.byId(nbt.getInt("CollarColor")));
}
+ // Purpur start
+ this.isRabid = nbt.getBoolean("Purpur.IsRabid");
+ this.updatePathfinders(false);
+ // Purpur end
this.readPersistentAngerSaveData(this.level, nbt);
}
@@ -237,6 +313,11 @@ public class Wolf extends TamableAnimal implements NeutralMob {
public void tick() {
super.tick();
if (this.isAlive()) {
+ // Purpur start
+ if (this.age % 300 == 0 && this.isRabid()) {
+ this.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 400));
+ }
+ // Purpur end
this.interestedAngleO = this.interestedAngle;
if (this.isInterested()) {
this.interestedAngle += (1.0F - this.interestedAngle) * 0.4F;
@@ -434,6 +515,20 @@ public class Wolf extends TamableAnimal implements NeutralMob {
return InteractionResult.SUCCESS;
}
+ // Purpur start
+ else if (this.level.purpurConfig.wolfMilkCuresRabies && itemstack.getItem() == Items.MILK_BUCKET && this.isRabid()) {
+ if (!player.isCreative()) {
+ player.setItemInHand(hand, new ItemStack(Items.BUCKET));
+ }
+ this.setRabid(false);
+ for (int i = 0; i < 10; ++i) {
+ ((ServerLevel) level).sendParticles(((ServerLevel) level).players, null, ParticleTypes.HAPPY_VILLAGER,
+ getX() + random.nextFloat(), getY() + (random.nextFloat() * 1.5), getZ() + random.nextFloat(), 1,
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0, true);
+ }
+ return InteractionResult.SUCCESS;
+ }
+ // Purpur end
return super.mobInteract(player, hand);
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 9a48046093f3de6f68c5e33adbbe5ea3090315ec..69abb2cee655040032d3300591689b5f99bb879b 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1739,6 +1739,8 @@ public class PurpurWorldConfig {
public boolean wolfRidable = false;
public boolean wolfRidableInWater = false;
public double wolfMaxHealth = 8.0D;
+ public boolean wolfMilkCuresRabies = true;
+ public double wolfNaturalRabid = 0.0D;
public int wolfBreedingTicks = 6000;
private void wolfSettings() {
wolfRidable = getBoolean("mobs.wolf.ridable", wolfRidable);
@@ -1749,6 +1751,8 @@ public class PurpurWorldConfig {
set("mobs.wolf.attributes.max_health", oldValue);
}
wolfMaxHealth = getDouble("mobs.wolf.attributes.max_health", wolfMaxHealth);
+ wolfMilkCuresRabies = getBoolean("mobs.wolf.milk-cures-rabid-wolves", wolfMilkCuresRabies);
+ wolfNaturalRabid = getDouble("mobs.wolf.spawn-rabid-chance", wolfNaturalRabid);
wolfBreedingTicks = getInt("mobs.wolf.breeding-delay-ticks", wolfBreedingTicks);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java
index f856b42201c17f8da21251e54fcf052336916e70..ac0803d42be2f36a2f40487ee31413d059d2f0e2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java
@@ -43,4 +43,16 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf {
public void setCollarColor(DyeColor color) {
this.getHandle().setCollarColor(net.minecraft.world.item.DyeColor.byId(color.getWoolData()));
}
+
+ // Purpur start
+ @Override
+ public boolean isRabid() {
+ return getHandle().isRabid();
+ }
+
+ @Override
+ public void setRabid(boolean isRabid) {
+ getHandle().setRabid(isRabid);
+ }
+ // Purpur end
}

View File

@@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Thu, 10 Dec 2020 13:43:28 -0500
Subject: [PATCH] Configurable default wolf collar color
This allows for the server to set a default collar color when a wolf is tamed.
Resets to RED when the value is invalid.
diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
index 3e7409ebf1f94b9cf55f2d0b0fe17ca8ec44659f..518dd0e6b4889c049e438b393baa795a5eac3e7d 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
@@ -188,6 +188,12 @@ public class Wolf extends TamableAnimal implements NeutralMob {
this.updatePathfinders(false);
return super.finalizeSpawn(world, difficulty, type, data, nbt);
}
+
+ @Override
+ public void tame(Player player) {
+ setCollarColor(level.purpurConfig.wolfDefaultCollarColor);
+ super.tame(player);
+ }
// Purpur end
@Override
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 69abb2cee655040032d3300591689b5f99bb879b..70a6f1bc6f0d8a057a65b95651ab547f48167f1c 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -3,6 +3,7 @@ package net.pl3x.purpur;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Difficulty;
+import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Explosion;
@@ -1739,6 +1740,7 @@ public class PurpurWorldConfig {
public boolean wolfRidable = false;
public boolean wolfRidableInWater = false;
public double wolfMaxHealth = 8.0D;
+ public DyeColor wolfDefaultCollarColor = DyeColor.RED;
public boolean wolfMilkCuresRabies = true;
public double wolfNaturalRabid = 0.0D;
public int wolfBreedingTicks = 6000;
@@ -1751,6 +1753,11 @@ public class PurpurWorldConfig {
set("mobs.wolf.attributes.max_health", oldValue);
}
wolfMaxHealth = getDouble("mobs.wolf.attributes.max_health", wolfMaxHealth);
+ try {
+ wolfDefaultCollarColor = DyeColor.valueOf(getString("mobs.wolf.default-collar-color", wolfDefaultCollarColor.name()));
+ } catch (IllegalArgumentException ignore) {
+ wolfDefaultCollarColor = DyeColor.RED;
+ }
wolfMilkCuresRabies = getBoolean("mobs.wolf.milk-cures-rabid-wolves", wolfMilkCuresRabies);
wolfNaturalRabid = getDouble("mobs.wolf.spawn-rabid-chance", wolfNaturalRabid);
wolfBreedingTicks = getInt("mobs.wolf.breeding-delay-ticks", wolfBreedingTicks);

View File

@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sat, 12 Dec 2020 09:10:59 -0600
Subject: [PATCH] Phantom flames on swoop
diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
index 782d4499f925950d66072b63f34a828bcc51d2e7..3ea6f2d96245caa85f365c488b8cc019a8318009 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
@@ -227,6 +227,7 @@ public class Phantom extends FlyingMob implements Enemy {
this.level.addParticle(ParticleTypes.MYCELIUM, this.getX() - (double) f2, this.getY() + (double) f4, this.getZ() - (double) f3, 0.0D, 0.0D, 0.0D);
}
+ if (level.purpurConfig.phantomFlamesOnSwoop && attackPhase == AttackPhase.SWOOP) shoot(); // Purpur
}
@Override
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 70a6f1bc6f0d8a057a65b95651ab547f48167f1c..98f02e3b3f257040f03deb5df8938edbd623ab0d 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1146,6 +1146,7 @@ public class PurpurWorldConfig {
public float phantomFlameDamage = 1.0F;
public int phantomFlameFireTime = 8;
public boolean phantomAllowGriefing = false;
+ public boolean phantomFlamesOnSwoop = false;
public double phantomMaxHealth = 20.0D;
public double phantomAttackedByCrystalRadius = 0.0D;
public float phantomAttackedByCrystalDamage = 1.0F;
@@ -1172,6 +1173,7 @@ public class PurpurWorldConfig {
phantomFlameDamage = (float) getDouble("mobs.phantom.flames.damage", phantomFlameDamage);
phantomFlameFireTime = getInt("mobs.phantom.flames.fire-time", phantomFlameFireTime);
phantomAllowGriefing = getBoolean("mobs.phantom.allow-griefing", phantomAllowGriefing);
+ phantomFlamesOnSwoop = getBoolean("mobs.phantom.flames-on-swoop", phantomFlamesOnSwoop);
if (PurpurConfig.version < 10) {
double oldValue = getDouble("mobs.phantom.attributes.max-health", phantomMaxHealth);
set("mobs.phantom.attributes.max-health", null);

View File

@@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Sat, 12 Dec 2020 14:34:18 -0800
Subject: [PATCH] Option for chests to open even with a solid block on top
diff --git a/src/main/java/net/minecraft/world/level/block/ChestBlock.java b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
index d980a556785b52fe827310b83638139df0816b11..3c8c02fc92374def12254f7ffad604b2779117f6 100644
--- a/src/main/java/net/minecraft/world/level/block/ChestBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
@@ -349,6 +349,7 @@ public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements
}
private static boolean isBlockedChestByBlock(BlockGetter world, BlockPos pos) {
+ if (world instanceof Level && ((Level) world).purpurConfig.chestOpenWithBlockOnTop) return false; // Purpur
BlockPos blockposition1 = pos.above();
return world.getBlockState(blockposition1).isRedstoneConductor(world, blockposition1);
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 98f02e3b3f257040f03deb5df8938edbd623ab0d..56010a52b16075e5307e33e02a9fb25b45ff0032 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -405,6 +405,11 @@ public class PurpurWorldConfig {
}
}
+ public boolean chestOpenWithBlockOnTop = false;
+ private void chestSettings() {
+ chestOpenWithBlockOnTop = getBoolean("blocks.chest.open-with-solid-block-on-top", chestOpenWithBlockOnTop);
+ }
+
public boolean dispenserApplyCursedArmor = true;
public boolean dispenserPlaceAnvils = false;
private void dispenserSettings() {

View File

@@ -0,0 +1,208 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sat, 12 Dec 2020 21:19:05 -0600
Subject: [PATCH] Implement TPSBar
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 9cbaaf4cd138e6c1d2d51afcef24a81a3f2973c5..13e90bf9506862a4830b50dcce06cc95a6ada5e3 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -200,6 +200,7 @@ public class Commands {
WhitelistCommand.register(this.dispatcher);
net.pl3x.purpur.command.DemoCommand.register(this.dispatcher); // Purpur
net.pl3x.purpur.command.PingCommand.register(this.dispatcher); // Purpur
+ net.pl3x.purpur.command.TPSBarCommand.register(this.dispatcher); // Purpur
}
if (environment.includeIntegrated) {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 91e6d0b6560ffa8e870eca9707d5cd117fcb2347..d525bd371bedf75c24afd4a8a1240b31f91aa9da 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1040,6 +1040,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.safeShutdown(flag, false);
}
public void safeShutdown(boolean flag, boolean isRestarting) {
+ net.pl3x.purpur.task.TPSBarTask.stop(); // Purpur
this.isRestarting = isRestarting;
this.hasLoggedStop = true; // Paper
if (isDebugging()) io.papermc.paper.util.TraceUtil.dumpTraceForThread("Server stopped"); // Paper
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 5fa2723c9899c69ac326f95acf49cd47406378f9..a9098119009b60ea8dbdb4c118cfc20b112d44e0 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -345,6 +345,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
DedicatedServer.LOGGER.info("JMX monitoring enabled");
}
+ net.pl3x.purpur.task.TPSBarTask.start(); // Purpur
+
return true;
}
}
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 7bab62ac11d31f9eb0936f8c8540ad19685b49ee..f71097f1386de7ba6aaaffe8728e9ac18c5270c5 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -593,6 +593,8 @@ public abstract class PlayerList {
if (entityplayer.didPlayerJoinEvent) this.cserver.getPluginManager().callEvent(playerQuitEvent); // Paper - if we disconnected before join ever fired, don't fire quit
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
+ net.pl3x.purpur.task.TPSBarTask.removePlayer(cserver.getPlayer(entityplayer)); // Purpur
+
if (server.isSameThread()) entityplayer.doTick(); // SPIGOT-924 // Paper - don't tick during emergency shutdowns (Watchdog)
// CraftBukkit end
diff --git a/src/main/java/net/pl3x/purpur/command/TPSBarCommand.java b/src/main/java/net/pl3x/purpur/command/TPSBarCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..2803a1b95121fbff3066fd2d1abaf8723386781f
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/command/TPSBarCommand.java
@@ -0,0 +1,24 @@
+package net.pl3x.purpur.command;
+
+import com.mojang.brigadier.CommandDispatcher;
+import net.minecraft.commands.CommandSourceStack;
+import net.minecraft.commands.Commands;
+import net.minecraft.server.level.ServerPlayer;
+import net.pl3x.purpur.task.TPSBarTask;
+
+public class TPSBarCommand {
+ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
+ dispatcher.register(Commands.literal("tpsbar")
+ .requires(listener -> listener.hasPermission(2))
+ .executes(context -> execute(context.getSource(), context.getSource().getPlayerOrException()))
+ ).setPermission("bukkit.command.tpsbar");
+ }
+
+ private static int execute(CommandSourceStack source, ServerPlayer player) {
+ if (player != null) {
+ TPSBarTask.togglePlayer(player.getBukkitEntity());
+ return 1;
+ }
+ return 0;
+ }
+}
diff --git a/src/main/java/net/pl3x/purpur/task/TPSBarTask.java b/src/main/java/net/pl3x/purpur/task/TPSBarTask.java
new file mode 100644
index 0000000000000000000000000000000000000000..11791bbd4dbe4037f7a5b630be2ff1fa4d599513
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/task/TPSBarTask.java
@@ -0,0 +1,116 @@
+package net.pl3x.purpur.task;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.NamespacedKey;
+import org.bukkit.boss.BarColor;
+import org.bukkit.boss.BarStyle;
+import org.bukkit.boss.BossBar;
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
+import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitRunnable;
+
+public class TPSBarTask extends BukkitRunnable {
+ private static TPSBarTask instance;
+ private final NamespacedKey key;
+ private BossBar bossbar;
+
+ private TPSBarTask() {
+ this.key = new NamespacedKey("purpur", "tpsbar");
+ }
+
+ private static TPSBarTask instance() {
+ if (instance == null) {
+ instance = new TPSBarTask();
+ }
+ return instance;
+ }
+
+ private BossBar bossbar() {
+ if (bossbar == null) {
+ bossbar = Bukkit.getBossBar(key);
+ if (bossbar == null) {
+ bossbar = Bukkit.createBossBar(key, "TPS: 20.0", BarColor.RED, BarStyle.SEGMENTED_20);
+ }
+ bossbar.setVisible(true);
+ bossbar.setProgress(1.0D);
+ }
+ return bossbar;
+ }
+
+ @Override
+ public void run() {
+ BossBar bossbar = bossbar();
+ if (bossbar.getPlayers().isEmpty()) {
+ return;
+ }
+
+ double tps = Bukkit.getTPS()[0];
+ if (tps > 20.0D) {
+ tps = 20.0D;
+ } else if (tps < 0.0D) {
+ tps = 0.0D;
+ }
+
+ bossbar.setVisible(true);
+ bossbar.setProgress(Math.max(Math.min(tps / 20.0D, 1.0D), 0.0D));
+
+ String tpsColor;
+ if (tps >= 18) {
+ tpsColor = "&2";
+ bossbar.setColor(BarColor.GREEN);
+ } else if (tps >= 15) {
+ tpsColor = "&e";
+ bossbar.setColor(BarColor.YELLOW);
+ } else {
+ tpsColor = "&4";
+ bossbar.setColor(BarColor.RED);
+ }
+
+ double mspt = Bukkit.getAverageTickTime();
+ String msptColor;
+ if (mspt < 40) {
+ msptColor = "&2";
+ } else if (mspt < 50) {
+ msptColor = "&e";
+ } else {
+ msptColor = "&4";
+ }
+
+ bossbar.setTitle(ChatColor.translateAlternateColorCodes('&', "&eTPS&3: " + tpsColor + String.format("%.2f", tps) + " &eMSPT&3: " + msptColor + String.format("%.3f", mspt)));
+ }
+
+ @Override
+ public void cancel() {
+ super.cancel();
+ BossBar bossbar = bossbar();
+ bossbar.setVisible(false);
+ bossbar.removeAll();
+ Bukkit.removeBossBar(key);
+ }
+
+ public static void removePlayer(Player player) {
+ instance().bossbar().removePlayer(player);
+ }
+
+ public static void togglePlayer(Player player) {
+ BossBar bossbar = instance().bossbar();
+ if (bossbar.getPlayers().contains(player)) {
+ bossbar.removePlayer(player);
+ } else {
+ bossbar.addPlayer(player);
+ instance.run();
+ }
+ }
+
+ public static void start() {
+ stop();
+ instance().runTaskTimerAsynchronously(new MinecraftInternalPlugin(), 20L, 20L);
+ }
+
+ public static void stop() {
+ if (instance != null) {
+ instance.cancel();
+ }
+ }
+}