Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 21:10:10 +01:00
Fix for entity spawning and some code cleanup
Dieser Commit ist enthalten in:
Ursprung
bc8f02788f
Commit
e4a839cbbc
@ -175,7 +175,7 @@ public abstract class EntityLiving extends Entity {
|
|||||||
|
|
||||||
this.extinguish();
|
this.extinguish();
|
||||||
} else {
|
} else {
|
||||||
if (this.getAirTicks() != 300) {
|
if (this.getAirTicks() != 300) { // CraftBukkit -- only set if needed to work around a datawatcher inefficiency
|
||||||
this.setAirTicks(maxAirTicks);
|
this.setAirTicks(maxAirTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -8,7 +7,8 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
// CraftBukkit
|
// CraftBukkit
|
||||||
import org.bukkit.craftbukkit.util.LongAbstractHashtable;
|
import java.util.ArrayList;
|
||||||
|
import org.bukkit.craftbukkit.util.LongBaseHashtable;
|
||||||
import org.bukkit.craftbukkit.util.EntryBase;
|
import org.bukkit.craftbukkit.util.EntryBase;
|
||||||
import org.bukkit.craftbukkit.util.LongHash;
|
import org.bukkit.craftbukkit.util.LongHash;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
@ -47,8 +47,7 @@ public final class SpawnerCreature {
|
|||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// b.clear(); // CraftBukkit
|
// b.clear(); // CraftBukkit
|
||||||
LongAbstractHashtable chunkCoords; // CraftBukkit
|
LongBaseHashtable chunkCoords = new LongBaseHashtable(); // CraftBukkit
|
||||||
chunkCoords = new LongAbstractHashtable() {};
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
@ -78,7 +77,7 @@ public final class SpawnerCreature {
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
ChunkCoordinates chunkcoordinates = world.getSpawn();
|
ChunkCoordinates chunkcoordinates = world.getSpawn();
|
||||||
ArrayList<EntryBase> entries = chunkCoords.entries(); // CraftBukkit
|
ArrayList<EntryBase> b = chunkCoords.entries(); // CraftBukkit
|
||||||
EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values();
|
EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values();
|
||||||
|
|
||||||
j = aenumcreaturetype.length;
|
j = aenumcreaturetype.length;
|
||||||
@ -86,14 +85,15 @@ public final class SpawnerCreature {
|
|||||||
for (int j1 = 0; j1 < j; ++j1) {
|
for (int j1 = 0; j1 < j; ++j1) {
|
||||||
EnumCreatureType enumcreaturetype = aenumcreaturetype[j1];
|
EnumCreatureType enumcreaturetype = aenumcreaturetype[j1];
|
||||||
|
|
||||||
|
if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= enumcreaturetype.b() * b.size() / 256) {
|
||||||
|
|
||||||
if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= enumcreaturetype.b() * entries.size() / 256) {
|
// CraftBukkit start
|
||||||
|
|
||||||
label108:
|
label108:
|
||||||
for (EntryBase base : entries) {
|
for (EntryBase base : b) {
|
||||||
ChunkEntry entry = (SpawnerCreature.ChunkEntry) base;
|
ChunkEntry entry = (SpawnerCreature.ChunkEntry) base;
|
||||||
if (!entry.spawn) {
|
if (!entry.spawn) {
|
||||||
ChunkPosition chunkposition = a(world, LongHash.msw(entry.getX()) * 16, entry.getZ() * 16);
|
ChunkPosition chunkposition = a(world, entry.getX() * 16, entry.getZ() * 16);
|
||||||
|
// CraftBukkit end
|
||||||
int k1 = chunkposition.x;
|
int k1 = chunkposition.x;
|
||||||
int l1 = chunkposition.y;
|
int l1 = chunkposition.y;
|
||||||
int i2 = chunkposition.z;
|
int i2 = chunkposition.z;
|
||||||
|
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import static org.bukkit.craftbukkit.util.Java15Compat.Arrays_copyOf;
|
import static org.bukkit.craftbukkit.util.Java15Compat.Arrays_copyOf;
|
||||||
|
|
||||||
public abstract class LongAbstractHashtable extends LongHash {
|
public class LongBaseHashtable extends LongHash {
|
||||||
|
|
||||||
EntryBase[][][] values = new EntryBase[256][][];
|
EntryBase[][][] values = new EntryBase[256][][];
|
||||||
EntryBase cache = null;
|
EntryBase cache = null;
|
@ -1,11 +1,10 @@
|
|||||||
package org.bukkit.craftbukkit.util;
|
package org.bukkit.craftbukkit.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import net.minecraft.server.Chunk;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import static org.bukkit.craftbukkit.util.Java15Compat.Arrays_copyOf;
|
import static org.bukkit.craftbukkit.util.Java15Compat.Arrays_copyOf;
|
||||||
|
|
||||||
public class LongHashtable<V> extends LongAbstractHashtable {
|
public class LongHashtable<V> extends LongBaseHashtable {
|
||||||
|
|
||||||
public void put(int msw, int lsw, V value) {
|
public void put(int msw, int lsw, V value) {
|
||||||
put(toLong(msw, lsw), value);
|
put(toLong(msw, lsw), value);
|
||||||
@ -20,7 +19,7 @@ public class LongHashtable<V> extends LongAbstractHashtable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized V get(long key) {
|
public synchronized V get(long key) {
|
||||||
Entry entry = ((Entry)getEntry(key));
|
Entry entry = ((Entry) getEntry(key));
|
||||||
return entry != null ? entry.value : null;
|
return entry != null ? entry.value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ public class LongHashtable<V> extends LongAbstractHashtable {
|
|||||||
ArrayList<EntryBase> entries = entries();
|
ArrayList<EntryBase> entries = entries();
|
||||||
|
|
||||||
for(EntryBase entry : entries) {
|
for(EntryBase entry : entries) {
|
||||||
ret.add(((Entry)entry).value);
|
ret.add(((Entry) entry).value);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren