package com.gtnewhorizon.structurelib.structure; import com.gtnewhorizon.structurelib.structure.IStructureElement.PlaceResult; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import java.util.UUID; class SurvivalBuildStructureWalker implements IStructureWalker { private final T object; private final ItemStack trigger; private final IItemSource source; private final EntityPlayerMP actor; private final int elementBudget; private final boolean check; private int built; public SurvivalBuildStructureWalker(T object, ItemStack trigger, IItemSource source, EntityPlayerMP actor, int elementBudget, boolean check) { this.object = object; this.trigger = trigger; this.source = source; this.actor = actor; this.elementBudget = elementBudget; this.check = check; built = 0; } @Override public boolean visit(IStructureElement element, World world, int x, int y, int z) { PlaceResult placeResult = element.survivalPlaceBlock(object, world, x, y, z, trigger, source, actor); switch (placeResult) { case SKIP: return true; case ACCEPT: if (check) element.check(object, world, x, y, z); return ++built < elementBudget; case REJECT: return false; case ACCEPT_STOP: if (check) element.check(object, world, x, y, z); built += 1; // intentional fallthrough case STOP: return false; default: throw new NullPointerException(); } } public int getBuilt() { return built; } }