Fixes and adjustments with String ids.
* Start renaming methods internally (getType for getting Material) - unfinished. * Temporary fix for the NCPCompatbukkit/cbreflect module: fetch NMS blocks by id until we have a mapping and/or something efficient and future proof in place.
This commit is contained in:
parent
9d7ddec697
commit
7c5d67b1d4
|
@ -29,7 +29,7 @@ public interface IReflectBlock {
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Object nms_getById(Material id);
|
||||
public Object nms_getByMaterial(Material id);
|
||||
|
||||
/**
|
||||
* Get the material for a Block instance.
|
||||
|
|
|
@ -137,12 +137,13 @@ public class ReflectBlock implements IReflectBlock {
|
|||
return blockPos;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Object nms_getById(final Material id) {
|
||||
public Object nms_getByMaterial(final Material id) {
|
||||
if (this.nmsGetById == null) {
|
||||
fail();
|
||||
}
|
||||
return ReflectionUtil.invokeMethod(this.nmsGetById, null, id);
|
||||
return ReflectionUtil.invokeMethod(this.nmsGetById, null, id.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -212,12 +212,13 @@ public class ReflectBlockSix implements IReflectBlock {
|
|||
return blockPos;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Object nms_getById(final Material id) {
|
||||
public Object nms_getByMaterial(final Material id) {
|
||||
if (this.nmsGetById == null) {
|
||||
fail();
|
||||
}
|
||||
return ReflectionUtil.invokeMethod(this.nmsGetById, null, id);
|
||||
return ReflectionUtil.invokeMethod(this.nmsGetById, null, id.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -283,11 +283,11 @@ public class ReflectHelper {
|
|||
* @param id
|
||||
* @return Block instance (could be null).
|
||||
*/
|
||||
public Object nmsBlock_getById(Material id) {
|
||||
public Object nmsBlock_getByMaterial(Material id) {
|
||||
if (reflectBlock == null) {
|
||||
fail();
|
||||
}
|
||||
return this.reflectBlock.nms_getById(id);
|
||||
return this.reflectBlock.nms_getByMaterial(id);
|
||||
}
|
||||
|
||||
public Object nmsBlock_getMaterial(Object block) {
|
||||
|
@ -312,7 +312,7 @@ public class ReflectHelper {
|
|||
}
|
||||
|
||||
public AlmostBoolean isBlockSolid(Material id) {
|
||||
Object obj = nmsBlock_getById(id);
|
||||
Object obj = nmsBlock_getByMaterial(id);
|
||||
if (obj == null) {
|
||||
return AlmostBoolean.MAYBE;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ public class ReflectHelper {
|
|||
}
|
||||
|
||||
public AlmostBoolean isBlockLiquid(Material id) {
|
||||
Object obj = nmsBlock_getById(id);
|
||||
Object obj = nmsBlock_getByMaterial(id);
|
||||
if (obj == null) {
|
||||
return AlmostBoolean.MAYBE;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ public class ReflectHelper {
|
|||
if (reflectBlock == null) {
|
||||
fail();
|
||||
}
|
||||
final Object nmsBlock = nmsBlock_getById(id);
|
||||
final Object nmsBlock = nmsBlock_getByMaterial(id);
|
||||
if (nmsBlock == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -731,6 +731,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||
final Player player = (Player) entity;
|
||||
if (player.isDead() && BridgeHealth.getHealth(player) <= 0.0) {
|
||||
// Heal after death.
|
||||
// TODO: Problematic. At least skip CUSTOM.
|
||||
event.setCancelled(true);
|
||||
counters.addPrimaryThread(idCancelDead, 1);
|
||||
return;
|
||||
|
@ -738,6 +739,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||
if (event.getRegainReason() != RegainReason.SATIATED) {
|
||||
return;
|
||||
}
|
||||
// TODO: EATING reason / peaceful difficulty / regen potion - byCaptain SpigotMC
|
||||
if (fastHeal.isEnabled(player) && fastHeal.check(player)) {
|
||||
// TODO: Can clients force events with 0-re-gain ?
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -786,7 +786,7 @@ public class BlockChangeTracker {
|
|||
for (final BlockChangeEntry entry : entries) {
|
||||
if (entry.canUpdate(ref, direction)
|
||||
&& (matchFlags == 0
|
||||
|| (matchFlags & BlockProperties.getBlockFlags(entry.previousState.getId())) != 0)) {
|
||||
|| (matchFlags & BlockProperties.getBlockFlags(entry.previousState.getType())) != 0)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public class OnGroundReference {
|
|||
while(itEntries.hasNext()) {
|
||||
entry = itEntries.next();
|
||||
if (ref != null && !ref.canUpdateWith(entry)
|
||||
|| !BlockProperties.isGround(entry.previousState.getId(), ignoreFlags)) {
|
||||
|| !BlockProperties.isGround(entry.previousState.getType(), ignoreFlags)) {
|
||||
entry = null;
|
||||
}
|
||||
else {
|
||||
|
@ -137,7 +137,7 @@ public class OnGroundReference {
|
|||
if (entry == null) {
|
||||
node = blockCache.getOrCreateBlockCacheNode(x, y, z, false);
|
||||
// Fast exclusion check right here.
|
||||
if (!BlockProperties.isGround(node.getId(), ignoreFlags)) {
|
||||
if (!BlockProperties.isGround(node.getType(), ignoreFlags)) {
|
||||
entriesAbove = entries;
|
||||
return false;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class OnGroundReference {
|
|||
while(itEntries.hasNext()) {
|
||||
entry = itEntries.next();
|
||||
if (entry.nextEntryTick >= 0 && entryAbove.tick > entry.nextEntryTick
|
||||
|| !BlockProperties.isGround(entry.previousState.getId(), ignoreFlags)) {
|
||||
|| !BlockProperties.isGround(entry.previousState.getType(), ignoreFlags)) {
|
||||
entry = null;
|
||||
}
|
||||
else {
|
||||
|
@ -200,7 +200,7 @@ public class OnGroundReference {
|
|||
if (entry == null) {
|
||||
node = blockCache.getOrCreateBlockCacheNode(x, y, z, false);
|
||||
// Fast exclusion check right here.
|
||||
if (!BlockProperties.isGround(node.getId(), ignoreFlags)) {
|
||||
if (!BlockProperties.isGround(node.getType(), ignoreFlags)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ public class OnGroundReference {
|
|||
while (itEntries.hasNext()) {
|
||||
entry = itEntries.next();
|
||||
node = entry.previousState;
|
||||
if (BlockProperties.isGround(node.getId(), ignoreFlags)) {
|
||||
if (BlockProperties.isGround(node.getType(), ignoreFlags)) {
|
||||
// TODO: If nodeAbove is ground too, could exclude cases here.
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public class DebugUtil {
|
|||
}
|
||||
builder.append(" id=");
|
||||
final IBlockCacheNode node = blockCache.getOrCreateBlockCacheNode(x, y, z, true);
|
||||
final Material id = node.getId();
|
||||
final Material id = node.getType();
|
||||
builder.append(id);
|
||||
builder.append(" data=");
|
||||
builder.append(node.getData());
|
||||
|
|
|
@ -493,7 +493,7 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
|
|||
if (node == null) {
|
||||
getOrCreateBlockCacheNode();
|
||||
}
|
||||
return node.getId();
|
||||
return node.getType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -505,7 +505,7 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
|
|||
if (nodeBelow == null) {
|
||||
getOrCreateBlockCacheNodeBelow();
|
||||
}
|
||||
return nodeBelow.getId();
|
||||
return nodeBelow.getType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -801,7 +801,7 @@ public class RichBoundsLocation implements IGetBukkitLocation, IGetBlockPosition
|
|||
// TODO: Consider dropping this shortcut.
|
||||
final int bY = Location.locToBlock(y - yOnGround);
|
||||
final IBlockCacheNode useNode = bY == blockY ? getOrCreateBlockCacheNode() : (bY == blockY -1 ? getOrCreateBlockCacheNodeBelow() : blockCache.getOrCreateBlockCacheNode(blockX, bY, blockZ, false));
|
||||
final Material id = useNode.getId();
|
||||
final Material id = useNode.getType();
|
||||
final long flags = BlockProperties.getBlockFlags(id);
|
||||
// TODO: Might remove check for variable ?
|
||||
if ((flags & BlockProperties.F_GROUND) != 0 && (flags & BlockProperties.F_VARIABLE) == 0) {
|
||||
|
|
|
@ -57,7 +57,7 @@ public abstract class BlockCache {
|
|||
* Always set.
|
||||
* @return
|
||||
*/
|
||||
public Material getId();
|
||||
public Material getType();
|
||||
|
||||
/**
|
||||
* Ensure to test with isDataSet().
|
||||
|
@ -134,7 +134,7 @@ public abstract class BlockCache {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Material getId() {
|
||||
public Material getType() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ public abstract class BlockCache {
|
|||
public boolean equals(final Object obj) {
|
||||
if (obj instanceof IBlockCacheNode) {
|
||||
final IBlockCacheNode other = (IBlockCacheNode) obj;
|
||||
return id == other.getId()
|
||||
return id == other.getType()
|
||||
&& (!isDataFetched() && !other.isDataFetched()
|
||||
|| isDataFetched() && other.isDataFetched() && data == other.getData())
|
||||
&& (!isBoundsFetched() && !other.isBoundsFetched()
|
||||
|
@ -368,7 +368,7 @@ public abstract class BlockCache {
|
|||
* @return the type id
|
||||
*/
|
||||
public Material getTypeId(final int x, final int y, final int z) {
|
||||
return getOrCreateNode(x, y, z).getId();
|
||||
return getOrCreateNode(x, y, z).getType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2315,7 +2315,7 @@ public class BlockProperties {
|
|||
public static final boolean isPassable(final BlockCache access,
|
||||
final double x, final double y, final double z,
|
||||
final IBlockCacheNode node, final IBlockCacheNode nodeAbove) {
|
||||
final Material id = node.getId();
|
||||
final Material id = node.getType();
|
||||
// Simple exclusion check first.
|
||||
if (isPassable(id)) {
|
||||
return true;
|
||||
|
@ -2367,7 +2367,7 @@ public class BlockProperties {
|
|||
final int bx = Location.locToBlock(x);
|
||||
final int bz = Location.locToBlock(z);
|
||||
final IBlockCacheNode nodeBelow = access.getOrCreateBlockCacheNode(x, y, z, false);
|
||||
final Material belowId = nodeBelow.getId();
|
||||
final Material belowId = nodeBelow.getType();
|
||||
final long belowFlags = getBlockFlags(belowId);
|
||||
if ((belowFlags & F_HEIGHT150) == 0 || isPassable(belowId)) {
|
||||
return true;
|
||||
|
@ -2458,7 +2458,7 @@ public class BlockProperties {
|
|||
final double dT) {
|
||||
// Note: Since this is only called if the bounding box collides, out-of-bounds checks should not be necessary.
|
||||
// TODO: Add a flag if a workaround exists (!), might store the type of workaround extra (generic!), or extra flags.
|
||||
final Material id = node.getId();
|
||||
final Material id = node.getType();
|
||||
final long flags = getBlockFlags(id);
|
||||
if ((flags & F_STAIRS) != 0) {
|
||||
if ((access.getData(bx, by, bz) & 0x4) != 0) {
|
||||
|
@ -2664,7 +2664,7 @@ public class BlockProperties {
|
|||
public static double getGroundMinHeight(final BlockCache access,
|
||||
final int x, final int y, final int z,
|
||||
final IBlockCacheNode node, final long flags) {
|
||||
final Material id = node.getId();
|
||||
final Material id = node.getType();
|
||||
final double[] bounds = node.getBounds(access, x, y, z);
|
||||
// TODO: Check which ones are really needed !
|
||||
if ((flags & F_HEIGHT_8SIM_INC) != 0) {
|
||||
|
@ -3042,7 +3042,7 @@ public class BlockProperties {
|
|||
IBlockCacheNode nodeAbove = null;
|
||||
for (int y = iMaxY; y >= iMinY; y--) {
|
||||
final IBlockCacheNode node = access.getOrCreateBlockCacheNode(x, y, z, false);
|
||||
final Material id = node.getId();
|
||||
final Material id = node.getType();
|
||||
final long cFlags = getBlockFlags(id);
|
||||
if ((cFlags & flags) != 0) {
|
||||
// Might collide.
|
||||
|
@ -3139,7 +3139,7 @@ public class BlockProperties {
|
|||
IBlockCacheNode nodeAbove = null;
|
||||
for (int y = iMaxY; y >= iMinY; y--) {
|
||||
final IBlockCacheNode node = access.getOrCreateBlockCacheNode(x, y, z, false);
|
||||
if (id == node.getId()) {
|
||||
if (id == node.getType()) {
|
||||
if (node.hasNonNullBounds().decideOptimistically()) {
|
||||
if (collidesBlock(access, minX, minY, minZ, maxX, maxY, maxZ, x, y, z, node, nodeAbove, flags)) {
|
||||
return true;
|
||||
|
@ -3311,7 +3311,7 @@ public class BlockProperties {
|
|||
bminY = 0.0;
|
||||
bmaxY = 0.125;
|
||||
}
|
||||
else if (node.getId() == Material.ENDER_PORTAL_FRAME) {
|
||||
else if (node.getType() == Material.ENDER_PORTAL_FRAME) {
|
||||
// TODO: Test
|
||||
// TODO: Other concepts ...
|
||||
bminY = 0;
|
||||
|
@ -3381,7 +3381,7 @@ public class BlockProperties {
|
|||
if (node == null) {
|
||||
node = access.getOrCreateBlockCacheNode(x, y, z, false);
|
||||
}
|
||||
final Material id = node.getId();
|
||||
final Material id = node.getType();
|
||||
if (isLiquid(id)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -3634,7 +3634,7 @@ public class BlockProperties {
|
|||
final IBlockCacheNode node, IBlockCacheNode nodeAbove) {
|
||||
// TODO: Relevant methods called here should be changed to use IBlockCacheNode (node, nodeAbove).
|
||||
|
||||
final Material id = node.getId(); // TODO: Pass on the node (signatures...).
|
||||
final Material id = node.getType(); // TODO: Pass on the node (signatures...).
|
||||
final long flags = getBlockFlags(id);
|
||||
|
||||
|
||||
|
@ -3706,7 +3706,7 @@ public class BlockProperties {
|
|||
if (nodeAbove == null) {
|
||||
nodeAbove = access.getOrCreateBlockCacheNode(x, y + 1, z, false);
|
||||
}
|
||||
final Material aboveId = nodeAbove.getId();
|
||||
final Material aboveId = nodeAbove.getType();
|
||||
final long aboveFlags = getBlockFlags(aboveId);
|
||||
if ((aboveFlags & F_IGN_PASSABLE) != 0) {
|
||||
// Ignore these (Note for above block check before ground property).
|
||||
|
@ -4029,7 +4029,7 @@ public class BlockProperties {
|
|||
final double dT) {
|
||||
// TODO: Method signature with node, nodeAbove.
|
||||
final IBlockCacheNode node = access.getOrCreateBlockCacheNode(blockX, blockY, blockZ, false);
|
||||
if (BlockProperties.isPassable(node.getId())) {
|
||||
if (BlockProperties.isPassable(node.getType())) {
|
||||
return true;
|
||||
}
|
||||
double[] bounds = access.getBounds(blockX, blockY, blockZ);
|
||||
|
@ -4065,7 +4065,7 @@ public class BlockProperties {
|
|||
maxZ = dZ * dT + oZ + blockZ;
|
||||
minZ = oZ + blockZ;
|
||||
}
|
||||
if (!collidesBlock(access, minX, minY, minZ, maxX, maxY, maxZ, blockX, blockY, blockZ, node, null, getBlockFlags(node.getId()) | F_COLLIDE_EDGES)) {
|
||||
if (!collidesBlock(access, minX, minY, minZ, maxX, maxY, maxZ, blockX, blockY, blockZ, node, null, getBlockFlags(node.getType()) | F_COLLIDE_EDGES)) {
|
||||
// TODO: Might check for fence too, here.
|
||||
return true;
|
||||
}
|
||||
|
@ -4113,7 +4113,7 @@ public class BlockProperties {
|
|||
final double maxX, final double maxY, final double maxZ) {
|
||||
// TODO: This mostly is copy and paste from isPassableRay.
|
||||
final IBlockCacheNode node = access.getOrCreateBlockCacheNode(blockX, blockY, blockZ, false);
|
||||
final Material id = node.getId();
|
||||
final Material id = node.getType();
|
||||
if (BlockProperties.isPassable(id)) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue