mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 18:37:42 +01:00
MORE WORK
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
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 ticks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 1d7685f5373249a6cc950ebd8a75cda53e5680d6..9a41d4ae2a64ba542dd9b6b98b01dd660a43b2dc 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -151,7 +151,7 @@ public abstract class PlayerList {
|
||||
private int viewDistance;
|
||||
private EnumGamemode u;
|
||||
private boolean v;
|
||||
- private int w;
|
||||
+ private int w; private int getTick() { return this.w; } private int setTick(int i) { return this.w = i; } // Purpur - OBFHELPER
|
||||
|
||||
// CraftBukkit start
|
||||
private CraftServer cserver;
|
||||
@@ -1028,22 +1028,23 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
- if (++this.w > 600) {
|
||||
- // CraftBukkit start
|
||||
- for (int i = 0; i < this.players.size(); ++i) {
|
||||
- final EntityPlayer target = (EntityPlayer) this.players.get(i);
|
||||
-
|
||||
- target.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(this.players, new Predicate<EntityPlayer>() {
|
||||
- @Override
|
||||
- public boolean apply(EntityPlayer input) {
|
||||
- return target.getBukkitEntity().canSee(input.getBukkitEntity());
|
||||
- }
|
||||
- })));
|
||||
+ // Purpur start
|
||||
+ int tick = getTick();
|
||||
+ if (tick < this.players.size()) {
|
||||
+ final org.bukkit.craftbukkit.entity.CraftPlayer target = this.players.get(tick).getBukkitEntity();
|
||||
+ final java.util.List<EntityPlayer> list = new java.util.ArrayList<>();
|
||||
+ for (EntityPlayer entityplayer : this.players) {
|
||||
+ if (target.canSee(entityplayer.getUniqueID())) {
|
||||
+ list.add(entityplayer);
|
||||
+ }
|
||||
}
|
||||
- // CraftBukkit end
|
||||
- this.w = 0;
|
||||
+ target.getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, list));
|
||||
}
|
||||
-
|
||||
+ if (++tick > 600) {
|
||||
+ tick = 0;
|
||||
+ }
|
||||
+ setTick(tick);
|
||||
+ // Purpur end
|
||||
}
|
||||
|
||||
public void sendAll(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 45bf2b87518ba81cb4a18a59d11dba9430e63e40..175dfb418f910d6486109073d0a406461a48f7ec 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1447,7 +1447,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public boolean canSee(Player player) {
|
||||
- return !hiddenPlayers.containsKey(player.getUniqueId());
|
||||
+ // Purpur start
|
||||
+ return canSee(player.getUniqueId());
|
||||
+ }
|
||||
+
|
||||
+ public boolean canSee(UUID uuid) {
|
||||
+ return !hiddenPlayers.containsKey(uuid);
|
||||
+ // Purpur end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,283 +0,0 @@
|
||||
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/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
||||
index a1a8441e26ce1414b2406f9be559eeb3a34453d9..65cafb25252aa1d2013311a8fef364b96ee7273c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
||||
@@ -2197,6 +2197,7 @@ public abstract class EntityLiving extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
+ public final void setItemInHand(EnumHand enumHand, ItemStack itemStack) { this.a(enumHand, itemStack); } // Purpur - OBFHELPER
|
||||
public void a(EnumHand enumhand, ItemStack itemstack) {
|
||||
if (enumhand == EnumHand.MAIN_HAND) {
|
||||
this.setSlot(EnumItemSlot.MAINHAND, itemstack);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalAvoidTarget.java b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalAvoidTarget.java
|
||||
index 5115c56487a12f904ff836355375f66a16098790..35502bd2f7d9cebf5cfe1060e300a5032dbe6a5d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalAvoidTarget.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalAvoidTarget.java
|
||||
@@ -17,7 +17,7 @@ public class PathfinderGoalAvoidTarget<T extends EntityLiving> extends Pathfinde
|
||||
protected final EntityCreature a;
|
||||
private final double i;
|
||||
private final double j;
|
||||
- protected T b;
|
||||
+ protected T b; protected T getTarget() { return this.b; } // Purpur - OBFHELPER
|
||||
protected final float c;
|
||||
protected PathEntity d;
|
||||
protected final NavigationAbstract e;
|
||||
@@ -27,12 +27,7 @@ public class PathfinderGoalAvoidTarget<T extends EntityLiving> extends Pathfinde
|
||||
private final PathfinderTargetCondition k;
|
||||
|
||||
public PathfinderGoalAvoidTarget(EntityCreature entitycreature, Class<T> oclass, float f, double d0, double d1) {
|
||||
- Predicate predicate = (entityliving) -> {
|
||||
- return true;
|
||||
- };
|
||||
- Predicate predicate1 = IEntitySelector.e;
|
||||
-
|
||||
- this(entitycreature, oclass, predicate, f, d0, d1, predicate1::test);
|
||||
+ this(entitycreature, oclass, entityliving -> true, f, d0, d1, IEntitySelector.e::test); // Purpur - decompile fix
|
||||
}
|
||||
|
||||
public PathfinderGoalAvoidTarget(EntityCreature entitycreature, Class<T> oclass, Predicate<EntityLiving> predicate, float f, double d0, double d1, Predicate<EntityLiving> predicate1) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/EntityWolf.java b/src/main/java/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
index dd3c7ad7701ad18ccaf86d73fde7051090ed3d57..e8c6aca70db693250224d1c162e3c2684687ea41 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
@@ -10,15 +10,19 @@ import net.minecraft.network.syncher.DataWatcher;
|
||||
import net.minecraft.network.syncher.DataWatcherObject;
|
||||
import net.minecraft.network.syncher.DataWatcherRegistry;
|
||||
import net.minecraft.server.PathfinderGoalHasRider;
|
||||
+import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.sounds.SoundEffects;
|
||||
import net.minecraft.util.IntRange;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.TimeRange;
|
||||
+import net.minecraft.world.DifficultyDamageScaler;
|
||||
import net.minecraft.world.EnumHand;
|
||||
import net.minecraft.world.EnumInteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
+import net.minecraft.world.effect.MobEffect;
|
||||
+import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityAgeable;
|
||||
import net.minecraft.world.entity.EntityInsentient;
|
||||
@@ -27,9 +31,12 @@ import net.minecraft.world.entity.EntityPose;
|
||||
import net.minecraft.world.entity.EntitySize;
|
||||
import net.minecraft.world.entity.EntityTameableAnimal;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
+import net.minecraft.world.entity.EnumMobSpawn;
|
||||
+import net.minecraft.world.entity.GroupDataEntity;
|
||||
import net.minecraft.world.entity.IEntityAngerable;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeProvider;
|
||||
import net.minecraft.world.entity.ai.attributes.GenericAttributes;
|
||||
+import net.minecraft.world.entity.ai.goal.PathfinderGoal;
|
||||
import net.minecraft.world.entity.ai.goal.PathfinderGoalAvoidTarget;
|
||||
import net.minecraft.world.entity.ai.goal.PathfinderGoalBeg;
|
||||
import net.minecraft.world.entity.ai.goal.PathfinderGoalBreed;
|
||||
@@ -60,6 +67,7 @@ import net.minecraft.world.item.ItemDye;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.World;
|
||||
+import net.minecraft.world.level.WorldAccess;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@@ -73,11 +81,42 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
private static final DataWatcherObject<Boolean> br = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i);
|
||||
private static final DataWatcherObject<Integer> bs = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.b);
|
||||
private static final DataWatcherObject<Integer> bt = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.b);
|
||||
- public static final Predicate<EntityLiving> bq = (entityliving) -> {
|
||||
+ public static Predicate<EntityLiving> vanillaPredicate() { return bq; } public static final Predicate<EntityLiving> bq = (entityliving) -> { // Purpur - OBFHELPER
|
||||
EntityTypes<?> entitytypes = entityliving.getEntityType();
|
||||
|
||||
return entitytypes == EntityTypes.SHEEP || entitytypes == EntityTypes.RABBIT || entitytypes == EntityTypes.FOX;
|
||||
};
|
||||
+ // Purpur start - rabid wolf spawn chance
|
||||
+ private boolean isRabid = false;
|
||||
+ private static final Predicate<EntityLiving> RABID_PREDICATE = e -> e instanceof EntityPlayer || e instanceof EntityInsentient;
|
||||
+ private final PathfinderGoal PATHFINDER_VANILLA = new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, vanillaPredicate());
|
||||
+ private final PathfinderGoal PATHFINDER_RABID = new PathfinderGoalRandomTargetNonTamed<>(this, EntityLiving.class, false, RABID_PREDICATE);
|
||||
+ private static final class PathfinderGoalAvoidRabidWolves extends PathfinderGoalAvoidTarget<EntityWolf> {
|
||||
+ private final EntityWolf wolf;
|
||||
+
|
||||
+ public PathfinderGoalAvoidRabidWolves(EntityWolf wolf, float distance, double minSpeed, double maxSpeed) {
|
||||
+ super(wolf, EntityWolf.class, distance, minSpeed, maxSpeed);
|
||||
+ this.wolf = wolf;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean a() { // shouldExecute
|
||||
+ return super.a() && !this.wolf.isRabid() && this.getTarget() != null && this.getTarget().isRabid(); // wolves which are not rabid run away from rabid wolves
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void c() { // startExecuting
|
||||
+ this.wolf.setGoalTarget(null);
|
||||
+ super.c();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void e() { // tick
|
||||
+ this.wolf.setGoalTarget(null);
|
||||
+ super.e();
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
private float bu;
|
||||
private float bv;
|
||||
private boolean bw;
|
||||
@@ -112,6 +151,37 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
public int getPurpurBreedTime() {
|
||||
return this.world.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) {
|
||||
+ setTamed(false);
|
||||
+ setOwnerUUID(null);
|
||||
+ this.targetSelector.addGoal(5, PATHFINDER_RABID);
|
||||
+ if (modifyEffects) this.addEffect(new MobEffect(MobEffects.CONFUSION, 1200));
|
||||
+ } else {
|
||||
+ this.targetSelector.addGoal(5, PATHFINDER_VANILLA);
|
||||
+ this.pacify();
|
||||
+ if (modifyEffects) this.removeEffect(MobEffects.CONFUSION);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public GroupDataEntity prepare(WorldAccess worldaccess, DifficultyDamageScaler difficultydamagescaler, EnumMobSpawn enummobspawn, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) {
|
||||
+ this.isRabid = world.purpurConfig.wolfNaturalRabid > 0.0D && random.nextDouble() <= world.purpurConfig.wolfNaturalRabid;
|
||||
+ this.updatePathfinders(false);
|
||||
+ return super.prepare(worldaccess, difficultydamagescaler, enummobspawn, groupdataentity, nbttagcompound);
|
||||
+ }
|
||||
// Purpur end
|
||||
|
||||
@Override
|
||||
@@ -120,6 +190,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
this.goalSelector.a(1, new PathfinderGoalHasRider(this)); // Purpur
|
||||
this.goalSelector.a(2, new PathfinderGoalSit(this));
|
||||
this.goalSelector.a(3, new EntityWolf.a<>(this, EntityLlama.class, 24.0F, 1.5D, 1.5D));
|
||||
+ this.goalSelector.addGoal(3, new PathfinderGoalAvoidRabidWolves(this, 24.0F, 1.5D, 1.5D)); // Purpur
|
||||
this.goalSelector.a(4, new PathfinderGoalLeapAtTarget(this, 0.4F));
|
||||
this.goalSelector.a(5, new PathfinderGoalMeleeAttack(this, 1.0D, true));
|
||||
this.goalSelector.a(6, new PathfinderGoalFollowOwner(this, 1.0D, 10.0F, 2.0F, false));
|
||||
@@ -133,7 +204,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this));
|
||||
this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_));
|
||||
- this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bq));
|
||||
+ //this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bq)); // Purpur - moved to updatePathfinders()
|
||||
this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bo));
|
||||
this.targetSelector.a(7, new PathfinderGoalNearestAttackableTarget<>(this, EntitySkeletonAbstract.class, false));
|
||||
this.targetSelector.a(8, new PathfinderGoalUniversalAngerReset<>(this, true));
|
||||
@@ -178,6 +249,7 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
public void saveData(NBTTagCompound nbttagcompound) {
|
||||
super.saveData(nbttagcompound);
|
||||
nbttagcompound.setByte("CollarColor", (byte) this.getCollarColor().getColorIndex());
|
||||
+ nbttagcompound.setBoolean("Purpur.IsRabid", this.isRabid); // Purpur
|
||||
this.c(nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -187,6 +259,10 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
if (nbttagcompound.hasKeyOfType("CollarColor", 99)) {
|
||||
this.setCollarColor(EnumColor.fromColorIndex(nbttagcompound.getInt("CollarColor")));
|
||||
}
|
||||
+ // Purpur start
|
||||
+ this.isRabid = nbttagcompound.getBoolean("Purpur.IsRabid");
|
||||
+ this.updatePathfinders(false);
|
||||
+ // Purpur end
|
||||
|
||||
this.a((WorldServer) this.world, nbttagcompound);
|
||||
}
|
||||
@@ -231,6 +307,11 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.isAlive()) {
|
||||
+ // Purpur start
|
||||
+ if (this.ticksLived % 300 == 0 && this.isRabid()) {
|
||||
+ this.addEffect(new MobEffect(MobEffects.CONFUSION, 400));
|
||||
+ }
|
||||
+ // Purpur end
|
||||
this.bv = this.bu;
|
||||
if (this.eY()) {
|
||||
this.bu += (1.0F - this.bu) * 0.4F;
|
||||
@@ -402,6 +483,20 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
+ // Purpur start
|
||||
+ else if (this.world.purpurConfig.wolfMilkCuresRabies && itemstack.getItem() == Items.MILK_BUCKET && this.isRabid()) {
|
||||
+ if (!entityhuman.isCreative()) {
|
||||
+ entityhuman.setItemInHand(enumhand, new ItemStack(Items.BUCKET));
|
||||
+ }
|
||||
+ this.setRabid(false);
|
||||
+ for (int i = 0; i < 10; ++i) {
|
||||
+ ((WorldServer) world).sendParticles(((WorldServer) world).players, null, Particles.HAPPY_VILLAGER,
|
||||
+ locX() + random.nextFloat(), locY() + (random.nextFloat() * 1.5), locZ() + random.nextFloat(), 1,
|
||||
+ random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, 0, true);
|
||||
+ }
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
|
||||
return super.b(entityhuman, enumhand);
|
||||
}
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 7d32788c5e538be6eff9b6ff4655f279ac1e0e6b..5a05d4e511bf7c96d3e01c59e6e53b105bf7baf6 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -1219,10 +1219,14 @@ public class PurpurWorldConfig {
|
||||
|
||||
public boolean wolfRidable = false;
|
||||
public boolean wolfRidableInWater = false;
|
||||
+ public boolean wolfMilkCuresRabies = true;
|
||||
+ public double wolfNaturalRabid = 0.0D;
|
||||
public int wolfBreedingTicks = 6000;
|
||||
private void wolfSettings() {
|
||||
wolfRidable = getBoolean("mobs.wolf.ridable", wolfRidable);
|
||||
wolfRidableInWater = getBoolean("mobs.wolf.ridable-in-water", wolfRidableInWater);
|
||||
+ 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 dc5ba91ebdef25d633205a65148b62f1853b4da5..71e5b36b7d0bb92ef6e94759318a4a82a19e729a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java
|
||||
@@ -45,4 +45,16 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf {
|
||||
public void setCollarColor(DyeColor color) {
|
||||
getHandle().setCollarColor(EnumColor.fromColorIndex(color.getWoolData()));
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ @Override
|
||||
+ public boolean isRabid() {
|
||||
+ return getHandle().isRabid();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setRabid(boolean isRabid) {
|
||||
+ getHandle().setRabid(isRabid);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
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/EntityWolf.java b/src/main/java/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
index e8c6aca70db693250224d1c162e3c2684687ea41..e33aadead6e6c5e0a7b39ef95e7aeb0f0092a94e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
@@ -182,6 +182,12 @@ public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable
|
||||
this.updatePathfinders(false);
|
||||
return super.prepare(worldaccess, difficultydamagescaler, enummobspawn, groupdataentity, nbttagcompound);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void tame(EntityHuman entityhuman) {
|
||||
+ setCollarColor(world.purpurConfig.wolfDefaultCollarColor);
|
||||
+ super.tame(entityhuman);
|
||||
+ }
|
||||
// Purpur end
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 5a05d4e511bf7c96d3e01c59e6e53b105bf7baf6..0666c523f82b9083ed8e81570faa923bbeb00ab8 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 com.destroystokyo.paper.PaperConfig;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
+import net.minecraft.world.item.EnumColor;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -1219,12 +1220,18 @@ public class PurpurWorldConfig {
|
||||
|
||||
public boolean wolfRidable = false;
|
||||
public boolean wolfRidableInWater = false;
|
||||
+ public EnumColor wolfDefaultCollarColor = EnumColor.RED;
|
||||
public boolean wolfMilkCuresRabies = true;
|
||||
public double wolfNaturalRabid = 0.0D;
|
||||
public int wolfBreedingTicks = 6000;
|
||||
private void wolfSettings() {
|
||||
wolfRidable = getBoolean("mobs.wolf.ridable", wolfRidable);
|
||||
wolfRidableInWater = getBoolean("mobs.wolf.ridable-in-water", wolfRidableInWater);
|
||||
+ try {
|
||||
+ wolfDefaultCollarColor = EnumColor.valueOf(getString("mobs.wolf.default-collar-color", wolfDefaultCollarColor.name()));
|
||||
+ } catch (IllegalArgumentException ignore) {
|
||||
+ wolfDefaultCollarColor = EnumColor.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);
|
||||
@@ -1,38 +0,0 @@
|
||||
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/EntityPhantom.java b/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
||||
index 437d602cf4a0da52fc61a50321d795290eea11bf..fe07d9798eaae670e218d25fe23256c87c41d686 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityPhantom.java
|
||||
@@ -226,6 +226,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
|
||||
this.world.addParticle(Particles.MYCELIUM, this.locX() - (double) f2, this.locY() + (double) f4, this.locZ() - (double) f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
+ if (world.purpurConfig.phantomFlamesOnSwoop && getAttackPhase() == 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 f0f8165c51c17855d0c719d47bea194b80ff7847..c84a331c157ea1180813cba1107bf901a35b2833 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -1206,6 +1206,7 @@ public class PurpurWorldConfig {
|
||||
public boolean phantomIgnorePlayersWithTorch = false;
|
||||
public boolean phantomBurnInDaylight = true;
|
||||
public boolean phantomAllowGriefing = false;
|
||||
+ public boolean phantomFlamesOnSwoop = false;
|
||||
public double phantomMaxHealth = 20.0D;
|
||||
private void phantomSettings() {
|
||||
phantomRidable = getBoolean("mobs.phantom.ridable", phantomRidable);
|
||||
@@ -1232,6 +1233,7 @@ public class PurpurWorldConfig {
|
||||
phantomBurnInDaylight = getBoolean("mobs.phantom.burn-in-daylight", phantomBurnInDaylight);
|
||||
phantomIgnorePlayersWithTorch = getBoolean("mobs.phantom.ignore-players-with-torch", phantomIgnorePlayersWithTorch);
|
||||
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);
|
||||
@@ -1,34 +0,0 @@
|
||||
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/BlockChest.java b/src/main/java/net/minecraft/world/level/block/BlockChest.java
|
||||
index a45ee959f41e7f349ff2c309f21fa44ec671cb87..cddf8e3d34385eb264cd28ba6b4392d682df0360 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BlockChest.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BlockChest.java
|
||||
@@ -306,6 +306,7 @@ public class BlockChest extends BlockChestAbstract<TileEntityChest> implements I
|
||||
}
|
||||
|
||||
private static boolean a(IBlockAccess iblockaccess, BlockPosition blockposition) {
|
||||
+ if (iblockaccess instanceof World && ((World) iblockaccess).purpurConfig.chestOpenWithBlockOnTop) return false; // Purpur
|
||||
BlockPosition blockposition1 = blockposition.up();
|
||||
|
||||
return iblockaccess.getType(blockposition1).isOccluding(iblockaccess, blockposition1);
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index c84a331c157ea1180813cba1107bf901a35b2833..3d1cfd550b12c8dd4bd536c518ac169ff6bbfe50 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -439,6 +439,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() {
|
||||
@@ -1,211 +0,0 @@
|
||||
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/CommandDispatcher.java b/src/main/java/net/minecraft/commands/CommandDispatcher.java
|
||||
index 0ea56c863a9a1019b36f7f9f9164301aef12637b..4338b459011bf7a083790b7bb76cf1b24471fd19 100644
|
||||
--- a/src/main/java/net/minecraft/commands/CommandDispatcher.java
|
||||
+++ b/src/main/java/net/minecraft/commands/CommandDispatcher.java
|
||||
@@ -193,6 +193,7 @@ public class CommandDispatcher {
|
||||
CommandWhitelist.a(this.b);
|
||||
net.pl3x.purpur.command.DemoCommand.register(getDispatcher()); // Purpur
|
||||
net.pl3x.purpur.command.PingCommand.register(getDispatcher()); // Purpur
|
||||
+ net.pl3x.purpur.command.TPSBarCommand.register(getDispatcher()); // Purpur
|
||||
}
|
||||
|
||||
if (commanddispatcher_servertype.d) {
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 5c5da6e2be6d3a0ca2fee4e0a5510ccb15fa8020..ab49314a0b2fb70bab879be2adcf938bb43c5dcb 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -991,6 +991,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||
this.safeShutdown(flag, false);
|
||||
}
|
||||
public void safeShutdown(boolean flag, boolean isRestarting) {
|
||||
+ net.pl3x.purpur.task.TPSBarTask.stop(); // Purpur
|
||||
this.isRunning = false;
|
||||
this.isRestarting = isRestarting;
|
||||
this.hasLoggedStop = true; // Paper
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index f9a9bf683bad6957fe1e7987b83c0278ba5379f8..ee257bdbded60f6e119ce3349f75a7603ff49e8d 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -339,6 +339,8 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
||||
MinecraftServerBeans.a((MinecraftServer) this);
|
||||
}
|
||||
|
||||
+ 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 9a41d4ae2a64ba542dd9b6b98b01dd660a43b2dc..659c178684464787c73471ad960d5b37f9dbe2ec 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -597,6 +597,8 @@ public abstract class PlayerList {
|
||||
if (entityplayer.didPlayerJoinEvent) 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.isMainThread()) entityplayer.playerTick(); // 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..807f5709af7fd9497633ecfc9e932f0dfd4df231
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/pl3x/purpur/command/TPSBarCommand.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package net.pl3x.purpur.command;
|
||||
+
|
||||
+import net.minecraft.commands.CommandDispatcher;
|
||||
+import net.minecraft.commands.CommandListenerWrapper;
|
||||
+import net.minecraft.server.level.EntityPlayer;
|
||||
+import net.pl3x.purpur.task.TPSBarTask;
|
||||
+
|
||||
+public class TPSBarCommand {
|
||||
+ public static void register(com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher) {
|
||||
+ dispatcher.register(CommandDispatcher.literal("tpsbar")
|
||||
+ .requires((listener) -> {
|
||||
+ return listener.hasPermission(2);
|
||||
+ })
|
||||
+ .executes((context) -> {
|
||||
+ return execute(context.getSource(), context.getSource().getPlayerOrException());
|
||||
+ })
|
||||
+ ).setPermission("bukkit.command.tpsbar");
|
||||
+ }
|
||||
+
|
||||
+ private static int execute(CommandListenerWrapper sender, EntityPlayer 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..a9d71d2b769b8e4e0f5039e997fc5ebc1cc9bfbb
|
||||
--- /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();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user