mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-16 10:34:52 +00:00
Use argument object for survival autoplace
This commit is contained in:
24 files changed
+1083
-183
No files matched your search
+31
-12
@@ -1,34 +1,53 @@
|
||||
package com.gtnewhorizon.structurelib.structure;
|
||||
|
||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
|
||||
import com.gtnewhorizon.structurelib.structure.IStructureElement.PlaceResult;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
class SurvivalBuildStructureWalker<T> implements IStructureWalker<T> {
|
||||
private final T object;
|
||||
private final ItemStack trigger;
|
||||
private final IItemSource source;
|
||||
private final EntityPlayerMP actor;
|
||||
final T object;
|
||||
final ItemStack trigger;
|
||||
private final int elementBudget;
|
||||
private final ISurvivalBuildEnvironment params;
|
||||
private final boolean check;
|
||||
private int built = -1;
|
||||
|
||||
private final AutoPlaceEnvironment env;
|
||||
|
||||
public SurvivalBuildStructureWalker(
|
||||
T object, ItemStack trigger, IItemSource source, EntityPlayerMP actor, int elementBudget, boolean check) {
|
||||
T object,
|
||||
ItemStack trigger,
|
||||
int elementBudget,
|
||||
ISurvivalBuildEnvironment params,
|
||||
IStructureDefinition<?> definition,
|
||||
String piece,
|
||||
ExtendedFacing facing,
|
||||
int[] baseOffsetABC,
|
||||
boolean check) {
|
||||
this.object = object;
|
||||
this.trigger = trigger;
|
||||
this.source = source;
|
||||
this.actor = actor;
|
||||
this.elementBudget = elementBudget;
|
||||
this.params = params;
|
||||
this.check = check;
|
||||
|
||||
env = new AutoPlaceEnvironment(
|
||||
params.getActor(),
|
||||
params.getActor()::addChatComponentMessage,
|
||||
definition,
|
||||
piece,
|
||||
facing,
|
||||
baseOffsetABC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z) {
|
||||
PlaceResult placeResult = element.survivalPlaceBlock(
|
||||
object, world, x, y, z, trigger, source, actor, actor::addChatComponentMessage);
|
||||
public boolean visit(IStructureElement<T> element, World world, int x, int y, int z, int a, int b, int c) {
|
||||
env.offsetABC[0] = a;
|
||||
env.offsetABC[1] = b;
|
||||
env.offsetABC[2] = c;
|
||||
env.setSource(params.getSource());
|
||||
PlaceResult placeResult = element.survivalPlaceBlock(object, world, x, y, z, trigger, env);
|
||||
if (placeResult != PlaceResult.SKIP && built == -1) built = 0;
|
||||
switch (placeResult) {
|
||||
case SKIP:
|
||||
@@ -37,7 +56,7 @@ class SurvivalBuildStructureWalker<T> implements IStructureWalker<T> {
|
||||
if (check) element.check(object, world, x, y, z);
|
||||
return ++built < elementBudget;
|
||||
case REJECT:
|
||||
StructureLibAPI.markHintParticleError(actor, world, x, y, z);
|
||||
StructureLibAPI.markHintParticleError(params.getActor(), world, x, y, z);
|
||||
return false;
|
||||
case ACCEPT_STOP:
|
||||
if (check) element.check(object, world, x, y, z);
|
||||
|
||||
Reference in new issue
Block a user