Skip to content

Commit

Permalink
Pissing on the pastel nodes like I piss in Maya
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzyypaaras committed Jan 14, 2025
1 parent cbde9ed commit a760175
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.dafuqs.spectrum.blocks.pastel_network.nodes.*;
import de.dafuqs.spectrum.helpers.ColorHelper;
import de.dafuqs.spectrum.helpers.*;
import de.dafuqs.spectrum.networking.*;
import net.minecraft.block.entity.*;
import net.minecraft.nbt.*;
import net.minecraft.registry.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ else if (transferLooper.getTick() % 2 == 0) {
if (cap || priority != Priority.GENERIC) {
if (cap) {
this.transferLooper.reset();
// If someone complains about network usage I am going to fucking kill myself
SpectrumS2CPacketSender.syncPastelNetworkEdges(this, toNbt());
}
try {
this.transmissionLogic.tick(priority);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.dafuqs.spectrum.*;
import de.dafuqs.spectrum.blocks.pastel_network.nodes.*;
import de.dafuqs.spectrum.networking.*;
import net.minecraft.nbt.*;
import net.minecraft.registry.*;
import net.minecraft.server.world.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,13 @@ public NbtCompound toInitialChunkDataNbt() {
@Override
public void markRemoved() {
super.markRemoved();
Pastel.getInstance(world.isClient).removeNode(this, world.getBlockState(pos).getBlock() instanceof PastelNodeBlock ? NodeRemovalReason.UNLOADED : NodeRemovalReason.BROKEN);
// Hanky jacks
if (world.isClient()) {
Pastel.getInstance(true).removeNode(this, world.getBlockState(pos).getBlock() instanceof PastelNodeBlock ? NodeRemovalReason.UNLOADED : NodeRemovalReason.BROKEN);
}
else {
Pastel.getInstance(false).removeNode(this, NodeRemovalReason.UNLOADED);
}
}

public @NotNull UUID getInitialID() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.dafuqs.spectrum.api.energy.color.*;
import de.dafuqs.spectrum.blocks.fusion_shrine.*;
import de.dafuqs.spectrum.blocks.particle_spawner.*;
import de.dafuqs.spectrum.blocks.pastel_network.*;
import de.dafuqs.spectrum.blocks.pastel_network.network.*;
import de.dafuqs.spectrum.blocks.pastel_network.nodes.*;
import de.dafuqs.spectrum.blocks.pedestal.*;
Expand Down Expand Up @@ -543,7 +544,19 @@ public static void registerS2CReceivers() {
}
});
}))));


ClientPlayNetworking.registerGlobalReceiver(SpectrumS2CPackets.PASTEL_NETWORK_EDGE_SYNC, (client, handler, buf, responseSender) -> {
var uuid = buf.readUuid();
var nbt = buf.readNbt();

client.execute(() -> {
Pastel.getInstance(true).getNetwork(uuid).ifPresentOrElse(
n -> n.fromNbt(nbt),
() -> {

});
});
});
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.dafuqs.spectrum.networking;

import de.dafuqs.spectrum.*;
import de.dafuqs.spectrum.api.block.*;
import de.dafuqs.spectrum.api.color.*;
import de.dafuqs.spectrum.api.energy.*;
Expand All @@ -18,6 +19,7 @@
import net.minecraft.entity.*;
import net.minecraft.entity.player.*;
import net.minecraft.item.*;
import net.minecraft.nbt.*;
import net.minecraft.network.*;
import net.minecraft.particle.*;
import net.minecraft.registry.*;
Expand Down Expand Up @@ -488,4 +490,13 @@ public static void sendPastelNodeStatusUpdate(List<PastelNodeBlockEntity> nodes,
}
}

public static void syncPastelNetworkEdges(ServerPastelNetwork serverPastelNetwork, NbtCompound graphStorage) {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeUuid(serverPastelNetwork.getUUID());
buf.writeNbt(graphStorage);

assert SpectrumCommon.minecraftServer != null; //shhhh
for (ServerPlayerEntity player : PlayerLookup.all(SpectrumCommon.minecraftServer))
ServerPlayNetworking.send(player, SpectrumS2CPackets.PASTEL_NETWORK_EDGE_SYNC, buf);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ public class SpectrumS2CPackets {
public static final Identifier BLACK_HOLE_CHEST_STATUS_UPDATE = SpectrumCommon.locate("black_hole_chest_status");
public static final Identifier RESTOCKING_CHEST_STATUS_UPDATE = SpectrumCommon.locate("restocking_chest_status");
public static final Identifier PASTEL_NODE_STATUS_UPDATE = SpectrumCommon.locate("pastel_node_status");
public static final Identifier PASTEL_NETWORK_EDGE_SYNC = SpectrumCommon.locate("pastel_edge_sync");

}

0 comments on commit a760175

Please sign in to comment.