use of fr.neatmonster.nocheatplus.compat.MCAccess in project NoCheatPlus by NoCheatPlus.
the class MovingListener method prepareCreativeFlyCheck.
private void prepareCreativeFlyCheck(final Player player, final Location from, final Location to, final PlayerMoveInfo moveInfo, final PlayerMoveData thisMove, final int multiMoveCount, final int tick, final MovingData data, final MovingConfig cc) {
data.adjustFlySpeed(player.getFlySpeed(), tick, cc.speedGrace);
data.adjustWalkSpeed(player.getWalkSpeed(), tick, cc.speedGrace);
// TODO: Adjust height of PlayerLocation more efficiently / fetch model early.
final ModelFlying model = cc.getModelFlying(player, moveInfo.from, data, cc);
if (MovingConfig.ID_JETPACK_ELYTRA.equals(model.getId())) {
final MCAccess mcAccess = this.mcAccess.getHandle();
MovingUtil.setElytraProperties(player, moveInfo.from, from, cc.yOnGround, mcAccess);
MovingUtil.setElytraProperties(player, moveInfo.to, to, cc.yOnGround, mcAccess);
thisMove.set(moveInfo.from, moveInfo.to);
if (multiMoveCount > 0) {
thisMove.multiMoveCount = multiMoveCount;
}
}
thisMove.modelFlying = model;
}
use of fr.neatmonster.nocheatplus.compat.MCAccess in project NoCheatPlus by NoCheatPlus.
the class Direction method check.
/**
* "Classic" check.
*
* @param player
* the player
* @param damaged
* the damaged
* @return true, if successful
*/
public boolean check(final Player player, final Location loc, final Entity damaged, final boolean damagedIsFake, final Location dLoc, final FightData data, final FightConfig cc) {
boolean cancel = false;
final MCAccess mcAccess = this.mcAccess.getHandle();
// if (damaged instanceof EntityComplex || damaged instanceof EntityComplexPart)
if (!damagedIsFake && mcAccess.isComplexPart(damaged)) {
return false;
}
// Find out how wide the entity is.
final double width = damagedIsFake ? 0.6 : mcAccess.getWidth(damaged);
// entity.height is broken and will always be 0, therefore. Calculate height instead based on boundingBox.
final double height = damagedIsFake ? (damaged instanceof LivingEntity ? ((LivingEntity) damaged).getEyeHeight() : 1.75) : mcAccess.getHeight(damaged);
// TODO: allow any hit on the y axis (might just adapt interface to use foot position + height)!
// How far "off" is the player with their aim. We calculate from the players eye location and view direction to
// the center of the target entity. If the line of sight is more too far off, "off" will be bigger than 0.
final Vector direction = loc.getDirection();
final double off;
if (cc.directionStrict) {
off = CollisionUtil.combinedDirectionCheck(loc, player.getEyeHeight(), direction, dLoc.getX(), dLoc.getY() + height / 2D, dLoc.getZ(), width, height, TrigUtil.DIRECTION_PRECISION, 80.0);
} else {
// Also take into account the angle.
off = CollisionUtil.directionCheck(loc, player.getEyeHeight(), direction, dLoc.getX(), dLoc.getY() + height / 2D, dLoc.getZ(), width, height, TrigUtil.DIRECTION_PRECISION);
}
if (off > 0.1) {
// Player failed the check. Let's try to guess how far they were from looking directly to the entity...
final Vector blockEyes = new Vector(dLoc.getX() - loc.getX(), dLoc.getY() + height / 2D - loc.getY() - player.getEyeHeight(), dLoc.getZ() - loc.getZ());
final double distance = blockEyes.crossProduct(direction).length() / direction.length();
// Add the overall violation level of the check.
data.directionVL += distance;
// Execute whatever actions are associated with this check and the violation level and find out if we should
// cancel the event.
cancel = executeActions(player, data.directionVL, distance, cc.directionActions).willCancel();
if (cancel) {
// Deal an attack penalty time.
data.attackPenalty.applyPenalty(cc.directionPenalty);
}
} else {
// Reward the player by lowering their violation level.
data.directionVL *= 0.8D;
}
return cancel;
}
use of fr.neatmonster.nocheatplus.compat.MCAccess in project NoCheatPlus by NoCheatPlus.
the class Direction method getContext.
/**
* Data context for iterating over TraceEntry instances.
* @param player
* @param loc
* @param damaged
* @param damagedLoc
* @param data
* @param cc
* @return
*/
public DirectionContext getContext(final Player player, final Location loc, final Entity damaged, final boolean damagedIsFake, final Location damagedLoc, final FightData data, final FightConfig cc) {
final DirectionContext context = new DirectionContext();
// Find out how wide the entity is.
if (damagedIsFake) {
// Assume player / default.
// Later prefer bukkit based provider.
context.damagedComplex = false;
} else {
final MCAccess mcAccess = this.mcAccess.getHandle();
context.damagedComplex = mcAccess.isComplexPart(damaged);
}
context.direction = loc.getDirection();
context.lengthDirection = context.direction.length();
return context;
}
use of fr.neatmonster.nocheatplus.compat.MCAccess in project NoCheatPlus by NoCheatPlus.
the class VehicleMoveInfo method set.
@Override
protected void set(final RichEntityLocation rLoc, final Location loc, final Entity entity, final double yOnGround) {
if (getExtendFullWidth() > 0.0) {
final MCAccess mcAccess = from.getMCAccess();
rLoc.set(loc, entity, mcAccess.getWidth(entity) + getExtendFullWidth(), mcAccess.getHeight(entity), yOnGround);
} else {
rLoc.set(loc, entity, yOnGround);
}
}
use of fr.neatmonster.nocheatplus.compat.MCAccess in project NoCheatPlus by NoCheatPlus.
the class BlockProperties method initBlocks.
/**
* Inits the blocks.
*
* @param mcAccessHandle
* the mc access handle
* @param worldConfigProvider
* the world config provider
*/
private static void initBlocks(final IHandle<MCAccess> mcAccessHandle, final WorldConfigProvider<?> worldConfigProvider) {
final MCAccess mcAccess = mcAccessHandle.getHandle();
// Reset tool props.
blocks.clear();
// Generic initialization.
for (Material mat : Material.values()) {
blockFlags.put(mat, 0L);
if (mcAccess.isBlockLiquid(mat).decide()) {
// TODO: do not set F_GROUND for liquids ?
setFlag(mat, F_LIQUID);
if (mcAccess.isBlockSolid(mat).decide())
setFlag(mat, F_SOLID);
} else if (mcAccess.isBlockSolid(mat).decide()) {
setFlag(mat, F_SOLID | F_GROUND);
}
}
// Stairs.
for (final Material mat : new Material[] { Material.NETHER_BRICK_STAIRS, Material.COBBLESTONE_STAIRS, Material.SMOOTH_STAIRS, Material.BRICK_STAIRS, Material.SANDSTONE_STAIRS, Material.WOOD_STAIRS, Material.SPRUCE_WOOD_STAIRS, Material.BIRCH_WOOD_STAIRS, Material.JUNGLE_WOOD_STAIRS }) {
// Set ground too, to be sure.
setFlag(mat, F_STAIRS | F_HEIGHT100 | F_XZ100 | F_GROUND | F_GROUND_HEIGHT);
}
// Step (ground + full width).
for (final Material mat : new Material[] { Material.STEP, Material.WOOD_STEP }) {
setFlag(mat, F_GROUND | F_XZ100);
}
// Rails
for (final Material mat : new Material[] { Material.RAILS, Material.DETECTOR_RAIL, Material.POWERED_RAIL }) {
setFlag(mat, F_RAILS);
}
// WATER.
for (final Material mat : new Material[] { Material.STATIONARY_WATER, Material.WATER }) {
setFlag(mat, F_LIQUID | F_HEIGHT_8SIM_DEC | F_WATER | F_FALLDIST_ZERO);
}
// LAVA.
for (final Material mat : new Material[] { Material.LAVA, Material.STATIONARY_LAVA }) {
setFlag(mat, F_LIQUID | F_HEIGHT_8SIM_DEC | F_LAVA | F_FALLDIST_HALF);
}
// Snow (1.4.x)
setFlag(Material.SNOW, F_HEIGHT_8SIM_INC);
// Climbable
for (final Material mat : new Material[] { Material.VINE, Material.LADDER }) {
setFlag(mat, F_CLIMBABLE);
}
// Ground (can stand on).
for (final Material mat : new Material[] { Material.WATER_LILY, Material.LADDER, Material.DIODE_BLOCK_OFF, Material.DIODE_BLOCK_ON, Material.COCOA, Material.SNOW, Material.BREWING_STAND, Material.PISTON_MOVING_PIECE, Material.PISTON_EXTENSION, Material.STEP, Material.WOOD_STEP }) {
setFlag(mat, F_GROUND);
}
// Full block height.
for (final Material mat : new Material[] { // Material.ENDER_PORTAL_FRAME,
Material.BREWING_STAND, Material.PISTON_EXTENSION, // Server reports the visible shape 0.9375, client moves on full block height.
Material.SOIL }) {
setFlag(mat, F_HEIGHT100);
}
// Full width/xz-bounds.
for (final Material mat : new Material[] { Material.PISTON_EXTENSION, Material.ENDER_PORTAL_FRAME }) {
setFlag(mat, F_XZ100);
}
// ICE
setFlag(Material.ICE, F_ICE);
// Not ground (!).
for (final Material mat : new Material[] { Material.WALL_SIGN, Material.SIGN_POST }) {
// TODO: Might keep solid since it is meant to be related to block shapes rather ("original mc value").
maskFlag(mat, ~(F_GROUND | F_SOLID));
}
// Ignore for passable.
for (final Material mat : new Material[] { // More strictly needed.
Material.WOOD_PLATE, Material.STONE_PLATE, Material.WALL_SIGN, Material.SIGN_POST, Material.DIODE_BLOCK_ON, Material.DIODE_BLOCK_OFF, Material.BREWING_STAND, // Compatibility.
Material.LADDER, // Somewhat needed (xz-bounds vary, not critical to pass through).
Material.CAKE_BLOCK // Workarounds.
// Material.COCOA,
}) {
setFlag(mat, F_IGN_PASSABLE);
}
// Fences, 1.5 block high.
for (final Material mat : new Material[] { Material.FENCE, Material.FENCE_GATE, Material.NETHER_FENCE, Material.COBBLE_WALL }) {
setFlag(mat, F_HEIGHT150 | F_VARIABLE | F_THICK_FENCE);
}
// F_PASSABLE_X4
for (final Material mat : new Material[] { Material.FENCE_GATE, // TODO: Players can stand on - still passable past 1.9?
Material.TRAP_DOOR }) {
// TODO: PASSABLE_X4 is abused for other checks, need another one?
setFlag(mat, F_PASSABLE_X4);
}
// F_VARIABLE_REDSTONE, F_VARIABLE_USE
for (Material material : Material.values()) {
if (material.isBlock()) {
final String name = material.name().toLowerCase();
if (name.endsWith("_door") || name.endsWith("_trapdoor") || name.endsWith("fence_gate")) {
setFlag(material, F_VARIABLE_REDSTONE);
if (!name.contains("iron")) {
setFlag(material, F_VARIABLE_USE);
}
}
}
}
// F_FACING_LOW3D2_NSWE
for (final Material mat : new Material[] { Material.LADDER }) {
setFlag(mat, F_FACING_LOW3D2_NSWE);
}
// F_FACING_LOW2_SNEW
for (final Material mat : new Material[] { Material.TRAP_DOOR }) {
setFlag(mat, F_ATTACHED_LOW2_SNEW);
}
// Thin fences (iron fence, glass panes).
for (final Material mat : new Material[] { Material.IRON_FENCE, Material.THIN_GLASS }) {
setFlag(mat, F_THIN_FENCE | F_VARIABLE);
}
// Flexible ground (height):
for (final Material mat : new Material[] { // Strictly needed (multiple boxes otherwise).
Material.PISTON_EXTENSION, Material.BREWING_STAND, Material.ENDER_PORTAL_FRAME, // XZ-bounds issues.
Material.CAKE_BLOCK, // Issues standing on with F_PASSABLE_X4.
Material.TRAP_DOOR, // 1.10.2 +- client uses the reported height.
Material.SOIL }) {
setFlag(mat, F_GROUND_HEIGHT);
}
// Instantly breakable.
for (final Material mat : instantMat) {
setBlock(mat, instantType);
}
// Leaf type
for (Material mat : new Material[] { Material.LEAVES, Material.BED_BLOCK }) {
setBlock(mat, leafType);
}
setFlag(Material.LEAVES, F_LEAVES);
// Cobweb
setFlag(Material.WEB, F_COBWEB);
// Huge mushroom type (...)
for (Material mat : new Material[] { Material.HUGE_MUSHROOM_1, Material.HUGE_MUSHROOM_2, Material.VINE, Material.COCOA }) {
setBlock(mat, hugeMushroomType);
}
setBlock(Material.SNOW, new BlockProps(getToolProps(Material.WOOD_SPADE), 0.1f, secToMs(0.5, 0.1, 0.05, 0.05, 0.05, 0.05)));
setBlock(Material.SNOW_BLOCK, new BlockProps(getToolProps(Material.WOOD_SPADE), 0.1f, secToMs(1, 0.15, 0.1, 0.05, 0.05, 0.05)));
for (Material mat : new Material[] { Material.REDSTONE_LAMP_ON, Material.REDSTONE_LAMP_OFF, Material.GLOWSTONE, Material.GLASS }) {
setBlock(mat, glassType);
}
setBlock(Material.THIN_GLASS, glassType);
setBlock(Material.NETHERRACK, new BlockProps(woodPickaxe, 0.4f, secToMs(2, 0.3, 0.15, 0.1, 0.1, 0.05)));
setBlock(Material.LADDER, new BlockProps(noTool, 0.4f, secToMs(0.6), 2.5f));
setBlock(Material.CACTUS, new BlockProps(noTool, 0.4f, secToMs(0.6)));
setBlock(Material.WOOD_PLATE, new BlockProps(woodAxe, 0.5f, secToMs(0.75, 0.4, 0.2, 0.15, 0.1, 0.1)));
setBlock(Material.STONE_PLATE, new BlockProps(woodPickaxe, 0.5f, secToMs(2.5, 0.4, 0.2, 0.15, 0.1, 0.07)));
setBlock(Material.SAND, sandType);
setBlock(Material.SOUL_SAND, sandType);
for (Material mat : new Material[] { Material.LEVER, Material.PISTON_BASE, Material.PISTON_EXTENSION, Material.PISTON_STICKY_BASE, Material.STONE_BUTTON, Material.PISTON_MOVING_PIECE }) {
setBlock(mat, leverType);
}
// setBlock(Material.ICE, new BlockProps(woodPickaxe, 0.5f, secToMs(2.5, 0.4, 0.2, 0.15, 0.1, 0.1)));
setBlock(Material.ICE, new BlockProps(woodPickaxe, 0.5f, secToMs(0.7, 0.35, 0.18, 0.12, 0.09, 0.06)));
setBlock(Material.DIRT, sandType);
setBlock(Material.CAKE_BLOCK, leverType);
setBlock(Material.BREWING_STAND, new BlockProps(woodPickaxe, 0.5f, secToMs(2.5, 0.4, 0.2, 0.15, 0.1, 0.1)));
setBlock(Material.SPONGE, new BlockProps(noTool, 0.6f, secToMs(0.9)));
for (Material mat : new Material[] { Material.MYCEL, Material.GRAVEL, Material.GRASS, Material.SOIL, Material.CLAY }) {
setBlock(mat, gravelType);
}
for (Material mat : new Material[] { Material.RAILS, Material.POWERED_RAIL, Material.DETECTOR_RAIL }) {
setBlock(mat, new BlockProps(woodPickaxe, 0.7f, railsTimes));
}
setBlock(Material.MONSTER_EGGS, new BlockProps(noTool, 0.75f, secToMs(1.15)));
setBlock(Material.WOOL, new BlockProps(noTool, 0.8f, secToMs(1.2), 3f));
setBlock(Material.SANDSTONE, sandStoneType);
setBlock(Material.SANDSTONE_STAIRS, sandStoneType);
for (Material mat : new Material[] { Material.STONE, Material.SMOOTH_BRICK, Material.SMOOTH_STAIRS }) {
setBlock(mat, stoneType);
}
setBlock(Material.NOTE_BLOCK, new BlockProps(woodAxe, 0.8f, secToMs(1.2, 0.6, 0.3, 0.2, 0.15, 0.1)));
final BlockProps pumpkinType = new BlockProps(woodAxe, 1, secToMs(1.5, 0.75, 0.4, 0.25, 0.2, 0.15));
setBlock(Material.WALL_SIGN, pumpkinType);
setBlock(Material.SIGN_POST, pumpkinType);
setBlock(Material.PUMPKIN, pumpkinType);
setBlock(Material.JACK_O_LANTERN, pumpkinType);
setBlock(Material.MELON_BLOCK, new BlockProps(noTool, 1, secToMs(1.45), 3));
setBlock(Material.BOOKSHELF, new BlockProps(woodAxe, 1.5f, secToMs(2.25, 1.15, 0.6, 0.4, 0.3, 0.2)));
for (Material mat : new Material[] { Material.WOOD_STAIRS, Material.WOOD, Material.WOOD_STEP, Material.LOG, Material.FENCE, Material.FENCE_GATE, Material.JUKEBOX, Material.JUNGLE_WOOD_STAIRS, Material.SPRUCE_WOOD_STAIRS, Material.BIRCH_WOOD_STAIRS, // ?
Material.WOOD_DOUBLE_STEP // double slabs ?
}) {
setBlock(mat, woodType);
}
for (Material mat : new Material[] { Material.COBBLESTONE_STAIRS, Material.COBBLESTONE, Material.NETHER_BRICK, Material.NETHER_BRICK_STAIRS, Material.NETHER_FENCE, Material.CAULDRON, Material.BRICK, Material.BRICK_STAIRS, Material.MOSSY_COBBLESTONE, Material.BRICK, Material.BRICK_STAIRS, // ?
Material.STEP, // ?
Material.DOUBLE_STEP }) {
setBlock(mat, brickType);
}
setBlock(Material.WORKBENCH, chestType);
setBlock(Material.CHEST, chestType);
setBlock(Material.WOODEN_DOOR, woodDoorType);
setBlock(Material.TRAP_DOOR, woodDoorType);
for (Material mat : new Material[] { Material.ENDER_STONE, Material.COAL_ORE }) {
setBlock(mat, coalType);
}
// Former: coalType.
setBlock(Material.DRAGON_EGG, new BlockProps(noTool, 3f, secToMs(4.5)));
final long[] ironTimes = secToMs(15, 15, 1.15, 0.75, 0.6, 15);
final BlockProps ironType = new BlockProps(stonePickaxe, 3, ironTimes);
for (Material mat : new Material[] { Material.LAPIS_ORE, Material.LAPIS_BLOCK, Material.IRON_ORE }) {
setBlock(mat, ironType);
}
final long[] diamondTimes = secToMs(15, 15, 15, 0.75, 0.6, 15);
final BlockProps diamondType = new BlockProps(ironPickaxe, 3, diamondTimes);
for (Material mat : new Material[] { Material.REDSTONE_ORE, Material.GLOWING_REDSTONE_ORE, Material.EMERALD_ORE, Material.GOLD_ORE, Material.DIAMOND_ORE }) {
setBlock(mat, diamondType);
}
setBlock(Material.GOLD_BLOCK, goldBlockType);
setBlock(Material.FURNACE, dispenserType);
setBlock(Material.BURNING_FURNACE, dispenserType);
setBlock(Material.DISPENSER, dispenserType);
setBlock(Material.WEB, new BlockProps(woodSword, 4, secToMs(20, 0.4, 0.4, 0.4, 0.4, 0.4)));
for (Material mat : new Material[] { Material.MOB_SPAWNER, Material.IRON_DOOR_BLOCK, Material.IRON_FENCE, Material.ENCHANTMENT_TABLE, Material.EMERALD_BLOCK }) {
setBlock(mat, ironDoorType);
}
setBlock(Material.IRON_BLOCK, ironBlockType);
setBreakingTimeOverridesByEfficiency(new BlockBreakKey().blockType(Material.IRON_BLOCK).toolType(ToolType.PICKAXE).materialBase(MaterialBase.WOOD), ironBlockType.breakingTimes[1], 6200L, 3500L, 2050L, 1350L, 900L);
setBlock(Material.DIAMOND_BLOCK, diamondBlockType);
setBlock(Material.ENDER_CHEST, new BlockProps(woodPickaxe, 22.5f));
setBlock(Material.OBSIDIAN, new BlockProps(diamondPickaxe, 50, secToMs(250, 125, 62.5, 41.6, 9.4, 20.8)));
// More 1.4 (not insta).
// TODO: Either move all to an extra setup class, or integrate above.
// TODO
setBlock(Material.BEACON, new BlockProps(noTool, 25f, secToMs(4.45)));
setBlock(Material.COBBLE_WALL, brickType);
setFlag(Material.COBBLE_WALL, F_HEIGHT150);
setBlock(Material.WOOD_BUTTON, leverType);
// TODO
setBlock(Material.SKULL, new BlockProps(noTool, 8.5f, secToMs(1.45)));
setFlag(Material.SKULL, F_GROUND);
// TODO
setBlock(Material.ANVIL, new BlockProps(woodPickaxe, 5f));
setFlag(Material.FLOWER_POT, F_GROUND);
// Indestructible.
for (Material mat : new Material[] { Material.AIR, Material.ENDER_PORTAL, Material.ENDER_PORTAL_FRAME, Material.PORTAL, Material.LAVA, Material.WATER, Material.BEDROCK, Material.STATIONARY_LAVA, Material.STATIONARY_WATER }) {
setBlock(mat, indestructibleType);
}
// 95 Locked chest
// blocks[95] = indestructibleType; // Locked chest (prevent crash with 1.7).
Material mat = BlockInit.getMaterial("LOCKED_CHEST");
if (mat != null) {
BlockFlags.setFlagsAs(mat.name(), Material.CHEST);
// Breaks like chest later on.
setBlockProps(mat.name(), BlockProperties.instantType);
}
}
Aggregations