Code cleanup

This commit is contained in:
LemADEC 2017-06-26 00:39:10 +02:00
parent 82838aa9e6
commit f65879eb8d
2 changed files with 5 additions and 14 deletions

View file

@ -757,14 +757,12 @@ public class WarpDrive implements LoadingCallback {
event.registerServerCommand(new CommandReload());
}
private Ticket registerChunkLoadTE(TileEntityAbstractChunkLoading tileEntity, boolean refreshLoading) {
public Ticket registerChunkLoadTileEntity(TileEntityAbstractChunkLoading tileEntity) {
World worldObj = tileEntity.getWorldObj();
if (ForgeChunkManager.ticketCountAvailableFor(this, worldObj) > 0) {
Ticket ticket = ForgeChunkManager.requestTicket(this, worldObj, Type.NORMAL);
if (ticket != null) {
tileEntity.giveTicket(ticket); // FIXME calling the caller is a bad idea
if (refreshLoading)
tileEntity.refreshLoading();
return ticket;
} else {
WarpDrive.logger.error("Ticket not granted");
@ -775,14 +773,6 @@ public class WarpDrive implements LoadingCallback {
return null;
}
public Ticket registerChunkLoadTE(TileEntityAbstractChunkLoading te) {
return registerChunkLoadTE(te, true);
}
public Ticket getTicket(TileEntityAbstractChunkLoading te) {
return registerChunkLoadTE(te, false);
}
@Override
public void ticketsLoaded(List<Ticket> tickets, World world) {
for (Ticket ticket : tickets) {

View file

@ -48,7 +48,7 @@ public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractE
int numTicketsRequired = (int) Math.ceil((double) chunkList.size() / ticketSize); // FIXME there should be only one ticket per requesting TileEntity
if (ticketList.size() != numTicketsRequired) {
for(int i = ticketList.size(); i < numTicketsRequired; i++) {
WarpDrive.instance.getTicket(this);
WarpDrive.instance.registerChunkLoadTileEntity(this);
}
}
@ -80,8 +80,9 @@ public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractE
ticketList.clear();
areChunksLoaded = false;
}
} else if(loadRequested) {
WarpDrive.instance.registerChunkLoadTE(this);
} else if (loadRequested) {
WarpDrive.instance.registerChunkLoadTileEntity(this);
refreshLoading();
}
}