Use argument object for survival autoplace

This commit is contained in:
Glease committed 2022-09-16 18:57:04 +08:00
1 parent 23605fc22d
commit c0814274ec
24 files changed
+1083 -183

No files matched your search

@@ -112,7 +112,7 @@ import org.apache.commons.lang3.tuple.Pair;
* <h1>Helper Methods</h1>
* These don't construct a {@link IStructureElement}, but is helpful to the instantiation or implementation of these.
* <ul>
* <li>{@link #survivalPlaceBlock(Block, int, World, int, int, int, IItemSource, EntityPlayerMP, Consumer)} and its overloads:
* <li>{@link #survivalPlaceBlock(Block, int, World, int, int, int, IItemSource, EntityPlayer, Consumer)} and its overloads:
* Helper method to cut common boilerplate for implementing {@link IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer)}</li>
* <li>{@link #getPseudoJavaCode(World, ExtendedFacing, int, int, int, int, int, int, Function, int, int, int, boolean)}:
* Generate a structure code template from existing structure.</li>
@@ -147,6 +147,7 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
Object o,
World world,
@@ -252,6 +253,22 @@ public class StructureUtility {
*/
public static PlaceResult survivalPlaceBlock(
Block block, int meta, World world, int x, int y, int z, IItemSource s, EntityPlayerMP actor) {
return survivalPlaceBlock(block, meta, world, x, y, z, s, (EntityPlayer) actor);
}
/**
* This is a helper method for implementing {@link IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer)}
* <p>
* This method will try to look up an {@link ItemBlock} for given block and meta from {@code s} and place it at given
* location.
* This method assume block at given coord is NOT acceptable, but may or may not be trivially replaceable
* This method might yield error messages to the player only if there is likely a programming error or exploit.
*
* @param s drain resources from this place
* @param actor source of action. cannot be null.
*/
public static PlaceResult survivalPlaceBlock(
Block block, int meta, World world, int x, int y, int z, IItemSource s, EntityPlayer actor) {
return survivalPlaceBlock(block, meta, world, x, y, z, s, actor, null);
}
@@ -278,6 +295,32 @@ public class StructureUtility {
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
return survivalPlaceBlock(block, meta, world, x, y, z, s, (EntityPlayer) actor, chatter);
}
/**
* This is a helper method for implementing {@link IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer)}
* <p>
* This method will try to look up an {@link ItemBlock} for given block and meta from {@code s} and place it at given
* location.
* This method assume block at given coord is NOT acceptable, but may or may not be trivially replaceable
* This method might yield error messages to the player only if there is likely a programming error or exploit.
* This method might yield error messages to the chatter.
*
* @param s drain resources from this place
* @param actor source of action. cannot be null.
* @param chatter normal error destination. can be null to suppress them.
*/
public static PlaceResult survivalPlaceBlock(
Block block,
int meta,
World world,
int x,
int y,
int z,
IItemSource s,
EntityPlayer actor,
Consumer<IChatComponent> chatter) {
if (block == null) throw new NullPointerException();
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor)) return PlaceResult.REJECT;
Item itemBlock = Item.getItemFromBlock(block);
@@ -323,6 +366,32 @@ public class StructureUtility {
int z,
IItemSource s,
EntityPlayerMP actor) {
return survivalPlaceBlock(stack, nbtMode, tag, assumeStackPresent, world, x, y, z, s, (EntityPlayer) actor);
}
/**
* This is a helper method for implementing {@link IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer)}
* <p>
* This method will try to look up an {@link ItemBlock} for given block and meta from {@code s} and place it at given
* location.
* This method assume block at given coord is NOT acceptable, but may or may not be trivially replaceable
* This method might yield error messages to the player only if there is likely a programming error or exploit.
*
* @param stack a valid stack with stack size of exactly 1. Must be of an ItemBlock!
* @param s drain resources from this place
* @param actor source of action. cannot be null.
*/
public static PlaceResult survivalPlaceBlock(
ItemStack stack,
NBTMode nbtMode,
NBTTagCompound tag,
boolean assumeStackPresent,
World world,
int x,
int y,
int z,
IItemSource s,
EntityPlayer actor) {
return survivalPlaceBlock(stack, nbtMode, tag, assumeStackPresent, world, x, y, z, s, actor, null);
}
@@ -352,6 +421,36 @@ public class StructureUtility {
IItemSource s,
EntityPlayerMP actor,
@Nullable Consumer<IChatComponent> chatter) {
return survivalPlaceBlock(
stack, nbtMode, tag, assumeStackPresent, world, x, y, z, s, (EntityPlayer) actor, chatter);
}
/**
* This is a helper method for implementing {@link IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, Consumer)}
* <p>
* This method will try to look up an {@link ItemBlock} for given block and meta from {@code s} and place it at given
* location.
* This method assume block at given coord is NOT acceptable, but may or may not be trivially replaceable
* This method might yield error messages to the player only if there is likely a programming error or exploit.
* This method might yield error messages to the chatter.
*
* @param stack a valid stack with stack size of exactly 1. Must be of an ItemBlock!
* @param s drain resources from this place
* @param actor source of action. cannot be null.
* @param chatter normal error destination. can be null to suppress them.
*/
public static PlaceResult survivalPlaceBlock(
ItemStack stack,
NBTMode nbtMode,
NBTTagCompound tag,
boolean assumeStackPresent,
World world,
int x,
int y,
int z,
IItemSource s,
EntityPlayer actor,
@Nullable Consumer<IChatComponent> chatter) {
if (stack == null) throw new NullPointerException();
if (stack.stackSize != 1) throw new IllegalArgumentException();
if (!(stack.getItem() instanceof ItemBlock)) throw new IllegalArgumentException();
@@ -577,9 +676,9 @@ public class StructureUtility {
* @param allKnownTiers A list of 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 bit.
* This list is only for hint particle spawning and survival build.
* The hint/autoplace code will choose 1st pair to spawn/place if trigger item has master channel data of 1,
* 2nd pair if 2, and so on.
* This list is only for hint particle spawning and survival build.
* The hint/autoplace code will choose 1st pair to spawn/place if trigger item has master channel data of 1,
* 2nd pair if 2, and so on.
* @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 context object
* @param setter a function to set the current tier into context object
@@ -593,7 +692,7 @@ public class StructureUtility {
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>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
return check.check(t, world, x, y, z);
@@ -626,15 +725,7 @@ public class StructureUtility {
@Override
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
Pair<Block, Integer> hint = getHint(trigger);
if (hint == null) return PlaceResult.REJECT; // TODO or SKIP?
Block block = world.getBlock(x, y, z);
@@ -643,7 +734,15 @@ public class StructureUtility {
if (Objects.equals(tier, tierExtractor.convert(hint.getKey(), hint.getValue())))
return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
hint.getKey(), hint.getValue(), world, x, y, z, s, actor, chatter);
hint.getKey(),
hint.getValue(),
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
}
@@ -676,7 +775,7 @@ public class StructureUtility {
if (meta < 0) throw new IllegalArgumentException();
if (meta > 15) throw new IllegalArgumentException();
if (StringUtils.isBlank(modid)) throw new IllegalArgumentException();
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
private Block block;
private Block getBlock() {
@@ -705,18 +804,11 @@ public class StructureUtility {
@Override
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
if (getBlock() == null) return PlaceResult.REJECT;
return StructureUtility.survivalPlaceBlock(getBlock(), meta, world, x, y, z, s, actor, chatter);
return StructureUtility.survivalPlaceBlock(
getBlock(), meta, world, x, y, z, env.getSource(), env.getActor(), env.getChatter());
}
};
}
@@ -773,6 +865,7 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
@@ -787,6 +880,16 @@ public class StructureUtility {
if (init()) return StructureUtility.survivalPlaceBlock(block, meta, world, x, y, z, s, actor, chatter);
return fallback.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
if (init())
return StructureUtility.survivalPlaceBlock(
block, meta, world, x, y, z, env.getSource(), env.getActor(), env.getChatter());
return fallback.survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -928,7 +1031,7 @@ public class StructureUtility {
throw new IllegalArgumentException();
}
if (defaultBlock instanceof ICustomBlockSetting) {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
Block worldBlock = world.getBlock(x, y, z);
@@ -948,23 +1051,24 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
} else {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
Block worldBlock = world.getBlock(x, y, z);
@@ -984,19 +1088,20 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
}
@@ -1021,7 +1126,7 @@ public class StructureUtility {
}
}
if (defaultBlock instanceof ICustomBlockSetting) {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
Block worldBlock = world.getBlock(x, y, z);
@@ -1042,23 +1147,24 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
} else {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
Block worldBlock = world.getBlock(x, y, z);
@@ -1079,19 +1185,20 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
}
@@ -1110,7 +1217,7 @@ public class StructureUtility {
throw new IllegalArgumentException();
}
if (block instanceof ICustomBlockSetting) {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
Block worldBlock = world.getBlock(x, y, z);
@@ -1130,23 +1237,24 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
} else {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
Block worldBlock = world.getBlock(x, y, z);
@@ -1166,19 +1274,20 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
}
@@ -1192,7 +1301,7 @@ public class StructureUtility {
throw new IllegalArgumentException();
}
if (block instanceof ICustomBlockSetting) {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
return block == world.getBlock(x, y, z);
@@ -1211,23 +1320,24 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
} else {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
return block == world.getBlock(x, y, z);
@@ -1246,19 +1356,20 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (check(t, world, x, y, z)) return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
}
@@ -1300,7 +1411,7 @@ public class StructureUtility {
throw new IllegalArgumentException();
}
if (defaultBlock instanceof ICustomBlockSetting) {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
Block worldBlock = world.getBlock(x, y, z);
@@ -1320,24 +1431,25 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (world.getBlock(x, y, z) == defaultBlock && world.getBlockMetadata(x, y, z) == defaultMeta)
return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
} else {
return new IStructureElement<T>() {
return new StructureElement_Bridge<T>() {
@Override
public boolean check(T t, World world, int x, int y, int z) {
Block worldBlock = world.getBlock(x, y, z);
@@ -1357,20 +1469,21 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
int x,
int y,
int z,
ItemStack trigger,
IItemSource s,
EntityPlayerMP actor,
Consumer<IChatComponent> chatter) {
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (world.getBlock(x, y, z) == defaultBlock && world.getBlockMetadata(x, y, z) == defaultMeta)
return PlaceResult.SKIP;
return StructureUtility.survivalPlaceBlock(
defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
defaultBlock,
defaultMeta,
world,
x,
y,
z,
env.getSource(),
env.getActor(),
env.getChatter());
}
};
}
@@ -1465,6 +1578,7 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
@@ -1477,6 +1591,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return element.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return element.survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -1509,6 +1629,7 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
@@ -1521,6 +1642,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return element.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return element.survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -1562,6 +1689,7 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
@@ -1576,6 +1704,13 @@ public class StructureUtility {
return downstream.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
return placeResultWhenDisabled;
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
if (predicate.test(t)) return downstream.survivalPlaceBlock(t, world, x, y, z, trigger, env);
return placeResultWhenDisabled;
}
};
}
@@ -1650,6 +1785,7 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
@@ -1662,6 +1798,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return elem.survivalPlaceBlock(t.getCurrentContext(), world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return elem.survivalPlaceBlock(t.getCurrentContext(), world, x, y, z, trigger, env);
}
};
}
// endregion
@@ -1732,6 +1874,7 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
@@ -1744,6 +1887,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return to.get().survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return to.get().survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -1791,6 +1940,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return to.apply(t).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return to.apply(t).survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -1857,6 +2012,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return map.get(keyExtractor.apply(t)).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return map.get(keyExtractor.apply(t)).survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -1930,6 +2091,13 @@ public class StructureUtility {
return map.getOrDefault(keyExtractor.apply(t), defaultElem)
.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return map.getOrDefault(keyExtractor.apply(t), defaultElem)
.survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2000,6 +2168,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return array[keyExtractor.apply(t)].survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return array[keyExtractor.apply(t)].survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2086,6 +2260,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return to.apply(t, trigger).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return to.apply(t, trigger).survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2161,6 +2341,12 @@ public class StructureUtility {
return map.get(keyExtractor.apply(t, trigger))
.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return map.get(keyExtractor.apply(t, trigger)).survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2245,6 +2431,13 @@ public class StructureUtility {
return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem)
.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem)
.survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2298,6 +2491,12 @@ public class StructureUtility {
return array[keyExtractor.apply(t, trigger)].survivalPlaceBlock(
t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return array[keyExtractor.apply(t, trigger)].survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2370,6 +2569,12 @@ public class StructureUtility {
Consumer<IChatComponent> chatter) {
return to.apply(t, trigger).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return to.apply(t, trigger).survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2457,6 +2662,12 @@ public class StructureUtility {
return map.get(keyExtractor.apply(t, trigger))
.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return map.get(keyExtractor.apply(t, trigger)).survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2546,6 +2757,13 @@ public class StructureUtility {
return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem)
.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem)
.survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2620,6 +2838,7 @@ public class StructureUtility {
}
@Override
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
@@ -2633,6 +2852,12 @@ public class StructureUtility {
return array[keyExtractor.apply(t, trigger)].survivalPlaceBlock(
t, world, x, y, z, trigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
return array[keyExtractor.apply(t, trigger)].survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
@@ -2723,6 +2948,7 @@ public class StructureUtility {
return backing.placeBlock(t, world, x, y, z, ChannelDataAccessor.withChannel(trigger, channel));
}
@Deprecated
public PlaceResult survivalPlaceBlock(
T t,
World world,
@@ -2740,6 +2966,17 @@ public class StructureUtility {
warnNoExplicitSubChannel(actor);
return backing.survivalPlaceBlock(t, world, x, y, z, newTrigger, s, actor, chatter);
}
@Override
public PlaceResult survivalPlaceBlock(
T t, World world, int x, int y, int z, ItemStack trigger, AutoPlaceEnvironment env) {
ItemStack newTrigger = ChannelDataAccessor.withChannel(trigger, channel);
if (newTrigger == trigger)
// we will bypass the chatter filter here, as this is a warning that player definitively want to see
// instead of some false positive error messages like item not find
warnNoExplicitSubChannel(env.getActor());
return backing.survivalPlaceBlock(t, world, x, y, z, trigger, env);
}
};
}
// endregion
@@ -3076,7 +3313,7 @@ public class StructureUtility {
Arrays.toString(abc));
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], abc[0], abc[1], abc[2])) {
if (StructureLibAPI.isDebugEnabled()) {
StructureLib.LOGGER.info(
"Multi [{}, {}, {}] {} stop @ {} {}",
@@ -3100,7 +3337,8 @@ public class StructureUtility {
Arrays.toString(xyz),
Arrays.toString(abc));
}
if (!predicate.blockNotLoaded(element, world, xyz[0], xyz[1], xyz[2])) return false;
if (!predicate.blockNotLoaded(element, world, xyz[0], xyz[1], xyz[2], abc[0], abc[1], abc[2]))
return false;
}
abc[0] += 1;
}