File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
src/main/java/io/github/mattidragon/demobox Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 11package io .github .mattidragon .demobox ;
22
3+ import eu .pb4 .predicate .api .PredicateRegistry ;
34import net .fabricmc .api .ModInitializer ;
45import net .minecraft .util .Identifier ;
56import org .slf4j .Logger ;
@@ -16,5 +17,6 @@ public static Identifier id(String path) {
1617 @ Override
1718 public void onInitialize () {
1819 DemoBoxCommand .register ();
20+ PredicateRegistry .register (DemoBoxPredicate .ID , DemoBoxPredicate .CODEC );
1921 }
2022}
Original file line number Diff line number Diff line change 1+ package io .github .mattidragon .demobox ;
2+
3+ import com .mojang .serialization .MapCodec ;
4+ import eu .pb4 .predicate .api .AbstractPredicate ;
5+ import eu .pb4 .predicate .api .PredicateContext ;
6+ import eu .pb4 .predicate .api .PredicateResult ;
7+ import net .minecraft .util .Identifier ;
8+ import xyz .nucleoid .plasmid .game .manager .GameSpaceManager ;
9+
10+ public class DemoBoxPredicate extends AbstractPredicate {
11+ public static final Identifier ID = DemoBox .id ("in_demo" );
12+ public static final DemoBoxPredicate INSTANCE = new DemoBoxPredicate ();
13+ public static final MapCodec <DemoBoxPredicate > CODEC = MapCodec .unit (INSTANCE );
14+
15+ public DemoBoxPredicate () {
16+ super (ID , CODEC );
17+ }
18+
19+ @ Override
20+ public PredicateResult <?> test (PredicateContext context ) {
21+ var world = context .world ();
22+ if (world == null ) return PredicateResult .ofFailure ();
23+ var gameSpace = GameSpaceManager .get ().byWorld (world );
24+ if (gameSpace == null ) return PredicateResult .ofFailure ();
25+ if (gameSpace .getMetadata ().sourceConfig ().type () != DemoBoxGame .TYPE ) return PredicateResult .ofFailure ();
26+ return PredicateResult .ofSuccess ();
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments