Skip to content

Commit

Permalink
Allow CT to add flags to existing materials (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
TechLord22 authored Sep 16, 2021
1 parent 152c268 commit eb4eb2f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main/java/gregtech/api/unification/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import stanhebben.zenscript.annotations.*;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.*;

@ZenClass("mods.gregtech.material.Material")
@ZenRegister
Expand Down Expand Up @@ -111,13 +108,20 @@ protected void registerMaterial(Material material) {
MaterialRegistry.register(this);
}

@ZenMethod
public void addFlag(MaterialFlag... flags) {
public void addFlags(MaterialFlag... flags) {
if (MaterialRegistry.isFrozen())
throw new IllegalStateException("Cannot add flag to material when registry is frozen!");
this.flags.addFlags(flags).verify(this);
}

@ZenMethod
public void addFlags(String... names) {
addFlags(Arrays.stream(names)
.map(MaterialFlag::getByName)
.filter(Objects::nonNull)
.toArray(MaterialFlag[]::new));
}

public boolean hasFlag(MaterialFlag flag) {
return flags.hasFlag(flag);
}
Expand Down

0 comments on commit eb4eb2f

Please sign in to comment.