mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 20:25:13 +00:00
Full Imports and Code Format Optimization
This commit is contained in:
1 parent
250edf099c
commit
6815f579a7
1192 files changed
+60344
-62167
No files matched your search
@@ -17,73 +17,75 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ChunkController implements LoadingCallback{
|
||||
public static ChunkController Instance;
|
||||
|
||||
public HashMap<Entity,Ticket> tickets = new HashMap<Entity,Ticket>();
|
||||
|
||||
public ChunkController(){
|
||||
Instance = this;
|
||||
}
|
||||
public class ChunkController implements LoadingCallback {
|
||||
public static ChunkController Instance;
|
||||
|
||||
public void clear(){
|
||||
tickets = new HashMap<Entity,Ticket>();
|
||||
}
|
||||
public HashMap<Entity, Ticket> tickets = new HashMap<Entity, Ticket>();
|
||||
|
||||
public Ticket getTicket(EntityNPCInterface npc) {
|
||||
Ticket ticket = tickets.get(npc);
|
||||
if(ticket != null)
|
||||
return ticket;
|
||||
if(size() >= ConfigMain.ChunkLoaders)
|
||||
return null;
|
||||
ticket = ForgeChunkManager.requestTicket(CustomNpcs.instance, npc.worldObj, Type.ENTITY);
|
||||
if(ticket == null)
|
||||
return null;
|
||||
ticket.bindEntity(npc);
|
||||
ticket.setChunkListDepth(6);
|
||||
tickets.put(npc, ticket);
|
||||
return null;
|
||||
}
|
||||
public ChunkController() {
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void deleteNPC(EntityNPCInterface npc) {
|
||||
Ticket ticket = tickets.get(npc);
|
||||
if(ticket != null){
|
||||
tickets.remove(npc);
|
||||
ForgeChunkManager.releaseTicket(ticket);
|
||||
}
|
||||
}
|
||||
public void clear() {
|
||||
tickets = new HashMap<Entity, Ticket>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ticketsLoaded(List<Ticket> tickets, World world) {
|
||||
for(Ticket ticket : tickets){
|
||||
if(!(ticket.getEntity() instanceof EntityNPCInterface))
|
||||
continue;
|
||||
EntityNPCInterface npc = (EntityNPCInterface) ticket.getEntity();
|
||||
if(npc.advanced.job == EnumJobType.ChunkLoader && !tickets.contains(npc)){
|
||||
this.tickets.put(npc, ticket);
|
||||
double x = npc.posX / 16;
|
||||
double z = npc.posZ / 16;
|
||||
|
||||
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.floor_double(z)));
|
||||
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.ceiling_double_int(z)));
|
||||
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.ceiling_double_int(z)));
|
||||
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.floor_double(z)));
|
||||
}
|
||||
}
|
||||
}
|
||||
public int size() {
|
||||
return tickets.size();
|
||||
}
|
||||
public void unload(int toRemove) {
|
||||
Iterator<Entity> ite = tickets.keySet().iterator();
|
||||
int i = 0;
|
||||
while(ite.hasNext()){
|
||||
if(i >= toRemove)
|
||||
return;
|
||||
Entity entity = ite.next();
|
||||
ForgeChunkManager.releaseTicket(tickets.get(entity));
|
||||
ite.remove();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
public Ticket getTicket(EntityNPCInterface npc) {
|
||||
Ticket ticket = tickets.get(npc);
|
||||
if (ticket != null)
|
||||
return ticket;
|
||||
if (size() >= ConfigMain.ChunkLoaders)
|
||||
return null;
|
||||
ticket = ForgeChunkManager.requestTicket(CustomNpcs.instance, npc.worldObj, Type.ENTITY);
|
||||
if (ticket == null)
|
||||
return null;
|
||||
ticket.bindEntity(npc);
|
||||
ticket.setChunkListDepth(6);
|
||||
tickets.put(npc, ticket);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deleteNPC(EntityNPCInterface npc) {
|
||||
Ticket ticket = tickets.get(npc);
|
||||
if (ticket != null) {
|
||||
tickets.remove(npc);
|
||||
ForgeChunkManager.releaseTicket(ticket);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ticketsLoaded(List<Ticket> tickets, World world) {
|
||||
for (Ticket ticket : tickets) {
|
||||
if (!(ticket.getEntity() instanceof EntityNPCInterface))
|
||||
continue;
|
||||
EntityNPCInterface npc = (EntityNPCInterface) ticket.getEntity();
|
||||
if (npc.advanced.job == EnumJobType.ChunkLoader && !tickets.contains(npc)) {
|
||||
this.tickets.put(npc, ticket);
|
||||
double x = npc.posX / 16;
|
||||
double z = npc.posZ / 16;
|
||||
|
||||
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.floor_double(z)));
|
||||
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.ceiling_double_int(z)));
|
||||
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.floor_double(x), MathHelper.ceiling_double_int(z)));
|
||||
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(MathHelper.ceiling_double_int(x), MathHelper.floor_double(z)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return tickets.size();
|
||||
}
|
||||
|
||||
public void unload(int toRemove) {
|
||||
Iterator<Entity> ite = tickets.keySet().iterator();
|
||||
int i = 0;
|
||||
while (ite.hasNext()) {
|
||||
if (i >= toRemove)
|
||||
return;
|
||||
Entity entity = ite.next();
|
||||
ForgeChunkManager.releaseTicket(tickets.get(entity));
|
||||
ite.remove();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user