Skip to content
This repository was archived by the owner on May 29, 2022. It is now read-only.

Bunch of patches + hopper fix #352

Merged
merged 42 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0830961
undo #74
crafter23456 Feb 19, 2022
65351cb
add SportPaper #207 Block#toLegacyData optimisation
crafter23456 Feb 19, 2022
d9a8216
add SportPaper #206 Remove the world before nullifying chunkLoader & …
crafter23456 Feb 19, 2022
af7c34e
add SportPaper #204 dont divide d14 by 0
crafter23456 Feb 19, 2022
906515f
add SportPaper #220 Use EnumMap in CraftPlayer#playEffect()
crafter23456 Feb 19, 2022
67ba4c1
add SportPaper #218 Update entity head yaw on teleport
crafter23456 Feb 19, 2022
1ee07be
add SportPaper #130 fix CraftLivingEntity#damage not calling EntityDa…
crafter23456 Feb 19, 2022
fb58656
add Migot #036 Check for lava only once per tick
crafter23456 Feb 19, 2022
8530f71
add optimize region cache - paper 1.13 backport
crafter23456 Feb 19, 2022
fa62baf
update readme
crafter23456 Feb 19, 2022
b388597
backport parts of light queue changes from 1.13
crafter23456 Feb 20, 2022
0a001e0
Paper #0178 Disable Vanilla Chunk GC in favor of Bukkits
crafter23456 Feb 20, 2022
6e842aa
Paper #0176 Auto fix bad Y levels on player login
crafter23456 Feb 20, 2022
ead58d0
Paper #0172 Incremental Auto Saving
crafter23456 Feb 20, 2022
0d70a5a
Paper Chunk registration fixes & Fix infinite loop when saving chunks
crafter23456 Feb 20, 2022
ea26cc5
Paper #0163 MC-80966 - Always send chunk sections
crafter23456 Feb 20, 2022
25c8d15
Paper Fix hopper suck in patch bug
crafter23456 Feb 20, 2022
f639d78
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity…
crafter23456 Feb 20, 2022
400bd69
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftS…
crafter23456 Feb 20, 2022
8b91923
third time to add dictionary.java...
crafter23456 Feb 24, 2022
8a12b67
im very dump
crafter23456 Feb 24, 2022
4b5d317
forth time to fix that... shall have more sleep
crafter23456 Feb 24, 2022
78d7d8d
Update NachoSpigot-Server/src/main/java/net/minecraft/server/Entity.java
crafter23456 Feb 24, 2022
97b0d13
Update NachoSpigot-Server/src/main/java/net/minecraft/server/Entity.java
crafter23456 Feb 24, 2022
e95bf40
Update NachoSpigot-Server/src/main/java/net/minecraft/server/RegionFi…
crafter23456 Feb 24, 2022
4740db6
revert kigpaper optimize damage source
crafter23456 Feb 24, 2022
8cf13c9
get away because of revert
crafter23456 Feb 24, 2022
a8a3c67
Update NachoSpigot-Server/src/main/java/net/minecraft/server/ChunkSec…
crafter23456 Feb 25, 2022
3023a79
Fix spaces
crafter23456 Feb 25, 2022
0d4f95d
Fix spaces
crafter23456 Feb 25, 2022
72ba7b8
Fix spaces
crafter23456 Feb 25, 2022
d49d5b7
Update NachoSpigot-Server/src/main/java/net/minecraft/server/WorldSer…
crafter23456 Feb 25, 2022
26b3c92
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/CraftW…
crafter23456 Feb 25, 2022
5fe0231
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity…
crafter23456 Feb 25, 2022
ed39593
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity…
crafter23456 Feb 25, 2022
853dbc1
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/entity…
crafter23456 Feb 25, 2022
a64aef0
Update NachoSpigot-Server/src/main/java/com/destroystokyo/paper/Paper…
crafter23456 Feb 25, 2022
09bfcc0
Update NachoSpigot-Server/src/main/java/net/minecraft/server/EntityPl…
crafter23456 Feb 25, 2022
60daec5
Update NachoSpigot-Server/src/main/java/net/minecraft/server/Minecraf…
crafter23456 Feb 25, 2022
82562a1
Update NachoSpigot-Server/src/main/java/net/minecraft/server/RegionFi…
crafter23456 Feb 25, 2022
57ed16f
Update NachoSpigot-Server/src/main/java/net/minecraft/server/World.java
crafter23456 Feb 25, 2022
fc32a46
Update NachoSpigot-Server/src/main/java/net/minecraft/server/RegionFi…
crafter23456 Feb 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NachoSpigot-Server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.68.Final</version>
<version>4.1.74.Final</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,5 @@ private void portalSearchRadius()
{
portalSearchRadius = getInt("portal-search-radius", 128);
}
public boolean queueLightUpdates = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.cobblesword.nachospigot.commons;

import net.minecraft.server.EnumParticle;
import org.bukkit.Effect;

import java.util.EnumMap;

public class Dictionary {
public static final EnumMap<Effect, EnumParticle> EFFECT_TO_PARTICLE = new EnumMap<>(Effect.class);

static {
String tmp;
for (EnumParticle p : EnumParticle.values()) {
tmp = p.b().replace("_", "");
for (Effect e : Effect.values()) {
// This is pretty much the original code, but we only call it once / effect & matching particle
if (e.getName() != null && e.getName().startsWith(tmp)) {
EFFECT_TO_PARTICLE.put(e, p);
break;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,7 @@ public IBlockData fromLegacyData(int i) {
}

public int toLegacyData(IBlockData iblockdata) {
if (iblockdata != null && !iblockdata.a().isEmpty()) {
throw new IllegalArgumentException("Don\'t know how to convert " + iblockdata + " back into data...");
} else {
return 0;
}
return 0; // Sportpaper - optimize toLegacyData removing unneeded sanity checks
}

public IBlockData updateState(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) {
Expand Down
33 changes: 14 additions & 19 deletions NachoSpigot-Server/src/main/java/net/minecraft/server/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ private void d(int i, int j) {
this.g[i + j * 16] = true;
this.k = true;
}

private void recheckGaps(boolean flag) { h(flag); } // Paper

private void h(boolean flag) {
this.world.methodProfiler.a("recheckGaps");
Expand Down Expand Up @@ -1158,7 +1160,7 @@ public <T extends Entity> void a(Class<? extends T> oclass, AxisAlignedBB axisal

// PaperSpigot start
int[] counts;
if (ItemStack.class.isAssignableFrom(oclass)) {
if (EntityItem.class.isAssignableFrom(oclass)) {
counts = itemCounts;
} else if (IInventory.class.isAssignableFrom(oclass)) {
counts = inventoryEntityCounts;
Expand Down Expand Up @@ -1280,10 +1282,20 @@ public BlockPosition h(BlockPosition blockposition) {

return new BlockPosition(blockposition.getX(), this.f[k], blockposition.getZ());
}

// Paper start
private boolean shouldRecheckGaps = false;
public void doGapCheck() {
if (shouldRecheckGaps) {
this.recheckGaps(false);
shouldRecheckGaps = false;
}
}
// Paper end

public void b(boolean flag) {
if (this.k && !this.world.worldProvider.o() && !flag) {
this.recheckGaps(this.world.isClientSide); // PaperSpigot - Asynchronous lighting updates
shouldRecheckGaps = true; // Paper
}

this.p = true;
Expand All @@ -1304,23 +1316,6 @@ public void b(boolean flag) {

}

/**
* PaperSpigot - Recheck gaps asynchronously.
*/
public void recheckGaps(final boolean isClientSide) {
if (!world.paperSpigotConfig.useAsyncLighting) {
this.h(isClientSide);
return;
}

world.lightingExecutor.submit(new Runnable() {
@Override
public void run() {
Chunk.this.h(isClientSide);
}
});
}

public boolean isReady() {
// Spigot Start
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public void b() {
if (this.c()) {
continue;
}
break; // Paper - fix infinite loop when saving chunks
}
} finally {
this.e = false;
Expand Down Expand Up @@ -296,10 +297,6 @@ private void a(Chunk chunk, World world, NBTTagCompound nbttagcompound) {
nbttagcompound1 = new NBTTagCompound();
tileentity.b(nbttagcompound1);
nbttaglist2.add(nbttagcompound1);

if(tileentity instanceof TileEntityHopper) {
Arrays.fill(((TileEntityHopper) tileentity).items, null);
}
}

nbttagcompound.set("TileEntities", nbttaglist2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public int c(int i, int j, int k) {
}

public boolean a() {
return this.nonEmptyBlockCount == 0;
//return this.nonEmptyBlockCount == 0;
// Paper - MC-80966
// Even if there are no blocks, there may be other information associated with the chunk, always send it.
return false;
}

public boolean shouldTick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ public synchronized void setSeed(long seed) {
public void inactiveTick() { }
// Spigot end

// Migot start
private boolean isInLava;
private int lastLavaCheck = Integer.MIN_VALUE;
// Migot end

public int getId() {
return this.id;
}
Expand Down Expand Up @@ -1070,7 +1075,15 @@ public boolean a(Material material) {
}

public boolean ab() {
return this.world.a(this.getBoundingBox().grow(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA);
// Migot start - Check for lava only once per tick
// return this.world.a(this.getBoundingBox().grow(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA);
int currentTick = MinecraftServer.currentTick;
if (this.lastLavaCheck != currentTick) {
this.lastLavaCheck = currentTick;
this.isInLava = this.world.a(this.getBoundingBox().grow(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA);
}
return this.isInLava;
// Migot end
}

public void a(float f, float f1, float f2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public void a(NBTTagCompound nbttagcompound) {
this.playerInteractManager.setGameMode(WorldSettings.EnumGamemode.getById(nbttagcompound.getInt("playerGameType")));
}
}


if (this.locY > 300) this.locY = 200;
this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,11 @@ protected void A() throws ExceptionWorldConflict { // CraftBukkit - added throws
this.r.b().a(agameprofile);
}

if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
if (autosavePeriod > 0 /*&& this.ticks % autosavePeriod == 0*/) { // CraftBukkit // Paper - Incremental Auto Saving
SpigotTimings.worldSaveTimer.startTiming(); // Spigot
this.methodProfiler.a("save");
this.playerList.savePlayers(); // Nacho - deobfuscate playerList
//this.playerList.savePlayers(); // Nacho - deobfuscate playerList
if (this.ticks % autosavePeriod == 0) this.playerList.savePlayers(); // Paper - Incremental Auto Saving
// Spigot Start
// We replace this with saving each individual world as this.saveChunks(...) is broken,
// and causes the main thread to sleep for random amounts of time depending on chunk activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public class RegionFileCache {
public static final Map<File, RegionFile> a = Maps.newHashMap(); // Spigot - private -> public

// PaperSpigot start
public static synchronized RegionFile a(File file, int i, int j) {
public static /*synchronized*/ RegionFile a(File file, int i, int j) {// Paper 1.13 Backport - remove synchronization
return a(file, i, j, true);
}
public static synchronized RegionFile a(File file, int i, int j, boolean create) {
public static /*synchronized*/ RegionFile a(File file, int i, int j, boolean create) {// Paper 1.13 Backport - remove synchronization
// PaperSpigot end
File file1 = new File(file, "region");
File file2 = new File(file1, "r." + (i >> 5) + "." + (j >> 5) + ".mca");
Expand All @@ -41,7 +41,7 @@ public static synchronized RegionFile a(File file, int i, int j, boolean create)
}
}

public static synchronized void a() {
public static /*synchronized*/ void a() { // Paper - remove synchronization
Iterator iterator = RegionFileCache.a.values().iterator();

while (iterator.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,8 @@ public void entityJoinedWorld(Entity entity, boolean flag) {
}

int k = MathHelper.floor(entity.locX / 16.0D);
int l = MathHelper.floor(entity.locY / 16.0D);
//int l = MathHelper.floor(entity.locY / 16.0D);
int l = Math.min(15, Math.max(0, MathHelper.floor(entity.locY / 16.0D))); // Paper - stay consistent with chunk add/remove behavior
int i1 = MathHelper.floor(entity.locZ / 16.0D);

// Nacho start - deobfuscate chunkX, chunkY, chunkZ removeEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,13 +962,15 @@ public void save(boolean flag, IProgressUpdate iprogressupdate) throws Exception

this.chunkProvider.saveChunks(flag, iprogressupdate);
// CraftBukkit - ArrayList -> Collection
Collection<Chunk> arraylist = this.chunkProviderServer.a();
/* //Paper start Collection<Chunk> arraylist = this.chunkProviderServer.a();

for (Chunk value : arraylist) {
if (value != null && !this.manager.a(value.locX, value.locZ)) {
this.chunkProviderServer.queueUnload(value.locX, value.locZ);
}
}
*/
// Paper end

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,10 @@ public boolean unloadWorld(World world, boolean save) {
if (e.isCancelled()) {
return false;
}


worlds.remove(world.getName().toLowerCase());
console.worlds.remove(handle);

if (save) {
try {
handle.save(true, null);
Expand All @@ -1064,9 +1067,6 @@ public boolean unloadWorld(World world, boolean save) {
chunkProviderServer.chunks.clear();
}

worlds.remove(world.getName().toLowerCase());
console.worlds.remove(handle);

// KigPaper start - fix memory leak
CraftingManager craftingManager = CraftingManager.getInstance();
CraftInventoryView lastView = (CraftInventoryView) craftingManager.lastCraftView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.UUID;

import dev.cobblesword.nachospigot.commons.Constants;
import dev.cobblesword.nachospigot.commons.Dictionary;
import me.elier.nachospigot.config.NachoConfig;
import net.minecraft.server.*;

Expand Down Expand Up @@ -60,7 +61,6 @@
import org.bukkit.util.Vector;

import net.jafama.FastMath;
import me.elier.nachospigot.config.NachoConfig;

public class CraftWorld implements World {
public static final int CUSTOM_DIMENSION_OFFSET = 10;
Expand Down Expand Up @@ -1465,25 +1465,17 @@ public void playEffect( Location location, Effect effect, int id, int data, floa
} else
{
net.minecraft.server.EnumParticle particle = null;
int[] extra = null;
for ( net.minecraft.server.EnumParticle p : net.minecraft.server.EnumParticle.values() )
{
if ( effect.getName().startsWith( p.b().replace("_", "") ) )
{
particle = p;
if ( effect.getData() != null )
{
if ( effect.getData().equals( org.bukkit.Material.class ) )
{
extra = new int[]{ id };
} else
{
extra = new int[]{ (data << 12) | (id & 0xFFF) };
}
}
break;
}
int[] extra = null;
if ((particle = Dictionary.EFFECT_TO_PARTICLE.get(effect)) != null) {
if ( effect.getData() != null ) {
if ( effect.getData().equals( org.bukkit.Material.class ) ) {
extra = new int[]{ id };
} else {
extra = new int[]{ (data << 12) | (id & 0xFFF) };
}
}
}

if ( extra == null )
{
extra = Constants.EMPTY_ARRAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public boolean teleport(Location location, TeleportCause cause) {
// entity.world = ((CraftWorld) location.getWorld()).getHandle();
// Spigot end
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
entity.f(location.getYaw()); // KigPaper - update head yaw to keep consistency with /tp
entity.world.entityJoinedWorld(entity, false); // PaperSpigot - Fix issues with entities not being switched to their new chunk
// entity.setLocation() throws no event, and so cannot be cancelled
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import me.elier.nachospigot.config.NachoConfig;
import net.md_5.bungee.api.chat.BaseComponent;
import dev.cobblesword.nachospigot.commons.Dictionary;

import net.minecraft.server.*;
import net.minecraft.server.PacketPlayOutTitle.EnumTitleAction;
Expand Down Expand Up @@ -1532,22 +1533,16 @@ public void playEffect( Location location, Effect effect, int id, int data, floa
{
net.minecraft.server.EnumParticle particle = null;
int[] extra = null;
for ( net.minecraft.server.EnumParticle p : net.minecraft.server.EnumParticle.values() )
{
if ( effect.getName().startsWith( p.b().replace("_", "") ) )
if ((particle = Dictionary.EFFECT_TO_PARTICLE.get(effect)) != null) {
if ( effect.getData() != null )
{
particle = p;
if ( effect.getData() != null )
if ( effect.getData().equals( Material.class ) )
{
extra = new int[]{ id };
} else
{
if ( effect.getData().equals( org.bukkit.Material.class ) )
{
extra = new int[]{ id };
} else
{
extra = new int[]{ (data << 12) | (id & 0xFFF) };
}
extra = new int[]{ (data << 12) | (id & 0xFFF) };
}
break;
}
}
if ( extra == null )
Expand Down
Loading