Fix for entity spawning and some code cleanup

This commit is contained in:
Tahg 2011-12-06 19:21:10 -05:00
parent bc8f02788f
commit e4a839cbbc
4 changed files with 15 additions and 16 deletions

View File

@ -175,7 +175,7 @@ public abstract class EntityLiving extends Entity {
this.extinguish();
} else {
if (this.getAirTicks() != 300) {
if (this.getAirTicks() != 300) { // CraftBukkit -- only set if needed to work around a datawatcher inefficiency
this.setAirTicks(maxAirTicks);
}
}

View File

@ -1,6 +1,5 @@
package net.minecraft.server;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@ -8,7 +7,8 @@ import java.util.List;
import java.util.Random;
// 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.LongHash;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -47,8 +47,7 @@ public final class SpawnerCreature {
return 0;
} else {
// b.clear(); // CraftBukkit
LongAbstractHashtable chunkCoords; // CraftBukkit
chunkCoords = new LongAbstractHashtable() {};
LongBaseHashtable chunkCoords = new LongBaseHashtable(); // CraftBukkit
int i;
int j;
@ -78,7 +77,7 @@ public final class SpawnerCreature {
i = 0;
ChunkCoordinates chunkcoordinates = world.getSpawn();
ArrayList<EntryBase> entries = chunkCoords.entries(); // CraftBukkit
ArrayList<EntryBase> b = chunkCoords.entries(); // CraftBukkit
EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values();
j = aenumcreaturetype.length;
@ -86,14 +85,15 @@ public final class SpawnerCreature {
for (int j1 = 0; j1 < j; ++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:
for (EntryBase base : entries) {
for (EntryBase base : b) {
ChunkEntry entry = (SpawnerCreature.ChunkEntry) base;
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 l1 = chunkposition.y;
int i2 = chunkposition.z;

View File

@ -7,7 +7,7 @@ import java.util.ArrayList;
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 cache = null;

View File

@ -1,11 +1,10 @@
package org.bukkit.craftbukkit.util;
import java.util.ArrayList;
import net.minecraft.server.Chunk;
import net.minecraft.server.MinecraftServer;
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) {
put(toLong(msw, lsw), value);