-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#515] Implemented a mechanism to selectively disable auto-updates fo…
…r bulk syncing large amount of objects
- Loading branch information
Showing
7 changed files
with
123 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...de/srendi/advancedperipherals/common/network/toclient/RenderableObjectBulkSyncPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package de.srendi.advancedperipherals.common.network.toclient; | ||
|
||
import de.srendi.advancedperipherals.AdvancedPeripherals; | ||
import de.srendi.advancedperipherals.client.smartglasses.OverlayObjectHolder; | ||
import de.srendi.advancedperipherals.common.network.base.IPacket; | ||
import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.ObjectDecodeRegistry; | ||
import de.srendi.advancedperipherals.common.smartglasses.modules.overlay.objects.RenderableObject; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraftforge.network.NetworkEvent; | ||
|
||
public class RenderableObjectBulkSyncPacket implements IPacket { | ||
|
||
private final RenderableObject[] objects; | ||
|
||
public RenderableObjectBulkSyncPacket(RenderableObject[] objects) { | ||
this.objects = objects; | ||
} | ||
|
||
@Override | ||
public void handle(NetworkEvent.Context context) { | ||
OverlayObjectHolder.addOrUpdateObjects(objects); | ||
} | ||
|
||
@Override | ||
public void encode(FriendlyByteBuf buffer) { | ||
buffer.writeInt(objects.length); | ||
for (RenderableObject object : objects) | ||
object.encode(buffer); | ||
} | ||
|
||
public static RenderableObjectBulkSyncPacket decode(FriendlyByteBuf buffer) { | ||
AdvancedPeripherals.debug("Size" + buffer.readableBytes()); | ||
|
||
int size = buffer.readInt(); | ||
RenderableObject[] objects = new RenderableObject[size]; | ||
|
||
for (int i = 0; i < size; i++) { | ||
int id = buffer.readInt(); | ||
objects[i] = ObjectDecodeRegistry.getObject(id, buffer); | ||
} | ||
|
||
return new RenderableObjectBulkSyncPacket(objects); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters