mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-19 19:49:54 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
538459eab5 | ||
|
|
3a9ec8b6ac | ||
|
|
330a13271b | ||
|
|
bf5dd5566b | ||
|
|
b9d0143245 | ||
|
|
43fc39c99b | ||
|
|
6337536dc3 |
No files matched your search
@@ -27,3 +27,4 @@ whitelist.json
|
|||||||
*.iws
|
*.iws
|
||||||
src/main/resources/mixins.*.json
|
src/main/resources/mixins.*.json
|
||||||
*.bat
|
*.bat
|
||||||
|
layout.json
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
// Add your dependencies here
|
// Add your dependencies here
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api("com.github.GTNewHorizons:GTNHLib:0.5.19:dev")
|
api("com.github.GTNewHorizons:GTNHLib:0.6.13:dev")
|
||||||
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.6.44-GTNH:dev")
|
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.7.29-GTNH:dev")
|
||||||
|
|
||||||
testImplementation(platform('org.junit:junit-bom:5.9.2'))
|
testImplementation(platform('org.junit:junit-bom:5.9.2'))
|
||||||
testImplementation('org.junit.jupiter:junit-jupiter')
|
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -206,7 +205,7 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# and any embedded shellness will be escaped.
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.29'
|
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.37'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,6 +100,8 @@ public class StructureLib {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static boolean isGTLoaded;
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent e) {
|
public void preInit(FMLPreInitializationEvent e) {
|
||||||
ConfigurationHandler.INSTANCE.init(e.getSuggestedConfigurationFile());
|
ConfigurationHandler.INSTANCE.init(e.getSuggestedConfigurationFile());
|
||||||
@@ -118,6 +120,8 @@ public class StructureLib {
|
|||||||
if (Loader.isModLoaded(STRUCTURECOMPAT_MODID)) {
|
if (Loader.isModLoaded(STRUCTURECOMPAT_MODID)) {
|
||||||
COMPAT = Loader.instance().getIndexedModList().get(STRUCTURECOMPAT_MODID).getMod();
|
COMPAT = Loader.instance().getIndexedModList().get(STRUCTURECOMPAT_MODID).getMod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isGTLoaded = Loader.isModLoaded("gregtech");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class StructureLibAPI {
|
|||||||
*/
|
*/
|
||||||
public static void enableInstrument(Object identifier) {
|
public static void enableInstrument(Object identifier) {
|
||||||
if (isInstrumentEnabled()) throw new IllegalStateException();
|
if (isInstrumentEnabled()) throw new IllegalStateException();
|
||||||
instrument.set(instrument);
|
instrument.set(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,6 +25,17 @@ import com.gtnewhorizon.structurelib.gui.GuiScrollableList.IGuiScreen;
|
|||||||
|
|
||||||
public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen {
|
public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen {
|
||||||
|
|
||||||
|
private static final String I18N_PREFIX = "item.structurelib.constructableTrigger.gui.";
|
||||||
|
|
||||||
|
private static final int ADD_BTN = 0;
|
||||||
|
private static final int UNSET_BTN = 1;
|
||||||
|
private static final int WIPE_BTN = 2;
|
||||||
|
private static final int SHOW_ERROR_BTN = 3;
|
||||||
|
private static final int GT_NO_HATCH_BTN = 4;
|
||||||
|
|
||||||
|
private static final String SHOW_ERROR_CHANNEL = "show_error";
|
||||||
|
private static final String GT_NO_HATCH_CHANNEL = "gt_no_hatch";
|
||||||
|
|
||||||
private static final int KEY_MAX_WIDTH = 50;
|
private static final int KEY_MAX_WIDTH = 50;
|
||||||
private final ItemStack trigger;
|
private final ItemStack trigger;
|
||||||
private final GuiChannelsList list;
|
private final GuiChannelsList list;
|
||||||
@@ -128,7 +139,7 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
|
|
||||||
addButton(
|
addButton(
|
||||||
new GuiButton(
|
new GuiButton(
|
||||||
0,
|
ADD_BTN,
|
||||||
guiLeft + 12,
|
guiLeft + 12,
|
||||||
guiTop + 157,
|
guiTop + 157,
|
||||||
47,
|
47,
|
||||||
@@ -136,7 +147,7 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
I18n.format("item.structurelib.constructableTrigger.gui.add")));
|
I18n.format("item.structurelib.constructableTrigger.gui.add")));
|
||||||
addButton(
|
addButton(
|
||||||
new GuiButton(
|
new GuiButton(
|
||||||
1,
|
UNSET_BTN,
|
||||||
guiLeft + 65,
|
guiLeft + 65,
|
||||||
guiTop + 157,
|
guiTop + 157,
|
||||||
47,
|
47,
|
||||||
@@ -144,13 +155,27 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
I18n.format("item.structurelib.constructableTrigger.gui.unset")));
|
I18n.format("item.structurelib.constructableTrigger.gui.unset")));
|
||||||
addButton(
|
addButton(
|
||||||
new GuiButton(
|
new GuiButton(
|
||||||
2,
|
WIPE_BTN,
|
||||||
guiLeft + 118,
|
guiLeft + 118,
|
||||||
guiTop + 157,
|
guiTop + 157,
|
||||||
47,
|
47,
|
||||||
20,
|
20,
|
||||||
I18n.format("item.structurelib.constructableTrigger.gui.wipe")));
|
I18n.format("item.structurelib.constructableTrigger.gui.wipe")));
|
||||||
|
|
||||||
|
addButton(
|
||||||
|
new GuiButton(
|
||||||
|
SHOW_ERROR_BTN,
|
||||||
|
StructureLib.isGTLoaded ? guiLeft + 12 : guiLeft + 52,
|
||||||
|
guiTop + 180,
|
||||||
|
73,
|
||||||
|
20,
|
||||||
|
""));
|
||||||
|
|
||||||
|
// only show GT hatch button if GT is loaded
|
||||||
|
if (StructureLib.isGTLoaded) {
|
||||||
|
addButton(new GuiButton(GT_NO_HATCH_BTN, guiLeft + 92, guiTop + 180, 73, 20, ""));
|
||||||
|
}
|
||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +196,7 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getYSize() {
|
public int getYSize() {
|
||||||
return 188;
|
return 211;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -199,10 +224,29 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
return buttonList;
|
return buttonList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isMouseOverValue() {
|
||||||
|
int mx = Mouse.getEventX() * this.width / this.mc.displayWidth;
|
||||||
|
int my = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
|
||||||
|
return mx >= value.xPosition && mx < value.xPosition + value.width
|
||||||
|
&& my >= value.yPosition
|
||||||
|
&& my < value.yPosition + value.height;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMouseInput() {
|
public void handleMouseInput() {
|
||||||
int delta = Mouse.getEventDWheel();
|
int delta = Mouse.getEventDWheel();
|
||||||
if (delta != 0) list.handleDWheel(delta);
|
if (delta != 0) {
|
||||||
|
if (isMouseOverValue()) {
|
||||||
|
if (delta > 0) {
|
||||||
|
value.setText(String.valueOf(getValue() + 1));
|
||||||
|
} else {
|
||||||
|
value.setText(String.valueOf(Math.max(getValue() - 1, 1)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list.handleDWheel(delta);
|
||||||
|
}
|
||||||
|
}
|
||||||
super.handleMouseInput();
|
super.handleMouseInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,10 +294,26 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
// STACKOVERFLOW!
|
// STACKOVERFLOW!
|
||||||
String keyText = key.getText();
|
String keyText = key.getText();
|
||||||
boolean existing = !StringUtils.isEmpty(keyText) && ChannelDataAccessor.hasSubChannel(trigger, keyText);
|
boolean existing = !StringUtils.isEmpty(keyText) && ChannelDataAccessor.hasSubChannel(trigger, keyText);
|
||||||
getButtonList().get(0).displayString = existing ? I18n.format("item.structurelib.constructableTrigger.gui.set")
|
getButtonList().get(ADD_BTN).displayString = existing ? I18n.format(I18N_PREFIX + "set")
|
||||||
: I18n.format("item.structurelib.constructableTrigger.gui.add");
|
: I18n.format(I18N_PREFIX + "add");
|
||||||
getButtonList().get(0).enabled = !StringUtils.isBlank(value.getText());
|
getButtonList().get(ADD_BTN).enabled = !StringUtils.isBlank(value.getText())
|
||||||
getButtonList().get(1).enabled = existing && !StringUtils.isBlank(value.getText());
|
&& Integer.parseInt(value.getText()) > 0;
|
||||||
|
getButtonList().get(UNSET_BTN).enabled = existing && !StringUtils.isBlank(value.getText());
|
||||||
|
|
||||||
|
if (ChannelDataAccessor.hasSubChannel(trigger, SHOW_ERROR_CHANNEL)) {
|
||||||
|
getButtonList().get(SHOW_ERROR_BTN).displayString = I18n.format(I18N_PREFIX + "error.hide");
|
||||||
|
} else {
|
||||||
|
getButtonList().get(SHOW_ERROR_BTN).displayString = I18n.format(I18N_PREFIX + "error.show");
|
||||||
|
}
|
||||||
|
|
||||||
|
// this button only exists if GT is loaded.
|
||||||
|
if (StructureLib.isGTLoaded) {
|
||||||
|
if (ChannelDataAccessor.hasSubChannel(trigger, GT_NO_HATCH_CHANNEL)) {
|
||||||
|
getButtonList().get(GT_NO_HATCH_BTN).displayString = I18n.format(I18N_PREFIX + "gt_no_hatch.disable");
|
||||||
|
} else {
|
||||||
|
getButtonList().get(GT_NO_HATCH_BTN).displayString = I18n.format(I18N_PREFIX + "gt_no_hatch.enable");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getValue() {
|
private int getValue() {
|
||||||
@@ -268,18 +328,35 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
protected void actionPerformed(GuiButton btn) {
|
protected void actionPerformed(GuiButton btn) {
|
||||||
if (btn == null) return;
|
if (btn == null) return;
|
||||||
switch (btn.id) {
|
switch (btn.id) {
|
||||||
case 0:
|
case ADD_BTN:
|
||||||
int value = getValue();
|
int value = getValue();
|
||||||
if (value <= 0) return;
|
if (value <= 0) return;
|
||||||
ChannelDataAccessor.setChannelData(trigger, key.getText(), value);
|
ChannelDataAccessor.setChannelData(trigger, key.getText(), value);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case UNSET_BTN:
|
||||||
ChannelDataAccessor.unsetChannelData(trigger, key.getText());
|
ChannelDataAccessor.unsetChannelData(trigger, key.getText());
|
||||||
break;
|
break;
|
||||||
case 2:
|
case WIPE_BTN:
|
||||||
ChannelDataAccessor.wipeChannelData(trigger);
|
ChannelDataAccessor.wipeChannelData(trigger);
|
||||||
break;
|
break;
|
||||||
|
case SHOW_ERROR_BTN:
|
||||||
|
if (ChannelDataAccessor.hasSubChannel(trigger, SHOW_ERROR_CHANNEL)) {
|
||||||
|
ChannelDataAccessor.unsetChannelData(trigger, SHOW_ERROR_CHANNEL);
|
||||||
|
} else {
|
||||||
|
ChannelDataAccessor.setChannelData(trigger, SHOW_ERROR_CHANNEL, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GT_NO_HATCH_BTN:
|
||||||
|
if (ChannelDataAccessor.hasSubChannel(trigger, GT_NO_HATCH_CHANNEL)) {
|
||||||
|
ChannelDataAccessor.unsetChannelData(trigger, GT_NO_HATCH_CHANNEL);
|
||||||
|
} else {
|
||||||
|
ChannelDataAccessor.setChannelData(trigger, GT_NO_HATCH_CHANNEL, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
|
||||||
super.actionPerformed(btn);
|
super.actionPerformed(btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,6 +427,7 @@ public class GuiScreenConfigureChannels extends GuiScreen implements IGuiScreen
|
|||||||
Entry<String, Integer> e = getElementAt(elementIndex);
|
Entry<String, Integer> e = getElementAt(elementIndex);
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
ChannelDataAccessor.unsetChannelData(trigger, e.getKey());
|
ChannelDataAccessor.unsetChannelData(trigger, e.getKey());
|
||||||
|
updateButtons();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ import org.lwjgl.input.Keyboard;
|
|||||||
import com.gtnewhorizon.structurelib.StructureLib;
|
import com.gtnewhorizon.structurelib.StructureLib;
|
||||||
import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor;
|
import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor;
|
||||||
import com.gtnewhorizon.structurelib.alignment.constructable.ConstructableUtility;
|
import com.gtnewhorizon.structurelib.alignment.constructable.ConstructableUtility;
|
||||||
|
import com.gtnewhorizon.structurelib.gui.GuiScreenConfigureChannels;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
|
||||||
public class ItemConstructableTrigger extends Item {
|
public class ItemConstructableTrigger extends Item {
|
||||||
|
|
||||||
@@ -32,7 +35,7 @@ public class ItemConstructableTrigger extends Item {
|
|||||||
if (player.isSneaking()) {
|
if (player.isSneaking()) {
|
||||||
StructureLib.instance().proxy().displayConfigGUI("registries");
|
StructureLib.instance().proxy().displayConfigGUI("registries");
|
||||||
} else {
|
} else {
|
||||||
player.openGui(StructureLib.instance(), 0, world, player.inventory.currentItem, 0, 0);
|
FMLCommonHandler.instance().showGuiScreen(new GuiScreenConfigureChannels(stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onItemRightClick(stack, world, player);
|
return super.onItemRightClick(stack, world, player);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import com.gtnewhorizon.structurelib.StructureLib;
|
import com.gtnewhorizon.structurelib.StructureLib;
|
||||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||||
|
import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor;
|
||||||
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
|
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
|
||||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
|||||||
* itself.</li>
|
* itself.</li>
|
||||||
* <li>The "C" position would be the number of blocks between you and controller, not counting controller itself.</li>
|
* <li>The "C" position would be the number of blocks between you and controller, not counting controller itself.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param <T> Type of the context object. Usually this will be the multiblock controller.
|
* @param <T> Type of the context object. Usually this will be the multiblock controller.
|
||||||
*/
|
*/
|
||||||
public interface IStructureDefinition<T> {
|
public interface IStructureDefinition<T> {
|
||||||
@@ -72,7 +73,7 @@ public interface IStructureDefinition<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a structure check.
|
* Run a structure check.
|
||||||
*
|
*
|
||||||
* @param object context object. usually multiblock controller.
|
* @param object context object. usually multiblock controller.
|
||||||
* @param piece the structure piece's string identifier.
|
* @param piece the structure piece's string identifier.
|
||||||
* @param world the world object this check takes place in.
|
* @param world the world object this check takes place in.
|
||||||
@@ -107,7 +108,7 @@ public interface IStructureDefinition<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawn hint particles. Should not be called on server side.
|
* Spawn hint particles. Should not be called on server side.
|
||||||
*
|
*
|
||||||
* @param object context object. usually multiblock controller.
|
* @param object context object. usually multiblock controller.
|
||||||
* @param piece the structure piece's string identifier.
|
* @param piece the structure piece's string identifier.
|
||||||
* @param world the world object this check takes place in.
|
* @param world the world object this check takes place in.
|
||||||
@@ -320,7 +321,7 @@ public interface IStructureDefinition<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Low level utility.
|
* Low level utility.
|
||||||
*
|
*
|
||||||
* @param object context object. usually multiblock controller.
|
* @param object context object. usually multiblock controller.
|
||||||
* @param trigger The trigger item that contains channel data.
|
* @param trigger The trigger item that contains channel data.
|
||||||
* @param elements the structure piece
|
* @param elements the structure piece
|
||||||
@@ -394,6 +395,10 @@ public interface IStructureDefinition<T> {
|
|||||||
basePositionC,
|
basePositionC,
|
||||||
ignoreBlockUnloaded((e, w, x, y, z, a, b, c) -> {
|
ignoreBlockUnloaded((e, w, x, y, z, a, b, c) -> {
|
||||||
e.spawnHint(object, world, x, y, z, trigger);
|
e.spawnHint(object, world, x, y, z, trigger);
|
||||||
|
if (ChannelDataAccessor.hasSubChannel(trigger, "show_error")
|
||||||
|
&& !e.couldBeValid(object, world, x, y, z, trigger)) {
|
||||||
|
StructureLibAPI.markHintParticleError(StructureLib.getCurrentPlayer(), world, x, y, z);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
"spawnHint");
|
"spawnHint");
|
||||||
@@ -420,7 +425,7 @@ public interface IStructureDefinition<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of builder.
|
* Create a new instance of builder.
|
||||||
*
|
*
|
||||||
* @param <T> type of context object
|
* @param <T> type of context object
|
||||||
*/
|
*/
|
||||||
static <T> StructureDefinition.Builder<T> builder() {
|
static <T> StructureDefinition.Builder<T> builder() {
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ public interface IStructureElement<T> {
|
|||||||
|
|
||||||
boolean check(T t, World world, int x, int y, int z);
|
boolean check(T t, World world, int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pure (stateless and side effect free) function to test if current block could be valid. Used to give user hints
|
||||||
|
* about incorrectly placed blocks given a controller and trigger item. If couldBeValid(...) == false for a set of
|
||||||
|
* channels, with those same tiers, check(...) == false. Not required, defaults to true which is always safe but
|
||||||
|
* won't give the user error hints.
|
||||||
|
*/
|
||||||
|
default boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger);
|
boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger);
|
||||||
|
|
||||||
boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger);
|
boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger);
|
||||||
@@ -185,6 +195,11 @@ public interface IStructureElement<T> {
|
|||||||
return IStructureElement.this.check(t, world, x, y, z);
|
return IStructureElement.this.check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return IStructureElement.this.couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return IStructureElement.this.spawnHint(t, world, x, y, z, trigger);
|
return IStructureElement.this.spawnHint(t, world, x, y, z, trigger);
|
||||||
|
|||||||
@@ -31,6 +31,16 @@ public interface IStructureElementChain<T> extends IStructureElement<T> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
for (IStructureElement<T> fallback : fallbacks()) {
|
||||||
|
if (fallback.couldBeValid(t, world, x, y, z, trigger)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
for (IStructureElement<T> fallback : fallbacks()) {
|
for (IStructureElement<T> fallback : fallbacks()) {
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ public interface IStructureElementCheckOnly<T> extends IStructureElement<T> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ interface IStructureNavigate<T> extends IStructureElement<T> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ class LazyStructureElement<T> implements IStructureElementDeferred<T> {
|
|||||||
return get(t).check(t, world, x, y, z);
|
return get(t).check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return get(t).couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return get(t).placeBlock(t, world, x, y, z, trigger);
|
return get(t).placeBlock(t, world, x, y, z, trigger);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gtnewhorizon.structurelib.structure;
|
package com.gtnewhorizon.structurelib.structure;
|
||||||
|
|
||||||
|
import static com.gtnewhorizon.structurelib.StructureLib.LOGGER;
|
||||||
|
import static com.gtnewhorizon.structurelib.StructureLib.PANIC_MODE;
|
||||||
import static java.lang.Integer.MIN_VALUE;
|
import static java.lang.Integer.MIN_VALUE;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -155,6 +157,11 @@ public class StructureUtility {
|
|||||||
return world.isAirBlock(x, y, z);
|
return world.isAirBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(Object t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 13);
|
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 13);
|
||||||
@@ -186,6 +193,11 @@ public class StructureUtility {
|
|||||||
return !world.isAirBlock(x, y, z);
|
return !world.isAirBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(Object t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 14);
|
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 14);
|
||||||
@@ -225,6 +237,11 @@ public class StructureUtility {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(Object t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 15);
|
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 15);
|
||||||
@@ -318,18 +335,24 @@ public class StructureUtility {
|
|||||||
int itemMeta = itemBlock instanceof ISpecialItemBlock
|
int itemMeta = itemBlock instanceof ISpecialItemBlock
|
||||||
? ((ISpecialItemBlock) itemBlock).getItemMetaFromBlockMeta(block, meta)
|
? ((ISpecialItemBlock) itemBlock).getItemMetaFromBlockMeta(block, meta)
|
||||||
: meta;
|
: meta;
|
||||||
if (!s.takeOne(new ItemStack(itemBlock, 1, itemMeta), false)) {
|
ItemStack stack = new ItemStack(itemBlock, 1, itemMeta);
|
||||||
|
if (!s.takeOne(stack, true)) {
|
||||||
if (chatter != null) chatter.accept(
|
if (chatter != null) chatter.accept(
|
||||||
new ChatComponentTranslation(
|
new ChatComponentTranslation(
|
||||||
"structurelib.autoplace.error.no_simple_block",
|
"structurelib.autoplace.error.no_simple_block",
|
||||||
new ItemStack(itemBlock, 1, itemMeta).func_151000_E()));
|
stack.func_151000_E()));
|
||||||
return PlaceResult.REJECT;
|
return PlaceResult.REJECT;
|
||||||
}
|
}
|
||||||
if (block instanceof ICustomBlockSetting) {
|
if (block instanceof ICustomBlockSetting) {
|
||||||
ICustomBlockSetting block2 = (ICustomBlockSetting) block;
|
ICustomBlockSetting blockCustom = (ICustomBlockSetting) block;
|
||||||
block2.setBlock(world, x, y, z, meta);
|
blockCustom.setBlock(world, x, y, z, meta);
|
||||||
} else {
|
} else if (!stack.copy()
|
||||||
world.setBlock(x, y, z, block, meta, 2);
|
.tryPlaceItemIntoWorld(actor, world, x, y, z, ForgeDirection.UP.ordinal(), 0.5f, 0.5f, 0.5f)) {
|
||||||
|
return PlaceResult.REJECT;
|
||||||
|
}
|
||||||
|
if (!s.takeOne(stack, false)) {
|
||||||
|
// rollback
|
||||||
|
world.setBlockToAir(x, y, z);
|
||||||
}
|
}
|
||||||
return PlaceResult.ACCEPT;
|
return PlaceResult.ACCEPT;
|
||||||
}
|
}
|
||||||
@@ -479,6 +502,11 @@ public class StructureUtility {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), meta);
|
StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), meta);
|
||||||
@@ -499,6 +527,11 @@ public class StructureUtility {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, icons.get());
|
StructureLibAPI.hintParticle(world, x, y, z, icons.get());
|
||||||
@@ -519,6 +552,11 @@ public class StructureUtility {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticleTinted(world, x, y, z, icons.get(), RGBa);
|
StructureLibAPI.hintParticleTinted(world, x, y, z, icons.get(), RGBa);
|
||||||
@@ -556,7 +594,7 @@ public class StructureUtility {
|
|||||||
TIER current = getter.apply(t);
|
TIER current = getter.apply(t);
|
||||||
if (Objects.equals(notSet, current)) {
|
if (Objects.equals(notSet, current)) {
|
||||||
if (Objects.equals(notSet, tier)) {
|
if (Objects.equals(notSet, tier)) {
|
||||||
if (StructureLib.PANIC_MODE) {
|
if (PANIC_MODE) {
|
||||||
throw new AssertionError("tierExtractor should never return notSet: " + notSet);
|
throw new AssertionError("tierExtractor should never return notSet: " + notSet);
|
||||||
} else {
|
} else {
|
||||||
StructureLib.LOGGER.error("#########################################");
|
StructureLib.LOGGER.error("#########################################");
|
||||||
@@ -667,9 +705,23 @@ public class StructureUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Pair<Block, Integer> getHint(ItemStack trigger) {
|
private Pair<Block, Integer> getHint(ItemStack trigger) {
|
||||||
|
if (hints.isEmpty()) return null;
|
||||||
return hints.get(Math.min(Math.max(trigger.stackSize, 1), hints.size()) - 1);
|
return hints.get(Math.min(Math.max(trigger.stackSize, 1), hints.size()) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
Pair<Block, Integer> hint = getHint(trigger);
|
||||||
|
if (hint == null) return true;
|
||||||
|
TIER hintTier = tierExtractor.convert(hint.getKey(), hint.getValue());
|
||||||
|
Block block = world.getBlock(x, y, z);
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
TIER worldTier = tierExtractor.convert(block, meta);
|
||||||
|
|
||||||
|
// if the block is in the same tier as the hint block, this could be valid
|
||||||
|
return Objects.equals(hintTier, worldTier);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
Pair<Block, Integer> hint = getHint(trigger);
|
Pair<Block, Integer> hint = getHint(trigger);
|
||||||
@@ -767,6 +819,11 @@ public class StructureUtility {
|
|||||||
return world.getBlock(x, y, z) == getBlock() && (wildcard || world.getBlockMetadata(x, y, z) == meta);
|
return world.getBlock(x, y, z) == getBlock() && (wildcard || world.getBlockMetadata(x, y, z) == meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
if (getBlock() == null) return error().spawnHint(t, world, x, y, z, trigger);
|
if (getBlock() == null) return error().spawnHint(t, world, x, y, z, trigger);
|
||||||
@@ -841,10 +898,16 @@ public class StructureUtility {
|
|||||||
|
|
||||||
@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) {
|
||||||
if (init()) return world.getBlock(x, y, z) != block && world.getBlockMetadata(x, y, z) == meta;
|
if (init()) return world.getBlock(x, y, z) == block && world.getBlockMetadata(x, y, z) == meta;
|
||||||
else return fallback.check(t, world, x, y, z);
|
else return fallback.check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
if (init()) return world.getBlock(x, y, z) == block && world.getBlockMetadata(x, y, z) == meta;
|
||||||
|
else return fallback.couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
if (init()) {
|
if (init()) {
|
||||||
@@ -921,6 +984,11 @@ public class StructureUtility {
|
|||||||
return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z);
|
return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
||||||
@@ -958,6 +1026,11 @@ public class StructureUtility {
|
|||||||
.contains(worldBlock.getDamageValue(world, x, y, z));
|
.contains(worldBlock.getDamageValue(world, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
||||||
@@ -982,6 +1055,11 @@ public class StructureUtility {
|
|||||||
return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z);
|
return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
||||||
@@ -1016,6 +1094,13 @@ public class StructureUtility {
|
|||||||
return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z));
|
return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
// calling iBlockAdder can potentially modify external state
|
||||||
|
// therefore we assume this can always be valid.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
||||||
@@ -1049,6 +1134,11 @@ public class StructureUtility {
|
|||||||
return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z);
|
return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
||||||
@@ -1093,6 +1183,11 @@ public class StructureUtility {
|
|||||||
return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z);
|
return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
||||||
@@ -1158,6 +1253,11 @@ public class StructureUtility {
|
|||||||
.contains(worldBlock.getDamageValue(world, x, y, z));
|
.contains(worldBlock.getDamageValue(world, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
||||||
@@ -1203,6 +1303,11 @@ public class StructureUtility {
|
|||||||
.contains(worldBlock.getDamageValue(world, x, y, z));
|
.contains(worldBlock.getDamageValue(world, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
||||||
@@ -1251,6 +1356,14 @@ public class StructureUtility {
|
|||||||
if (block == null || defaultBlock == null) {
|
if (block == null || defaultBlock == null) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
if (block == Blocks.air) {
|
||||||
|
if (PANIC_MODE) {
|
||||||
|
throw new IllegalArgumentException("ofBlock() does not accept air. use isAir() instead");
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("ofBlock() does not accept air. use isAir() instead");
|
||||||
|
return isAir();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (block instanceof ICustomBlockSetting) {
|
if (block instanceof ICustomBlockSetting) {
|
||||||
return new IStructureElement<T>() {
|
return new IStructureElement<T>() {
|
||||||
|
|
||||||
@@ -1260,6 +1373,11 @@ public class StructureUtility {
|
|||||||
return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z);
|
return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
||||||
@@ -1287,6 +1405,11 @@ public class StructureUtility {
|
|||||||
return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z);
|
return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
||||||
@@ -1323,6 +1446,11 @@ public class StructureUtility {
|
|||||||
return block == world.getBlock(x, y, z);
|
return block == world.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
||||||
@@ -1350,6 +1478,11 @@ public class StructureUtility {
|
|||||||
return block == world.getBlock(x, y, z);
|
return block == world.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return check(t, world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
||||||
@@ -1416,6 +1549,13 @@ public class StructureUtility {
|
|||||||
return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z));
|
return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
// calling iBlockAdder can potentially modify external state
|
||||||
|
// therefore we assume this can always be valid.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
|
||||||
@@ -1455,6 +1595,13 @@ public class StructureUtility {
|
|||||||
return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z));
|
return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
// calling iBlockAdder can potentially modify external state
|
||||||
|
// therefore we assume this can always be valid.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
|
||||||
@@ -1510,6 +1657,13 @@ public class StructureUtility {
|
|||||||
return iTileAdder.apply(t, tileEntity);
|
return iTileAdder.apply(t, tileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
// calling iTileAdder can potentially modify external state
|
||||||
|
// therefore we assume this can always be valid.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
||||||
@@ -1536,6 +1690,13 @@ public class StructureUtility {
|
|||||||
return tileClass.isInstance(tileEntity) && iTileAdder.test(t, tileClass.cast(tileEntity));
|
return tileClass.isInstance(tileEntity) && iTileAdder.test(t, tileClass.cast(tileEntity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
// calling iTileAdder can potentially modify external state
|
||||||
|
// therefore we assume this can always be valid.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
|
||||||
@@ -1569,6 +1730,11 @@ public class StructureUtility {
|
|||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return element.couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return element.placeBlock(t, world, x, y, z, trigger);
|
return element.placeBlock(t, world, x, y, z, trigger);
|
||||||
@@ -1620,6 +1786,11 @@ public class StructureUtility {
|
|||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return element.couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return element.placeBlock(t, world, x, y, z, trigger);
|
return element.placeBlock(t, world, x, y, z, trigger);
|
||||||
@@ -1678,6 +1849,13 @@ public class StructureUtility {
|
|||||||
return predicate.test(t) && downstream.check(t, world, x, y, z);
|
return predicate.test(t) && downstream.check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
// this COULD potentially impact external state
|
||||||
|
// but predicate really should not have side effects
|
||||||
|
return predicate.test(t) && downstream.couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
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);
|
return predicate.test(t) && downstream.spawnHint(t, world, x, y, z, trigger);
|
||||||
@@ -1774,6 +1952,11 @@ public class StructureUtility {
|
|||||||
return elem.check(t.getCurrentContext(), world, x, y, z);
|
return elem.check(t.getCurrentContext(), world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return elem.couldBeValid(t.getCurrentContext(), world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return elem.spawnHint(t.getCurrentContext(), world, x, y, z, trigger);
|
return elem.spawnHint(t.getCurrentContext(), world, x, y, z, trigger);
|
||||||
@@ -1861,6 +2044,11 @@ public class StructureUtility {
|
|||||||
return to.get().check(t, world, x, y, z);
|
return to.get().check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return to.get().couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return to.get().placeBlock(t, world, x, y, z, trigger);
|
return to.get().placeBlock(t, world, x, y, z, trigger);
|
||||||
@@ -1914,6 +2102,11 @@ public class StructureUtility {
|
|||||||
return to.apply(t).check(t, world, x, y, z);
|
return to.apply(t).check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return to.apply(t).couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return to.apply(t).placeBlock(t, world, x, y, z, trigger);
|
return to.apply(t).placeBlock(t, world, x, y, z, trigger);
|
||||||
@@ -2126,6 +2319,11 @@ public class StructureUtility {
|
|||||||
return to.apply(t, null).check(t, world, x, y, z);
|
return to.apply(t, null).check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return to.apply(t, trigger).couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger);
|
return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger);
|
||||||
@@ -2318,6 +2516,11 @@ public class StructureUtility {
|
|||||||
return toCheck.apply(t).check(t, world, x, y, z);
|
return toCheck.apply(t).check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
return to.apply(t, trigger).couldBeValid(t, world, x, y, z, trigger);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger);
|
return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger);
|
||||||
@@ -2562,6 +2765,11 @@ public class StructureUtility {
|
|||||||
return backing.check(t, world, x, y, z);
|
return backing.check(t, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean couldBeValid(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
|
ItemStack newTrigger = ChannelDataAccessor.withChannel(trigger, channel);
|
||||||
|
return backing.couldBeValid(t, world, x, y, z, newTrigger);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
|
||||||
ItemStack newTrigger = ChannelDataAccessor.withChannel(trigger, channel);
|
ItemStack newTrigger = ChannelDataAccessor.withChannel(trigger, channel);
|
||||||
// We know spawnHint will only be called on client side, so the lack of player isn't quite an issue
|
// We know spawnHint will only be called on client side, so the lack of player isn't quite an issue
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
tile.structurelib.blockhint.name=Hint
|
||||||
tile.structurelib.blockhint.0.name=Hint 1 dot
|
tile.structurelib.blockhint.0.name=Hint 1 dot
|
||||||
tile.structurelib.blockhint.1.name=Hint 2 dots
|
tile.structurelib.blockhint.1.name=Hint 2 dots
|
||||||
tile.structurelib.blockhint.2.name=Hint 3 dots
|
tile.structurelib.blockhint.2.name=Hint 3 dots
|
||||||
@@ -35,6 +36,10 @@ item.structurelib.constructableTrigger.gui.add=Add
|
|||||||
item.structurelib.constructableTrigger.gui.set=Set
|
item.structurelib.constructableTrigger.gui.set=Set
|
||||||
item.structurelib.constructableTrigger.gui.unset=Unset
|
item.structurelib.constructableTrigger.gui.unset=Unset
|
||||||
item.structurelib.constructableTrigger.gui.wipe=§4Wipe
|
item.structurelib.constructableTrigger.gui.wipe=§4Wipe
|
||||||
|
item.structurelib.constructableTrigger.gui.error.show=Show Errors
|
||||||
|
item.structurelib.constructableTrigger.gui.error.hide=Hide Errors
|
||||||
|
item.structurelib.constructableTrigger.gui.gt_no_hatch.enable=No Hatch
|
||||||
|
item.structurelib.constructableTrigger.gui.gt_no_hatch.disable=Hatches
|
||||||
|
|
||||||
structurelib.autoplace.built_stat=Built %s blocks
|
structurelib.autoplace.built_stat=Built %s blocks
|
||||||
structurelib.autoplace.complete=§aThis multiblock has completed!
|
structurelib.autoplace.complete=§aThis multiblock has completed!
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
tile.structurelib.blockhint.name=提示方块
|
||||||
tile.structurelib.blockhint.0.name=提示方块:1号
|
tile.structurelib.blockhint.0.name=提示方块:1号
|
||||||
tile.structurelib.blockhint.1.name=提示方块:2号
|
tile.structurelib.blockhint.1.name=提示方块:2号
|
||||||
tile.structurelib.blockhint.2.name=提示方块:3号
|
tile.structurelib.blockhint.2.name=提示方块:3号
|
||||||
@@ -35,6 +36,10 @@ item.structurelib.constructableTrigger.gui.add=添加
|
|||||||
item.structurelib.constructableTrigger.gui.set=替换
|
item.structurelib.constructableTrigger.gui.set=替换
|
||||||
item.structurelib.constructableTrigger.gui.unset=删除
|
item.structurelib.constructableTrigger.gui.unset=删除
|
||||||
item.structurelib.constructableTrigger.gui.wipe=§4全部清空
|
item.structurelib.constructableTrigger.gui.wipe=§4全部清空
|
||||||
|
item.structurelib.constructableTrigger.gui.error.show=显示结构错误
|
||||||
|
item.structurelib.constructableTrigger.gui.error.hide=隐藏结构错误
|
||||||
|
item.structurelib.constructableTrigger.gui.gt_no_hatch.enable=跳过舱室
|
||||||
|
item.structurelib.constructableTrigger.gui.gt_no_hatch.disable=放置舱室
|
||||||
|
|
||||||
structurelib.autoplace.built_stat=已放置 %s 个方块
|
structurelib.autoplace.built_stat=已放置 %s 个方块
|
||||||
structurelib.autoplace.complete=§a这个多方块结构已经完成自动搭建!
|
structurelib.autoplace.complete=§a这个多方块结构已经完成自动搭建!
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 2.8 KiB |
Reference in new issue
Block a user