mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-09 15:04:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a069612e04 | ||
|
|
ab09b791bd | ||
|
|
b086a65828 | ||
|
|
f1f6dae00f |
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
modGroup = com.gtnewhorizon
|
||||
modVersion = 1.0.7
|
||||
modVersion = 1.0.9
|
||||
modBaseName = StructureLib
|
||||
|
||||
forgeVersion = 1.7.10-10.13.4.1614-1.7.10
|
||||
@@ -120,4 +120,12 @@ public class StructureLibAPI {
|
||||
public static Item getItemBlockHint() {
|
||||
return StructureLib.itemBlockHint;
|
||||
}
|
||||
|
||||
public static boolean isDebugEnabled() {
|
||||
return StructureLib.DEBUG_MODE;
|
||||
}
|
||||
|
||||
public static void setDebugEnabled(boolean enabled) {
|
||||
StructureLib.DEBUG_MODE = enabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gtnewhorizon.structurelib.structure;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
* a function to extract tier info from a block.
|
||||
* @param <TIER>
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ITierConverter<TIER> {
|
||||
TIER convert(Block block, int meta);
|
||||
}
|
||||
@@ -13,7 +13,9 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -21,13 +23,16 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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 static java.lang.Integer.MIN_VALUE;
|
||||
@@ -187,6 +192,81 @@ public class StructureUtility {
|
||||
|
||||
//region block
|
||||
|
||||
/**
|
||||
* A more primitive variant of {@link #ofBlocksTiered(ITierConverter, List, Object, BiConsumer, Function)}
|
||||
* Main difference is this one is check only.
|
||||
* @see #ofBlocksTiered(ITierConverter, Object, BiConsumer, Function)
|
||||
*/
|
||||
public static <T, TIER> IStructureElementCheckOnly<T> ofBlocksTiered(ITierConverter<TIER> tierExtractor, @Nullable TIER notSet, BiConsumer<T, TIER> setter, Function<T, TIER> getter) {
|
||||
if (tierExtractor == null) throw new IllegalArgumentException();
|
||||
if (setter == null) throw new IllegalArgumentException();
|
||||
if (getter == null) throw new IllegalArgumentException();
|
||||
|
||||
return (t, world, x, y, z) -> {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
TIER tier = tierExtractor.convert(block, meta);
|
||||
TIER current = getter.apply(t);
|
||||
if (Objects.equals(notSet, current)) {
|
||||
setter.accept(t, tier);
|
||||
return true;
|
||||
}
|
||||
return Objects.equals(current, tier);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Element representing a component with different tiers. Player can use more blueprint to get hints denoting more
|
||||
* advanced components.
|
||||
*
|
||||
* There is yet no TileEntity counter part of this utility. Feel free to submit a PR to add it.
|
||||
* @param allKnownTiers All known tiers as of calling. Can be empty or null. No hint will be spawned if empty or null. Cannot have null elements.
|
||||
* First element denotes the most primitive tier. Last element denotes the most advanced tier.
|
||||
* If not all tiers are available at definition construction time, use {@link #lazy(Supplier)} or its overloads to delay a little bit.
|
||||
* @param notSet The value returned from {@code getter} when there were no tier info found in T yet. Can be null.
|
||||
* @param getter a function to retrieve the current tier from T
|
||||
* @param setter a function to set the current tier into T
|
||||
* @param tierExtractor a function to extract tier info from a block.
|
||||
*/
|
||||
public static <T, TIER> IStructureElement<T> ofBlocksTiered(ITierConverter<TIER> tierExtractor, @Nullable List<Pair<Block, Integer>> allKnownTiers, @Nullable TIER notSet, BiConsumer<T, TIER> setter, Function<T, TIER> getter) {
|
||||
List<Pair<Block, Integer>> hints = allKnownTiers == null ? Collections.emptyList() : allKnownTiers;
|
||||
if (hints.stream().anyMatch(Objects::isNull)) throw new IllegalArgumentException();
|
||||
IStructureElementCheckOnly<T> check = ofBlocksTiered(tierExtractor, notSet, setter, getter);
|
||||
return new IStructureElement<T>() {
|
||||
@Override
|
||||
public boolean check(T t, World world, int x, int y, int z) {
|
||||
return check.check(t, world, x, y, z);
|
||||
}
|
||||
|
||||
private Pair<Block, Integer> getHint(ItemStack trigger) {
|
||||
return hints.get(Math.min(Math.max(trigger.stackSize, 1), hints.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||
Pair<Block, Integer> hint = getHint(trigger);
|
||||
if (hint == null)
|
||||
return false;
|
||||
StructureLibAPI.hintParticle(world, x, y, z, hint.getKey(), hint.getValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||
Pair<Block, Integer> hint = getHint(trigger);
|
||||
if (hint == null)
|
||||
return false;
|
||||
if (hint.getKey() instanceof ICustomBlockSetting) {
|
||||
ICustomBlockSetting block = (ICustomBlockSetting) hint.getKey();
|
||||
block.setBlock(world, x, y, z, hint.getValue());
|
||||
} else {
|
||||
world.setBlock(x, y, z, hint.getKey(), hint.getValue(), 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Denote a block using unlocalized names. This can be useful to get around mod loading order issues.
|
||||
* <p>
|
||||
@@ -209,7 +289,7 @@ public class StructureUtility {
|
||||
|
||||
@Override
|
||||
public boolean check(T t, World world, int x, int y, int z) {
|
||||
return world.getBlock(x, y, z) != getBlock() && world.getBlockMetadata(x, y, z) == meta;
|
||||
return world.getBlock(x, y, z) == getBlock() && world.getBlockMetadata(x, y, z) == meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,15 +17,15 @@ tile.structurelib.blockhint.15.name=提示方块:错误
|
||||
|
||||
item.structurelib.frontRotationTool.name=正面旋转扳手 (StructureLib)
|
||||
item.structurelib.frontRotationTool.desc.0=可以旋转/翻转多方块主机
|
||||
item.structurelib.frontRotationTool.desc.1=旋转/翻转多方块主机时,会
|
||||
item.structurelib.frontRotationTool.desc.2=带动机器结构一起旋转/翻转。
|
||||
item.structurelib.frontRotationTool.desc.1=多方块机器结构也需要跟随
|
||||
item.structurelib.frontRotationTool.desc.2=多方块主机一起旋转/翻转。
|
||||
|
||||
item.structurelib.constructableTrigger.name=多方块机器蓝图 (StructureLib)
|
||||
item.structurelib.constructableTrigger.name=多方块结构全息投影仪
|
||||
item.structurelib.constructableTrigger.desc.0=可以显示多方块机器的结构
|
||||
item.structurelib.constructableTrigger.desc.1=只能在多方块主机上使用,将会显示机器
|
||||
item.structurelib.constructableTrigger.desc.2=结构的细节。 (译者注:请搭高使用)
|
||||
item.structurelib.constructableTrigger.desc.3= (创造模式下潜行右键可以直接完成搭建)
|
||||
item.structurelib.constructableTrigger.desc.4=手中蓝图数量会影响显示的机器等级/模式/类型
|
||||
item.structurelib.constructableTrigger.desc.4=此物品堆叠数量会影响显示的机器等级/模式/类型
|
||||
|
||||
structurelib.blockhint.desc.0=帮助你搭建机器
|
||||
structurelib.blockhint.0.name=提示方块:1号
|
||||
@@ -49,4 +49,13 @@ structurelib.blockhint.14.name=提示方块:非空气
|
||||
structurelib.blockhint.desc.4=确保这里不是空气方块。
|
||||
structurelib.blockhint.15.name=提示方块:错误
|
||||
structurelib.blockhint.desc.5=ERROR,你想要做什么?
|
||||
itemGroup.structurelib=StructureLib
|
||||
itemGroup.structurelib=StructureLib
|
||||
|
||||
structurelib.config.client=客户端-配置
|
||||
structurelib.config.client.tooltip=修改此配置只会改变游戏中的显示效果,而不会改变实际工作模式。
|
||||
structurelib.config.client.hologram=全息投影仪-配置
|
||||
structurelib.config.client.hologram.tooltip=这将决定默认情况下,机器结构细节将如何被投影到世界中。
|
||||
structurelib.config.client.hologram.maxCoexisting=最多可以同时存在的全息投影数量
|
||||
structurelib.config.client.hologram.maxCoexisting.tooltip=这决定最多可以同时存在多少台机器的全息投影。一般一次使用全息投影仪右键生成的所有机器结构细节被视为一个全息投影。当同时存在多个全息投影,并超过此数量时,再次使用全息投影仪会移除旧有的全息投影。
|
||||
structurelib.config.client.hologram.removeColliding=移除冲突的全息投影
|
||||
structurelib.config.client.hologram.removeColliding.tooltip=当新的全息投影与已存在的全息投影冲突时,开启此选项时会移除已存在的全息投影。
|
||||
Reference in new issue
Block a user