com.yungnickyoung.minecraft.yungsapi.world.structure.condition.NotCondition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of YungsApi-1.21-Fabric Show documentation
Show all versions of YungsApi-1.21-Fabric Show documentation
A common API for YUNG's Minecraft mods
The newest version!
package com.yungnickyoung.minecraft.yungsapi.world.structure.condition;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.yungnickyoung.minecraft.yungsapi.world.structure.context.StructureContext;
/**
* Simple condition that passes if its wrapped condition does not pass.
*/
public class NotCondition extends StructureCondition {
public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((builder) -> builder
.group(
StructureConditionType.CONDITION_CODEC.fieldOf("condition").forGetter(condition -> condition.condition)
).apply(builder, NotCondition::new));
/**
* Wrapped condition to be negated.
*/
private final StructureCondition condition;
public NotCondition(StructureCondition condition) {
this.condition = condition;
}
@Override
public StructureConditionType> type() {
return StructureConditionType.NOT;
}
@Override
public boolean passes(StructureContext ctx) {
return !condition.passes(ctx);
}
}