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

Few little optimisations #365

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2c2e703
remove unneeded boat interaction event
crafter23456 Feb 27, 2022
36fb0ae
Use Vanilla Minecart Speeds + comment fixes
crafter23456 Feb 28, 2022
beb221c
few things
crafter23456 Feb 28, 2022
c6d2600
Update NachoSpigot-Server/src/main/java/net/minecraft/server/Minecraf…
crafter23456 Feb 28, 2022
636e7b6
Update NachoSpigot-Server/pom.xml
crafter23456 Feb 28, 2022
dc6731b
Update NachoSpigot-Server/src/main/java/net/minecraft/server/ChunkPro…
crafter23456 Feb 28, 2022
4ff4644
Update NachoSpigot-Server/src/main/java/net/minecraft/server/TileEnti…
crafter23456 Feb 28, 2022
4f0f4af
Update pom.xml
crafter23456 Feb 28, 2022
961820d
Update pom.xml
crafter23456 Feb 28, 2022
38cbe6e
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/block/…
crafter23456 Feb 28, 2022
e2cda97
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/block/…
crafter23456 Feb 28, 2022
392058d
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/block/…
crafter23456 Feb 28, 2022
c58cf15
Update NachoSpigot-Server/src/main/java/org/bukkit/craftbukkit/block/…
crafter23456 Mar 1, 2022
7c8bf14
fix compiling
crafter23456 Mar 1, 2022
23c4925
Update pom.xml
Mar 2, 2022
ef37ae2
Merge branch 'CobbleSword:master' into patch-1
Mar 2, 2022
c97f630
Merge pull request #2 from Elierrr/patch-1
crafter23456 Mar 2, 2022
7864b34
Update pom.xml
Mar 2, 2022
1e23b17
Update pom.xml
Mar 2, 2022
25937e7
Merge pull request #3 from Elierrr/patch-1
crafter23456 Mar 2, 2022
85145b4
revert "unneeded boat event trigger"
crafter23456 Mar 2, 2022
41fdd06
missed that
crafter23456 Mar 2, 2022
209f4fd
Update README.md
crafter23456 Mar 2, 2022
b1f7f2a
revert things, update things
crafter23456 Mar 26, 2022
3b418fc
update paper repository link
crafter23456 Apr 19, 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
5 changes: 2 additions & 3 deletions NachoSpigot-API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.avaje</groupId>
Expand Down Expand Up @@ -83,7 +83,7 @@
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>3.21.0</version>
<version>3.21.2</version>
</dependency>
<!-- Kyori api -->
<!-- https://mvnrepository.com/artifact/net.kyori/adventure-api -->
Expand All @@ -92,7 +92,6 @@
<artifactId>adventure-key</artifactId>
<version>4.9.3</version>
</dependency>

<!-- testing -->
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
<dependency>
<groupId>junit</groupId>
Expand Down
39 changes: 11 additions & 28 deletions NachoSpigot-Server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.5.6</version>
<version>8.5.8</version>
</dependency>
<dependency>
<groupId>net.jafama</groupId>
Expand All @@ -69,7 +69,7 @@
<dependency>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
<version>3.2</version>
<version>5.0.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
Expand Down Expand Up @@ -100,23 +100,6 @@
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.17.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-iostreams</artifactId>
<version>2.17.1</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to remove these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say. Paper only use the log4j core and the other thing I don't remember currently but we have that too. And my anticheat has a fix for log4j which only activates if the server didn't done it before. Isn't a 100% trust but if paper do it, I guess

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it would be safe, I don't think it's recommended to combine multiple versions of a library.
IMO, this should be reverted. There's no reason for this.

</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -169,8 +152,8 @@
<url>https://maven.elmakers.com/repository/</url>
</repository>
<repository>
<id>velocity-repo</id>
<url>https://repo.velocitypowered.com/snapshots/</url>
<id>velocity</id>
<url>https://nexus.velocitypowered.com/repository/maven-public/</url>
</repository>
</repositories>

Expand All @@ -180,26 +163,26 @@
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>com.lukegb.mojo</groupId>
<artifactId>gitdescribe-maven-plugin</artifactId>
<version>1.3</version>
<groupId>net.md-5</groupId>
<artifactId>scriptus</artifactId>
<version>0.4</version>
<configuration>
<outputPrefix>git-NachoSpigot-</outputPrefix>
<scmDirectory>..</scmDirectory>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<phase>initialize</phase>
<goals>
<goal>gitdescribe</goal>
<goal>describe</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<version>3.2.2</version>
<configuration>
<finalName>NachoSpigot</finalName>
<forceCreation>true</forceCreation> <!-- Required to prevent shading the jar multiple times -->
Expand Down Expand Up @@ -312,7 +295,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.10.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public String a(T t0) {

// TacoSpigot start
@Override
public int
getValueId(T value) {
public int getValueId(T value) {
return value.ordinal();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class DataWatcher {
// TacoSpigot end
// Spigot End
private boolean e;
// private ReadWriteLock f = new ReentrantReadWriteLock(); // Spigot - Remove DataWatcher Locking
//private ReadWriteLock f = new ReentrantReadWriteLock(); // Spigot - Remove DataWatcher Locking
boolean registrationLocked; // Spigot

public DataWatcher(Entity entity) {
Expand All @@ -50,9 +50,9 @@ public <T> void a(int i, T t0) {
} else {
DataWatcher.WatchableObject datawatcher_watchableobject = new DataWatcher.WatchableObject(integer, i, t0); // Spigot

// this.f.writeLock().lock(); // Spigot - not required
//this.f.writeLock().lock(); // Spigot - not required
this.dataValues.put(i, datawatcher_watchableobject); // Spigot
// this.f.writeLock().unlock(); // Spigot - not required
//this.f.writeLock().unlock(); // Spigot - not required
this.b = false;
}
}
Expand Down Expand Up @@ -109,8 +109,8 @@ private DataWatcher.WatchableObject j(int i) {

this.f.readLock().unlock();
return datawatcher_watchableobject;
*/

*/
return (WatchableObject) this.dataValues.get(i);
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public List<DataWatcher.WatchableObject> b() {
ArrayList arraylist = null;

if (this.e) {
// this.f.readLock().lock(); // Spigot - not required
//this.f.readLock().lock(); // Spigot - not required
Iterator iterator = this.dataValues.values().iterator(); // Spigot // TacoSpigot

while (iterator.hasNext()) {
Expand All @@ -169,7 +169,7 @@ public List<DataWatcher.WatchableObject> b() {
arraylist = Lists.newArrayList();
}

// Spigot start - copy ItemStacks to prevent ConcurrentModificationExceptions
// Spigot start - copy ItemStacks to prevent ConcurrentModificationExceptions
if ( datawatcher_watchableobject.b() instanceof ItemStack )
{
datawatcher_watchableobject = new WatchableObject(
Expand All @@ -184,15 +184,15 @@ public List<DataWatcher.WatchableObject> b() {
}
}

// this.f.readLock().unlock(); // Spigot - not required
//this.f.readLock().unlock(); // Spigot - not required
}

this.e = false;
return arraylist;
}

public void a(PacketDataSerializer serializer) throws IOException {
// this.f.readLock().lock(); // Spigot - not required
//this.f.readLock().lock(); // Spigot - not required
Iterator iterator = this.dataValues.values().iterator(); // Spigot // TacoSpigot

while (iterator.hasNext()) {
Expand All @@ -201,14 +201,14 @@ public void a(PacketDataSerializer serializer) throws IOException {
a(serializer, datawatcher_watchableobject);
}

// this.f.readLock().unlock(); // Spigot - not required
//this.f.readLock().unlock(); // Spigot - not required
serializer.writeByte(127);
}

public List<DataWatcher.WatchableObject> c() {
ArrayList arraylist = Lists.newArrayList(); // Spigot

// this.f.readLock().lock(); // Spigot - not required
//this.f.readLock().lock(); // Spigot - not required

arraylist.addAll(this.dataValues.values()); // Spigot // TacoSpigot
// Spigot start - copy ItemStacks to prevent ConcurrentModificationExceptions
Expand All @@ -227,7 +227,7 @@ public List<DataWatcher.WatchableObject> c() {
}
// Spigot end

// this.f.readLock().unlock(); // Spigot - not required
//this.f.readLock().unlock(); // Spigot - not required
return arraylist;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public abstract class EntityMinecartAbstract extends Entity implements INamableT
private double derailedX = 0.5;
private double derailedY = 0.5;
private double derailedZ = 0.5;
private double flyingX = 0.95;
private double flyingY = 0.95;
private double flyingZ = 0.95;
private double flyingX = 0.949999988079071D; // Paper - restore vanilla precision
private double flyingY = 0.949999988079071D; // Paper - restore vanilla precision
private double flyingZ = 0.949999988079071D; // Paper - restore vanilla precision
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
public double maxSpeed = 0.4D;
// CraftBukkit end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
float f8 = f3 * f5;
double d3 = 5.0D;
Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
MovingObjectPosition movingobjectposition = world.rayTrace(vec3d, vec3d1, true);
MovingObjectPosition movingobjectpositionblock = world.rayTrace(vec3d, vec3d1, true);

if (movingobjectposition == null) {
if (movingobjectpositionblock == null) {
return itemstack;
} else {
Vec3D vec3d2 = entityhuman.d(f);
Expand All @@ -51,23 +51,24 @@ public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
if (flag) {
return itemstack;
} else {
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
BlockPosition blockposition = movingobjectposition.a();
if (movingobjectpositionblock.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) {

BlockPosition blockposition = movingobjectpositionblock.a();
/* Paper - Remove unneeded interaction event trigger
Sculas marked this conversation as resolved.
Show resolved Hide resolved
// CraftBukkit start - Boat placement
org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectposition.direction, itemstack);

if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
*/ // Paper - Remove unneeded interaction event trigger

if (world.getType(blockposition).getBlock() == Blocks.SNOW_LAYER) {
blockposition = blockposition.down();
}

EntityBoat entityboat = new EntityBoat(world, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 1.0F), (double) ((float) blockposition.getZ() + 0.5F));

entityboat.yaw = (float) (((MathHelper.floor((double) (entityhuman.yaw * 4.0F / 360.0F) + 0.5D) & 3) - 1) * 90);
if (!world.getCubes(entityboat, entityboat.getBoundingBox().grow(-0.1D, -0.1D, -0.1D)).isEmpty()) {
return itemstack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,10 @@ public void B() {

SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
// Send time updates to everyone, it will get the right time from the world the player is in.
// Paper start - optimize time updates
int i;

// Paper start - optimize time updates
/*
if ((this.ticks % 20) == 0)
{
for (i = 0; i < this.worlds.size(); ++i) {
Expand All @@ -834,7 +835,26 @@ public void B() {
}
}
}
} */
for (i = 0; i < this.worlds.size(); ++i) { // Nacho
final WorldServer world = this.worlds.get(i); // Nacho
final boolean doDaylight = world.getGameRules().getBoolean("doDaylightCycle");
final long dayTime = world.getDayTime();
long worldTime = world.getTime();
final PacketPlayOutUpdateTime worldPacket = new PacketPlayOutUpdateTime(worldTime, dayTime, doDaylight);
for (EntityHuman entityhuman : world.players) {
if (!(entityhuman instanceof EntityPlayer) || (ticks + entityhuman.getId()) % 20 != 0) {
continue;
}
EntityPlayer entityplayer = (EntityPlayer) entityhuman;
long playerTime = entityplayer.getPlayerTime();
PacketPlayOutUpdateTime packet = (playerTime == dayTime) ? worldPacket :
new PacketPlayOutUpdateTime(worldTime, playerTime, doDaylight);
entityplayer.playerConnection.sendPacket(packet); // Add support for per player time
}
}
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
// Paper end

SpigotTimings.timeUpdateTimer.stopTiming(); // Spigot

for (i = 0; i < this.worlds.size(); ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) {

TileEntitySign tileentitysign = (TileEntitySign) tileentity;

if (!tileentitysign.b() || tileentitysign.c() != this.player) {
if (!tileentitysign.b() || tileentitysign.signEditor == null || !tileentitysign.signEditor.equals(this.player.getUniqueID())) { // Paper
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
this.sendPacket(new PacketPlayOutUpdateSign(tileentity.world, packetplayinupdatesign.a(), tileentitysign.lines)); // CraftBukkit
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ private static ItemStack c(IInventory iinventory, ItemStack itemstack, int i, En
tileentityhopper.d(tileentityhopper.world.spigotConfig.hopperTransfer); // Spigot
}

// iinventory.update(); // Paper
//iinventory.update(); // Paper
}

iinventory.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class TileEntitySign extends TileEntity {
public boolean isEditable = true;
private EntityHuman h;
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
private final CommandObjectiveExecutor i = new CommandObjectiveExecutor();
public java.util.UUID signEditor;
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved

public TileEntitySign() {}

Expand Down Expand Up @@ -121,7 +122,10 @@ public boolean b() {
}

public void a(EntityHuman entityhuman) {
this.h = entityhuman;
// Paper start
//this.h = entityhuman;
signEditor = entityhuman != null ? entityhuman.getUniqueID() : null;
// Paper end
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
}

public EntityHuman c() {
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public class CraftBlockState implements BlockState {
protected int type;
protected MaterialData data;
protected int flag;
protected final byte light;
//protected final byte light; // CraftBukkit - SPIGOT-2286
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved

public CraftBlockState(final Block block) {
this.world = (CraftWorld) block.getWorld();
this.x = block.getX();
this.y = block.getY();
this.z = block.getZ();
this.type = block.getTypeId();
this.light = block.getLightLevel();
//this.light = block.getLightLevel(); // CraftBukkit - SPIGOT-2286
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
this.chunk = (CraftChunk) block.getChunk();
this.flag = 3;

Expand All @@ -48,7 +48,7 @@ public CraftBlockState(final Block block, int flag) {
public CraftBlockState(Material material) {
world = null;
type = material.getId();
light = 0;
// light = 0; // CraftBukkit - SPIGOT-2286
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
chunk = null;
x = y = z = 0;
}
Expand Down Expand Up @@ -132,7 +132,8 @@ public int getTypeId() {
}

public byte getLightLevel() {
return light;
//return light; // CraftBukkit - SPIGOT-2286
return getBlock().getLightLevel(); // CraftBukkit - SPIGOT-2286
crafter23456 marked this conversation as resolved.
Show resolved Hide resolved
}

public Block getBlock() {
Expand Down
Loading