mirror of
https://github.com/GTNewHorizons/StructureLib.git
synced 2026-11-18 19:29:19 +00:00
Add fluid block autoplace with a pluggable fluid cost and source API
Water, lava and every Forge fluid block can now be placed by survival autoplace, paid for with fluid instead of with an item. * Fluid costs are registered per block state, water and lava are registered by default, and a registration can ask for fluid even when the block also has an item form. * A fluid is only placed once the rest of the structure is in place, so it cannot flow out of a half built multiblock, and only the fluid missing from a position is charged, so topping up a leak costs the difference instead of a whole bucket. * The fluid comes from the player: their fluid containers, plus whatever mods contribute through the new fluid container extractor and fluid source provider registries. * Existing structure definitions need no change, as ofBlock and the other block elements become fluid elements when the block has no item form.
This commit is contained in:
1 parent
d829ae466b
commit
98101c00aa
27 files changed
+2395
-83
No files matched your search
@@ -10,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.gtnewhorizon.structurelib.ConfigurationHandler;
|
||||
import com.gtnewhorizon.structurelib.StructureLib;
|
||||
import com.gtnewhorizon.structurelib.StructureLibAPI;
|
||||
import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor;
|
||||
@@ -303,6 +304,7 @@ public interface IStructureDefinition<T> {
|
||||
piece,
|
||||
extendedFacing,
|
||||
new int[] { basePositionA, basePositionB, basePositionC },
|
||||
new int[] { basePositionX, basePositionY, basePositionZ },
|
||||
check);
|
||||
StructureUtility.iterateV2(
|
||||
getStructureFor(piece),
|
||||
@@ -418,7 +420,7 @@ public interface IStructureDefinition<T> {
|
||||
return true;
|
||||
}),
|
||||
"spawnHint");
|
||||
} else {
|
||||
} else if (ConfigurationHandler.INSTANCE.getFluidGateMode() == FluidAutoplace.GateMode.NONE) {
|
||||
StructureUtility.iterateV2(
|
||||
elements,
|
||||
world,
|
||||
@@ -434,6 +436,40 @@ public interface IStructureDefinition<T> {
|
||||
return true;
|
||||
}),
|
||||
"placeBlock");
|
||||
} else {
|
||||
// Build everything that isn't a fluid first, then fill the structure with fluid. That way a fluid has
|
||||
// something holding it by the time it is placed. This is the creative mode counterpart of the fluid
|
||||
// placement gate that survival autoplace uses.
|
||||
StructureUtility.iterateV2(
|
||||
elements,
|
||||
world,
|
||||
extendedFacing,
|
||||
basePositionX,
|
||||
basePositionY,
|
||||
basePositionZ,
|
||||
basePositionA,
|
||||
basePositionB,
|
||||
basePositionC,
|
||||
ignoreBlockUnloaded((e, w, x, y, z, a, b, c) -> {
|
||||
if (!e.isFluidElement(object)) e.placeBlock(object, world, x, y, z, trigger);
|
||||
return true;
|
||||
}),
|
||||
"placeBlock");
|
||||
StructureUtility.iterateV2(
|
||||
elements,
|
||||
world,
|
||||
extendedFacing,
|
||||
basePositionX,
|
||||
basePositionY,
|
||||
basePositionZ,
|
||||
basePositionA,
|
||||
basePositionB,
|
||||
basePositionC,
|
||||
ignoreBlockUnloaded((e, w, x, y, z, a, b, c) -> {
|
||||
if (e.isFluidElement(object)) e.placeBlock(object, world, x, y, z, trigger);
|
||||
return true;
|
||||
}),
|
||||
"placeFluid");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user