Compare commits

..
2 Commits
Author SHA1 Message Date
Glease eea5227fe3 Pull my onlyIf from GT++ 2021-12-22 21:20:27 +08:00
Glease 1f520cfd73 Add localization stuff I forgot 2021-12-22 21:17:47 +08:00
4 changed files with 129 additions and 7 deletions

No files matched your search

@@ -14,6 +14,10 @@ public interface IAlignment extends IAlignmentLimits,IAlignmentProvider {
ExtendedFacing getExtendedFacing();
/**
* Set the facing without additional checks.
* Tools altering facing should use {@link #toolSetExtendedFacing(ExtendedFacing)} instead.
*/
void setExtendedFacing(ExtendedFacing alignment);
IAlignmentLimits getAlignmentLimits();
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableSet;
import com.gtnewhorizon.structurelib.alignment.IAlignment;
import com.gtnewhorizon.structurelib.alignment.IntegerAxisSwap;
import com.gtnewhorizon.structurelib.util.Vec3Impl;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
@@ -276,6 +277,10 @@ public enum ExtendedFacing {
return this.name;
}
public String getLocalizedName() {
return StatCollector.translateToLocal("structurelib.facing." + getIndex());
}
public static ExtendedFacing byName(String name) {
return name == null ? null : NAME_LOOKUP.get(name.toLowerCase(Locale.ROOT));
}
@@ -27,13 +27,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntBinaryOperator;
import java.util.function.Supplier;
import java.util.function.*;
import static java.lang.Integer.MIN_VALUE;
@@ -816,6 +810,28 @@ public class StructureUtility {
//endregion
/**
* Enable this structure element only if given predicate returns true.
*/
public static <T> IStructureElement<T> onlyIf(Predicate<? super T> predicate, IStructureElement<? super T> downstream) {
return new IStructureElement<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
return predicate.test(t) && downstream.check(t, world, x, y, z);
}
@Override
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
return predicate.test(t) && downstream.spawnHint(t, world, x, y, z, trigger);
}
@Override
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
return predicate.test(t) && downstream.placeBlock(t, world, x, y, z, trigger);
}
};
}
/**
* Take care while chaining, as it will try to call every structure element until it returns true.
* If none does it will finally return false.
@@ -51,6 +51,103 @@ structurelib.blockhint.15.name=Hint error
structurelib.blockhint.desc.5=ERROR, what did u expect?
itemGroup.structurelib=StructureLib
structurelib.facing.0=down normal none
structurelib.facing.1=down normal horizontal
structurelib.facing.2=down normal vertical
structurelib.facing.3=down normal both
structurelib.facing.4=down clockwise none
structurelib.facing.5=down clockwise horizontal
structurelib.facing.6=down clockwise vertical
structurelib.facing.7=down clockwise both
structurelib.facing.8=down upside down
structurelib.facing.9=down upside down
structurelib.facing.10=down upside down
structurelib.facing.11=down upside down
structurelib.facing.12=down counter clockwise
structurelib.facing.13=down counter clockwise
structurelib.facing.14=down counter clockwise
structurelib.facing.15=down counter clockwise
structurelib.facing.16=up normal none
structurelib.facing.17=up normal horizontal
structurelib.facing.18=up normal vertical
structurelib.facing.19=up normal both
structurelib.facing.20=up clockwise none
structurelib.facing.21=up clockwise horizontal
structurelib.facing.22=up clockwise vertical
structurelib.facing.23=up clockwise both
structurelib.facing.24=up upside down
structurelib.facing.25=up upside down
structurelib.facing.26=up upside down
structurelib.facing.27=up upside down
structurelib.facing.28=up counter clockwise
structurelib.facing.29=up counter clockwise
structurelib.facing.30=up counter clockwise
structurelib.facing.31=up counter clockwise
structurelib.facing.32=north normal none
structurelib.facing.33=north normal horizontal
structurelib.facing.34=north normal vertical
structurelib.facing.35=north normal both
structurelib.facing.36=north clockwise none
structurelib.facing.37=north clockwise horizontal
structurelib.facing.38=north clockwise vertical
structurelib.facing.39=north clockwise both
structurelib.facing.40=north upside down
structurelib.facing.41=north upside down
structurelib.facing.42=north upside down
structurelib.facing.43=north upside down
structurelib.facing.44=north counter clockwise
structurelib.facing.45=north counter clockwise
structurelib.facing.46=north counter clockwise
structurelib.facing.47=north counter clockwise
structurelib.facing.48=south normal none
structurelib.facing.49=south normal horizontal
structurelib.facing.50=south normal vertical
structurelib.facing.51=south normal both
structurelib.facing.52=south clockwise none
structurelib.facing.53=south clockwise horizontal
structurelib.facing.54=south clockwise vertical
structurelib.facing.55=south clockwise both
structurelib.facing.56=south upside down
structurelib.facing.57=south upside down
structurelib.facing.58=south upside down
structurelib.facing.59=south upside down
structurelib.facing.60=south counter clockwise
structurelib.facing.61=south counter clockwise
structurelib.facing.62=south counter clockwise
structurelib.facing.63=south counter clockwise
structurelib.facing.64=west normal none
structurelib.facing.65=west normal horizontal
structurelib.facing.66=west normal vertical
structurelib.facing.67=west normal both
structurelib.facing.68=west clockwise none
structurelib.facing.69=west clockwise horizontal
structurelib.facing.70=west clockwise vertical
structurelib.facing.71=west clockwise both
structurelib.facing.72=west upside down
structurelib.facing.73=west upside down
structurelib.facing.74=west upside down
structurelib.facing.75=west upside down
structurelib.facing.76=west counter clockwise
structurelib.facing.77=west counter clockwise
structurelib.facing.78=west counter clockwise
structurelib.facing.79=west counter clockwise
structurelib.facing.80=east normal none
structurelib.facing.81=east normal horizontal
structurelib.facing.82=east normal vertical
structurelib.facing.83=east normal both
structurelib.facing.84=east clockwise none
structurelib.facing.85=east clockwise horizontal
structurelib.facing.86=east clockwise vertical
structurelib.facing.87=east clockwise both
structurelib.facing.88=east upside down
structurelib.facing.89=east upside down
structurelib.facing.90=east upside down
structurelib.facing.91=east upside down
structurelib.facing.92=east counter clockwise
structurelib.facing.93=east counter clockwise
structurelib.facing.94=east counter clockwise
structurelib.facing.95=east counter clockwise
structurelib.config.client=Client Side Configurations
structurelib.config.client.tooltip=Configurations that only changes how the game looks like, but not how it functions.
structurelib.config.client.hologram=Hologram Configurations