Search in sources :

Example 6 with SmartTileEntity

use of com.simibubi.create.foundation.tileEntity.SmartTileEntity in project Create by Creators-of-Create.

the class ScrollValueRenderer method tick.

public static void tick() {
    Minecraft mc = Minecraft.getInstance();
    HitResult target = mc.hitResult;
    if (target == null || !(target instanceof BlockHitResult))
        return;
    BlockHitResult result = (BlockHitResult) target;
    ClientLevel world = mc.level;
    BlockPos pos = result.getBlockPos();
    Direction face = result.getDirection();
    ScrollValueBehaviour behaviour = TileEntityBehaviour.get(world, pos, ScrollValueBehaviour.TYPE);
    if (behaviour == null)
        return;
    if (!behaviour.isActive())
        return;
    if (behaviour.needsWrench && !AllItems.WRENCH.isIn(mc.player.getMainHandItem()))
        return;
    boolean highlight = behaviour.testHit(target.getLocation());
    if (behaviour instanceof BulkScrollValueBehaviour && AllKeys.ctrlDown()) {
        BulkScrollValueBehaviour bulkScrolling = (BulkScrollValueBehaviour) behaviour;
        for (SmartTileEntity smartTileEntity : bulkScrolling.getBulk()) {
            ScrollValueBehaviour other = smartTileEntity.getBehaviour(ScrollValueBehaviour.TYPE);
            if (other != null)
                addBox(world, smartTileEntity.getBlockPos(), face, other, highlight);
        }
    } else
        addBox(world, pos, face, behaviour, highlight);
}
Also used : BlockHitResult(net.minecraft.world.phys.BlockHitResult) HitResult(net.minecraft.world.phys.HitResult) ClientLevel(net.minecraft.client.multiplayer.ClientLevel) BlockPos(net.minecraft.core.BlockPos) BlockHitResult(net.minecraft.world.phys.BlockHitResult) SmartTileEntity(com.simibubi.create.foundation.tileEntity.SmartTileEntity) Minecraft(net.minecraft.client.Minecraft) Direction(net.minecraft.core.Direction)

Aggregations

SmartTileEntity (com.simibubi.create.foundation.tileEntity.SmartTileEntity)6 ValueBoxTransform (com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform)2 Sided (com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided)2 Minecraft (net.minecraft.client.Minecraft)2 ClientLevel (net.minecraft.client.multiplayer.ClientLevel)2 BlockPos (net.minecraft.core.BlockPos)2 Direction (net.minecraft.core.Direction)2 Entity (net.minecraft.world.entity.Entity)2 ItemStack (net.minecraft.world.item.ItemStack)2 BlockHitResult (net.minecraft.world.phys.BlockHitResult)2 HitResult (net.minecraft.world.phys.HitResult)2 AirshipAssemblerTileEntity (com.eriksonn.createaeronautics.blocks.airship_assembler.AirshipAssemblerTileEntity)1 ITickableTileEntity (net.minecraft.tileentity.ITickableTileEntity)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1