parent
0da4f6f63a
commit
912ea44cc8
@ -458,9 +458,7 @@ public class DiskStorageHistory implements ChangeSet, FaweChangeSet {
|
|||||||
try {
|
try {
|
||||||
NamedTag nt = stream.readNamedTag();
|
NamedTag nt = stream.readNamedTag();
|
||||||
return nt != null ? ((CompoundTag) nt.getTag()) : null;
|
return nt != null ? ((CompoundTag) nt.getTag()) : null;
|
||||||
} catch (IOException e) {
|
} catch (IOException ignore) {}
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,54 @@
|
|||||||
package com.boydti.fawe.object.clipboard;
|
package com.boydti.fawe.object.clipboard;
|
||||||
|
|
||||||
public class DiskOptimizedClipboard {
|
import com.boydti.fawe.object.IntegerTrio;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* // TODO
|
||||||
|
* A clipboard with disk backed storage. (lower memory + loads on crash)
|
||||||
|
* - Uses an auto closable RandomAccessFile for getting / setting id / data
|
||||||
|
* - I don't know how to reduce nbt / entities to O(1) complexity, so it is stored in memory.
|
||||||
|
*/
|
||||||
|
public class DiskOptimizedClipboard extends FaweClipboard {
|
||||||
|
|
||||||
|
private final HashMap<IntegerTrio, CompoundTag> nbtMap;
|
||||||
|
private final HashSet<ClipboardEntity> entities;
|
||||||
|
|
||||||
|
public DiskOptimizedClipboard(int width, int height, int length) {
|
||||||
|
super(width, height, length);
|
||||||
|
nbtMap = new HashMap<>();
|
||||||
|
entities = new HashSet<ClipboardEntity>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getBlock(int x, int y, int z) {
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED / WIP");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(int x, int y, int z, BaseBlock block) {
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED / WIP");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entity createEntity(Extent world, double x, double y, double z, float yaw, float pitch, BaseEntity entity) {
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED / WIP");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Entity> getEntities() {
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED / WIP");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(ClipboardEntity clipboardEntity) {
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED / WIP");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,15 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
|||||||
public boolean setBlock(int x, int y, int z, BaseBlock block) {
|
public boolean setBlock(int x, int y, int z, BaseBlock block) {
|
||||||
final int id = block.getId();
|
final int id = block.getId();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0: {
|
||||||
|
int i = x + z * width + (y >> 4) * area;
|
||||||
|
byte[] idArray = ids[i];
|
||||||
|
if (idArray != null) {
|
||||||
|
int y2 = y & 0xF;
|
||||||
|
idArray[y2] = 0;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
case 54:
|
case 54:
|
||||||
case 130:
|
case 130:
|
||||||
case 142:
|
case 142:
|
||||||
|
@ -605,8 +605,10 @@ public class EditSession implements Extent {
|
|||||||
return FaweCache.CACHE_BLOCK[combinedId4Data];
|
return FaweCache.CACHE_BLOCK[combinedId4Data];
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return this.world.getLazyBlock(new Vector(x, y, z));
|
BaseBlock block = this.world.getBlock(new Vector(x, y, z));
|
||||||
|
return block;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
return FaweCache.CACHE_BLOCK[combinedId4Data];
|
return FaweCache.CACHE_BLOCK[combinedId4Data];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1464,7 +1466,7 @@ public class EditSession implements Extent {
|
|||||||
EditSession.this.flushQueue();
|
EditSession.this.flushQueue();
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
return this.changes = visitor.getAffected();
|
return this.changes = copy.getAffected();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,8 +78,6 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
this.mx = origin.getBlockX();
|
this.mx = origin.getBlockX();
|
||||||
this.my = origin.getBlockY();
|
this.my = origin.getBlockY();
|
||||||
this.mz = origin.getBlockZ();
|
this.mz = origin.getBlockZ();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user