dniym/IllegalStack

Bedrock breaking exploit

Closed this issue · 3 comments

VidTu commented

So this is not hard to fix this bug: (Fix for 1.12.2)

public class PortalFix implements Listener {
	private static final List<Material> UNBREAKABLE = Arrays.asList(Material.BEDROCK, Material.ENDER_PORTAL, Material.ENDER_PORTAL_FRAME,
			Material.COMMAND, Material.COMMAND_CHAIN, Material.COMMAND_REPEATING, Material.STRUCTURE_BLOCK, Material.BARRIER); //List of unbreakable on 1.12.2.
	@EventHandler
	public void onPortal(PortalCreateEvent event) {
		for (Block b : event.getBlocks()) {
			if (UNBREAKABLE.contains(b.getType())) {
				//Blocking breaking of unbreakable blocks.
				event.setCancelled(true);
				break;
			}
			if (b.getY() > 255) {
				//Blocking portals spawning at world height limit, preventing from https://i.imgur.com/mqAXdpU.png
				event.setCancelled(true);
				break;
			}
		}
	}
}
dniym commented

Only issue with this is the list of unbreakable items can change depending on the version, this list would have to be fixed to add the correct material name based on the version...

For example: Material.COMMAND is fine for 1.12 but in other versions its known as Material.COMMAND_BLOCK,
likewise Material.ENDER_PORTAL in 1.12 works but its Material.END_PORTAL in 1.17

VidTu commented

yea, I know.
but this is a serious exploit and I think you can do something cross-version with Material.matchMaterial or Material.valueOf

dniym commented

Added as of version 2.3.1