2021-06-19 07:52:33 +02:00
|
|
|
package com.jozufozu.flywheel.config;
|
|
|
|
|
2021-06-30 21:43:54 +02:00
|
|
|
|
2021-11-18 23:59:39 +01:00
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
2021-09-15 08:45:29 +02:00
|
|
|
import net.minecraft.network.FriendlyByteBuf;
|
2021-12-07 06:29:21 +01:00
|
|
|
import net.minecraftforge.network.NetworkEvent;
|
2021-09-15 09:26:51 +02:00
|
|
|
|
2021-06-19 07:52:33 +02:00
|
|
|
/**
|
|
|
|
* Thanks, @zelophed
|
|
|
|
*/
|
|
|
|
public class SConfigureBooleanPacket {
|
|
|
|
|
|
|
|
private final BooleanConfig target;
|
|
|
|
private final BooleanDirective directive;
|
|
|
|
|
|
|
|
public SConfigureBooleanPacket(BooleanConfig target, BooleanDirective directive) {
|
|
|
|
this.target = target;
|
|
|
|
this.directive = directive;
|
|
|
|
}
|
|
|
|
|
2021-09-15 08:45:29 +02:00
|
|
|
public SConfigureBooleanPacket(FriendlyByteBuf buffer) {
|
2021-11-01 01:24:57 +01:00
|
|
|
target = BooleanConfig.decode(buffer);
|
|
|
|
directive = BooleanDirective.decode(buffer);
|
2021-06-19 07:52:33 +02:00
|
|
|
}
|
|
|
|
|
2021-09-15 08:45:29 +02:00
|
|
|
public void encode(FriendlyByteBuf buffer) {
|
2021-11-01 01:24:57 +01:00
|
|
|
target.encode(buffer);
|
|
|
|
directive.encode(buffer);
|
2021-06-19 07:52:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void execute(Supplier<NetworkEvent.Context> ctx) {
|
2021-11-01 01:24:57 +01:00
|
|
|
if (directive != null) {
|
|
|
|
target.receiver.get()
|
|
|
|
.accept(directive);
|
|
|
|
}
|
2021-06-30 21:43:54 +02:00
|
|
|
ctx.get()
|
|
|
|
.setPacketHandled(true);
|
2021-06-19 07:52:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|