Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
made pipes able to path through mini portals
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Aug 26, 2024
1 parent 61d3191 commit 714956d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package muramasa.gregtech.blockentity.miniportals;

import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.blockentity.IExtendingBlockEntity;
import muramasa.antimatter.machine.MachineState;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.tool.AntimatterToolType;
Expand All @@ -17,14 +18,15 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public abstract class BlockEntityMiniPortal extends BlockEntityMachine<BlockEntityMiniPortal> {
public abstract class BlockEntityMiniPortal extends BlockEntityMachine<BlockEntityMiniPortal> implements IExtendingBlockEntity {

public static List<BlockEntityMiniPortal>
sListWorldSide = new ArrayList<>();
Expand Down Expand Up @@ -106,6 +108,16 @@ protected boolean allowExplosionsInRain() {
return false;
}

@Override
public void onBlockUpdate(BlockPos neighbor) {
super.onBlockUpdate(neighbor);
Direction facing = Utils.getOffsetFacing(this.getBlockPos(), neighbor);
if (otherSide != null && !otherSide.isRemoved()){
BlockPos offset = otherSide.getBlockPos().relative(facing.getOpposite());
otherSide.getLevel().neighborChanged(offset, otherSide.getLevel().getBlockState(offset).getBlock(), otherSide.getBlockPos());
}
}

@Override
public InteractionResult onInteractBoth(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit, @Nullable AntimatterToolType type) {
ItemStack stack = player.getItemInHand(hand);
Expand Down Expand Up @@ -220,6 +232,14 @@ public boolean toggleMachine() {
return false;
}

@Override
public BlockEntity getExtendedBlockEntity(Direction side) {
if (otherSide != null && !otherSide.isRemoved()){
return otherSide.getCachedBlockEntity(side);
}
return this;
}

@Override
public List<String> getInfo(boolean simple) {
List<String> info = super.getInfo(simple);
Expand Down

0 comments on commit 714956d

Please sign in to comment.