mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
update to forEachMatcher in Patchouli
This commit is contained in:
parent
f27c1e4312
commit
b6a496ed99
5 changed files with 6 additions and 29 deletions
|
@ -1,16 +1,12 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockLog;
|
import net.minecraft.block.BlockLog;
|
||||||
import net.minecraft.block.BlockSapling;
|
import net.minecraft.block.BlockSapling;
|
||||||
import net.minecraft.block.BlockStoneBrick;
|
import net.minecraft.block.BlockStoneBrick;
|
||||||
import net.minecraft.block.BlockStoneBrick.EnumType;
|
import net.minecraft.block.BlockStoneBrick.EnumType;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.Rotation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import vazkii.patchouli.common.multiblock.Multiblock;
|
import vazkii.patchouli.common.multiblock.Multiblock;
|
||||||
import vazkii.patchouli.common.multiblock.Multiblock.StateMatcher;
|
import vazkii.patchouli.common.multiblock.Multiblock.StateMatcher;
|
||||||
import vazkii.patchouli.common.multiblock.MultiblockRegistry;
|
import vazkii.patchouli.common.multiblock.MultiblockRegistry;
|
||||||
|
@ -40,25 +36,4 @@ public final class Multiblocks {
|
||||||
'0', StateMatcher.fromPredicate(Blocks.SAPLING, state -> state.getBlock() instanceof BlockSapling || state.getBlock() instanceof BlockLog),
|
'0', StateMatcher.fromPredicate(Blocks.SAPLING, state -> state.getBlock() instanceof BlockSapling || state.getBlock() instanceof BlockLog),
|
||||||
' ', StateMatcher.ANY)
|
' ', StateMatcher.ANY)
|
||||||
).setSymmetrical(true);
|
).setSymmetrical(true);
|
||||||
|
|
||||||
public static boolean validateLoosely(Multiblock mb, World world, BlockPos pos, Block ignored) {
|
|
||||||
return validateLoosely(mb, pos,
|
|
||||||
(start, x, y, z, matcher) -> matcher.displayState.getBlock() == ignored || mb.test(world, start, x, y, z, Rotation.NONE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean validateLoosely(Multiblock mb, BlockPos pos, LooseValidator validator) {
|
|
||||||
BlockPos start = pos.add(-mb.offX, -mb.offY, -mb.offZ);
|
|
||||||
for (int x = 0; x < mb.sizeX; x++)
|
|
||||||
for (int y = 0; y < mb.sizeY; y++)
|
|
||||||
for (int z = 0; z < mb.sizeZ; z++) {
|
|
||||||
if (!validator.works(start, x, y, z, mb.stateTargets[x][y][z])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface LooseValidator {
|
|
||||||
boolean works(BlockPos start, int x, int y, int z, StateMatcher matcher);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isRitualOkay() {
|
private boolean isRitualOkay() {
|
||||||
if (!Multiblocks.validateLoosely(Multiblocks.TREE_RITUAL, this.world, this.ritualPos, ModBlocks.WOOD_STAND)) {
|
if (!Multiblocks.TREE_RITUAL.forEachMatcher(this.world, this.ritualPos, Rotation.NONE, (char) 0, (start, actionPos, x, y, z, ch, matcher) ->
|
||||||
|
matcher.displayState.getBlock() == ModBlocks.WOOD_STAND || Multiblocks.TREE_RITUAL.test(this.world, start, x, y, z, Rotation.NONE))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.timer < this.recipe.time / 2) {
|
if (this.timer < this.recipe.time / 2) {
|
||||||
|
|
|
@ -27,7 +27,8 @@ public class TerrainGenEvents {
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
BlockPos pos = event.getPos();
|
BlockPos pos = event.getPos();
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (Multiblocks.validateLoosely(Multiblocks.TREE_RITUAL, world, pos, ModBlocks.WOOD_STAND)) {
|
if (Multiblocks.TREE_RITUAL.forEachMatcher(world, pos, Rotation.NONE, (char) 0, (start, actionPos, x, y, z, ch, matcher) ->
|
||||||
|
matcher.displayState.getBlock() == ModBlocks.WOOD_STAND || Multiblocks.TREE_RITUAL.test(world, start, x, y, z, Rotation.NONE))) {
|
||||||
IBlockState sapling = world.getBlockState(pos);
|
IBlockState sapling = world.getBlockState(pos);
|
||||||
ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling);
|
ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling);
|
||||||
if (!saplingStack.isEmpty()) {
|
if (!saplingStack.isEmpty()) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "multiblock",
|
"type": "multiblock",
|
||||||
"multiblock": "naturesaura:altar",
|
"multiblock_id": "naturesaura:altar",
|
||||||
"text": "How to assemble the $(item)Natural Altar$()"
|
"text": "How to assemble the $(item)Natural Altar$()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "multiblock",
|
"type": "multiblock",
|
||||||
"multiblock": "naturesaura:tree_ritual",
|
"multiblock_id": "naturesaura:tree_ritual",
|
||||||
"text": "Preparing the $(item)Ritual of the Forest$(). It is not required to have all $(item)Wood Stands$() present."
|
"text": "Preparing the $(item)Ritual of the Forest$(). It is not required to have all $(item)Wood Stands$() present."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue