Flywheel/src/main/java/com/jozufozu/flywheel/config/SConfigureBooleanPacket.java
Jozufozu 881ce3639d Merge remote-tracking branch 'origin/1.16/dev' into 1.17/dev
# Conflicts:
#	changelog.txt
#	gradle.properties
#	src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderDispatcher.java
#	src/main/java/com/jozufozu/flywheel/config/BooleanConfig.java
#	src/main/java/com/jozufozu/flywheel/config/SConfigureBooleanPacket.java
#	src/main/java/com/jozufozu/flywheel/event/ForgeEvents.java
#	src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java
#	src/main/java/com/jozufozu/flywheel/util/WorldAttached.java
#	src/main/resources/flywheel.mixins.json
2021-11-23 16:49:39 -08:00

41 lines
914 B
Java

package com.jozufozu.flywheel.config;
import java.util.function.Supplier;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.fmllegacy.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;
}
public SConfigureBooleanPacket(FriendlyByteBuf buffer) {
target = BooleanConfig.decode(buffer);
directive = BooleanDirective.decode(buffer);
}
public void encode(FriendlyByteBuf buffer) {
target.encode(buffer);
directive.encode(buffer);
}
public void execute(Supplier<NetworkEvent.Context> ctx) {
if (directive != null) {
target.receiver.get()
.accept(directive);
}
ctx.get()
.setPacketHandled(true);
}
}