Possible fix for out of bounds
This commit is contained in:
parent
afddbb9af9
commit
4f21126a76
7058
blocks.json
Normal file
7058
blocks.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,7 @@ public enum BBC {
|
||||
* Things to note about this class:
|
||||
* Can use multiple arguments %s, %s1, %s2, %s3 etc
|
||||
*/
|
||||
PREFIX("&8(&4&lFAWE&8)&7", "Info"),
|
||||
PREFIX("&8(&4&lFAWE&8)&r&7", "Info"),
|
||||
SCHEMATIC_PASTING("&7The schematic is pasting. This cannot be undone.", "Info"),
|
||||
FIX_LIGHTING_SELECTION("&7Lighting has been fixed in %s0 chunks. (It may take a second for the packets to send)", "Info"),
|
||||
UPDATED_LIGHTING_SELECTION("&7Lighting has been updated in %s0 chunks. (It may take a second for the packets to send)", "Info"),
|
||||
|
@ -118,7 +118,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, final BaseBlock block) throws WorldEditException {
|
||||
if (y > maxY) {
|
||||
if (y > maxY || y < 0) {
|
||||
return false;
|
||||
}
|
||||
final short id = (short) block.getId();
|
||||
|
@ -16,7 +16,6 @@ import com.intellectualcrafters.plot.util.block.QueueProvider;
|
||||
import com.plotsquared.listener.WEManager;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import java.util.HashSet;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlotSquaredFeature extends FaweMaskManager {
|
||||
public PlotSquaredFeature() {
|
||||
@ -61,7 +60,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
|
||||
@Override
|
||||
public FaweMask getMask(FawePlayer fp) {
|
||||
final PlotPlayer pp = PlotPlayer.wrap((Player) fp.parent);
|
||||
final PlotPlayer pp = PlotPlayer.wrap(fp.parent);
|
||||
final HashSet<RegionWrapper> regions;
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (plot != null && (plot.isOwner(pp.getUUID()) || plot.getTrusted().contains(pp.getUUID()) || (plot.getMembers().contains(pp.getUUID()) && pp.hasPermission("fawe.plotsquared.member")))) {
|
||||
|
@ -0,0 +1,166 @@
|
||||
package com.boydti.fawe.nukkit.core;
|
||||
|
||||
import cn.nukkit.block.Block;
|
||||
import cn.nukkit.block.BlockLiquid;
|
||||
import cn.nukkit.item.Item;
|
||||
import cn.nukkit.math.Vector3;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NukkitRegistryDumper {
|
||||
|
||||
private File file;
|
||||
private Gson gson;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
new NukkitRegistryDumper(new File("blocks.json")).run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public NukkitRegistryDumper(File file) {
|
||||
this.file = file;
|
||||
GsonBuilder builder = new GsonBuilder().setPrettyPrinting();
|
||||
builder.registerTypeAdapter(Vector3.class, new Vec3iAdapter());
|
||||
this.gson = builder.create();
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
Block.init();
|
||||
Item.init();
|
||||
List<Map<String, Object>> list = new LinkedList<Map<String, Object>>();
|
||||
HashSet<String> visited = new HashSet<>();
|
||||
for (Item item : Item.getCreativeItems()) {
|
||||
try {
|
||||
if (item != null && item.getBlock() != null && !visited.contains(item.getBlock().getName())) {
|
||||
Block block = item.getBlock();
|
||||
visited.add(block.getName());
|
||||
System.out.println("BLOCK " + block.getName());
|
||||
list.add(getProperties(block));
|
||||
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// for (Block block : Block.fullList) {
|
||||
// if (block != null) {
|
||||
// try {
|
||||
// System.out.println("BLOCK " + block.getName());
|
||||
// list.add(getProperties(block));
|
||||
// } catch (Throwable e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Collections.sort(list, new MapComparator());
|
||||
String out = gson.toJson(list);
|
||||
this.write(out);
|
||||
System.out.println("Wrote file: " + file.getAbsolutePath());
|
||||
}
|
||||
|
||||
private Map<String, Object> getProperties(Block b) {
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
Item item = Item.get(b.getId(), b.getDamage());
|
||||
map.put("legacyId", b.getId());
|
||||
map.put("id", b.getName());
|
||||
map.put("unlocalizedName", b.getName());
|
||||
map.put("localizedName", b.getName());
|
||||
map.put("material", getMaterial(b));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> getMaterial(Block b) {
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
Item item = Item.get(b.getId(), b.getDamage());
|
||||
map.put("powerSource", b.isPowerSource());
|
||||
map.put("lightOpacity", Block.lightFilter[b.getId()]);
|
||||
map.put("lightValue", b.getLightLevel());
|
||||
// map.put("usingNeighborLight", b.getUseNeighborBrightness(bs));
|
||||
map.put("hardness", b.getHardness());
|
||||
map.put("resistance", b.getResistance());
|
||||
// map.put("ticksRandomly", b.tickRate());
|
||||
map.put("tickRate", b.tickRate());
|
||||
map.put("fullCube", b.isSolid() && !b.isTransparent());
|
||||
map.put("slipperiness", b.getFrictionFactor());
|
||||
map.put("renderedAsNormalBlock", !b.isTransparent());
|
||||
//map.put("solidFullCube", b.isSolidFullCube());
|
||||
map.put("liquid", b instanceof BlockLiquid);
|
||||
map.put("solid", b.isSolid());
|
||||
map.put("movementBlocker", b.hasEntityCollision());
|
||||
//map.put("blocksLight", m.blocksLight());
|
||||
map.put("burnable", b.getBurnAbility() > 0);
|
||||
map.put("opaque", !b.isTransparent());
|
||||
map.put("replacedDuringPlacement", b.canBeReplaced());
|
||||
map.put("toolRequired", b.getToolType() != 0);
|
||||
map.put("canBeFlowedInto", b.canBeFlowedInto());
|
||||
// map.put("fragileWhenPushed", b instanceof BlockFlowable);
|
||||
// map.put("unpushable", m.getMobilityFlag() == EnumPushReaction.BLOCK);
|
||||
// map.put("adventureModeExempt", b.getField(m, Material.class, "isAdventureModeExempt", "field_85159_M"));
|
||||
map.put("mapColor", rgb(b.getColor().getRGB()));
|
||||
map.put("ambientOcclusionLightValue", b.isSolid() ? 0.2F : 1.0F);
|
||||
// try {
|
||||
// map.put("ambientOcclusionLightValue", b.b.getAmbientOcclusionLightValue(bs));
|
||||
// } catch (NoSuchMethodError ignored) {
|
||||
// map.put("ambientOcclusionLightValue", b.isBlockNormalCube(bs) ? 0.2F : 1.0F);
|
||||
// }
|
||||
map.put("grassBlocking", false); // idk what this property was originally supposed to be...grass uses a combination of light values to check growth
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private String rgb(int i) {
|
||||
int r = (i >> 16) & 0xFF;
|
||||
int g = (i >> 8) & 0xFF;
|
||||
int b = i & 0xFF;
|
||||
return String.format("#%02x%02x%02x", r, g, b);
|
||||
}
|
||||
|
||||
private void write(String s) {
|
||||
try {
|
||||
FileOutputStream str = new FileOutputStream(file);
|
||||
str.write(s.getBytes());
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error writing registry dump: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Vec3iAdapter extends TypeAdapter<Vector3> {
|
||||
@Override
|
||||
public Vector3 read(final JsonReader in) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@Override
|
||||
public void write(final JsonWriter out, final Vector3 vec) throws IOException {
|
||||
out.beginArray();
|
||||
out.value(vec.getX());
|
||||
out.value(vec.getY());
|
||||
out.value(vec.getZ());
|
||||
out.endArray();
|
||||
}
|
||||
}
|
||||
|
||||
private static class MapComparator implements Comparator<Map<String, Object>> {
|
||||
@Override
|
||||
public int compare(Map<String, Object> a, Map<String, Object> b) {
|
||||
return ((Integer) a.get("legacyId")).compareTo((Integer) b.get("legacyId"));
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,9 @@ import cn.nukkit.Player;
|
||||
import cn.nukkit.event.EventHandler;
|
||||
import cn.nukkit.event.Listener;
|
||||
import cn.nukkit.event.player.PlayerQuitEvent;
|
||||
import cn.nukkit.event.server.DataPacketSendEvent;
|
||||
import cn.nukkit.network.protocol.DataPacket;
|
||||
import cn.nukkit.network.protocol.TextPacket;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.IFawe;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
@ -36,6 +39,24 @@ public class FaweNukkit implements IFawe, Listener {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDataPacketSend(DataPacketSendEvent event) {
|
||||
DataPacket packet = event.getPacket();
|
||||
if (packet instanceof TextPacket) {
|
||||
TextPacket textPacket = (TextPacket) packet;
|
||||
int len = textPacket.message.length();
|
||||
int lineWidth = 52;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < textPacket.message.length(); i++) {
|
||||
if (i % 52 == 0) {
|
||||
builder.append((char) 1566);
|
||||
}
|
||||
builder.append(textPacket.message.charAt(i));
|
||||
}
|
||||
textPacket.message = builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -46,7 +67,11 @@ public class FaweNukkit implements IFawe, Listener {
|
||||
|
||||
@Override
|
||||
public void debug(String s) {
|
||||
plugin.getWELogger().log(Level.INFO, s);
|
||||
if (plugin.getWELogger() == null) {
|
||||
System.out.println(s);
|
||||
} else {
|
||||
plugin.getWELogger().log(Level.INFO, s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,7 +97,7 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
|
||||
|
||||
@Override
|
||||
public File getSaveFolder() {
|
||||
return new File(world.getFolderName() + File.separator + "region");
|
||||
return new File("worlds" + File.separator + world.getFolderName() + File.separator + "region");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user