mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-25 06:27:41 +01:00
Defer netcode to server thread
This commit is contained in:
parent
c170738a56
commit
b4ebd54c9c
2 changed files with 27 additions and 22 deletions
|
@ -64,10 +64,12 @@ public class ContraptionColliderLockPacket extends SimplePacketBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Context context) {
|
public boolean handle(Context context) {
|
||||||
AllPackets.getChannel()
|
context.enqueueWork(() -> {
|
||||||
.send(PacketDistributor.TRACKING_ENTITY.with(context::getSender),
|
AllPackets.getChannel()
|
||||||
new ContraptionColliderLockPacket(contraption, offset, context.getSender()
|
.send(PacketDistributor.TRACKING_ENTITY.with(context::getSender),
|
||||||
.getId()));
|
new ContraptionColliderLockPacket(contraption, offset, context.getSender()
|
||||||
|
.getId()));
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,26 +43,29 @@ public class ClipboardEditPacket extends SimplePacketBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(Context context) {
|
public boolean handle(Context context) {
|
||||||
ServerPlayer sender = context.getSender();
|
context.enqueueWork(() -> {
|
||||||
|
ServerPlayer sender = context.getSender();
|
||||||
if (targetedBlock != null) {
|
|
||||||
Level world = sender.level;
|
if (targetedBlock != null) {
|
||||||
if (world == null || !world.isLoaded(targetedBlock))
|
Level world = sender.level;
|
||||||
return true;
|
if (world == null || !world.isLoaded(targetedBlock))
|
||||||
if (!targetedBlock.closerThan(sender.blockPosition(), 20))
|
return;
|
||||||
return true;
|
if (!targetedBlock.closerThan(sender.blockPosition(), 20))
|
||||||
if (world.getBlockEntity(targetedBlock) instanceof ClipboardBlockEntity cbe) {
|
return;
|
||||||
cbe.dataContainer.setTag(data.isEmpty() ? null : data);
|
if (world.getBlockEntity(targetedBlock) instanceof ClipboardBlockEntity cbe) {
|
||||||
cbe.onEditedBy(sender);
|
cbe.dataContainer.setTag(data.isEmpty() ? null : data);
|
||||||
|
cbe.onEditedBy(sender);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
ItemStack itemStack = sender.getInventory()
|
||||||
|
.getItem(hotbarSlot);
|
||||||
|
if (!AllBlocks.CLIPBOARD.isIn(itemStack))
|
||||||
|
return;
|
||||||
|
itemStack.setTag(data.isEmpty() ? null : data);
|
||||||
|
});
|
||||||
|
|
||||||
ItemStack itemStack = sender.getInventory()
|
|
||||||
.getItem(hotbarSlot);
|
|
||||||
if (!AllBlocks.CLIPBOARD.isIn(itemStack))
|
|
||||||
return true;
|
|
||||||
itemStack.setTag(data.isEmpty() ? null : data);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue