2021-06-19 07:52:33 +02:00
|
|
|
package com.jozufozu.flywheel.config;
|
|
|
|
|
2021-06-30 21:43:54 +02:00
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
2021-09-15 08:45:29 +02:00
|
|
|
import net.minecraft.network.FriendlyByteBuf;
|
2021-06-19 07:52:33 +02:00
|
|
|
import net.minecraftforge.fml.network.NetworkEvent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-06-19 07:52:33 +02:00
|
|
|
target = BooleanConfig.values()[buffer.readByte()];
|
|
|
|
directive = BooleanDirective.values()[buffer.readByte()];
|
|
|
|
}
|
|
|
|
|
2021-09-15 08:45:29 +02:00
|
|
|
public void encode(FriendlyByteBuf buffer) {
|
2021-06-19 07:52:33 +02:00
|
|
|
buffer.writeByte(target.ordinal());
|
|
|
|
buffer.writeByte(directive.ordinal());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void execute(Supplier<NetworkEvent.Context> ctx) {
|
2021-06-30 21:43:54 +02:00
|
|
|
target.receiver.get()
|
|
|
|
.accept(directive);
|
|
|
|
ctx.get()
|
|
|
|
.setPacketHandled(true);
|
2021-06-19 07:52:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|