Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to 1.19.4, fix NoSuchMethod error.

Should be done, more or less (?)

Also catch a false positive with frogspawn placement on water (like lily).
  • Loading branch information
Lysandr0 committed Apr 1, 2023
1 parent 095dc1a commit 98e9635
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public class MCAccessBukkitModern extends MCAccessBukkit {
protected ReflectLivingEntity reflectLivingEntity = null;
protected final Map<Material, BukkitShapeModel> shapeModels = new HashMap<Material, BukkitShapeModel>();

// Blocks that can automatic fetch bounding box from API
// Blocks that can be fetched automatically from from the Bukkit API
private static final BukkitShapeModel MODEL_AUTO_FETCH = new BukkitFetchableBound();

// Blocks that form from multi-bounds
// Blocks that are formed from multiple bounding boxes
private static final BukkitShapeModel MODEL_BREWING_STAND = new BukkitStatic(
// Bottom rod
0.0625, 0.0, 0.0625, 0.9375, 0.125, 0.9375,
Expand Down Expand Up @@ -139,7 +139,7 @@ public MCAccessBukkitModern() {
this.reflectDamageSource = new ReflectDamageSource(this.reflectBase);
this.reflectLivingEntity = new ReflectLivingEntity(this.reflectBase, null, this.reflectDamageSource);
}
catch(ClassNotFoundException ex) {}
catch (ClassNotFoundException ex) {}
}

@Override
Expand Down Expand Up @@ -193,6 +193,7 @@ public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvide
Material.CHORUS_FLOWER}) {
processedBlocks.add(mat);
}

