Search in sources :

Example 1 with EnumFacing

use of net.minecraft.util.EnumFacing in project MinecraftForge by MinecraftForge.

the class ForgeBlockModelRenderer method render.

public static boolean render(VertexLighterFlat lighter, IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer wr, boolean checkSides, long rand) {
    lighter.setWorld(world);
    lighter.setState(state);
    lighter.setBlockPos(pos);
    boolean empty = true;
    List<BakedQuad> quads = model.getQuads(state, null, rand);
    if (!quads.isEmpty()) {
        lighter.updateBlockInfo();
        empty = false;
        for (BakedQuad quad : quads) {
            quad.pipe(lighter);
        }
    }
    for (EnumFacing side : EnumFacing.values()) {
        quads = model.getQuads(state, side, rand);
        if (!quads.isEmpty()) {
            if (!checkSides || state.shouldSideBeRendered(world, pos, side)) {
                if (empty)
                    lighter.updateBlockInfo();
                empty = false;
                for (BakedQuad quad : quads) {
                    quad.pipe(lighter);
                }
            }
        }
    }
    return !empty;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) EnumFacing(net.minecraft.util.EnumFacing)

Example 2 with EnumFacing

use of net.minecraft.util.EnumFacing in project MinecraftForge by MinecraftForge.

the class DispenseFluidContainer method fillContainer.

/**
     * Picks up fluid in front of a Dispenser and fills a container with it.
     */
@Nonnull
private ItemStack fillContainer(@Nonnull IBlockSource source, @Nonnull ItemStack stack) {
    World world = source.getWorld();
    EnumFacing dispenserFacing = source.getBlockState().getValue(BlockDispenser.FACING);
    BlockPos blockpos = source.getBlockPos().offset(dispenserFacing);
    FluidActionResult actionResult = FluidUtil.tryPickUpFluid(stack, null, world, blockpos, dispenserFacing.getOpposite());
    ItemStack resultStack = actionResult.getResult();
    if (!actionResult.isSuccess() || resultStack.isEmpty()) {
        return super.dispenseStack(source, stack);
    }
    if (stack.getCount() == 1) {
        return resultStack;
    } else if (((TileEntityDispenser) source.getBlockTileEntity()).addItemStack(resultStack) < 0) {
        this.dispenseBehavior.dispense(source, resultStack);
    }
    ItemStack stackCopy = stack.copy();
    stackCopy.shrink(1);
    return stackCopy;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) TileEntityDispenser(net.minecraft.tileentity.TileEntityDispenser) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 3 with EnumFacing

use of net.minecraft.util.EnumFacing in project MinecraftForge by MinecraftForge.

the class DispenseFluidContainer method dumpContainer.

/**
     * Drains a filled container and places the fluid in front of the Dispenser.
     */
@Nonnull
private ItemStack dumpContainer(IBlockSource source, @Nonnull ItemStack stack) {
    ItemStack singleStack = stack.copy();
    singleStack.setCount(1);
    IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(singleStack);
    if (fluidHandler == null) {
        return super.dispenseStack(source, stack);
    }
    FluidStack fluidStack = fluidHandler.drain(Fluid.BUCKET_VOLUME, false);
    EnumFacing dispenserFacing = source.getBlockState().getValue(BlockDispenser.FACING);
    BlockPos blockpos = source.getBlockPos().offset(dispenserFacing);
    FluidActionResult result = fluidStack != null ? FluidUtil.tryPlaceFluid(null, source.getWorld(), blockpos, stack, fluidStack) : FluidActionResult.FAILURE;
    if (result.isSuccess()) {
        ItemStack drainedStack = result.getResult();
        if (drainedStack.getCount() == 1) {
            return drainedStack;
        } else if (!drainedStack.isEmpty() && ((TileEntityDispenser) source.getBlockTileEntity()).addItemStack(drainedStack) < 0) {
            this.dispenseBehavior.dispense(source, drainedStack);
        }
        ItemStack stackCopy = drainedStack.copy();
        stackCopy.shrink(1);
        return stackCopy;
    } else {
        return this.dispenseBehavior.dispense(source, stack);
    }
}
Also used : IFluidHandlerItem(net.minecraftforge.fluids.capability.IFluidHandlerItem) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 4 with EnumFacing

use of net.minecraft.util.EnumFacing in project MinecraftForge by MinecraftForge.

the class VanillaInventoryCodeHooks method dropperInsertHook.

/**
     * Copied from BlockDropper#dispense and added capability support
     */
public static boolean dropperInsertHook(World world, BlockPos pos, TileEntityDispenser dropper, int slot, @Nonnull ItemStack stack) {
    EnumFacing enumfacing = world.getBlockState(pos).getValue(BlockDropper.FACING);
    BlockPos blockpos = pos.offset(enumfacing);
    Pair<IItemHandler, Object> destinationResult = getItemHandler(world, (double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), enumfacing.getOpposite());
    if (destinationResult == null) {
        return true;
    } else {
        IItemHandler itemHandler = destinationResult.getKey();
        Object destination = destinationResult.getValue();
        ItemStack dispensedStack = stack.copy().splitStack(1);
        ItemStack remainder = putStackInInventoryAllSlots(dropper, destination, itemHandler, dispensedStack);
        if (remainder.isEmpty()) {
            remainder = stack.copy();
            remainder.shrink(1);
        } else {
            remainder = stack.copy();
        }
        dropper.setInventorySlotContents(slot, remainder);
        return false;
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 5 with EnumFacing

use of net.minecraft.util.EnumFacing in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockCannon method setDefaultDirection.

private void setDefaultDirection(World worldIn, BlockPos pos, IBlockState state) {
    if (!worldIn.isRemote) {
        EnumFacing enumfacing = (EnumFacing) state.getValue(LOOKING);
        boolean flag = worldIn.getBlockState(pos.north()).isFullBlock();
        boolean flag1 = worldIn.getBlockState(pos.south()).isFullBlock();
        if (enumfacing == EnumFacing.NORTH && flag && !flag1) {
            enumfacing = EnumFacing.SOUTH;
        } else if (enumfacing == EnumFacing.SOUTH && flag1 && !flag) {
            enumfacing = EnumFacing.NORTH;
        } else {
            boolean flag2 = worldIn.getBlockState(pos.west()).isFullBlock();
            boolean flag3 = worldIn.getBlockState(pos.east()).isFullBlock();
            if (enumfacing == EnumFacing.WEST && flag2 && !flag3) {
                enumfacing = EnumFacing.EAST;
            } else if (enumfacing == EnumFacing.EAST && flag3 && !flag2) {
                enumfacing = EnumFacing.WEST;
            }
        }
        worldIn.setBlockState(pos, state.withProperty(LOOKING, enumfacing), 2);
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing)

Aggregations

EnumFacing (net.minecraft.util.EnumFacing)1673 BlockPos (net.minecraft.util.math.BlockPos)491 IBlockState (net.minecraft.block.state.IBlockState)403 TileEntity (net.minecraft.tileentity.TileEntity)392 ItemStack (net.minecraft.item.ItemStack)192 Block (net.minecraft.block.Block)158 ArrayList (java.util.ArrayList)121 World (net.minecraft.world.World)114 Vec3d (net.minecraft.util.math.Vec3d)104 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)98 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)88 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)73 EntityPlayer (net.minecraft.entity.player.EntityPlayer)65 FluidStack (net.minecraftforge.fluids.FluidStack)65 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)63 Nullable (javax.annotation.Nullable)51 List (java.util.List)48 Nonnull (javax.annotation.Nonnull)47 HashSet (java.util.HashSet)43 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)43