Send Packet52MultiBlockChange

is there any way to do this with native api or mcp?

What鈥檚 your usecase? You can send Individual blocks via the Viewer interface, otherwise there鈥檚 a plugin called packet gate, or you can tie into mcp

1 Like

its a multithread visual system that can work with the signal block update or that chunk update its use case is infinite. also link the plugin i could only find this PacketGate Item Cosmetic Plugin

is there any way i can use this Implement networking API by simon816 路 Pull Request #226 路 SpongePowered/SpongeForge 路 GitHub ?

also this is what i鈥檓 using :smiley: any help would be nice in porting it to sponge

also is mcp future proof and only needs updating if forge changes witch is unlikely in this case?

public void multiBlockUpdate(List list){

	if(list.size()<5){
		for(DummyBlock b : list){
			BukkitPlugin.self.sendBlock(player,b,b.getLocation());
		}
		return;
	}
	
		if(debug)DEBUG.log("multiBlockChange: procesing:"+list.size()); 

     //make packets 1 pacet = 1 chunk
     
     HashMap<String, OutputSet> plist = new HashMap<String,OutputSet>();
     
     for(DummyBlock i : list){
    	 Location l = i.getLocation();
    	 int id = i.id;
    	 int sub = i.sub;
    	 int x = (int)l.getX();
    	 int y = (int)l.getY();
    	 int z = (int)l.getZ();
    	 
    	 int xx = x >> 4;
    	 int zz = z >> 4;
    	 
    	 String chunk = xx+","+zz;
    	 
    	short locPart = (short)((x & 0xF) << 12 | (z & 0xF) << 8 | (y & 0xFF));
 		short dataPart = (short)((id & 4095) << 4 | (sub & 0xF));

 		OutputSet set = plist.get(chunk);
 		
 		if(set==null){
 			set = new OutputSet();
 			plist.put(chunk,set);
 		}
    	
 		set.add(locPart,dataPart);
 		
 		
     }
     //send packets
     if(debug)DEBUG.log("sending "+plist.size()+"packets");
     
     for(Entry<String, OutputSet> entry : plist.entrySet()){
    	 
    	 PacketContainer packet = new PacketContainer(Play.Server.MULTI_BLOCK_CHANGE);
    	 
    	 String[] str = entry.getKey().split(",");
    	 
    	 int xx = Integer.parseInt(str[0]);
    	 int zz = Integer.parseInt(str[1]); 
    	 
    	 packet.getChunkCoordIntPairs().write(0, new ChunkCoordIntPair(xx,zz));
			packet.getIntegers().write(0, entry.getValue().blockCount);
			packet.getByteArrays().write(0, entry.getValue().stream.toByteArray());
			//packet.getProtocols().r
    	 
    	try {
			BukkitPlugin.self.Protocol.sendServerPacket(player,packet);
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
    	 
    	 
    	 try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
     }
}
1 Like

so it seams GitHub - CrushedPixel/PacketGate: Sponge library to manipulate incoming and outgoing Packets. is used with vanilla sponge will this work in forge? and it uses net.minecraft.network.play for packets. is this not obfuscated in sponge?

1 Like

This uses Minecraft code which is not changed by Forge, so yes it will work fine. And it gets obfuscated by Gradle when it gets compiled; only crazy people would code against Minecraft APIs in their obfuscated form (unless forced to like in Bukkit).

3 Likes