some minehq patches

This commit is contained in:
Beaness 2022-07-31 17:04:47 +02:00
parent b498c50b2d
commit 23e68a05f9
17 changed files with 43 additions and 31 deletions

View File

@ -104,7 +104,7 @@ public class eSpigotConfig
public static boolean fixBouncingArrows; public static boolean fixBouncingArrows;
private static void fixBouncingArrows() private static void fixBouncingArrows()
{ {
mobAI = getBoolean( "settings.fix-bouncing-arrows", true ); fixBouncingArrows = getBoolean( "settings.fix-bouncing-arrows", true );
} }
public static boolean obfuscatePlayerHealth; public static boolean obfuscatePlayerHealth;

View File

@ -65,15 +65,15 @@ public class BlockOre extends Block {
int j = 0; int j = 0;
if (this == Blocks.COAL_ORE) { if (this == Blocks.COAL_ORE) {
j = MathHelper.nextInt(world.random, 0, 2); j = MathHelper.nextInt(world.random, 0, 2 * (j + 1)); // Kohi - boosted
} else if (this == Blocks.DIAMOND_ORE) { } else if (this == Blocks.DIAMOND_ORE) {
j = MathHelper.nextInt(world.random, 3, 7); j = MathHelper.nextInt(world.random, 3, 7 * (j + 1)); // Kohi - boosted
} else if (this == Blocks.EMERALD_ORE) { } else if (this == Blocks.EMERALD_ORE) {
j = MathHelper.nextInt(world.random, 3, 7); j = MathHelper.nextInt(world.random, 3, 7 * (j + 1)); // Kohi - boosted
} else if (this == Blocks.LAPIS_ORE) { } else if (this == Blocks.LAPIS_ORE) {
j = MathHelper.nextInt(world.random, 2, 5); j = MathHelper.nextInt(world.random, 2, 5 * (j + 1)); // Kohi - boosted
} else if (this == Blocks.QUARTZ_ORE) { } else if (this == Blocks.QUARTZ_ORE) {
j = MathHelper.nextInt(world.random, 2, 5); j = MathHelper.nextInt(world.random, 2, 5 * (j + 1)); // Kohi - boosted
} }
return j; return j;

View File

@ -10,6 +10,7 @@ public class DispenseBehaviorItem implements IDispenseBehavior {
public DispenseBehaviorItem() {} public DispenseBehaviorItem() {}
public final ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { public final ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
if (itemstack != null && itemstack.count < 0) itemstack.count = 0; // EMC
ItemStack itemstack1 = this.b(isourceblock, itemstack); ItemStack itemstack1 = this.b(isourceblock, itemstack);
this.a(isourceblock); this.a(isourceblock);

View File

@ -62,7 +62,7 @@ public abstract class EntityAgeable extends EntityCreature {
if (!entityhuman.abilities.canInstantlyBuild) { if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count; --itemstack.count;
if (itemstack.count == 0) { // CraftBukkit - allow less than 0 stacks as "infinite" if (itemstack.count <= 0) { // EMC
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null); entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
} }
} }

View File

@ -639,7 +639,7 @@ public class EntityHorse extends EntityAnimal implements IInventoryListener {
} }
if (flag) { if (flag) {
if (!entityhuman.abilities.canInstantlyBuild && --itemstack.count == 0) { if (!entityhuman.abilities.canInstantlyBuild && --itemstack.count <= 0) { // EMC
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null); entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
} }

View File

@ -601,7 +601,7 @@ public abstract class EntityHuman extends EntityLiving {
public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) { public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) {
if (itemstack == null) { if (itemstack == null) {
return null; return null;
} else if (itemstack.count == 0) { } else if (itemstack.count <= 0) { // EMC
return null; return null;
} else { } else {
double d0 = this.locY - 0.30000001192092896D + (double) this.getHeadHeight(); double d0 = this.locY - 0.30000001192092896D + (double) this.getHeadHeight();

View File

@ -434,6 +434,13 @@ public abstract class EntityInsentient extends EntityLiving {
return true; return true;
} }
// Kohi start - check for despawn on inactive ticks
public void inactiveTick() {
super.inactiveTick();
this.w();
}
// Kohi end
protected void D() { protected void D() {
if (this.persistent) { if (this.persistent) {
this.ticksFarFromPlayer = 0; this.ticksFarFromPlayer = 0;
@ -450,7 +457,9 @@ public abstract class EntityInsentient extends EntityLiving {
this.die(); this.die();
} }
if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d3 > this.world.paperSpigotConfig.softDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // PaperSpigot - custom despawn distance // Kohi - decrease random check to account for decreased interval
// MineHQ - decrease random check even more for performance
if (this.ticksFarFromPlayer > 600 && this.random.nextInt(10) == 0 && d3 > this.world.paperSpigotConfig.softDespawnDistance) { // CraftBukkit - remove isTypeNotPersistent() check // PaperSpigot - custom despawn distance
this.die(); this.die();
} else if (d3 < this.world.paperSpigotConfig.softDespawnDistance) { // PaperSpigot - custom despawn distances } else if (d3 < this.world.paperSpigotConfig.softDespawnDistance) { // PaperSpigot - custom despawn distances
this.ticksFarFromPlayer = 0; this.ticksFarFromPlayer = 0;

View File

@ -138,7 +138,7 @@ public class EntityTrackerEntry {
} }
// CraftBukkit end // CraftBukkit end
if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.v <= 400 && !this.x && this.y == this.tracker.onGround) { if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.v <= 100 && !this.x && this.y == this.tracker.onGround) { // Kohi - greatly reduce forced teleport interval - 400 -> 100
if ((!flag || !flag1) && !(this.tracker instanceof EntityArrow)) { if ((!flag || !flag1) && !(this.tracker instanceof EntityArrow)) {
if (flag) { if (flag) {
object = new PacketPlayOutEntity.PacketPlayOutRelEntityMove(this.tracker.getId(), (byte) j1, (byte) k1, (byte) l1, this.tracker.onGround); object = new PacketPlayOutEntity.PacketPlayOutRelEntityMove(this.tracker.getId(), (byte) j1, (byte) k1, (byte) l1, this.tracker.onGround);

View File

@ -49,7 +49,7 @@ public class EntityZombie extends EntityMonster {
protected void initAttributes() { protected void initAttributes() {
super.initAttributes(); super.initAttributes();
this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(35.0D); this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(16.0D); // Kohi - change follow range from 35.0 to 16.0 for performance
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D); this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D);
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(3.0D); this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(3.0D);
this.getAttributeMap().b(EntityZombie.a).setValue(this.random.nextDouble() * 0.10000000149011612D); this.getAttributeMap().b(EntityZombie.a).setValue(this.random.nextDouble() * 0.10000000149011612D);

View File

@ -76,6 +76,7 @@ public final class ItemStack {
ItemStack itemstack = new ItemStack(); ItemStack itemstack = new ItemStack();
itemstack.c(nbttagcompound); itemstack.c(nbttagcompound);
if (itemstack.count < 0) itemstack.count = 0; // EMC
return itemstack.getItem() != null ? itemstack : null; return itemstack.getItem() != null ? itemstack : null;
} }

View File

@ -78,7 +78,7 @@ public class LoginListener implements PacketLoginInListener, IUpdatePlayerListBo
public void disconnect(String s) { public void disconnect(String s) {
try { try {
LoginListener.c.info("Disconnecting " + this.d() + ": " + s); LoginListener.c.info("Disconnecting " + this.i.getName() + ": " + s);
ChatComponentText chatcomponenttext = new ChatComponentText(s); ChatComponentText chatcomponenttext = new ChatComponentText(s);
this.networkManager.handle(new PacketLoginOutDisconnect(chatcomponenttext)); this.networkManager.handle(new PacketLoginOutDisconnect(chatcomponenttext));
@ -162,7 +162,7 @@ public class LoginListener implements PacketLoginInListener, IUpdatePlayerListBo
} }
public void a(IChatBaseComponent ichatbasecomponent) { public void a(IChatBaseComponent ichatbasecomponent) {
LoginListener.c.info(this.d() + " lost connection: " + ichatbasecomponent.c()); LoginListener.c.info((this.i != null ? this.i.getName() : this.networkManager.getSocketAddress()) + " lost connection: " + ichatbasecomponent.c());
} }
public String d() { public String d() {
@ -317,7 +317,7 @@ public class LoginListener implements PacketLoginInListener, IUpdatePlayerListBo
} }
} }
// CraftBukkit end // CraftBukkit end
LoginListener.c.info("UUID of player " + LoginListener.this.i.getName() + " is " + LoginListener.this.i.getId()); // LoginListener.c.info("UUID of player " + LoginListener.this.i.getName() + " is " + LoginListener.this.i.getId());
LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT; LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
} }
} }

View File

@ -463,8 +463,9 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2); this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2);
if (!this.player.noclip) { if (!this.player.noclip) {
boolean flag2 = worldserver.getCubes(this.player, this.player.getBoundingBox().shrink(f4, f4, f4)).isEmpty(); boolean flag2 = worldserver.getCubes(this.player, this.player.getBoundingBox().shrink(f4, f4, f4)).isEmpty();
boolean rayTraceCollision = delta > 0.3 && worldserver.rayTrace(new Vec3D(this.o, this.p + 1.0, this.q), new Vec3D(d1, d2 + 1.0, d3), false, true, false) != null;
if (flag && (flag1 || !flag2) && !this.player.isSleeping()) { if (flag && (flag1 || !flag2 || rayTraceCollision) && !this.player.isSleeping()) {
this.a(this.o, this.p, this.q, f2, f3); this.a(this.o, this.p, this.q, f2, f3);
return; return;
} }
@ -822,7 +823,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
} }
itemstack = this.player.inventory.getItemInHand(); itemstack = this.player.inventory.getItemInHand();
if (itemstack != null && itemstack.count == 0) { if (itemstack != null && itemstack.count <= 0) { // EMC
this.player.inventory.items[this.player.inventory.itemInHandIndex] = null; this.player.inventory.items[this.player.inventory.itemInHandIndex] = null;
itemstack = null; itemstack = null;
always = true; // KigPaper - send update packet always = true; // KigPaper - send update packet

View File

@ -390,7 +390,7 @@ public class PlayerInteractManager {
} }
} }
if (itemstack1.count == 0) { if (itemstack1.count <= 0) { // EMC
entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = null; entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = null;
} }

View File

@ -197,7 +197,7 @@ public abstract class PlayerList {
} }
// CraftBukkit - Moved from above, added world // CraftBukkit - Moved from above, added world
PlayerList.f.info(entityplayer.getName() + "[" + s1 + "] logged in with entity id " + entityplayer.getId() + " at ([" + entityplayer.world.worldData.getName() + "]" + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); PlayerList.f.info(entityplayer.getName() + " logged in at (" + entityplayer.world.worldData.getName() + ", " + String.format("%.1f", entityplayer.locX) + ", " + String.format("%.1f", entityplayer.locY) + ", " + String.format("%.1f", entityplayer.locZ) + ")");
} }
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {

View File

@ -52,6 +52,7 @@ public class Slot {
} }
public void set(ItemStack itemstack) { public void set(ItemStack itemstack) {
if (itemstack != null && itemstack.count < 0) itemstack.count = 0; // EMC
this.inventory.setItem(this.index, itemstack); this.inventory.setItem(this.index, itemstack);
this.f(); this.f();
} }

