Rough update for 1.7.2 blocks.

Adds an ice flag to BlockProperties.
This commit is contained in:
asofold 2013-12-01 21:33:07 +01:00
parent fd745458d6
commit 8d5a0b1dca
4 changed files with 61 additions and 2 deletions

View File

@ -167,6 +167,7 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
// TODO: (?) Set some generic properties matching what BlockCache.getShape returns.
final Set<Integer> fullBlocks = new HashSet<Integer>();
for (final Material mat : new Material[]{
// TODO: Ice !? / Packed ice !?
Material.GLASS, Material.GLOWSTONE, Material.ICE, Material.LEAVES,
Material.COMMAND, Material.BEACON,
Material.PISTON_BASE,

View File

@ -0,0 +1,37 @@
package fr.neatmonster.nocheatplus.compat.blocks.init.vanilla;
import org.bukkit.Material;
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
import fr.neatmonster.nocheatplus.compat.blocks.init.BlockInit;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
public class BlocksMC1_7_2 implements BlockPropertiesSetup{
public BlocksMC1_7_2() {
BlockInit.assertMaterialNameMatch(95, "stained", "glass");
BlockInit.assertMaterialNameMatch(174, "packed", "ice");
}
@Override
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// Stained glass
BlockInit.setAs(95, Material.GLASS);
// Stained glass pane
BlockInit.setAs(160, 102);
// Leaves 2
BlockInit.setAs(161, Material.LEAVES);
// Log 2
BlockInit.setAs(162, Material.LOG);
// Acacia wood stairs
BlockInit.setAs(163, Material.WOOD_STAIRS);
// Oak wood stairs
BlockInit.setAs(164, Material.WOOD_STAIRS);
// Packed ice
BlockInit.setAs(174, Material.ICE);
// Large flowers
BlockInit.setAs(175, Material.YELLOW_FLOWER);
}
}

View File

@ -340,6 +340,9 @@ public class BlockProperties {
/** All rail types a minecart can move on. */
public static final long F_RAILS = 0x10000;
/** ICE */
public static final long F_ICE = 0x20000;
/**
* Map flag to names.
*/
@ -539,6 +542,9 @@ public class BlockProperties {
blockFlags[mat.getId()] |= F_XZ100;
}
// ICE
blockFlags[Material.ICE.getId()] |= F_ICE;
// Not ground (!).
for (final Material mat : new Material[]{
Material.WALL_SIGN, Material.SIGN_POST,
@ -1259,6 +1265,10 @@ public class BlockProperties {
return (blockFlags[id] & F_LIQUID) != 0;
}
public static final boolean isIce(final int id) {
return (blockFlags[id] & F_ICE) != 0;
}
/**
* Might hold true for liquids too.
* @param id

View File

@ -372,8 +372,19 @@ public class PlayerLocation {
if (onIce == null) {
// TODO: Use a box here too ?
// TODO: check if player is really sneaking (refactor from survivalfly to static access in Combined ?)!
if (player.isSneaking() || player.isBlocking()) onIce = getTypeId(blockX, Location.locToBlock(minY - 0.1D), blockZ) == Material.ICE.getId();
else onIce = getTypeIdBelow().intValue() == Material.ICE.getId();
if (blockFlags != null && (blockFlags.longValue() & BlockProperties.F_ICE) == 0) {
// TODO: check onGroundMinY !?
onIce = false;
} else {
final int id;
if (player.isSneaking() || player.isBlocking()) {
id = getTypeId(blockX, Location.locToBlock(minY - 0.1D), blockZ);
}
else {
id = getTypeIdBelow().intValue();
}
onIce = BlockProperties.isIce(id);
}
}
return onIce;
}