mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-20 12:09:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95d1533342 |
No files matched your search
@@ -57,11 +57,13 @@ public interface IStructureElement<T> {
|
|||||||
* {@code StatCollector.translateToLocal()}. If a key has no matching translation, {@code translateToLocal} returns
|
* {@code StatCollector.translateToLocal()}. If a key has no matching translation, {@code translateToLocal} returns
|
||||||
* the input string unchanged, so pre-translated fallback strings also work.
|
* the input string unchanged, so pre-translated fallback strings also work.
|
||||||
*
|
*
|
||||||
|
* @param context the context object (e.g. the multiblock controller), used to determine state-dependent
|
||||||
|
* descriptions
|
||||||
* @return a list of accepted block descriptions as lang keys (or display names as fallback), or null if no
|
* @return a list of accepted block descriptions as lang keys (or display names as fallback), or null if no
|
||||||
* description is available
|
* description is available
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
default List<String> getDescription() {
|
default List<String> getDescription(T context) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,8 +232,8 @@ public interface IStructureElement<T> {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
return IStructureElement.this.getDescription();
|
return IStructureElement.this.getDescription(context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ public interface IStructureElementChain<T> extends IStructureElement<T> {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
default List<String> getDescription() {
|
default List<String> getDescription(T context) {
|
||||||
Set<String> descriptions = new LinkedHashSet<>();
|
Set<String> descriptions = new LinkedHashSet<>();
|
||||||
for (IStructureElement<T> fallback : fallbacks()) {
|
for (IStructureElement<T> fallback : fallbacks()) {
|
||||||
List<String> desc = fallback.getDescription();
|
List<String> desc = fallback.getDescription(context);
|
||||||
if (desc != null) {
|
if (desc != null) {
|
||||||
descriptions.addAll(desc);
|
descriptions.addAll(desc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class LazyStructureElement<T> implements IStructureElementDeferred<T> {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
return elem != null ? elem.getDescription() : null;
|
return elem != null ? elem.getDescription(context) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -722,7 +722,7 @@ public class StructureUtility {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Like {@link #ofBlocksTiered(ITierConverter, List, Object, BiConsumer, Function)}, but with an explicit
|
* Like {@link #ofBlocksTiered(ITierConverter, List, Object, BiConsumer, Function)}, but with an explicit
|
||||||
* description that will be returned by {@link IStructureElement#getDescription()}.
|
* description that will be returned by {@link IStructureElement#getDescription(Object)}.
|
||||||
*
|
*
|
||||||
* @param description the description lang keys to attach to this element, or null for no description
|
* @param description the description lang keys to attach to this element, or null for no description
|
||||||
* @see #ofBlocksTiered(ITierConverter, List, Object, BiConsumer, Function)
|
* @see #ofBlocksTiered(ITierConverter, List, Object, BiConsumer, Function)
|
||||||
@@ -735,11 +735,8 @@ public class StructureUtility {
|
|||||||
IStructureElementCheckOnly<T> check = ofBlocksTiered(tierExtractor, notSet, setter, getter);
|
IStructureElementCheckOnly<T> check = ofBlocksTiered(tierExtractor, notSet, setter, getter);
|
||||||
return new StructureElement_Bridge<T>() {
|
return new StructureElement_Bridge<T>() {
|
||||||
|
|
||||||
private T lastContext;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean check(T t, World world, int x, int y, int z) {
|
public boolean check(T t, World world, int x, int y, int z) {
|
||||||
lastContext = t;
|
|
||||||
return check.check(t, world, x, y, z);
|
return check.check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,7 +747,6 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
lastContext = t;
|
|
||||||
Pair<Block, Integer> hint = getHint(trigger);
|
Pair<Block, Integer> hint = getHint(trigger);
|
||||||
if (hint == null) return true;
|
if (hint == null) return true;
|
||||||
TIER hintTier = tierExtractor.convert(hint.getKey(), hint.getValue());
|
TIER hintTier = tierExtractor.convert(hint.getKey(), hint.getValue());
|
||||||
@@ -815,9 +811,8 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
if (lastContext == null) return description;
|
TIER currentTier = getter.apply(context);
|
||||||
TIER currentTier = getter.apply(lastContext);
|
|
||||||
if (Objects.equals(currentTier, notSet)) return description;
|
if (Objects.equals(currentTier, notSet)) return description;
|
||||||
|
|
||||||
for (Pair<Block, Integer> pair : hints) {
|
for (Pair<Block, Integer> pair : hints) {
|
||||||
@@ -1457,7 +1452,7 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
Item item = Item.getItemFromBlock(block);
|
Item item = Item.getItemFromBlock(block);
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
return Collections.singletonList(new ItemStack(item, 1, meta).getUnlocalizedName() + ".name");
|
return Collections.singletonList(new ItemStack(item, 1, meta).getUnlocalizedName() + ".name");
|
||||||
@@ -1544,7 +1539,7 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
Item item = Item.getItemFromBlock(block);
|
Item item = Item.getItemFromBlock(block);
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
return Collections.singletonList(new ItemStack(item, 1, meta).getUnlocalizedName() + ".name");
|
return Collections.singletonList(new ItemStack(item, 1, meta).getUnlocalizedName() + ".name");
|
||||||
@@ -1594,7 +1589,7 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
Item item = Item.getItemFromBlock(block);
|
Item item = Item.getItemFromBlock(block);
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
return Collections.singletonList(new ItemStack(item, 1, 0).getUnlocalizedName() + ".name");
|
return Collections.singletonList(new ItemStack(item, 1, 0).getUnlocalizedName() + ".name");
|
||||||
@@ -1634,7 +1629,7 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
Item item = Item.getItemFromBlock(block);
|
Item item = Item.getItemFromBlock(block);
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
return Collections.singletonList(new ItemStack(item, 1, 0).getUnlocalizedName() + ".name");
|
return Collections.singletonList(new ItemStack(item, 1, 0).getUnlocalizedName() + ".name");
|
||||||
@@ -1905,8 +1900,8 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
return element.getDescription();
|
return element.getDescription(context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1964,7 +1959,7 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2026,8 +2021,8 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
return element.getDescription();
|
return element.getDescription(context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -2101,8 +2096,8 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
return downstream.getDescription();
|
return downstream.getDescription(context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -2204,8 +2199,8 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
return elem.getDescription();
|
return elem.getDescription(context.getCurrentContext());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -3047,8 +3042,8 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDescription() {
|
public List<String> getDescription(T context) {
|
||||||
return backing.getDescription();
|
return backing.getDescription(context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user