mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 21:56:33 +01:00
Add async relighting option
This commit is contained in:
parent
b3b86bd3df
commit
c325f0745c
@ -331,6 +331,7 @@ public class Settings extends Config {
|
|||||||
"If packet sending should be delayed until relight is finished",
|
"If packet sending should be delayed until relight is finished",
|
||||||
})
|
})
|
||||||
public boolean DELAY_PACKET_SENDING = true;
|
public boolean DELAY_PACKET_SENDING = true;
|
||||||
|
public boolean ASYNC = true;
|
||||||
@Comment({
|
@Comment({
|
||||||
"The relighting mode to use:",
|
"The relighting mode to use:",
|
||||||
" - 0 = None (Do no relighting)",
|
" - 0 = None (Do no relighting)",
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package com.boydti.fawe.example;
|
package com.boydti.fawe.example;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.FaweChunk;
|
import com.boydti.fawe.object.FaweChunk;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.IntegerTrio;
|
import com.boydti.fawe.object.IntegerTrio;
|
||||||
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
@ -220,15 +223,25 @@ public class NMSRelighter implements Relighter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void sendChunks() {
|
public synchronized void sendChunks() {
|
||||||
Iterator<Map.Entry<Long, Integer>> iter = chunksToSend.entrySet().iterator();
|
RunnableVal<Object> runnable = new RunnableVal<Object>() {
|
||||||
while (iter.hasNext()) {
|
@Override
|
||||||
Map.Entry<Long, Integer> entry = iter.next();
|
public void run(Object value) {
|
||||||
long pair = entry.getKey();
|
Iterator<Map.Entry<Long, Integer>> iter = chunksToSend.entrySet().iterator();
|
||||||
int bitMask = entry.getValue();
|
while (iter.hasNext()) {
|
||||||
int x = MathMan.unpairIntX(pair);
|
Map.Entry<Long, Integer> entry = iter.next();
|
||||||
int z = MathMan.unpairIntY(pair);
|
long pair = entry.getKey();
|
||||||
queue.sendChunk(x, z, bitMask);
|
int bitMask = entry.getValue();
|
||||||
iter.remove();
|
int x = MathMan.unpairIntX(pair);
|
||||||
|
int z = MathMan.unpairIntY(pair);
|
||||||
|
queue.sendChunk(x, z, bitMask);
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (Settings.IMP.LIGHTING.ASYNC) {
|
||||||
|
runnable.run();
|
||||||
|
} else {
|
||||||
|
TaskManager.IMP.sync(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package com.sk89q.worldedit;
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.FaweInputStream;
|
import com.boydti.fawe.object.FaweInputStream;
|
||||||
import com.boydti.fawe.object.FaweOutputStream;
|
import com.boydti.fawe.object.FaweOutputStream;
|
||||||
@ -955,9 +956,15 @@ public class LocalSession {
|
|||||||
* @param item the item type ID
|
* @param item the item type ID
|
||||||
* @return the tool, which may be {@link null}
|
* @return the tool, which may be {@link null}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Nullable
|
@Nullable
|
||||||
public Tool getTool(int item) {
|
public Tool getTool(int item) {
|
||||||
return tools.get(item);
|
return tools.get(FaweCache.getCombined(item, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Tool getTool(int id, int data) {
|
||||||
|
return tools.get(FaweCache.getCombined(id, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -1007,19 +1014,25 @@ public class LocalSession {
|
|||||||
* @param tool the tool to set, which can be {@code null}
|
* @param tool the tool to set, which can be {@code null}
|
||||||
* @throws InvalidToolBindException if the item can't be bound to that item
|
* @throws InvalidToolBindException if the item can't be bound to that item
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setTool(int item, @Nullable Tool tool) throws InvalidToolBindException {
|
public void setTool(int item, @Nullable Tool tool) throws InvalidToolBindException {
|
||||||
setTool(item, tool, null);
|
setTool(item, tool, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setTool(int item, @Nullable Tool tool, Player player) throws InvalidToolBindException {
|
public void setTool(int item, @Nullable Tool tool, Player player) throws InvalidToolBindException {
|
||||||
if (item > 0 && item < 255) {
|
setTool(item, 0, tool, player);
|
||||||
throw new InvalidToolBindException(item, "Blocks can't be used");
|
}
|
||||||
} else if (item == config.wandItem) {
|
|
||||||
throw new InvalidToolBindException(item, "Already used for the wand");
|
public void setTool(int id, int data, @Nullable Tool tool, Player player) throws InvalidToolBindException {
|
||||||
} else if (item == config.navigationWand) {
|
if (id > 0 && id < 255) {
|
||||||
throw new InvalidToolBindException(item, "Already used for the navigation wand");
|
throw new InvalidToolBindException(id, "Blocks can't be used");
|
||||||
|
} else if (id == config.wandItem) {
|
||||||
|
throw new InvalidToolBindException(id, "Already used for the wand");
|
||||||
|
} else if (id == config.navigationWand) {
|
||||||
|
throw new InvalidToolBindException(id, "Already used for the navigation wand");
|
||||||
}
|
}
|
||||||
Tool previous = this.tools.put(item, tool);
|
Tool previous = this.tools.put(FaweCache.getCombined(id, data), tool);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (previous instanceof BrushTool) {
|
if (previous instanceof BrushTool) {
|
||||||
BrushTool brushTool = (BrushTool) previous;
|
BrushTool brushTool = (BrushTool) previous;
|
||||||
|
Loading…
Reference in New Issue
Block a user