Search in sources :

Example 11 with BlockFace

use of com.simibubi.create.foundation.utility.BlockFace in project Create by Creators-of-Create.

the class CapManipulationBehaviourBase method findNewCapability.

public void findNewCapability() {
    Level world = getWorld();
    BlockFace targetBlockFace = target.getTarget(world, tileEntity.getBlockPos(), tileEntity.getBlockState()).getOpposite();
    BlockPos pos = targetBlockFace.getPos();
    targetCapability = LazyOptional.empty();
    if (!world.isLoaded(pos))
        return;
    BlockEntity invTE = world.getBlockEntity(pos);
    if (invTE == null)
        return;
    Capability<T> capability = capability();
    targetCapability = bypassSided ? invTE.getCapability(capability) : invTE.getCapability(capability, targetBlockFace.getFace());
    if (targetCapability.isPresent())
        targetCapability.addListener(this::onHandlerInvalidated);
}
Also used : BlockFace(com.simibubi.create.foundation.utility.BlockFace) Level(net.minecraft.world.level.Level) BlockPos(net.minecraft.core.BlockPos) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Aggregations

BlockFace (com.simibubi.create.foundation.utility.BlockFace)11 BlockPos (net.minecraft.core.BlockPos)7 Direction (net.minecraft.core.Direction)6 Pair (com.simibubi.create.foundation.utility.Pair)3 ArrayList (java.util.ArrayList)3 BlockState (net.minecraft.world.level.block.state.BlockState)3 SmartTileEntity (com.simibubi.create.foundation.tileEntity.SmartTileEntity)2 TileEntityBehaviour (com.simibubi.create.foundation.tileEntity.TileEntityBehaviour)2 DirectBeltInputBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 IdentityHashMap (java.util.IdentityHashMap)2 List (java.util.List)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 ItemStack (net.minecraft.world.item.ItemStack)2 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)2 BlockEntityType (net.minecraft.world.level.block.entity.BlockEntityType)2 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)2 InstancedRenderDispatcher (com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher)1 AllBlocks (com.simibubi.create.AllBlocks)1