Issue #124: WorldEdit //regen issues
parent
28bb1c6c71
commit
aa0a821742
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>com.lishid</groupId>
|
||||
<artifactId>orebfuscator</artifactId>
|
||||
<version>4.1.5-SNAPSHOT</version>
|
||||
<version>4.1.6-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Orebfuscator4</name>
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.lishid.orebfuscator.hook;
|
||||
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
@ -27,6 +26,7 @@ import com.comphenix.protocol.events.PacketAdapter;
|
|||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.lishid.orebfuscator.chunkmap.ChunkData;
|
||||
import com.lishid.orebfuscator.hithack.BlockHitManager;
|
||||
import com.lishid.orebfuscator.obfuscation.Calculations;
|
||||
|
@ -78,4 +78,33 @@ public class ProtocolLibHook {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
private static boolean _isSaved;
|
||||
private void saveTestData(ChunkData chunkData) {
|
||||
if(_isSaved) return;
|
||||
|
||||
_isSaved = true;
|
||||
|
||||
FileOutputStream fos;
|
||||
try {
|
||||
fos = new FileOutputStream("D:\\Temp\\chunk.dat");
|
||||
fos.write(chunkData.chunkX & 0xff);
|
||||
fos.write((chunkData.chunkX >> 8) & 0xff);
|
||||
fos.write(chunkData.chunkZ & 0xff);
|
||||
fos.write((chunkData.chunkZ >> 8) & 0xff);
|
||||
fos.write(chunkData.primaryBitMask & 0xff);
|
||||
fos.write((chunkData.primaryBitMask >> 8) & 0xff);
|
||||
fos.write(chunkData.data.length & 0xff);
|
||||
fos.write((chunkData.data.length >> 8) & 0xff);
|
||||
fos.write((chunkData.data.length >> 16) & 0xff);
|
||||
fos.write(chunkData.data);
|
||||
fos.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -126,97 +126,99 @@ public class Calculations {
|
|||
|
||||
ChunkMapManager.blockDataToState(blockData, blockState);
|
||||
|
||||
if (blockState.id >= 256) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int x = startX | offsetX;
|
||||
int y = manager.getY();
|
||||
int z = startZ | offsetZ;
|
||||
|
||||
// Initialize data
|
||||
obfuscate = false;
|
||||
specialObfuscate = false;
|
||||
|
||||
// Check if the block should be obfuscated for the default engine modes
|
||||
if (OrebfuscatorConfig.isObfuscated(blockState.id, environment)) {
|
||||
if (initialRadius == 0) {
|
||||
// Do not interfere with PH
|
||||
if (OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, 1)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
} else {
|
||||
// Obfuscate all blocks
|
||||
obfuscate = true;
|
||||
}
|
||||
} else {
|
||||
// Check if any nearby blocks are transparent
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, initialRadius)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block should be obfuscated because of proximity check
|
||||
if (!obfuscate && OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (OrebfuscatorConfig.isProximityHiderOn(y, blockState.id)) {
|
||||
BlockCoord block = new BlockCoord(x, y, z);
|
||||
if (block != null) {
|
||||
proximityBlocks.add(block);
|
||||
}
|
||||
|
||||
obfuscate = true;
|
||||
if (OrebfuscatorConfig.UseSpecialBlockForProximityHider) {
|
||||
specialObfuscate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block is obfuscated
|
||||
if (obfuscate) {
|
||||
if (specialObfuscate) {
|
||||
// Proximity hider
|
||||
blockState.id = OrebfuscatorConfig.ProximityHiderID;
|
||||
} else {
|
||||
randomIncrement2 = OrebfuscatorConfig.random(incrementMax);
|
||||
|
||||
if (engineMode == 1) {
|
||||
// Engine mode 1, replace with stone
|
||||
blockState.id = (environment == Environment.NETHER ? 87 : 1);
|
||||
} else if (engineMode == 2) {
|
||||
// Ending mode 2, replace with random block
|
||||
if (randomBlocksLength > 1) {
|
||||
randomIncrement = CalculationsUtil.increment(randomIncrement, randomBlocksLength);
|
||||
}
|
||||
|
||||
blockState.id = OrebfuscatorConfig.getRandomBlock(randomIncrement, randomAlternate, environment);
|
||||
randomAlternate = !randomAlternate;
|
||||
}
|
||||
// Anti texturepack and freecam
|
||||
if (OrebfuscatorConfig.AntiTexturePackAndFreecam) {
|
||||
// Add random air blocks
|
||||
if (randomIncrement2 == 0) {
|
||||
randomCave = 1 + OrebfuscatorConfig.random(3);
|
||||
}
|
||||
|
||||
if (randomCave > 0) {
|
||||
blockState.id = 0;
|
||||
randomCave--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockState.meta = 0;
|
||||
}
|
||||
|
||||
// Check if the block should be obfuscated because of the darkness
|
||||
if (!obfuscate && OrebfuscatorConfig.DarknessHideBlocks && OrebfuscatorConfig.isDarknessObfuscated(blockState.id)) {
|
||||
if (!areAjacentBlocksBright(player.getWorld(), x, y, z, 1)) {
|
||||
// Hide block, setting it to air
|
||||
blockState.id = 0;
|
||||
blockState.meta = 0;
|
||||
}
|
||||
if (blockState.id < 256) {
|
||||
int x = startX | offsetX;
|
||||
int y = manager.getY();
|
||||
int z = startZ | offsetZ;
|
||||
|
||||
// Initialize data
|
||||
obfuscate = false;
|
||||
specialObfuscate = false;
|
||||
|
||||
// Check if the block should be obfuscated for the default engine modes
|
||||
if (OrebfuscatorConfig.isObfuscated(blockState.id, environment)) {
|
||||
if (initialRadius == 0) {
|
||||
// Do not interfere with PH
|
||||
if (OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, 1)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
} else {
|
||||
// Obfuscate all blocks
|
||||
obfuscate = true;
|
||||
}
|
||||
} else {
|
||||
// Check if any nearby blocks are transparent
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, initialRadius)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block should be obfuscated because of proximity check
|
||||
if (!obfuscate && OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (OrebfuscatorConfig.isProximityHiderOn(y, blockState.id)) {
|
||||
BlockCoord block = new BlockCoord(x, y, z);
|
||||
if (block != null) {
|
||||
proximityBlocks.add(block);
|
||||
}
|
||||
|
||||
obfuscate = true;
|
||||
if (OrebfuscatorConfig.UseSpecialBlockForProximityHider) {
|
||||
specialObfuscate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block is obfuscated
|
||||
if (obfuscate) {
|
||||
if (specialObfuscate) {
|
||||
// Proximity hider
|
||||
blockState.id = OrebfuscatorConfig.ProximityHiderID;
|
||||
} else {
|
||||
randomIncrement2 = OrebfuscatorConfig.random(incrementMax);
|
||||
|
||||
if (engineMode == 1) {
|
||||
// Engine mode 1, replace with stone
|
||||
blockState.id = (environment == Environment.NETHER ? 87 : 1);
|
||||
} else if (engineMode == 2) {
|
||||
// Ending mode 2, replace with random block
|
||||
if (randomBlocksLength > 1) {
|
||||
randomIncrement = CalculationsUtil.increment(randomIncrement, randomBlocksLength);
|
||||
}
|
||||
|
||||
blockState.id = OrebfuscatorConfig.getRandomBlock(randomIncrement, randomAlternate, environment);
|
||||
randomAlternate = !randomAlternate;
|
||||
}
|
||||
// Anti texturepack and freecam
|
||||
if (OrebfuscatorConfig.AntiTexturePackAndFreecam) {
|
||||
// Add random air blocks
|
||||
if (randomIncrement2 == 0) {
|
||||
randomCave = 1 + OrebfuscatorConfig.random(3);
|
||||
}
|
||||
|
||||
if (randomCave > 0) {
|
||||
blockState.id = 0;
|
||||
randomCave--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockState.meta = 0;
|
||||
}
|
||||
|
||||
// Check if the block should be obfuscated because of the darkness
|
||||
if (!obfuscate && OrebfuscatorConfig.DarknessHideBlocks && OrebfuscatorConfig.isDarknessObfuscated(blockState.id)) {
|
||||
if (!areAjacentBlocksBright(player.getWorld(), x, y, z, 1)) {
|
||||
// Hide block, setting it to air
|
||||
blockState.id = 0;
|
||||
blockState.meta = 0;
|
||||
}
|
||||
}
|
||||
|
||||
blockData = ChunkMapManager.blockStateToData(blockState);
|
||||
} else {
|
||||
blockData = 0;
|
||||
}
|
||||
|
||||
if(offsetY == 0 && offsetZ == 0 && offsetX == 0) {
|
||||
|
@ -226,8 +228,6 @@ public class Calculations {
|
|||
manager.initOutputSection();
|
||||
}
|
||||
|
||||
blockData = ChunkMapManager.blockStateToData(blockState);
|
||||
|
||||
manager.writeOutputBlock(blockData);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue