Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pylon uses an addon system, meaning anyone can add content to Pylon by writing a

## Find out more
Join our Discord: https://discord.gg/4tMAnBAacW
Visit our website: https://pylonmc.github.io/
Visit our website: https://pylonmc.github.io

## Warning
PYLON IS CURRENTLY EXPERIMENTAL. ONLY RUN IT ON A TEST SERVER THAT YOU ARE WILLING TO DELETE. THE NEXT PYLON VERSION WILL PROBABLY NOT BE COMPATIBLE WITH THE PREVIOUS ONE. IF YOU INSTALL PYLON SOMEWHERE YOU SHOULDN'T AND END UP LOSING DATA, WE WILL POINT AND LAUGH AT YOU.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import io.github.pylonmc.pylon.core.datatypes.PylonSerializers;
import io.github.pylonmc.pylon.core.entity.display.ItemDisplayBuilder;
import io.github.pylonmc.pylon.core.entity.display.transform.TransformBuilder;
import io.github.pylonmc.pylon.core.event.PylonCargoDuctConnectEvent;
import io.github.pylonmc.pylon.core.event.PylonCargoDuctDisconnectEvent;
import io.github.pylonmc.pylon.core.event.PylonCargoConnectEvent;
import io.github.pylonmc.pylon.core.event.PylonCargoDisconnectEvent;
import io.github.pylonmc.pylon.core.i18n.PylonArgument;
import io.github.pylonmc.pylon.core.item.PylonItem;
import io.github.pylonmc.pylon.core.item.builder.ItemStackBuilder;
Expand Down Expand Up @@ -79,7 +79,8 @@ public CargoExtractor(@NotNull Block block, @NotNull BlockCreateContext context)
throw new IllegalArgumentException("Cargo extractor can only be placed by player");
}

facing = playerPlaceContext.getPlayer().getFacing();
// TODO add a util function for this because ffs really
facing = PylonUtils.rotateToPlayerFacing(playerPlaceContext.getPlayer(), BlockFace.NORTH, true).getOppositeFace();

addCargoLogisticGroup(facing.getOppositeFace(), "output");
for (BlockFace face : PylonUtils.perpendicularImmediateFaces(facing)) {
Expand All @@ -97,7 +98,7 @@ public CargoExtractor(@NotNull Block block, @NotNull BlockCreateContext context)
.build(block.getLocation().toCenterLocation())
);

addEntity("input", new ItemDisplayBuilder()
addEntity("output", new ItemDisplayBuilder()
.itemStack(outputStack)
.transformation(new TransformBuilder()
.lookAlong(facing)
Expand Down Expand Up @@ -166,21 +167,18 @@ public void setupLogisticGroups() {}
}

@Override
public void onDuctConnected(@NotNull PylonCargoDuctConnectEvent event) {
public void onDuctConnected(@NotNull PylonCargoConnectEvent event) {
// Remove all faces that aren't to the connected block - this will make sure only
// one duct is connected at a time
BlockPosition ductPosition = new BlockPosition(event.getDuct().getBlock());
BlockPosition thisPosition = new BlockPosition(getBlock());
BlockFace connectedFace = PylonUtils.vectorToBlockFace(ductPosition.minus(thisPosition).getVector3i());
for (BlockFace face : getCargoLogisticGroups().keySet()) {
if (face != connectedFace) {
if (!getBlock().getRelative(face).equals(event.getBlock1().getBlock()) && !getBlock().getRelative(face).equals(event.getBlock2().getBlock())) {
removeCargoLogisticGroup(face);
}
}
}

@Override
public void onDuctDisconnected(@NotNull PylonCargoDuctDisconnectEvent event) {
public void onDuctDisconnected(@NotNull PylonCargoDisconnectEvent event) {
// Allow connecting to all faces now that there are zero connections
List<BlockFace> faces = PylonUtils.perpendicularImmediateFaces(facing);
faces.add(facing.getOppositeFace());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import io.github.pylonmc.pylon.core.datatypes.PylonSerializers;
import io.github.pylonmc.pylon.core.entity.display.ItemDisplayBuilder;
import io.github.pylonmc.pylon.core.entity.display.transform.TransformBuilder;
import io.github.pylonmc.pylon.core.event.PylonCargoDuctConnectEvent;
import io.github.pylonmc.pylon.core.event.PylonCargoDuctDisconnectEvent;
import io.github.pylonmc.pylon.core.event.PylonCargoConnectEvent;
import io.github.pylonmc.pylon.core.event.PylonCargoDisconnectEvent;
import io.github.pylonmc.pylon.core.i18n.PylonArgument;
import io.github.pylonmc.pylon.core.item.PylonItem;
import io.github.pylonmc.pylon.core.item.builder.ItemStackBuilder;
import io.github.pylonmc.pylon.core.logistics.LogisticGroup;
import io.github.pylonmc.pylon.core.util.PylonUtils;
import io.github.pylonmc.pylon.core.util.gui.unit.UnitFormat;
import io.github.pylonmc.pylon.core.util.position.BlockPosition;
import io.github.pylonmc.pylon.core.util.position.ChunkPosition;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
Expand Down Expand Up @@ -79,7 +78,7 @@ public CargoInserter(@NotNull Block block, @NotNull BlockCreateContext context)
throw new IllegalArgumentException("Cargo inserter can only be placed by player");
}

facing = playerPlaceContext.getPlayer().getFacing();
facing = PylonUtils.rotateToPlayerFacing(playerPlaceContext.getPlayer(), BlockFace.NORTH, true).getOppositeFace();

addCargoLogisticGroup(facing.getOppositeFace(), "input");
for (BlockFace face : PylonUtils.perpendicularImmediateFaces(facing)) {
Expand Down Expand Up @@ -157,26 +156,23 @@ public boolean isPartOfMultiblock(@NotNull Block otherBlock) {
public void setupLogisticGroups() {}

@Override
public void onDuctConnected(@NotNull PylonCargoDuctConnectEvent event) {
public void onDuctConnected(@NotNull PylonCargoConnectEvent event) {
// Remove all faces that aren't to the connected block - this will make sure only
// one duct is connected at a time
BlockPosition ductPosition = new BlockPosition(event.getDuct().getBlock());
BlockPosition thisPosition = new BlockPosition(getBlock());
BlockFace connectedFace = PylonUtils.vectorToBlockFace(ductPosition.minus(thisPosition).getVector3i());
for (BlockFace face : getCargoLogisticGroups().keySet()) {
if (face != connectedFace) {
if (!getBlock().getRelative(face).equals(event.getBlock1().getBlock()) && !getBlock().getRelative(face).equals(event.getBlock2().getBlock())) {
removeCargoLogisticGroup(face);
}
}
}

@Override
public void onDuctDisconnected(@NotNull PylonCargoDuctDisconnectEvent event) {
public void onDuctDisconnected(@NotNull PylonCargoDisconnectEvent event) {
// Allow connecting to all faces now that there are zero connections
List<BlockFace> faces = PylonUtils.perpendicularImmediateFaces(facing);
faces.add(facing.getOppositeFace());
for (BlockFace face : faces) {
addCargoLogisticGroup(face, "input");
addCargoLogisticGroup(face, "output");
}
for (BlockFace face : faces) {
if (BlockStorage.get(getBlock().getRelative(face)) instanceof CargoDuct duct) {
Expand Down