View File

@ -100,6 +100,7 @@ public class TileEntityDispenser extends TileEntityContainer implements IInvento
public void setItem(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
this.items[i] = itemstack; this.items[i] = itemstack;
if (itemstack != null && itemstack.count < 0) itemstack.count = 0; // EMC
if (itemstack != null && itemstack.count > this.getMaxStackSize()) { if (itemstack != null && itemstack.count > this.getMaxStackSize()) {
itemstack.count = this.getMaxStackSize(); itemstack.count = this.getMaxStackSize();
} }

View File

@ -3236,20 +3236,19 @@ public abstract class World implements IBlockAccess {
double d4 = -1.0D; double d4 = -1.0D;
EntityHuman entityhuman = null; EntityHuman entityhuman = null;
for (EntityHuman player : this.players) { for (EntityHuman player : a(EntityHuman.class, AxisAlignedBB.a(d0 - d3, d1 - d3, d2 - d3, d0 + d3, d1 + d3, d2 + d3))) {
EntityHuman entityhuman1 = player;
// CraftBukkit start - Fixed an NPE // CraftBukkit start - Fixed an NPE
if (entityhuman1 == null || !entityhuman1.ad()) { // CraftBukkit allow for more complex logic by using the "is alive" method if (player == null || !player.ad()) { // CraftBukkit allow for more complex logic by using the "is alive" method
continue; continue;
} }
// CraftBukkit end // CraftBukkit end
if (IEntitySelector.d.apply(entityhuman1)) { if (IEntitySelector.d.apply(player)) {
double d5 = entityhuman1.e(d0, d1, d2); double d5 = player.e(d0, d1, d2);
if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) { if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) {
d4 = d5; d4 = d5;
entityhuman = entityhuman1; entityhuman = player;
} }
} }
} }
@ -3282,20 +3281,19 @@ public abstract class World implements IBlockAccess {
double d4 = -1.0D; double d4 = -1.0D;
EntityHuman entityhuman = null; EntityHuman entityhuman = null;
for (EntityHuman player : this.players) { for (EntityHuman player : a(EntityHuman.class, AxisAlignedBB.a(d0 - d3, d1 - d3, d2 - d3, d0 + d3, d1 + d3, d2 + d3))) {
EntityHuman entityhuman1 = player;
// CraftBukkit start - Fixed an NPE // CraftBukkit start - Fixed an NPE
if (entityhuman1 == null || !entityhuman1.ad() || !entityhuman1.affectsSpawning) { // CraftBukkit allow for more complex logic by using the "is alive" method if (player == null || !player.ad() || !player.affectsSpawning) { // CraftBukkit allow for more complex logic by using the "is alive" method
continue; continue;
} }
// CraftBukkit end // CraftBukkit end
if (IEntitySelector.d.apply(entityhuman1)) { if (IEntitySelector.d.apply(player)) {
double d5 = entityhuman1.e(d0, d1, d2); double d5 = player.e(d0, d1, d2);
if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) { if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) {
d4 = d5; d4 = d5;
entityhuman = entityhuman1; entityhuman = player;
} }
} }
} }