Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9714ee7
1.16.5!
CalenXwX May 16, 2024
3b3fbd4
Correct reflection
CalenXwX May 21, 2024
3f7345c
Switched submodule links and updated mods.toml
CalenXwX May 25, 2024
14ad775
Updated submodule
CalenXwX May 25, 2024
bafa041
Updated expression module
CalenXwX May 25, 2024
907e79d
Fixed TileHeatExchange
CalenXwX Jun 1, 2024
75c0b79
Updated submodule
CalenXwX Jun 1, 2024
0931caa
Fixed PipeStripes extending
CalenXwX Jun 30, 2024
e60ef84
Fixed: builder rendering & builder pipe rotation & required items of …
CalenXwX Jul 21, 2024
cbdfdc5
Fix: builder pipe rotation
CalenXwX Jul 21, 2024
4f92d7a
Fix: dependencies
CalenXwX Jul 23, 2024
a4e8738
Fix: builder required material in TileEntity's storage
CalenXwX Jul 24, 2024
ea40975
FIX: trove4j dependency
CalenXwX Oct 12, 2024
da70efd
Fix: IVertexBuilder class cast
CalenXwX Oct 13, 2024
fb4ddb1
Updated gitsubmodule
CalenXwX Feb 15, 2025
a79ef94
Robotics!
CalenXwX Apr 21, 2025
c2ccbe4
Fixed: Ledger owner face skin
CalenXwX Apr 21, 2025
5bc2aa3
Update from latest commits of 1.12.2: Engine Pipe RF PlugTimer
CalenXwX Apr 24, 2025
3127234
Fixed registration
CalenXwX Apr 24, 2025
9aa0739
Update daizuli item pipe: selectable logic(strict direction / directi…
CalenXwX Apr 26, 2025
4a99877
Add configs to enable/disable facades, fix NPE when facade item disab…
CalenXwX Apr 26, 2025
699bfbc
Fix #21 tags
CalenXwX May 5, 2025
566f88e
Fix MJ-RF conversion & Make programming recipe input item modifiable
CalenXwX May 7, 2025
195e044
Fix Laser & Quarry rendering and Quarry debug message
CalenXwX May 14, 2025
01bbd39
Fix some bugs
CalenXwX Mar 8, 2026
b982024
Fix build
CalenXwX Mar 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix: builder pipe rotation
  • Loading branch information
CalenXwX committed Jul 21, 2024
commit cbdfdc571ff2c1a129f9171aac81bfca617abe9c
78 changes: 73 additions & 5 deletions common/buildcraft/transport/pipe/SchematicBlockPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import buildcraft.api.schematics.ISchematicBlock;
import buildcraft.api.schematics.SchematicBlockContext;
import buildcraft.api.transport.EnumWirePart;
import buildcraft.api.transport.pipe.IPipeHolder;
import buildcraft.api.transport.pipe.PipeApi;
import buildcraft.api.transport.pipe.PipeBehaviour;
import buildcraft.api.transport.pipe.PipeDefinition;
import buildcraft.api.transport.pluggable.PluggableDefinition;
import buildcraft.lib.misc.ColourUtil;
Expand All @@ -22,23 +24,26 @@
import buildcraft.lib.registry.TagManager;
import buildcraft.lib.registry.TagManager.EnumTagType;
import buildcraft.transport.BCTransportBlocks;
import buildcraft.transport.pipe.behaviour.PipeBehaviourDirectional;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.registries.ForgeRegistries;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.Optional;
import java.util.*;

public class SchematicBlockPipe implements ISchematicBlock {
private CompoundNBT tileNbt;
Expand Down Expand Up @@ -119,6 +124,7 @@ public SchematicBlockPipe getRotated(Rotation rotation) {
// schematicBlock.tileNbt = tileNbt;
schematicBlock.tileNbt = tileNbt.copy();
rotatePlugs(schematicBlock.tileNbt, rotation);
rotatePipe(schematicBlock.tileNbt, rotation);
// Calen 1.12.2 tileRotation -> 1.18.2 SkullBlock BlockState ROTATION_16
// schematicBlock.tileRotation = tileRotation.add(rotation);
return schematicBlock;
Expand Down Expand Up @@ -146,6 +152,8 @@ public boolean build(World world, BlockPos blockPos) {
// if (tileRotation != Rotation.NONE) {
// tileEntity.rotate(tileRotation);
// }
// Calen
checkDirectionalPipeDir(tileEntity, tileNbt);
return true;
}
}
Expand All @@ -169,6 +177,8 @@ public boolean buildWithoutChecks(IFakeWorld world, BlockPos blockPos) {
// if (tileRotation != Rotation.NONE) {
// tileEntity.rotate(tileRotation);
// }
// Calen
checkDirectionalPipeDir(tileEntity, tileNbt);
return true;
}
}
Expand Down Expand Up @@ -197,7 +207,7 @@ public void deserializeNBT(CompoundNBT nbt) throws InvalidInputDataException {
}

// Calen FIX: builder rotates plugs on pipes
private void rotatePlugs(CompoundNBT nbt, Rotation rotation) {
private static void rotatePlugs(CompoundNBT nbt, Rotation rotation) {
try {
CompoundNBT nbtPlugs = nbt.getCompound("plugs");
// get plug tag of each facing
Expand Down Expand Up @@ -232,12 +242,12 @@ private void rotatePlugs(CompoundNBT nbt, Rotation rotation) {
}
wireManagerNbt.putIntArray("parts", wiresArrayNew);
} catch (Exception e) {
BCLog.logger.error("[transport.pipe.schematic] Failed to rotate PipeHolder[" + this.tileNbt.toString() + "], rotation = [" + rotation + "]");
BCLog.logger.error("[transport.pipe.schematic] Failed to rotate PipeHolder[" + nbt.toString() + "], rotation = [" + rotation + "]");
BCLog.logger.error("[transport.pipe.schematic] ", e);
}
}

private void rotatePlugData(CompoundNBT plugNbt, Rotation rotation) {
private static void rotatePlugData(CompoundNBT plugNbt, Rotation rotation) {
CompoundNBT dataNbt = plugNbt.getCompound("data").getCompound("data");
for (String subTagName : dataNbt.getAllKeys()) {
CompoundNBT subTag = dataNbt.getCompound(subTagName);
Expand All @@ -254,4 +264,62 @@ private void rotatePlugData(CompoundNBT plugNbt, Rotation rotation) {
}
}
}

private static void rotatePipe(CompoundNBT nbt, Rotation rotation) {
// directional
CompoundNBT pipeNbt = nbt.getCompound("pipe");
CompoundNBT behNbt = pipeNbt.getCompound("beh");
if (!behNbt.isEmpty()) {
Direction currentDir = NBTUtilBC.readEnum(behNbt.get("currentDir"), Direction.class);
if (currentDir != null) {
Direction newDir = RotationUtil.rotateFacing(currentDir, rotation);
behNbt.putString("currentDir", newDir.name());
}
Direction direction = NBTUtilBC.readEnum(behNbt.get("direction"), Direction.class);
if (direction != null) {
Direction newDir = RotationUtil.rotateFacing(direction, rotation);
behNbt.putString("direction", newDir.name());
}
}
// filter
if (behNbt.contains("filters")) {
CompoundNBT filtersNbt = behNbt.getCompound("filters");
if (filtersNbt.contains("items")) {
ListNBT itemsNbt = filtersNbt.getList("items", Constants.NBT.TAG_COMPOUND);
Map<Direction, List<INBT>> oldFilters = new HashMap<>();
for (Direction dir : Direction.BY_2D_DATA) {
int startPos = dir.get3DDataValue() * 9;
List<INBT> filtersOfCurrentDir = new ArrayList<>(itemsNbt.subList(startPos, startPos + 9));
oldFilters.put(dir, filtersOfCurrentDir);
}
for (Direction dirOld : Direction.BY_2D_DATA) {
Direction dirNew = RotationUtil.rotateFacing(dirOld, rotation);
List<INBT> filters = oldFilters.get(dirOld);
int startPos = dirNew.get3DDataValue() * 9;
for (int index = 0; index < 9; index++) {
itemsNbt.set(startPos + index, filters.get(index));
}
}
}
}
}

private static void checkDirectionalPipeDir(TileEntity holder, CompoundNBT nbt) {
PipeBehaviour behaviour = ((IPipeHolder) holder).getPipe().getBehaviour();
if (behaviour instanceof PipeBehaviourDirectional) {
Direction currentDir = ((PipeBehaviourDirectional) behaviour).getCurrentDir();
try {
INBT correctDirNbt = nbt.getCompound("pipe").getCompound("beh").get("currentDir");
Direction correctDir = NBTUtilBC.readEnum(correctDirNbt, Direction.class);
if (correctDir != null) {
if (currentDir != correctDir) {
((PipeBehaviourDirectional) behaviour).setCurrentDir(correctDir);
}
}
} catch (Exception e) {
BCLog.logger.error("[transport.pipe.schematic] Found a placed pipe[" + nbt.toString() + "] has wrong direction[" + currentDir + "], but failed to correct it.");
BCLog.logger.error("[transport.pipe.schematic] ", e);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ public boolean advanceFacing() {
}

@Nullable
protected Direction getCurrentDir() {
public Direction getCurrentDir() {
return currentDir.face;
}

protected void setCurrentDir(Direction setTo) {
public void setCurrentDir(Direction setTo) {
if (this.currentDir.face == setTo) {
return;
}
Expand Down