mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-19 19:49:54 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c19ac860d4 | ||
|
|
d33cdd79c4 | ||
|
|
ed24f15033 | ||
|
|
15c34061bc | ||
|
|
728f25114b | ||
|
|
4a8c154855 | ||
|
|
f65010a547 |
No files matched your search
@@ -30,4 +30,5 @@ The project is developed using IDEA. Please manually configure the build to not
|
|||||||
|
|
||||||
## Current license
|
## Current license
|
||||||
Due to me adding in ItemStackMap, which was derived from code from CodeChicken's LGPL mod NEI. This mod is effectively considered
|
Due to me adding in ItemStackMap, which was derived from code from CodeChicken's LGPL mod NEI. This mod is effectively considered
|
||||||
licensed under LGPL in its entirety since commit ebef584b8c518f8202cfe0984fb28a6d23e52b3d.
|
licensed under LGPL in its entirety since commit ebef584b8c518f8202cfe0984fb28a6d23e52b3d or any squash commit containing it, e.g.
|
||||||
|
609e50428ee4e293f65f67f554a70b9fcfae97c4.
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
//version: 1659365110
|
//version: 1659977784
|
||||||
/*
|
/*
|
||||||
DO NOT CHANGE THIS FILE!
|
DO NOT CHANGE THIS FILE!
|
||||||
Also, you may replace this file at any time if there is an update available.
|
Also, you may replace this file at any time if there is an update available.
|
||||||
@@ -651,7 +651,7 @@ task updateBuildScript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
|
if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAvailable(projectDir.toString())) {
|
||||||
if (autoUpdateBuildScript.toBoolean()) {
|
if (autoUpdateBuildScript.toBoolean()) {
|
||||||
performBuildScriptUpdate(projectDir.toString())
|
performBuildScriptUpdate(projectDir.toString())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+3
-5
@@ -76,11 +76,9 @@ public class ConstructableUtility {
|
|||||||
} else if (constructable instanceof ISurvivalConstructable) {
|
} else if (constructable instanceof ISurvivalConstructable) {
|
||||||
int built = ((ISurvivalConstructable) constructable)
|
int built = ((ISurvivalConstructable) constructable)
|
||||||
.survivalConstruct(aStack, BUDGET, IItemSource.fromPlayer(playerMP), playerMP);
|
.survivalConstruct(aStack, BUDGET, IItemSource.fromPlayer(playerMP), playerMP);
|
||||||
if (built > 0)
|
if (built > 0) {
|
||||||
// TODO somehow notify extensions that their inventory might have been modified and need to be
|
playerMP.addChatMessage(new ChatComponentTranslation("structurelib.autoplace.built_stat", built));
|
||||||
// synced to client or saved
|
} else if (built == -1) {
|
||||||
playerMP.inventory.markDirty();
|
|
||||||
else if (built == -1) {
|
|
||||||
playerMP.addChatMessage(new ChatComponentTranslation("structurelib.autoplace.complete"));
|
playerMP.addChatMessage(new ChatComponentTranslation("structurelib.autoplace.complete"));
|
||||||
}
|
}
|
||||||
setLastUseTickToStackTag(aStack);
|
setLastUseTickToStackTag(aStack);
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package com.gtnewhorizon.structurelib.structure;
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
import static com.gtnewhorizon.structurelib.StructureLib.DEBUG_MODE;
|
import static com.gtnewhorizon.structurelib.StructureLib.DEBUG_MODE;
|
||||||
|
import static com.gtnewhorizon.structurelib.structure.IStructureWalker.ignoreBlockUnloaded;
|
||||||
|
import static com.gtnewhorizon.structurelib.structure.IStructureWalker.skipBlockUnloaded;
|
||||||
|
|
||||||
import com.gtnewhorizon.structurelib.StructureLib;
|
import com.gtnewhorizon.structurelib.StructureLib;
|
||||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
import java.util.Arrays;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -196,135 +197,67 @@ public interface IStructureDefinition<T> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// change base position to base offset
|
|
||||||
basePositionA = -basePositionA;
|
|
||||||
basePositionB = -basePositionB;
|
|
||||||
basePositionC = -basePositionC;
|
|
||||||
|
|
||||||
int[] abc = new int[] {basePositionA, basePositionB, basePositionC};
|
|
||||||
int[] xyz = new int[3];
|
|
||||||
|
|
||||||
if (checkBlocksIfNotNullForceCheckAllIfTrue != null) {
|
if (checkBlocksIfNotNullForceCheckAllIfTrue != null) {
|
||||||
|
boolean success;
|
||||||
if (checkBlocksIfNotNullForceCheckAllIfTrue) {
|
if (checkBlocksIfNotNullForceCheckAllIfTrue) {
|
||||||
for (IStructureElement<T> element : elements) {
|
success = StructureUtility.iterateV2(
|
||||||
if (element.isNavigating()) {
|
elements,
|
||||||
abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA();
|
world,
|
||||||
abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB();
|
extendedFacing,
|
||||||
abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC();
|
basePositionX,
|
||||||
} else {
|
basePositionY,
|
||||||
extendedFacing.getWorldOffset(abc, xyz);
|
basePositionZ,
|
||||||
xyz[0] += basePositionX;
|
basePositionA,
|
||||||
xyz[1] += basePositionY;
|
basePositionB,
|
||||||
xyz[2] += basePositionZ;
|
basePositionC,
|
||||||
|
(e, w, x, y, z) -> e.check(object, w, x, y, z),
|
||||||
StructureLib.LOGGER.info(
|
"check");
|
||||||
"Multi [{}, {}, {}] step @ {} {}",
|
|
||||||
basePositionX,
|
|
||||||
basePositionY,
|
|
||||||
basePositionZ,
|
|
||||||
Arrays.toString(xyz),
|
|
||||||
Arrays.toString(abc));
|
|
||||||
|
|
||||||
if (world.blockExists(xyz[0], xyz[1], xyz[2])) {
|
|
||||||
if (!element.check(object, world, xyz[0], xyz[1], xyz[2])) {
|
|
||||||
if (DEBUG_MODE) {
|
|
||||||
StructureLib.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", "
|
|
||||||
+ basePositionZ + "] failed @ " + Arrays.toString(xyz) + " "
|
|
||||||
+ Arrays.toString(abc));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (DEBUG_MODE) {
|
|
||||||
StructureLib.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", "
|
|
||||||
+ basePositionZ + "] !blockExists @ " + Arrays.toString(xyz) + " "
|
|
||||||
+ Arrays.toString(abc));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
abc[0] += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (IStructureElement<T> element : elements) {
|
success = StructureUtility.iterateV2(
|
||||||
if (element.isNavigating()) {
|
elements,
|
||||||
abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA();
|
world,
|
||||||
abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB();
|
extendedFacing,
|
||||||
abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC();
|
basePositionX,
|
||||||
} else {
|
basePositionY,
|
||||||
extendedFacing.getWorldOffset(abc, xyz);
|
basePositionZ,
|
||||||
xyz[0] += basePositionX;
|
basePositionA,
|
||||||
xyz[1] += basePositionY;
|
basePositionB,
|
||||||
xyz[2] += basePositionZ;
|
basePositionC,
|
||||||
|
skipBlockUnloaded((e, w, x, y, z) -> e.check(object, w, x, y, z)),
|
||||||
StructureLib.LOGGER.info(
|
"check force");
|
||||||
"Multi [{}, {}, {}] step @ {} {}",
|
|
||||||
basePositionX,
|
|
||||||
basePositionY,
|
|
||||||
basePositionZ,
|
|
||||||
Arrays.toString(xyz),
|
|
||||||
Arrays.toString(abc));
|
|
||||||
|
|
||||||
if (world.blockExists(xyz[0], xyz[1], xyz[2])) {
|
|
||||||
if (!element.check(object, world, xyz[0], xyz[1], xyz[2])) {
|
|
||||||
if (DEBUG_MODE) {
|
|
||||||
StructureLib.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", "
|
|
||||||
+ basePositionZ + "] failed @ " + Arrays.toString(xyz) + " "
|
|
||||||
+ Arrays.toString(abc));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (DEBUG_MODE) {
|
|
||||||
StructureLib.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", "
|
|
||||||
+ basePositionZ + "] !blockExists @ " + Arrays.toString(xyz) + " "
|
|
||||||
+ Arrays.toString(abc));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abc[0] += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE && success) {
|
||||||
StructureLib.LOGGER.info(
|
StructureLib.LOGGER.info(
|
||||||
"Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] pass");
|
"Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] pass");
|
||||||
}
|
}
|
||||||
|
return success;
|
||||||
} else {
|
} else {
|
||||||
if (hintsOnly) {
|
if (hintsOnly) {
|
||||||
for (IStructureElement<T> element : elements) {
|
StructureUtility.iterateV2(
|
||||||
if (element.isNavigating()) {
|
elements,
|
||||||
abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA();
|
world,
|
||||||
abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB();
|
extendedFacing,
|
||||||
abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC();
|
basePositionX,
|
||||||
} else {
|
basePositionY,
|
||||||
extendedFacing.getWorldOffset(abc, xyz);
|
basePositionZ,
|
||||||
xyz[0] += basePositionX;
|
basePositionA,
|
||||||
xyz[1] += basePositionY;
|
basePositionB,
|
||||||
xyz[2] += basePositionZ;
|
basePositionC,
|
||||||
|
ignoreBlockUnloaded((e, w, x, y, z) -> e.spawnHint(object, world, x, y, z, trigger)),
|
||||||
element.spawnHint(object, world, xyz[0], xyz[1], xyz[2], trigger);
|
"spawnHint");
|
||||||
|
|
||||||
abc[0] += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (IStructureElement<T> element : elements) {
|
StructureUtility.iterateV2(
|
||||||
if (element.isNavigating()) {
|
elements,
|
||||||
abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA();
|
world,
|
||||||
abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB();
|
extendedFacing,
|
||||||
abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC();
|
basePositionX,
|
||||||
} else {
|
basePositionY,
|
||||||
extendedFacing.getWorldOffset(abc, xyz);
|
basePositionZ,
|
||||||
xyz[0] += basePositionX;
|
basePositionA,
|
||||||
xyz[1] += basePositionY;
|
basePositionB,
|
||||||
xyz[2] += basePositionZ;
|
basePositionC,
|
||||||
|
ignoreBlockUnloaded((e, w, x, y, z) -> e.placeBlock(object, world, x, y, z, trigger)),
|
||||||
if (world.blockExists(xyz[0], xyz[1], xyz[2])) {
|
"placeBlock");
|
||||||
element.placeBlock(object, world, xyz[0], xyz[1], xyz[2], trigger);
|
|
||||||
}
|
|
||||||
abc[0] += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -4,4 +4,36 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
public interface IStructureWalker<T> {
|
public interface IStructureWalker<T> {
|
||||||
boolean visit(IStructureElement<T> element, World world, int x, int y, int z);
|
boolean visit(IStructureElement<T> element, World world, int x, int y, int z);
|
||||||
|
|
||||||
|
default boolean blockNotLoaded(IStructureElement<T> element, World world, int x, int y, int z) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> IStructureWalker<T> ignoreBlockUnloaded(IStructureWalker<T> walker) {
|
||||||
|
return new IStructureWalker<T>() {
|
||||||
|
@Override
|
||||||
|
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z) {
|
||||||
|
return walker.visit(element, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean blockNotLoaded(IStructureElement<T> element, World world, int x, int y, int z) {
|
||||||
|
return walker.visit(element, world, x, y, z);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> IStructureWalker<T> skipBlockUnloaded(IStructureWalker<T> walker) {
|
||||||
|
return new IStructureWalker<T>() {
|
||||||
|
@Override
|
||||||
|
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z) {
|
||||||
|
return walker.visit(element, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean blockNotLoaded(IStructureElement<T> element, World world, int x, int y, int z) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -427,9 +427,16 @@ public class StructureUtility {
|
|||||||
IItemSource s,
|
IItemSource s,
|
||||||
EntityPlayerMP actor,
|
EntityPlayerMP actor,
|
||||||
Consumer<IChatComponent> chatter) {
|
Consumer<IChatComponent> chatter) {
|
||||||
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
|
|
||||||
Pair<Block, Integer> hint = getHint(trigger);
|
Pair<Block, Integer> hint = getHint(trigger);
|
||||||
if (hint == null) return PlaceResult.REJECT; // TODO or SKIP?
|
if (hint == null) return PlaceResult.REJECT; // TODO or SKIP?
|
||||||
|
Block block = world.getBlock(x, y, z);
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
TIER tier = tierExtractor.convert(block, meta);
|
||||||
|
if (!Objects.equals(tier, notSet)) {
|
||||||
|
return Objects.equals(tier, tierExtractor.convert(hint.getKey(), hint.getValue()))
|
||||||
|
? PlaceResult.SKIP
|
||||||
|
: PlaceResult.REJECT;
|
||||||
|
}
|
||||||
return StructureUtility.survivalPlaceBlock(
|
return StructureUtility.survivalPlaceBlock(
|
||||||
hint.getKey(), hint.getValue(), world, x, y, z, s, actor, chatter);
|
hint.getKey(), hint.getValue(), world, x, y, z, s, actor, chatter);
|
||||||
}
|
}
|
||||||
@@ -2209,14 +2216,15 @@ public class StructureUtility {
|
|||||||
xyz[1] += basePositionY;
|
xyz[1] += basePositionY;
|
||||||
xyz[2] += basePositionZ;
|
xyz[2] += basePositionZ;
|
||||||
|
|
||||||
StructureLib.LOGGER.info(
|
if (DEBUG_MODE)
|
||||||
"Multi [{}, {}, {}] {} step @ {} {}",
|
StructureLib.LOGGER.info(
|
||||||
basePositionX,
|
"Multi [{}, {}, {}] {} step @ {} {}",
|
||||||
basePositionY,
|
basePositionX,
|
||||||
basePositionZ,
|
basePositionY,
|
||||||
iterateType,
|
basePositionZ,
|
||||||
Arrays.toString(xyz),
|
iterateType,
|
||||||
Arrays.toString(abc));
|
Arrays.toString(xyz),
|
||||||
|
Arrays.toString(abc));
|
||||||
|
|
||||||
if (world.blockExists(xyz[0], xyz[1], xyz[2])) {
|
if (world.blockExists(xyz[0], xyz[1], xyz[2])) {
|
||||||
if (!predicate.visit(element, world, xyz[0], xyz[1], xyz[2])) {
|
if (!predicate.visit(element, world, xyz[0], xyz[1], xyz[2])) {
|
||||||
@@ -2243,7 +2251,7 @@ public class StructureUtility {
|
|||||||
Arrays.toString(xyz),
|
Arrays.toString(xyz),
|
||||||
Arrays.toString(abc));
|
Arrays.toString(abc));
|
||||||
}
|
}
|
||||||
return false;
|
if (!predicate.blockNotLoaded(element, world, xyz[0], xyz[1], xyz[2])) return false;
|
||||||
}
|
}
|
||||||
abc[0] += 1;
|
abc[0] += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ item.structurelib.constructableTrigger.desc.3=(Sneak use on controller to build)
|
|||||||
item.structurelib.constructableTrigger.desc.4=Quantity of schematics in item stack affects tier/mode/type
|
item.structurelib.constructableTrigger.desc.4=Quantity of schematics in item stack affects tier/mode/type
|
||||||
item.structurelib.constructableTrigger.too_fast=Please wait %d ticks before another autoplace...
|
item.structurelib.constructableTrigger.too_fast=Please wait %d ticks before another autoplace...
|
||||||
|
|
||||||
|
structurelib.autoplace.built_stat=Built %s blocks
|
||||||
structurelib.autoplace.complete=§aThis multiblock has completed!
|
structurelib.autoplace.complete=§aThis multiblock has completed!
|
||||||
structurelib.autoplace.error.not_enabled=§cThis multiblock does not support autoplace in survival!
|
structurelib.autoplace.error.not_enabled=§cThis multiblock does not support autoplace in survival!
|
||||||
structurelib.autoplace.error.no_simple_block=§cSuggested to place §r%s§c but none was found
|
structurelib.autoplace.error.no_simple_block=§cSuggested to place §r%s§c but none was found
|
||||||
|
|||||||
@@ -24,9 +24,14 @@ item.structurelib.constructableTrigger.name=多方块结构全息投影仪
|
|||||||
item.structurelib.constructableTrigger.desc.0=可以显示多方块机器的结构
|
item.structurelib.constructableTrigger.desc.0=可以显示多方块机器的结构
|
||||||
item.structurelib.constructableTrigger.desc.1=只能在多方块主机上使用,将会显示机器
|
item.structurelib.constructableTrigger.desc.1=只能在多方块主机上使用,将会显示机器
|
||||||
item.structurelib.constructableTrigger.desc.2=结构的示意图。 (译者注:请搭高使用)
|
item.structurelib.constructableTrigger.desc.2=结构的示意图。 (译者注:请搭高使用)
|
||||||
item.structurelib.constructableTrigger.desc.3= (创造模式下潜行右键可以直接完成搭建)
|
item.structurelib.constructableTrigger.desc.3= (潜行右键可以直接完成搭建)
|
||||||
item.structurelib.constructableTrigger.desc.4=此物品堆叠数量会影响显示的机器等级/模式/类型
|
item.structurelib.constructableTrigger.desc.4=此物品堆叠数量会影响显示的机器等级/模式/类型
|
||||||
item.structurelib.constructableTrigger.too_fast=Please wait %d ticks before another autoplace...
|
item.structurelib.constructableTrigger.too_fast=请在下一次自动搭建前等待%dtick...
|
||||||
|
|
||||||
|
structurelib.autoplace.complete=§a这个多方块结构已经完成自动搭建!
|
||||||
|
structurelib.autoplace.error.not_enabled=§c这个多方块结构不支持在生存模式下自动搭建!
|
||||||
|
structurelib.autoplace.error.no_simple_block=§c建议放置§r%s§c,但没有找到它
|
||||||
|
structurelib.autoplace.error.no_item_stack=§c建议使用§r%s§c放置方块,但没有找到它
|
||||||
|
|
||||||
structurelib.blockhint.desc.0=帮助你搭建机器
|
structurelib.blockhint.desc.0=帮助你搭建机器
|
||||||
structurelib.blockhint.0.name=提示方块:1号
|
structurelib.blockhint.0.name=提示方块:1号
|
||||||
|
|||||||
Reference in new issue
Block a user