shift from uuid to EntityPlayerMP

ok maybe we shouldn't support building stuff for someone offline yet
This commit is contained in:
Glease committed 2022-07-09 03:09:19 +08:00
1 parent 4a7051ab63
commit 5e66f6b8aa
12 files changed
+98 -103

No files matched your search

@@ -13,8 +13,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.UUID;
import static com.gtnewhorizon.structurelib.StructureLib.proxy;
/**
@@ -149,9 +147,9 @@ public class StructureLibAPI {
* Determines if given block can be replaced without much effort. The exact predicate clauses is not stable and
* will be changed, but the general idea will always stay the same.
*
* Use this in your {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, UUID)}
* Use this in your {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP)}
*/
public static boolean isBlockTriviallyReplaceable(World w, int x, int y, int z, UUID actorProfile) {
public static boolean isBlockTriviallyReplaceable(World w, int x, int y, int z, EntityPlayerMP actor) {
// TODO extend this function a bit
return w.getBlock(x, y, z).isReplaceable(w, x, y, z);
}
@@ -37,7 +37,7 @@ public interface IMultiblockInfoContainer<T> {
void construct(ItemStack stackSize, boolean hintsOnly, T tileEntity, ExtendedFacing aSide);
/**
* Construct the structure using {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, UUID)}
* Construct the structure using {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, net.minecraft.entity.player.EntityPlayerMP)}
* @return -1 if done, a helping pointer
*/
default int survivalConstruct(ItemStack stackSize, int elementBudge, IItemSource source, UUID actorProfile, T tileEntity, ExtendedFacing aSide) {
@@ -8,7 +8,7 @@ import java.util.UUID;
public interface ISurvivalConstructable extends IConstructable {
/**
* Construct the structure using {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, UUID)}
* Construct the structure using {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, net.minecraft.entity.player.EntityPlayerMP)}
*
* @return -1 if done, otherwise number of elements placed this round
*/
@@ -2,11 +2,11 @@ package com.gtnewhorizon.structurelib.structure;
import com.gtnewhorizon.structurelib.StructureLib;
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.Arrays;
import java.util.UUID;
import static com.gtnewhorizon.structurelib.StructureLib.DEBUG_MODE;
@@ -55,7 +55,7 @@ public interface IStructureDefinition<T> {
/**
* @param elementBudget build up to this many elements
* @param source from where to drain resource
* @param actorProfile source of action
* @param actor source of action
* @param check whether {@link IStructureElement#check(Object, World, int, int, int)} should be called if anything
* would be placed. use with caution.
* if in doubt, call {@link #check(Object, String, World, ExtendedFacing, int, int, int, int, int, int, boolean)}
@@ -65,8 +65,8 @@ public interface IStructureDefinition<T> {
*/
default int survivalBuild(T object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing,
int basePositionX, int basePositionY, int basePositionZ,
int basePositionA, int basePositionB, int basePositionC, int elementBudget, IItemSource source, UUID actorProfile, boolean check) {
SurvivalBuildStructureWalker<T> walker = new SurvivalBuildStructureWalker<>(object, trigger, source, actorProfile, elementBudget, check);
int basePositionA, int basePositionB, int basePositionC, int elementBudget, IItemSource source, EntityPlayerMP actor, boolean check) {
SurvivalBuildStructureWalker<T> walker = new SurvivalBuildStructureWalker<>(object, trigger, source, actor, elementBudget, check);
StructureUtility.iterateV2(getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ,
basePositionA, basePositionB, basePositionC, walker, "iterateV2");
return walker.getBuilt();
@@ -1,11 +1,10 @@
package com.gtnewhorizon.structurelib.structure;
import com.gtnewhorizon.structurelib.StructureLibAPI;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.UUID;
import static com.gtnewhorizon.structurelib.StructureLib.DEBUG_MODE;
import static com.gtnewhorizon.structurelib.StructureLib.LOGGER;
import static com.gtnewhorizon.structurelib.StructureLib.PANIC_MODE;
@@ -23,15 +22,15 @@ public interface IStructureElement<T> {
/**
* Try place the block by taking resource from given IItemSource.
*
* @param s drain resources from this place
* @param actorProfile source of action.
* @param s drain resources from this place
* @param actor source of action.
*/
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (PANIC_MODE)
throw new RuntimeException("Panic Tripwire hit");
if (DEBUG_MODE)
LOGGER.error("Default implementation of survivalPlaceBlock hit! Things aren't going to work well! IStructureElement class: {}", getClass().getName());
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actorProfile))
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor))
return PlaceResult.REJECT;
return PlaceResult.SKIP;
}
@@ -1,10 +1,9 @@
package com.gtnewhorizon.structurelib.structure;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.UUID;
/**
* Use StructureUtility to instantiate
*/
@@ -42,10 +41,10 @@ public interface IStructureElementChain<T> extends IStructureElement<T> {
}
@Override
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
boolean haveSkip = false;
for (IStructureElement<T> fallback : fallbacks()) {
PlaceResult result = fallback.survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
PlaceResult result = fallback.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
switch (result) {
case REJECT:
break;
@@ -1,10 +1,9 @@
package com.gtnewhorizon.structurelib.structure;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.UUID;
public interface IStructureElementCheckOnly<T> extends IStructureElement<T> {
@Override
default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
@@ -17,7 +16,7 @@ public interface IStructureElementCheckOnly<T> extends IStructureElement<T> {
}
@Override
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return PlaceResult.SKIP;
}
}
@@ -1,10 +1,9 @@
package com.gtnewhorizon.structurelib.structure;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.UUID;
public interface IStructureElementNoPlacement<T> extends IStructureElement<T> {
@Override
default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
@@ -12,7 +11,7 @@ public interface IStructureElementNoPlacement<T> extends IStructureElement<T> {
}
@Override
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return PlaceResult.SKIP;
}
}
@@ -1,10 +1,9 @@
package com.gtnewhorizon.structurelib.structure;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.UUID;
/**
* Use StructureUtility to instantiate
*/
@@ -25,7 +24,7 @@ interface IStructureNavigate<T> extends IStructureElement<T> {
}
@Override
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
default PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return PlaceResult.SKIP;
}
@@ -1,9 +1,9 @@
package com.gtnewhorizon.structurelib.structure;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import java.util.UUID;
import java.util.function.Function;
class LazyStructureElement<T> implements IStructureElementDeferred<T> {
@@ -38,7 +38,7 @@ class LazyStructureElement<T> implements IStructureElementDeferred<T> {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return get(t).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return get(t).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
}
@@ -10,6 +10,7 @@ import com.gtnewhorizon.structurelib.util.ItemStackPredicate;
import com.gtnewhorizon.structurelib.util.Vec3Impl;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -55,9 +56,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(Object o, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(Object o, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(o, world, x, y, z)) return PlaceResult.ACCEPT;
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actorProfile))
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor))
return PlaceResult.REJECT;
world.setBlock(x, y, z, Blocks.air, 0, 2);
return PlaceResult.ACCEPT;
@@ -84,7 +85,7 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(Object o, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(Object o, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(o, world, x, y, z)) return PlaceResult.ACCEPT;
// user should place anything here.
// maybe make this configurable, but for now we try to take some cobble from user
@@ -114,7 +115,7 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(Object o, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(Object o, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return PlaceResult.REJECT;
}
};
@@ -126,10 +127,10 @@ public class StructureUtility {
/**
* This method assume block at given coord is NOT acceptable, but may or may not be trivially replaceable
*/
static PlaceResult survivalPlaceBlock(Block block, int meta, World world, int x, int y, int z, IItemSource s, UUID actorProfile) {
static PlaceResult survivalPlaceBlock(Block block, int meta, World world, int x, int y, int z, IItemSource s, EntityPlayerMP actor) {
if (block == null)
throw new NullPointerException();
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actorProfile))
if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, actor))
return PlaceResult.REJECT;
Item itemBlock = Item.getItemFromBlock(block);
int itemMeta = itemBlock instanceof ISpecialItemBlock ? ((ISpecialItemBlock) itemBlock).getItemMetaFromBlockMeta(block, meta) : meta;
@@ -301,12 +302,12 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
Pair<Block, Integer> hint = getHint(trigger);
if (hint == null)
return PlaceResult.REJECT; // TODO or SKIP?
return StructureUtility.survivalPlaceBlock(hint.getKey(), hint.getValue(), world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(hint.getKey(), hint.getValue(), world, x, z, z, s, actor);
}
};
}
@@ -349,11 +350,11 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
if (getBlock() == null)
return PlaceResult.REJECT; // TODO or SKIP?
return StructureUtility.survivalPlaceBlock(getBlock(), meta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(getBlock(), meta, world, x, z, z, s, actor);
}
};
}
@@ -410,11 +411,11 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
if (init())
return StructureUtility.survivalPlaceBlock(block, meta, world, x, z, z, s, actorProfile);
return fallback.survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
return StructureUtility.survivalPlaceBlock(block, meta, world, x, z, z, s, actor);
return fallback.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -538,9 +539,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
} else {
@@ -564,9 +565,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
}
@@ -605,9 +606,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
} else {
@@ -631,9 +632,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
}
@@ -664,9 +665,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
} else {
@@ -690,9 +691,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
}
@@ -725,9 +726,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
} else {
@@ -750,9 +751,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (check(t, world, x, y, z)) return PlaceResult.ACCEPT;
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
}
@@ -805,9 +806,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
//TODO should we call block adder to check????
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
} else {
@@ -831,9 +832,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
//TODO should we call block adder to check????
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actorProfile);
return StructureUtility.survivalPlaceBlock(defaultBlock, defaultMeta, world, x, z, z, s, actor);
}
};
}
@@ -910,8 +911,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return element.survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return element.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -938,8 +939,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return element.survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return element.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -974,9 +975,9 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
if (predicate.test(t))
return downstream.survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
return downstream.survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
return placeResultWhenDisabled;
}
};
@@ -1027,8 +1028,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return elem.survivalPlaceBlock(t.getCurrentContext(), world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return elem.survivalPlaceBlock(t.getCurrentContext(), world, x, y, z, trigger, s, actor);
}
};
}
@@ -1079,8 +1080,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return to.get().survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return to.get().survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1106,8 +1107,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return to.apply(t).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return to.apply(t).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1133,8 +1134,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return map.get(keyExtractor.apply(t)).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return map.get(keyExtractor.apply(t)).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1160,8 +1161,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return map.getOrDefault(keyExtractor.apply(t), defaultElem).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return map.getOrDefault(keyExtractor.apply(t), defaultElem).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1188,8 +1189,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return array[keyExtractor.apply(t)].survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return array[keyExtractor.apply(t)].survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1220,8 +1221,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return to.apply(t, trigger).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return to.apply(t, trigger).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1247,8 +1248,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return map.get(keyExtractor.apply(t, trigger)).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return map.get(keyExtractor.apply(t, trigger)).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1274,8 +1275,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1302,8 +1303,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return array[keyExtractor.apply(t, trigger)].survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return array[keyExtractor.apply(t, trigger)].survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1334,8 +1335,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return to.apply(t, trigger).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return to.apply(t, trigger).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1361,8 +1362,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return map.get(keyExtractor.apply(t, trigger)).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return map.get(keyExtractor.apply(t, trigger)).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1388,8 +1389,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1416,8 +1417,8 @@ public class StructureUtility {
}
@Override
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, UUID actorProfile) {
return array[keyExtractor.apply(t, trigger)].survivalPlaceBlock(t, world, x, y, z, trigger, s, actorProfile);
public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, IItemSource s, EntityPlayerMP actor) {
return array[keyExtractor.apply(t, trigger)].survivalPlaceBlock(t, world, x, y, z, trigger, s, actor);
}
};
}
@@ -1,6 +1,7 @@
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;
@@ -10,16 +11,16 @@ class SurvivalBuildStructureWalker<T> implements IStructureWalker<T> {
private final T object;
private final ItemStack trigger;
private final IItemSource source;
private final UUID actorProfile;
private final EntityPlayerMP actor;
private final int elementBudget;
private final boolean check;
private int built;
public SurvivalBuildStructureWalker(T object, ItemStack trigger, IItemSource source, UUID actorProfile, int elementBudget, boolean check) {
public SurvivalBuildStructureWalker(T object, ItemStack trigger, IItemSource source, EntityPlayerMP actor, int elementBudget, boolean check) {
this.object = object;
this.trigger = trigger;
this.source = source;
this.actorProfile = actorProfile;
this.actor = actor;
this.elementBudget = elementBudget;
this.check = check;
built = 0;
@@ -27,7 +28,7 @@ class SurvivalBuildStructureWalker<T> implements IStructureWalker<T> {
@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, actorProfile);
PlaceResult placeResult = element.survivalPlaceBlock(object, world, x, y, z, trigger, source, actor);
switch (placeResult) {
case SKIP:
return true;