for (final Material mat : BridgeMaterial.getAllBlocks(
"light", "glow_lichen", "big_dripleaf_stem",
// TODO: Not fully tested
Expand All @@ -214,7 +215,8 @@ public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvide
for (Material mat : BridgeMaterial.getAllBlocks(
"azalea", "flowering_azalea",
"sculk_sensor", "pointed_dripstone",
"stonecutter", "chain")) {
"stonecutter", "chain", "pink_petals", "frogspawn",
"torchflower", "decorated_pot")) {
addModel(mat, MODEL_AUTO_FETCH);
}

Expand Down Expand Up @@ -480,9 +482,7 @@ public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvide
// TODO: Perhaps another model flag.
addModel(mat, MODEL_GATE);
}
else {
addModel(mat, MODEL_THICK_FENCE);
}
else addModel(mat, MODEL_THICK_FENCE);
}
}
super.setupBlockProperties(worldConfigProvider);
Expand Down Expand Up @@ -510,7 +510,6 @@ public AlmostBoolean dealFallDamageFiresAnEvent() {
@Override
public void dealFallDamage(Player player, double damage) {
if (canDealFallDamage()) {

Object handle = getHandle(player);
if (handle != null) {
ReflectionUtil.invokeMethod(this.reflectLivingEntity.nmsDamageEntity, handle, this.reflectDamageSource.nmsFALL, (float) damage);
Expand Down
2 changes: 1 addition & 1 deletion NCPCompatProtocolLib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ public NoSlow(Plugin plugin) {

@Override
public void onPacketReceiving(final PacketEvent event) {
if (event.isPlayerTemporary()) return;
try {
if (event.isPlayerTemporary()) return;
}
catch(NoSuchMethodError e) {
// Ignore.
}

if (event.getPacketType().equals(PacketType.Play.Client.BLOCK_DIG)) {
handleDiggingPacket(event);
} else {
Expand Down
2 changes: 1 addition & 1 deletion NCPCore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ else if (BlockProperties.isAir(ncpAgainst)) { // Holds true for null blocks.
}
}
else if (!pData.hasPermission(Permissions.BLOCKPLACE_AGAINST_AIR, player)
&& placedMat != BridgeMaterial.LILY_PAD) {
&& placedMat != BridgeMaterial.LILY_PAD
&& placedMat != BridgeMaterial.FROGSPAWN) {
violation = true;
// Attempted to place a block against a null one (air)
}
}
else if (BlockProperties.isLiquid(ncpAgainst)) {
if ((placedMat != BridgeMaterial.LILY_PAD
|| !BlockProperties.isLiquid(block.getRelative(BlockFace.DOWN).getType()))
&& !BlockProperties.isWaterPlant(bIData.getLastType())
if (((placedMat != BridgeMaterial.LILY_PAD || placedMat != BridgeMaterial.FROGSPAWN) || !BlockProperties.isLiquid(block.getRelative(BlockFace.DOWN).getType()))
&& !BlockProperties.isWaterPlant(ncpAgainst)
&& !pData.hasPermission(Permissions.BLOCKPLACE_AGAINST_LIQUIDS, player)) {
violation = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public static boolean has(String name) {
public static final Material SCAFFOLDING = get("scaffolding");

/** Sign block. */
public static final Material SIGN = getFirstNotNull("acacia_sign", "birch_sign", "dark_oak_sign", "jungle_sign", "oak_sign", "spruce_sign", "acacia_wall_sign", "birch_wall_sign", "dark_oak_wall_sign", "jungle_wall_sign", "oak_wall_sign", "spruce_wall_sign", "sign_post", "sign", "wall_sign");
public static final Material SIGN = getFirstNotNull("bamboo_sign", "cherry_sign", "acacia_sign", "birch_sign", "dark_oak_sign", "jungle_sign", "oak_sign", "spruce_sign", "bamboo_wall_sign", "cherry_wall_sign", "acacia_wall_sign", "birch_wall_sign", "dark_oak_wall_sign", "jungle_wall_sign", "oak_wall_sign", "spruce_wall_sign", "sign_post", "sign", "wall_sign");

/** Some skull for reference. */
public static final Material SKELETON_SKULL = getFirst("skeleton_skull", "skull");
Expand Down Expand Up @@ -325,6 +325,8 @@ public static boolean has(String name) {

public static final Material VOID_AIR = get("void_air"); // May be null on legacy spigot.

public static final Material FROGSPAWN = get("frogspawn");

public static final Material WHEAT_CROPS = getFirstNotNull("crops", "wheat"); // Reversed

private static void getBySuffix(final String suffix, final AlmostBoolean isBlock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,46 @@ public BlocksMC1_19() {
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
BlockFlags.setFlagsAs("OCHRE_FROGLIGHT", Material.DIRT);
BlockProperties.setBlockProps("OCHRE_FROGLIGHT", new BlockProperties.BlockProps(BlockProperties.noTool, 0.3f));

BlockInit.setAs("VERDANT_FROGLIGHT", "OCHRE_FROGLIGHT");
BlockInit.setAs("PEARLESCENT_FROGLIGHT", "OCHRE_FROGLIGHT");

BlockInit.setAs("PEARLESCENT_FROGLIGHT", "OCHRE_FROGLIGHT");

//
BlockProperties.setBlockProps("MUD", new BlockProperties.BlockProps(BlockProperties.woodSpade, 0.5f));
BlockFlags.setBlockFlags("MUD", BlockFlags.SOLID_GROUND);
//

BlockProperties.setBlockProps("PACKED_MUD", new BlockProperties.BlockProps(BlockProperties.woodPickaxe, 1f));
BlockFlags.setFlagsAs("PACKED_MUD", Material.DIRT);

BlockInit.setAs("MUD_BRICKS", Material.ANDESITE);
BlockInit.setAs("MUD_BRICK_SLAB", Material.ANDESITE_SLAB);

BlockInit.setAs("MUD_BRICK_STAIRS", Material.ANDESITE_STAIRS);
BlockInit.setAs("MUD_BRICK_WALL", Material.ANDESITE_WALL);


BlockProperties.setBlockProps("FROGSPAWN", BlockProperties.instantType);

BlockFlags.setBlockFlags("FROGSPAWN", BlockFlags.F_IGN_PASSABLE);

BlockFlags.setFlagsAs("MUDDY_MANGROVE_ROOTS", Material.DIRT);
//
BlockProperties.setBlockProps("MUDDY_MANGROVE_ROOTS", new BlockProperties.BlockProps(BlockProperties.woodSpade, 0.7f));

BlockFlags.setFlagsAs("MANGROVE_ROOTS", Material.DIRT);
//

BlockProperties.setBlockProps("MANGROVE_ROOTS", new BlockProperties.BlockProps(BlockProperties.woodAxe, 0.7f));


BlockFlags.setBlockFlags("SCULK_VEIN", BlockFlags.F_IGN_PASSABLE);
//

BlockProperties.setBlockProps("SCULK_VEIN", new BlockProperties.BlockProps(BlockProperties.woodHoe, 0.2f));

BlockInit.setPropsAs("SCULK", "SCULK_VEIN");
BlockFlags.setFlagsAs("SCULK", Material.DIRT);

BlockFlags.setFlagsAs("SCULK_CATALYST", Material.DIRT);
//
BlockProperties.setBlockProps("SCULK_CATALYST", new BlockProperties.BlockProps(BlockProperties.woodHoe, 3f));

BlockFlags.setFlagsAs("REINFORCED_DEEPSLATE", Material.OBSIDIAN);
BlockProperties.setBlockProps("REINFORCED_DEEPSLATE", new BlockProperties.BlockProps(BlockProperties.noTool, 55f));
//

BlockProperties.setBlockProps("SCULK_SHRIEKER", new BlockProperties.BlockProps(BlockProperties.woodHoe, 3f));
BlockFlags.setBlockFlags("SCULK_SHRIEKER", BlockFlags.SOLID_GROUND);

Expand All @@ -85,6 +87,12 @@ public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
BlockInit.setAs("CHISELED_BOOKSHELF", Material.BOOKSHELF);
}

if (ServerVersion.compareMinecraftVersion("1.19.4") >= 0) {
BlockInit.setAs("SUSPICIOUS_SAND", Material.SAND);
BlockProperties.setBlockProps("DECORATED_POT", BlockProperties.instantType);
BlockFlags.setBlockFlags("DECORATED_POT", BlockFlags.SOLID_GROUND | BlockFlags.FULL_BOUNDS);
}

ConfigFile config = ConfigManager.getConfigFile();
if (config.getBoolean(ConfPaths.BLOCKBREAK_DEBUG, config.getBoolean(ConfPaths.CHECKS_DEBUG, false)))
StaticLog.logInfo("Added block-info for Minecraft 1.19 blocks.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class MaterialUtil {
///////////////////////

private static final List<String> woodTypes = Arrays.asList(
"acacia", "birch", "dark_oak", "jungle", "oak", "spruce", "warped", "crimson", "mangrove", "bamboo",
"acacia", "birch", "dark_oak", "jungle", "oak", "spruce", "warped", "crimson", "mangrove", "bamboo", "cherry",
"wood" // Legacy
);

Expand Down Expand Up @@ -532,7 +532,7 @@ public static void dumpStaticSets(final Class<?> clazz, final Level level) {
"spore_blossom", "small_dripleaf", "cave_vines", "cave_vines_plant",
"weeping_vines", "weeping_vines_plant",
"twisting_vines", "twisting_vines_plant",
"mangrove_propagule"
"mangrove_propagule", "pink_petals", "torchflower", "torchflower_crop"
),
new HashSet<Material>(Arrays.asList(BridgeMaterial.TALL_GRASS,
BridgeMaterial.WHEAT_CROPS, BridgeMaterial.CARROTS,
Expand Down
2 changes: 1 addition & 1 deletion NCPPlugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down

0 comments on commit 98e9635

Please sign in to comment.