finish block registry

Dieser Commit ist enthalten in:
Jesse Boyd 2019-04-05 17:51:42 +11:00
Ursprung be5541b61b
Commit 2143b9b5b7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
7 geänderte Dateien mit 23 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -177,7 +177,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
@Override @Override
public BlockMaterial getMaterial(BlockState state) { public BlockMaterial getMaterial(BlockState state) {
BlockType type = state.getBlockType();
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState(); IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
return new BlockMaterial_1_13(bs.getBlock(), bs); return new BlockMaterial_1_13(bs.getBlock(), bs);
} }

Datei anzeigen

@ -62,6 +62,7 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader; import org.bukkit.plugin.java.JavaPluginLoader;
import org.slf4j.Logger; import org.slf4j.Logger;

Datei anzeigen

@ -206,6 +206,7 @@ public class Schematic {
final int relx = to.getBlockX() + bot.getBlockX() - origin.getBlockX(); final int relx = to.getBlockX() + bot.getBlockX() - origin.getBlockX();
final int rely = to.getBlockY() + bot.getBlockY() - origin.getBlockY(); final int rely = to.getBlockY() + bot.getBlockY() - origin.getBlockY();
final int relz = to.getBlockZ() + bot.getBlockZ() - origin.getBlockZ(); final int relz = to.getBlockZ() + bot.getBlockZ() - origin.getBlockZ();
BlockArrayClipboard bac = (BlockArrayClipboard) clipboard; BlockArrayClipboard bac = (BlockArrayClipboard) clipboard;
if (copyBiomes) { if (copyBiomes) {
bac.IMP.forEach(new FaweClipboard.BlockReader() { bac.IMP.forEach(new FaweClipboard.BlockReader() {

Datei anzeigen

@ -1066,12 +1066,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
@Override @Override
public BlockState getBlock(BlockVector3 position) { public BlockState getBlock(BlockVector3 position) {
return world.getBlock(position); return extent.getBlock(position);
} }
@Override @Override
public BaseBlock getFullBlock(BlockVector3 position) { public BaseBlock getFullBlock(BlockVector3 position) {
return world.getFullBlock(position); return extent.getFullBlock(position);
} }
/** /**
@ -2610,7 +2610,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) {
continue; continue;
} }
for (int y = world.getMaxY(); y >= 1; --y) { for (int y = maxY; y >= 1; --y) {
BlockVector3 pt = BlockVector3.at(x, y, z); BlockVector3 pt = BlockVector3.at(x, y, z);
BlockType id = getBlock(pt).getBlockType(); BlockType id = getBlock(pt).getBlockType();
@ -2658,7 +2658,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) {
continue; continue;
} }
for (int y = world.getMaxY(); y >= 1; --y) { for (int y = maxY; y >= 1; --y) {
BlockVector3 pt = BlockVector3.at(x, y, z); BlockVector3 pt = BlockVector3.at(x, y, z);
BlockType id = getBlock(pt).getBlockType(); BlockType id = getBlock(pt).getBlockType();
if (id.getMaterial().isAir()) { if (id.getMaterial().isAir()) {
@ -2681,7 +2681,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
// Too high? // Too high?
if (y == world.getMaxY()) { if (y == maxY) {
break; break;
} }
@ -3469,7 +3469,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
final int bx = cx << 4; final int bx = cx << 4;
final int bz = cz << 4; final int bz = cz << 4;
final BlockVector3 cmin = BlockVector3.at(bx, 0, bz); final BlockVector3 cmin = BlockVector3.at(bx, 0, bz);
final BlockVector3 cmax = cmin.add(15, getMaxY(), 15); final BlockVector3 cmax = cmin.add(15, maxY, 15);
final boolean containsBot1 = (fe == null || fe.contains(cmin.getBlockX(), cmin.getBlockY(), cmin.getBlockZ())); final boolean containsBot1 = (fe == null || fe.contains(cmin.getBlockX(), cmin.getBlockY(), cmin.getBlockZ()));
final boolean containsBot2 = region.contains(cmin); final boolean containsBot2 = region.contains(cmin);
final boolean containsTop1 = (fe == null || fe.contains(cmax.getBlockX(), cmax.getBlockY(), cmax.getBlockZ())); final boolean containsTop1 = (fe == null || fe.contains(cmax.getBlockX(), cmax.getBlockY(), cmax.getBlockZ()));
@ -3488,7 +3488,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
int xx = x + bx; int xx = x + bx;
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
int zz = z + bz; int zz = z + bz;
for (int y = 0; y < getMaxY() + 1; y++) { for (int y = 0; y < maxY + 1; y++) {
BaseBlock block = getFullBlock(mutable.setComponents(xx, y, zz)); BaseBlock block = getFullBlock(mutable.setComponents(xx, y, zz));
fcs.add(mbv, block, BlockTypes.AIR.getDefaultState().toBaseBlock()); fcs.add(mbv, block, BlockTypes.AIR.getDefaultState().toBaseBlock());
} }
@ -3497,13 +3497,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
} else { } else {
if (!conNextX) { if (!conNextX) {
setExistingBlocks(BlockVector3.at(bx + 16, 0, bz), BlockVector3.at(bx + 31, getMaxY(), bz + 15)); setExistingBlocks(BlockVector3.at(bx + 16, 0, bz), BlockVector3.at(bx + 31, maxY, bz + 15));
} }
if (!conNextZ) { if (!conNextZ) {
setExistingBlocks(BlockVector3.at(bx, 0, bz + 16), BlockVector3.at(bx + 15, getMaxY(), bz + 31)); setExistingBlocks(BlockVector3.at(bx, 0, bz + 16), BlockVector3.at(bx + 15, maxY, bz + 31));
} }
if (!chunks.contains(mutable2D.setComponents(cx + 1, cz + 1)) && !conNextX && !conNextZ) { if (!chunks.contains(mutable2D.setComponents(cx + 1, cz + 1)) && !conNextX && !conNextZ) {
setExistingBlocks(BlockVector3.at(bx + 16, 0, bz + 16), BlockVector3.at(bx + 31, getMaxY(), bz + 31)); setExistingBlocks(BlockVector3.at(bx + 16, 0, bz + 16), BlockVector3.at(bx + 31, maxY, bz + 31));
} }
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
int xx = x + bx; int xx = x + bx;
@ -3511,7 +3511,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
for (int z = 0; z < 16; z++) { for (int z = 0; z < 16; z++) {
int zz = z + bz; int zz = z + bz;
mutable.mutZ(zz); mutable.mutZ(zz);
for (int y = 0; y < getMaxY() + 1; y++) { for (int y = 0; y < maxY + 1; y++) {
mutable.mutY(y); mutable.mutY(y);
boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable); boolean contains = (fe == null || fe.contains(xx, y, zz)) && region.contains(mutable);
if (contains) { if (contains) {

Datei anzeigen

@ -47,6 +47,7 @@ import java.util.Map;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;

Datei anzeigen

@ -314,7 +314,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
@Override @Override
public int getInternalId() { public int getInternalId() {
return blockType.getInternalId(); return internalId;
} }
@Override @Override

Datei anzeigen

@ -706,9 +706,9 @@ public final class BlockTypes {
this.propertiesMapArr[key.ordinal()] = property; this.propertiesMapArr[key.ordinal()] = property;
this.propertiesArr[prop_arr_i++] = property; this.propertiesArr[prop_arr_i++] = property;
propMap.put(entry.getKey(), property); propMap.put(entry.getKey(), property);
bitOffset += property.getNumBits();
maxInternalStateId += (property.getValues().size() << bitOffset); maxInternalStateId += (property.getValues().size() << bitOffset);
bitOffset += property.getNumBits();
} }
this.propertiesList = Arrays.asList(this.propertiesArr); this.propertiesList = Arrays.asList(this.propertiesArr);
this.propertiesMap = Collections.unmodifiableMap(propMap); this.propertiesMap = Collections.unmodifiableMap(propMap);
@ -726,14 +726,17 @@ public final class BlockTypes {
if (!propertiesList.isEmpty()) { if (!propertiesList.isEmpty()) {
this.stateOrdinals = generateStateOrdinals(internalId, states.size(), maxInternalStateId, propertiesList); this.stateOrdinals = generateStateOrdinals(internalId, states.size(), maxInternalStateId, propertiesList);
for (int propId = 0; propId < this.stateOrdinals.length; propId++) { for (int propId = 0; propId < this.stateOrdinals.length; propId++) {
int ordinal = this.stateOrdinals[propId]; int ordinal = this.stateOrdinals[propId];
if (ordinal != -1) { if (ordinal != -1) {
int stateId = internalId + (propId << BlockTypes.BIT_OFFSET); int stateId = internalId + (propId << BlockTypes.BIT_OFFSET);
states.add(new BlockState(type, stateId, ordinal)); BlockState state = new BlockState(type, stateId, ordinal);
states.add(state);
} }
} }
int defaultPropId = parseProperties(propertyString, propertiesMap) >> BlockTypes.BIT_OFFSET; int defaultPropId = parseProperties(propertyString, propertiesMap) >> BlockTypes.BIT_OFFSET;
this.defaultState = states.get(this.stateOrdinals[defaultPropId]); this.defaultState = states.get(this.stateOrdinals[defaultPropId]);
} else { } else {
this.defaultState = new BlockState(type, internalId, states.size()); this.defaultState = new BlockState(type, internalId, states.size());
@ -757,7 +760,7 @@ public final class BlockTypes {
private static int[] generateStateOrdinals(int internalId, int ordinal, int maxStateId, List<AbstractProperty<?>> props) { private static int[] generateStateOrdinals(int internalId, int ordinal, int maxStateId, List<AbstractProperty<?>> props) {
if (props.isEmpty()) return null; if (props.isEmpty()) return null;
int[] result = new int[maxStateId + 1]; int[] result = new int[maxStateId];
Arrays.fill(result, -1); Arrays.fill(result, -1);
int[] state = new int[props.size()]; int[] state = new int[props.size()];
int[] sizes = new int[props.size()]; int[] sizes = new int[props.size()];
@ -854,6 +857,7 @@ public final class BlockTypes {
$REGISTRY.put(type.getId().toLowerCase(), type); $REGISTRY.put(type.getId().toLowerCase(), type);
} }
states = stateList.toArray(new BlockState[stateList.size()]); states = stateList.toArray(new BlockState[stateList.size()]);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);